Package teamwork :: Package widgets :: Module ActionDialog
[hide private]
[frames] | no frames]

Source Code for Module teamwork.widgets.ActionDialog

 1  from Tkinter import * 
 2  import tkMessageBox 
 3  import Pmw 
 4   
 5  from teamwork.action.PsychActions import ActionCondition 
 6   
7 -class ActionDialog(Pmw.Dialog):
8 """Class for specifying L{ActionCondition}s 9 """
10 - def __init__(self,parent,**kw):
11 optiondefs = ( 12 ('actions', [], None), 13 ('activatecommand', self.setActions, None), 14 ) 15 self.defineoptions(kw, optiondefs) 16 Pmw.Dialog.__init__(self,parent) 17 self.createcomponent('label',(),None,Label,(self.interior(),), 18 bd=2,relief='ridge') 19 self.component('label').grid(row=0,column=0,sticky='ew',padx=10,pady=10) 20 self.createcomponent('options',(),None,Pmw.RadioSelect, 21 (self.interior(),),orient='vertical', 22 buttontype='checkbutton') 23 self.component('options').add('only',text='No other actions can occur') 24 self.component('options').grid(row=1,column=0,sticky='ew', 25 padx=10,pady=10) 26 self.createcomponent('actions',(),None,Pmw.ScrolledListBox, 27 (self.interior(),), 28 selectioncommand=self.selectAction, 29 listbox_exportselection=0, 30 listbox_selectmode='multiple') 31 self.component('actions').grid(row=2,column=0,sticky='ewns', 32 padx=10,pady=10) 33 self.initialiseoptions(ActionDialog)
34
35 - def setActions(self):
36 self.component('actions').setlist(self['actions']) 37 self.selectAction()
38
39 - def selectAction(self):
40 """Callback when clicking on the action selection box 41 """ 42 actions = list(self.component('actions').getvalue()) 43 actions.sort() 44 if len(actions) > 0: 45 self.component('label').configure(text=', '.join(actions)) 46 else: 47 self.component('label').configure(text='Any action')
48
49 - def getCondition(self):
50 """ 51 @return: the currently specified L{ActionCondition} 52 @rtype: L{ActionCondition} 53 """ 54 condition = ActionCondition('only' in self.component('options').getvalue()) 55 for action in self.component('actions').getvalue(): 56 condition.addCondition(action) 57 return condition
58