How do you use an if statment in wx python?
I I've read a tutorial but all the tutorial did was confuse me even more!!!
- husoskiLv 79 years agoFavorite Answer
It's the same as in any other Python...
if x < 5:
... statements to do if x is less than 5
... more staements
... all at the same indent level
... statements to do if x is 5 or more
... more statements
... again, same indentation
The "..." tokens are just for indentation. Pretend they are spaces or tabs.
The "else:" part is optional. If you leave it off, the default is "else do nothing."
You might want to learn Python basics in a simpler environment before messing with wxPython. The folks at wxpython.org say the same thing at the top of their "How to learn wxPython" wiki page:
A framework like wxWidgets or tkinter makes developing a GUI application easier, but it is still involved. You don't want to be trying to absorb event-driven code while you're still working on the basics of types, expressions, and statements...and you should learn some intermediate concepts too, such as modules, classes and exceptions.