From: Vines, J. (C. ARL/CISD) <jv...@ar...> - 2007-07-02 20:37:03
|
Classification: UNCLASSIFIED=20 Caveats: NONE =20 All, I am using the AppShell framework for a test application and am trying to get my callbacks working correctly. I have the AppShell application which makes a call to a Pmw.ComboBoxDialog class. How do I need setup my callbacks for my AppShell application?? Yes I'm new to Pmw :) My call in the AppShell application: def viewArmorLibrary(self): """Creates Tkinter listbox to select which library, Armor or Device""" ComboBoxDialog.ComboBoxDialog(None, 'armors') My ComboBoxDialog class: #!/usr/bin/env python from Tkinter import * import Pmw import xml.sax import XBeepXmlReader class ComboBoxDialog(Pmw.Dialog): # Dialog window with simple combobox. =20 # Dialog window displaying a list and entry field and requesting # the user to make a selection or enter a value def __init__(self, *args, **kw): #define which library to view, Armor or Device self.library =3D args[1] self.library_var =3D "" self.changed =3D BooleanVar() self.instructions =3D 'Double click value to select:\n' =20 if self.library =3D=3D 'armors': self.label =3D 'Armor' elif self.library =3D=3D 'devices': self.label =3D 'Device' =20 # Define the megawidget options. INITOPT =3D Pmw.INITOPT optiondefs =3D ( ('borderx', 10, INITOPT), ('bordery', 10, INITOPT), ) self.defineoptions(kw, optiondefs) # Initialise the base class (after defining the options). Pmw.Dialog.__init__(self, args[0]) =20 # Create the components. interior =3D self.interior() =20 aliases =3D ( ('listbox', 'combobox_listbox'), ('scrolledlist', 'combobox_scrolledlist'), ('entry', 'combobox_entry'), ('label', 'combobox_label'), ) self.parser =3D xml.sax.make_parser() self.handler =3D XBeepXmlReader.XBeepXmlReader() self.parser.setContentHandler( self.handler ) =20 #Need to check to see if file exists if self.library =3D=3D 'armors': file =3D "XBEEP/BEEP_Armors.xml" elif self.library =3D=3D 'devices': file =3D "XBEEP/BEEP_Devices.xml" else: print 'Cannot find the library...' sys.exit(1) =20 self.parser.parse(file) self._combobox =3D self.createcomponent('combobox', aliases, None, Pmw.ComboBox, (interior,), labelpos =3D 'n',=20 label_text =3D self.instructions + self.label + ':', scrolledlist_items=3Dself.handler.names, scrolledlist_dblclickcommand =3D self.getValue, dropdown =3D 0, ) self._combobox.pack(side=3D'top', expand=3D'true', = fill=3D'both', padx =3D self['borderx'], pady =3D self['bordery']) =20 # Check keywords and initialise options. self.initialiseoptions(ComboBoxDialog) =20 def myDestroy(self): print 'Here...' self.destroy() =20 def getValue(self): self.library_var =3D self._combobox.get() print '%s library value selected: %s' % (self.label, self.library_var) self.myDestroy() Pmw.forwardmethods(ComboBoxDialog, Pmw.ComboBox, '_combobox') Thanks in advance, =20 John =20 Classification: UNCLASSIFIED=20 Caveats: NONE |