Skip to content

Instantly share code, notes, and snippets.

@anaselli
Created August 31, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anaselli/807a84de3e1ee08b47d2 to your computer and use it in GitHub Desktop.
Save anaselli/807a84de3e1ee08b47d2 to your computer and use it in GitHub Desktop.
YItem comparison in python
import sys
import yui
factory = yui.YUI.widgetFactory()
dialog = factory.createMainDialog()
VBox = factory.createVBox(dialog)
mySelMinSize = factory.createMinSize(VBox, 50, 12)
mySel = factory.createSelectionBox(mySelMinSize, "Selection Box")
mySel.setNotify(True);
myOK = factory.createPushButton(VBox, "OK")
myItem = yui.YItem( "foo" )
mySel.addItem(myItem)
myItem2 = yui.YItem( "bar" )
mySel.addItem(myItem2)
while True:
event = dialog.waitForEvent()
if event.eventType() == yui.YEvent.CancelEvent:
break
if event.widget() == myOK:
break
if event.widget() == mySel:
item = mySel.selectedItem();
if item == myItem:
print "item comparison works and you chose", item.label()
elif item == myItem2:
print "item comparison works and you chose", item.label()
else:
print "item comparison does not work"
dialog.destroy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment