6 ms·
And doing your GUI with Tkinter, which has an API that fits incredibly well with Python is a problem because...?
by markroseman 8y ago
And doing your GUI with Tkinter, which has an API that fits incredibly well with Python is a problem because...?
- jimnotgym 8y agoI'm really pleased to hear you say that. Every time I have asked about Tkinter on here or SO I get "Tk is really old, you should be using Qt or blahblah". So I guess I start to doubt myself and think that the issues I am having are because I am such a noob I used this crappy old framework that no serious developer would. However I still find similar issues with Tkinter as I discussed above, I really didn't expect to have to learn how Tk event loops or whatever worked just to get my code to execute in the order it is written in! I guess I was just naive.
- markroseman 8y agoCheck out http://tkdocs.com http://tkdocs.com to get started _properly_ with tkinter. The blocking thing you can do in two ways. First, put your blocking stuff in another thread and do it there, and when it's done call back into the main thread to tear down the alert. The other way, to play nice with the event loop, is to do something like: makemydialog() Tk.update_idletasks() # process events so that the dialog shows up do_my_stuff teardown If within do_my_stuff you can periodically call update() to process events, it'll give the appearance of being more responsive. After you get a bit more experience with doing some GUI stuff, and if you want to have a more long-running GUI, it will become more natural to think of initiating everything in response to event handlers, as opposed to the batch model of running your program linearly from top to bottom.
- jimnotgym 8y agoYou have told me more in that message than the whole book I read on Tkinter, and all of the experts who told me I was using the wrong framework. Thank you. I guess looking at it, having a process that is going to take a few seconds and must block the user from progressing until it completes is perhaps not the scenario most tutorials envisage. Thanks again
- jcelerier 8y agoyuck, for the sake of everything, please don't use tk for new apps. They don't support hidpi (except for a global scaling of the app which sometimes does not even works - makes quite a bunch of tk apps unusable). For some reason they don't feel smooth either on > 60Hz screen.
- 1wd 8y agoOne problem I have with Tkinter is scrolling. In other frameworks I just say "this frame (containing lots of widgets) is scrollable" by setting one property to true and it just works. Including vertical and horizontal scrolling, mouse-wheel support, and standard keyboard shortcuts like page-down etc. In Tkinter this seems almost impossible. It takes dozens of lines of code; many events must be implemented manually, including low-level things like calculation of scroll offsets; good mouse-wheel support is very difficult; etc. It feels more like I'm _implementing_ (rather than _using_) the scrolling widget. And in the end it the UI flickers like crazy during scrolling. Is there something I overlooked?