4 ms·
I would love to hear more about this from the sages of HN. I really don't enjoy GUI development in Python. I am not a good enough CS to have the language to des
by jimnotgym 9y ago
I would love to hear more about this from the sages of HN. I really don't enjoy GUI development in Python. I am not a good enough CS to have the language to describe what is wrong, but I find it really hard to get Python GUI stuff to do what I want.
- blattimwind 9y agoIf you can't express what's wrong it will be even harder to find a solution.
- jimnotgym 9y agoSorry, I thought it was generally accepted that Python's relationship with the GUI was troubled? Put in plain English it is like this. I write quite a lot of code that integrates various enterprise systems together. Things like EDI management, and 'brokers' between incompatible API's. It is usually a mixture of Python/Bash/SQL. It is not my full-time job to code, but I get things done. As complexity increased I learned about version-control, OOP, and unit-testing. I have some pretty complex stuff in production. So I can self-learn all of those things, but not Python GUI programming The kind of thing I would happily launch from the command line, often needs a GUI when end users are involved. Even to have an app that takes an input>click OK>do some API stuff>return an answer seems absurdly complicated in Python and [insert whichever GUI framework]. In fact I find it simpler to add a web front end and a server than I do a desktop GUI. Qt was never on my list as I have enough battles to handle without negotiation with bosses for PyQt licensing costs. Hence my interest in this development. I didn't have this trouble with VB6 or VB.NET. Draw a box>draw a button>double-click the button>add the code you want to run when the button is clicked. When I do the same in Python I have dozens of lines of set-up code. I have a window with a text box and a button, surely that should be three lines of code (like in html)? Then I find that things are not running in the order I expected... Imagine for instance I want to put an alert box up that says "working", then call the function to do the work, then take the alert box away when the function exits...My Python head says this should look like this def on_ok_clicked(event): alert=framework.alertbox(text="working...") do_important_blocking_stuff() alert.destroy() and instead I find the GUI hanging while the function is running, then the alert box flash up and exit, or something equally unintuitive. There doesn't seem to be a Pythonic or indeed simple way to handle these super straight-forward use cases. I have no aspiration to be a UX person, or learn a new paradigm just to have a button that says "GO!". I'm guessing from the other comments that Qt for Python is not going to be my savior.
- toyg 9y ago> My Python head says this should look like this No, that's not "your python head", sorry, that's your "VB head" at best. That's lack of knowledge of how desktop GUI paradigms actually work and what an event loop is and how it interacts with threads. I do not disagree that VB (and Delphi) did a better job at hiding these concepts from the "just getting it done" crowd, but don't blame it on Python if you don't have a grasp of how C++ GUI toolkits actually work.
- jimnotgym 9y ago> but don't blame it on Python if you don't have a grasp of how C++ GUI toolkits actually work. I'm not blaming it on Python, honestly. I'm just really surprised that there isn't a framework that will hide that stuff from me like VB did. You are a 100% correct in that I don't know anything about desktop GUI paradigms, or C++ GUI toolkits. I really don't have the bandwidth to find out either! I'm also surprised that I need to. I don't think that is even my VB head, I am a business systems person who has successful modeled a physical process in software. In a recent case I did all of the work negotiating with vendors/management/users, I found the bugs in the vendors API, and I did this to an absurd deadline (with almost zero budget) created by a a vendor withdrawing a product with no notice. That's the kind of absurd thing us plebs in the "just getting it done" crowd have to do all of the time. But I am finding that simple GUI launchers for my software are really complicated in Python with the frameworks I have found. I am shocked that this is the piece that is defeating me! As I said before, I could write a web front-end for this kind of thing relatively easily (in the above case it was a hardware requirement that lead me to try again at the desktop GUI). Perhaps this is why we see so many people looking at the web-app-on-the-desktop that is so derided on these pages?
- mixmastamyk 9y agoYes, a shame that the FLOSS world never came up with a competitive integrated VB/Delphi clone in a better language like Python. Probably it would have been a huge undertaking, right when web dev was taking off. Although I've heard good things about Lazarus IDE, probably your best bet for such projects. Pascal is not hard to learn, or re-learn. https://en.wikipedia.org/wiki/Lazarus_(IDE) https://en.wikipedia.org/wiki/Lazarus_(IDE) http://www.lazarus-ide.org/ http://www.lazarus-ide.org/
- billsix 9y agoRetained-mode GUIs like Qt , wxWidgets, gtk, etc aren't intuitive. Try an immediate mode GUI, like my python bindings to nuklear https://github.com/billsix/pyNuklear https://github.com/billsix/pyNuklear
- btown 9y agoFor more context, immediate mode is much closer to the type of declarative UI popularized by libraries like React. The invariant is that what is displayed on screen is always a pure function of some state variable(s), and on any input/event, instead of needing to "reach into" some retained object that represents a certain piece of text in a certain pane in a certain window, you just change those state variables and re-render the entire UI from scratch. Sounds expensive, but for a 2D UI on hardware that's designed to do far more complicated things at 60FPS, it's far from the bottleneck. For instance, https://github.com/billsix/pyNuklear/blob/master/demo/overview.py#L305 https://github.com/billsix/pyNuklear/blob/master/demo/overvi... (this function is called repeatedly on each frame) is not significantly different from the example at https://reactjs.org/tutorial/tutorial.html#what-is-react https://reactjs.org/tutorial/tutorial.html#what-is-react ... but it is very different from something like `div = createDiv(); div2 = createDiv(parent=div)` etc. which would be a retained-mode API.
- billsix 9y agohttps://youtu.be/Z1qyvQsjK5Y https://youtu.be/Z1qyvQsjK5Y
- civilian 9y agoAnother option is pyImgui. Imgui is C++ based. pyimgui isn't on the latest imgui version, but it's coming along. https://github.com/swistakm/pyimgui https://github.com/swistakm/pyimgui
- vram22 9y agoWhat is the difference between the two GUI modes?
- 9y ago
- simion314 9y agoCan't you use a designer GUI to develop the static GUIs? You will have to understand how layouts actually work and how the designer translates your design into code/widgets/layouts. Then in Python you write your logic and event handlers. Qt also offers QML, if you are a fan of how those components look you may enjoy using it.