Re: Learning tkinter - a grid problem
On 12/6/2020 5:59 AM, Terry Reedy wrote: On 12/6/2020 3:11 AM, Sibylle Koczian wrote: Am 05.12.2020 um 19:56 schrieb Paulo da Silva: Why this example does not work? -- from tkinter import * root=Tk() root.geometry("400x200") S=Scrollbar(root) T=Text(root) ... mainloop() Shouldn't that be root.mainloop() ? Yes. The * import does not turn method into module functions. But no, sort of. MRAB is correct that there is (an undocumented) module function by the same name. It calls tkinter._default_root.tk.mainloop if _default_root is not None. This is true if tkinter._support_default_root == 1 (the default, but set to 0 in IDLE) and tkinter.Tk has been called at least once. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Learning tkinter - a grid problem
On 12/6/2020 3:11 AM, Sibylle Koczian wrote: Am 05.12.2020 um 19:56 schrieb Paulo da Silva: Why this example does not work? -- from tkinter import * root=Tk() root.geometry("400x200") S=Scrollbar(root) T=Text(root) ... mainloop() Shouldn't that be root.mainloop() ? Yes. The * import does not turn method into module functions. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Learning tkinter - a grid problem
Am 06.12.2020 um 15:19 schrieb MRAB: On 2020-12-06 08:11, Sibylle Koczian wrote: Am 05.12.2020 um 19:56 schrieb Paulo da Silva: Hi! Why this example does not work? -- from tkinter import * root=Tk() root.geometry("400x200") S=Scrollbar(root) T=Text(root) ... mainloop() - Shouldn't that be root.mainloop() ? The function 'mainloop' calls the 'mainloop' method of the root Tk window created by Tk(), so it does work as-is. Didn't know that, thank you! -- https://mail.python.org/mailman/listinfo/python-list
Re: Learning tkinter - a grid problem
On 2020-12-06 08:11, Sibylle Koczian wrote: Am 05.12.2020 um 19:56 schrieb Paulo da Silva: Hi! Why this example does not work? -- from tkinter import * root=Tk() root.geometry("400x200") S=Scrollbar(root) T=Text(root) ... mainloop() - Shouldn't that be root.mainloop() ? The function 'mainloop' calls the 'mainloop' method of the root Tk window created by Tk(), so it does work as-is. -- https://mail.python.org/mailman/listinfo/python-list
Re: Learning tkinter - a grid problem
Am 05.12.2020 um 19:56 schrieb Paulo da Silva: Hi! Why this example does not work? -- from tkinter import * root=Tk() root.geometry("400x200") S=Scrollbar(root) T=Text(root) ... mainloop() - Shouldn't that be root.mainloop() ? -- https://mail.python.org/mailman/listinfo/python-list
Re: Learning tkinter - a grid problem
Às 20:20 de 05/12/20, MRAB escreveu: > On 2020-12-05 18:56, Paulo da Silva wrote: >> Hi! >> >> Why this example does not work? >> > There are a few bits of configuration missing: > >> -- >> from tkinter import * >> >> root=Tk() >> root.geometry("400x200") > > Add: > > root.grid_rowconfigure(0, weight=1) > root.grid_columnconfigure(0, weight=1) > root.grid_columnconfigure(1, weight=0) > >> S=Scrollbar(root) >> T=Text(root) >> T.grid(row=0,column=0) >> S.grid(row=0,column=1) > > Change to: > > T.grid(row=0, column=0, sticky=NSEW) > S.grid(row=0, column=1, sticky=NS) > >> S.config(command=T.yview) >> T.config(yscrollcommand=S.set) >> txt="""This is a very big text >> - Ok, thank you. -- https://mail.python.org/mailman/listinfo/python-list
Re: Learning tkinter - a grid problem
On 2020-12-05 18:56, Paulo da Silva wrote: Hi! Why this example does not work? There are a few bits of configuration missing: -- from tkinter import * root=Tk() root.geometry("400x200") Add: root.grid_rowconfigure(0, weight=1) root.grid_columnconfigure(0, weight=1) root.grid_columnconfigure(1, weight=0) S=Scrollbar(root) T=Text(root) T.grid(row=0,column=0) S.grid(row=0,column=1) Change to: T.grid(row=0, column=0, sticky=NSEW) S.grid(row=0, column=1, sticky=NS) S.config(command=T.yview) T.config(yscrollcommand=S.set) txt="""This is a very big text - - - - - - - - - - - - - - - - Last line """ T.insert(END,txt) mainloop() - [snip] -- https://mail.python.org/mailman/listinfo/python-list
Learning tkinter - a grid problem
Hi! Why this example does not work? -- from tkinter import * root=Tk() root.geometry("400x200") S=Scrollbar(root) T=Text(root) T.grid(row=0,column=0) S.grid(row=0,column=1) S.config(command=T.yview) T.config(yscrollcommand=S.set) txt="""This is a very big text - - - - - - - - - - - - - - - - Last line """ T.insert(END,txt) mainloop() - I would like it to work more or less like this - from tkinter import * root=Tk() root.geometry("400x200") S=Scrollbar(root) T=Text(root) S.pack(side=RIGHT,fill=Y) T.pack(side=LEFT,fill=Y) S.config(command=T.yview) T.config(yscrollcommand=S.set) txt="""This is a very big text - - - - - - - - - - - - - - - - Last line """ T.insert(END,txt) mainloop() - Thanks for any help Paulo -- https://mail.python.org/mailman/listinfo/python-list