|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
我在canvas 上画了一个窗口,他有state属性
can.create_window((0,600),window=frame1,anchor='nw',tag='loginiff',state='normal')
假设我后面需要有时候显示这个窗口,有时候隐藏这个窗口,能否在后面的执行中改变这个state
- from tkinter import *
- from tkinter import ttk
- win = Tk()
- win.geometry("500x500+200+100")
- cv = Canvas(win, background='white')
- cv.pack()
- tgg = True
- def click_hide_show():
- global tgg
- if tgg:
- cv.itemconfigure('the_frm', state='hidden')
- tgg = not tgg
- else:
- cv.itemconfigure('the_frm', state='normal')
- tgg = not tgg
- b = Button(cv, text='隐藏/显示', command=click_hide_show)
- cv.create_window(10, 10, anchor='nw', window=b)
- frm = Frame(win, width=200, height=100, background='blue')
- cv_id = cv.create_window((100,100), window=frm, anchor='nw',tag='the_frm',state='normal')
- win.mainloop()
复制代码
|
|