2014-03-19, 15:38
(2014-03-19, 14:54)Aweponken Wrote:(2014-03-19, 12:03)Roman_V_M Wrote: That depends on your preferences. Coding style is completely up to you, as long as it works and supportable.Oh, okay!
So I'm trying to convert the radiobutton from the demo version.
The original code looks like this:
Should be something like(?):
PHP Code:window.connect(radiobutton, radio_update)
This should work, though personally I think that it is not too good that your function refers to an object (radiobutton) from outside (global?) scope. Usually this means bad code style. For good code style your function should communicate with the rest of your program only via its interface, i.e. function call signature and return/yield statement.
If you really don't want to use OOP then it should be something like this:
PHP Code:
def radio_update(radiobutton):
# Update radiobutton caption on toggle
if radiobutton.isSelected():
radiobutton.setLabel('On')
else:
radiobutton.setLabel('Off')