Thursday, 10 November 2011

wxPython - Little Things - Pt. 1 of many - Grey out radio buttons

When I use GUIs in Python, I always use wxPython. Simply because when I first wanted to create GUIs, wxPython was the one that I understood quickest. There is not much else to it.

I will not write another tutorial about it, because there are enough out there already. For basic ones, just have a look at these:

http://zetcode.com/wxpython/
http://wiki.wxpython.org/AnotherTutorial
http://wiki.wxpython.org/How%20to%20Learn%20wxPython
http://wiki.wxpython.org/Getting%20Started

and then there are also loads of videos on youtube and on showmedo. And last but definitely not least you may wanna check out the book on wxPython. These are all written (or made) by people who have the tendency to know more about the topic than I do.

So here is what I am going to do. Since I am still a learner myself, I will always try to note down a little bit of wisdom of wxPython to you.

The first one is the EnableItem(n, flag) method for a specific Radiobutton. Until this day, I truly thought that you could only enable or disable the entire radio box widget. Just call radiobox.Disable() or .Enable() and bob's your uncle (this works for all widgets I believe). Today, I wanted to disable separate buttons of the radio.
After some googling, I finally came across the wxWidgets documentation and stumbled across EnableItem(n, flag). So calling this with the index of your selection to be disabled and the flag "False", you actually can grey out a single button :)

Voila.

No comments:

Post a Comment