Python is a paramount programming languages. The same is to be said about user graphical interfaces. SaYa is an idiom I devised for tkinter developers to help them build less error-prone applications.
This morning I landed on this question asked on StackOverflow where the OP stumbled on this error he shared through his/her comment to my answer:
The origin of the problem is that the OP created a button widget within the class initializer and positioned in the same time:
When a mouse click event is performed, the callback is executed:
The Python interpreter raises a
TypeError exception late at runtime because it was assigned to destroy the
None singleton object.
In Python, everything is an object (yes, including classes), to achieve this principle, Python forces functions without a return type to return the
None object. This is the case of the 3 methods used to place widgets in tkinter:
Similar situations are frequent when developing GUIs in tkinter among newbies as well as experienced developers. That is why I created the SaYa idiom which I name using my parents’s first names first syllables to thank them for giving me the opportunity to live and a chance they were not able to afford for themselves: to study.
An idiom has at least one reason to exist. Here are the benefits of SaYa on tkinter GUIs:
- Ease of maintenance
- Narrowing down the attack surface on applications as this reduces bugs
SaYa is an idiom that proves to be benefical for all Python-tkinter developers.