I am planning to write a button widget, but I need your advise before I
start. So my plan is to create a button widget which has an "active
background" widget and an "inactive background" widget and another widget
that becomes the label of the button. Example (I just typed this in the
email so some API calls may be different or non-existent):
class Button(kaa.candy.Container):
def __init__(self, activeBackground, inactiveBackground, label):
add(activeBackground)
add(inactiveBackground)
add(label)
w = label.getWidth()
h = label.getHeight()
activeBackground.setSize(w, h)
inactiveBackground.setSize(w, h)
# initially all buttons are inactive (not selected)
activeBackground.hide()
self.active = false
A button can be made active (selected) or inactive with a method like so.
def setActive(self, state):
if self.active == state:
return
self.active = state
if state:
inactiveBackground.hide()
activeBackground.show()
else:
activeBackground.hide()
inactiveBackground.show()
And the candy xml may look like
<candyxml geometry="800x600">
<button name="test">
<rectangle width="200" height="50" color="0x888888"
border_size="2" border_color="0xffffff" radius="10" name="inactiveBg"/>
<rectangle width="200" height="50" color="0x008800"
border_size="2" border_color="0xffffff" radius="10" name="activeBg" />
<label name="test" align="center" font="Vera:24"
color="0xffffff" name="label">
Hello world
</label>
</button>
</candyxml>
Now my question is, how do I make button read the first rectangle (might as
well be any other widget say Image) as inactive background and the next
rectangle as active background and then the label (could be any widget) as
button label? Assuming the names "inactiveBg" "activeBg" etc in Button class
is stupid, but I did not know how else to do it. Please recommend a proper
course of action. Or may be my whole thinking is wrong and you have a better
suggestion for how a button should look and behave?
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Freevo-devel mailing list
Freevo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-devel