![]() |
code execution after event - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: code execution after event (/thread-14347.html) |
code execution after event - shift838 - Nov-25-2018 i am very new to Python. I'm a .NET programmer but want to get into Python so I can write cross-platform code that will work on Windows as well as Linux based OS'. I have coded a GUI python form for some testing with various buttons, combo boxes and check buttons. I want to be able to execute specific code say if a button is selected or a value is selected. Can someone point me to somewhere to read up on how to do this or give me some direction. Thank you, RE: code execution after event - Larz60+ - Nov-25-2018 Quote:I have coded a GUIwhich GUI package? RE: code execution after event - shift838 - Nov-25-2018 (Nov-25-2018, 10:09 PM)Larz60+ Wrote:Quote:I have coded a GUIwhich GUI package? tkinter RE: code execution after event - Larz60+ - Nov-26-2018 Although this document is rather old, It's still the best (In my opinion) tkinter reference: http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html pdf version: http://www.nmt.edu/tcc/help/pubs/tkinter/tkinter.pdf. There's also now: https://docs.python.org/3/library/tk.html which I haven't really reviewed, but looks to be very complete, and what's more, new. Looks like it might be a better choice. As far as executing specific code when a button is pushed, you need to look up event processing. There are a couple of ways of doing it, simplest is using control in the Button definition, most powerful is by using bind: http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/events.html or https://docs.python.org/3/library/tkinter.html#bindings-and-events . You can use lambda on the control version to add arguments, but bind still provides more flexibility. |