나는 한동안 tkinter와 함께 일해 왔습니다. 여기 코드를 기반으로 애플리케이션을 만들려고합니다.
Tkinter에서 위젯을 표시 / 숨기기하는 방법?
두 가지 기능 toggle_entry 및 comp_s가 있습니다.
버튼을 처음 클릭 할 때 toggle_entry + comp_s를 어떻게 실행하나요? 두 번째로 클릭하면 어떻게 toggle_entry를 실행합니다. 세 번째로 클릭하면 다시 toggle_entry + comp_s, 네 번째로 클릭하면 다시 toggle_entry 등 ...
from tkinter import *
import tkinter as tk
hidden = False
root = tk.Tk()
r = StringVar()
e = tk.Entry(root, width=6, textvariable=r)
e.grid(row=0, column=1)
def toggle_entry():
global hidden
if hidden:
e.grid()
else:
e.grid_remove()
hidden = not hidden
s = StringVar()
def comp_s(event):
global s
s=r.get() # construct string
print(s)
tk.Button(root, text='Toggle entry', command=toggle_entry).grid(row=0, column=0)
root.mainloop()
이런 걸 만들 수있어
count = 0
def test_click():
global count
count +=1
if count%2 ==0:
toggle_entry()
comp_s(event)
else :
toggle_entry()
tk.Button(root, text='Toggle entry', command=test_click).grid(row=0, column=0)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다