python - tk.Panedwindow isn't visible -
i'm learning tk , run problem using panedwindow python. code:
import tkinter tk import tkinter.ttk ttk class application(tk.frame): def __init__(self,master): #set top window geomotry tk.frame.__init__(self,master) pane = tk.panedwindow(self) pane.pack(fill=tk.both, expand=1) test=tk.label(pane,text='test') test.pack() root=tk.tk() root.geometry("800x600") app=application(root) tk.mainloop() nothing appears in root window.
everything in application visible if instance of application visible. not, because haven't called pack, place, or grid on instance of application (ie: app).
the other problem more of conceptual one. if add paned window have 1 pane, not have divider since there nothing divide.
here working version of code, second pane can more visualize it.
import tkinter tk import tkinter.ttk ttk class application(tk.frame): def __init__(self,master): #set top window geomotry tk.frame.__init__(self,master) pane = tk.panedwindow(self) pane.pack(fill=tk.both, expand=1) test=tk.label(pane, text='test', background="pink") pane.add(test) test2 = tk.label(pane, text="foo", background="blue") pane.add(test2) root=tk.tk() root.geometry("800x600") app=application(root) app.pack(fill="both", expand=true) tk.mainloop()
Comments
Post a Comment