Re: tkinter resizable text with grid
On Thursday, 6 December 2018 07:02:50 UTC, Paulo da Silva wrote: > Hi! > > Does anybody know why this code does not expand the text widget when I > increase the window size (with mouse)? I want height and width but as > minimum (or may be initial) size. > > import tkinter as tk > > class App: > def __init__(self,master): > self.tboard=tk.Text(master,height=40,width=50) > self.tboard.grid(row=1,column=1,sticky="nsew") > self.tboard.grid_rowconfigure(1,weight=1) > self.tboard.grid_columnconfigure(1,weight=1) > > root=tk.Tk() > app=App(root) > > root.mainloop() > > Thanks Others here have commented about Tkinter. I'm not a professional programmer, and I struggled with Python2 and Tkinter for a while. It worked, but it was a struggle. * A few years ago I started using Glade and Python3 (and gi.repository). Much easier, much less Python code, much easier to maintain. * Not that I'm much of a critic of Tkinter, just that the alternative is simpler and easier. -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter resizable text with grid
Às 07:11 de 07/12/18, Christian Gollwitzer escreveu: > Am 07.12.18 um 03:00 schrieb Paulo da Silva: >> Às 21:15 de 06/12/18, Rick Johnson escreveu: ... > So instead of complaining about lacking support in Tk, the > Python community should do their homework and provide wrappers to the > most common Tk extensions. > That was what I did. When I referred tk was in the context of python. I left tcl/tk long time ago and by that time the problems were the same as tkinter's today, not to mention the angels sex discussions/wars about which oop paradigm to use or if use any at all :-) Regards -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter resizable text with grid
Am 07.12.18 um 03:00 schrieb Paulo da Silva: Às 21:15 de 06/12/18, Rick Johnson escreveu: I kinda have a love/hate relationship with Tkinter and IDLE. On one hand i find them to be practical[2] and simple[3] and on the other, i find them to be poorly designed and unintuitive. And it's a real shame, because, both of these libraries have tons of potential, *IF*, they were designed probably and the shortcomings of TclTk were abstracted away behind a more Pythonic interface. hahaha... I'm using Tk from both Tcl and Python, and to me it seems like exactly the other way around. Tkinter feels clumsy compared to the "original" Tcl/Tk, because of some overzealous OOP-wrapping. "grid" is a good example; in Tcl, it is not a member of the widgets but instead a free function. It can take more than one slave, so, for instance grid .x .y .z grid .a x .b creates a 3x2 grid of widgets with the lower middle cell empty. No fiddling with row and column counting. For some strange reason the Tkinter designers decided that grid should be a method of the slave, which makes it feel much more clumsy. I fully agree. Nevertheless, what I miss more is the lack of more complex mega widgets - scrollable list of widgets with insert, append and remove methods and perhaps a spreadsheet like widget are two big ones. There are others smaller, like a single scrollable text with two scroll bars that hide when not needed, tab multi-choice container, etc ... These widgets do exist for Tcl/Tk. You can use a tablelist for both a list of widgets or a multi-column listbox https://wiki.tcl-lang.org/page/tablelist For the spreadsheet, TkTable is another solution which is more close to Excel: https://wiki.tcl-lang.org/page/Tktable "Tab multi-choice container" sounds to me like a ttk::notebook widget https://wiki.tcl-lang.org/page/notebook Another handy extension is TkDnD, which brings support for native Drag'n'drop, i.e. you can drop files from a file manager into your application: https://github.com/petasis/tkdnd - not to be confused with a cheap substitute https://kite.com/python/docs/Tkdnd which only supports drag/drop within one application instance. The "problem" with these pacakges, they are written in Tcl and/or C, is that they are not distributed along the Tk core and consequently there are no well-maintained Python wrappers availabe. In the Tcl community, these packages are considered "essential" for more complex GUI programming. So instead of complaining about lacking support in Tk, the Python community should do their homework and provide wrappers to the most common Tk extensions. Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter resizable text with grid
Às 21:15 de 06/12/18, Rick Johnson escreveu: > Paulo da Silva wrote: > ... > > In Tkinter, if you have a "container"[1] that only has a > single widget stuffed inside, and, you want that single > widget to expand to fill the extents of its parent > container, then, the pack geometry manager is the simplest > approach. > > w = create_a_widget() > w.pack(fill=X|Y|BOTH, expand=YES) Yes, I am aware of pack. Unfortunately the code fragment I posted is a very small part of a larger widget. ... > > I kinda have a love/hate relationship with Tkinter and IDLE. > On one hand i find them to be practical[2] and simple[3] and > on the other, i find them to be poorly designed and > unintuitive. And it's a real shame, because, both of these > libraries have tons of potential, *IF*, they were designed > probably and the shortcomings of TclTk were abstracted away > behind a more Pythonic interface. > I fully agree. Nevertheless, what I miss more is the lack of more complex mega widgets - scrollable list of widgets with insert, append and remove methods and perhaps a spreadsheet like widget are two big ones. There are others smaller, like a single scrollable text with two scroll bars that hide when not needed, tab multi-choice container, etc ... Unfortunately I rarely need gui programming and don't have the expertise to address such task. Being tk so old, I wonder why no one developed those expansions - continuing tix, for example. There are some implementations but they seem not being maintained. Pmw has some of the later, but it is not much stable for python3. Thanks for responding Paulo -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter resizable text with grid
Às 08:24 de 06/12/18, Peter Otten escreveu: > Paulo da Silva wrote: > ... > > You have to set the column/row weight of the /master/: > > master.grid_columnconfigure(1, weight=1) > master.grid_rowconfigure(1, weight=1) Ok. That works! > > Also, columns and rows usually start with 0. > Yes, I know that. I have other stuff there. Thank you very much Peter. -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter resizable text with grid
Paulo da Silva wrote: > Does anybody know why this code does not expand the text widget when I > increase the window size (with mouse)? I want height and width but as > minimum (or may be initial) size. > > import tkinter as tk > > class App: > def __init__(self,master): > self.tboard=tk.Text(master,height=40,width=50) > self.tboard.grid(row=1,column=1,sticky="nsew") You have to set the column/row weight of the /master/: master.grid_columnconfigure(1, weight=1) master.grid_rowconfigure(1, weight=1) Also, columns and rows usually start with 0. > root=tk.Tk() > app=App(root) > > root.mainloop() > > Thanks -- https://mail.python.org/mailman/listinfo/python-list
tkinter resizable text with grid
Hi! Does anybody know why this code does not expand the text widget when I increase the window size (with mouse)? I want height and width but as minimum (or may be initial) size. import tkinter as tk class App: def __init__(self,master): self.tboard=tk.Text(master,height=40,width=50) self.tboard.grid(row=1,column=1,sticky="nsew") self.tboard.grid_rowconfigure(1,weight=1) self.tboard.grid_columnconfigure(1,weight=1) root=tk.Tk() app=App(root) root.mainloop() Thanks -- https://mail.python.org/mailman/listinfo/python-list