tkinter
in을 사용하는 간단한 GUI 코드 가 있습니다 Jupyter
.
from tkinter import *
root = Tk()
text = Text(root, width = 40, height = 15)
text.pack()
root.mainloop()
사용자가 입력 한 텍스트는 어떻게받을 수 있습니까? 해당 코드의 끝에
추가 text.get('1.0', 'end')
하면 작동하지 않으며 text.get('1.0', 'end')
다른 셀에 추가 해도 root
창을 닫을 때까지 실행이 시작되지 않고 그 후에 오류가 발생합니다.
이렇게 :
In[1]: from tkinter import *
root = Tk()
text = Text(root, width = 40, height = 15)
text.pack()
root.mainloop()
In[2]: text.get('1.0', 'end')
In[2]
Tk()
창을 닫을 때까지 실행을 시작하지 않으며 창을 닫고 실행 In[2]
을 시작 하면 다음 오류가 발생합니다.
TclError: invalid command name ".!text"
당신은과 상호 작용할 수 없습니다 tkinter mainloop
으로부터 ipython
대화 형.
텍스트 가져 오기 버튼을 추가 한 경우이를 누르면 텍스트 위젯 콘텐츠가 검색됩니다.
이렇게 :
import tkinter as tk
root = tk.Tk()
text = tk.Text(root, width=40, height = 15)
text.pack()
tk.Button(root, text='get text', command=lambda: print(text.get('1.0', tk.END))).pack()
root.mainloop()
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다