demoActionFactory.py

demoActionFactory.py
1 import MaxPlus
2 
3 somethingHappened = False
4 
5 
6 def doSomething():
7  global somethingHappened
8  somethingHappened = True
9  print "I sleep all night and I work all day!"
10 
11 
12 def printAction(a):
13  print "id ", a.Id
14  print "button text ", a.ButtonText
15  print "menu text ", a.MenuText
16  print "description ", a.Description
17  print "category ", a.Category
18  print "checked ", a.Checked
19  print "indeterminate ", a.Indeterminate
20  print "visible ", a.Visible
21  print "enabled ", a.Enabled
22  print "dynamic ", a.Dynamic
23  print "shortcut ", a.Shortcut
24 
25 action = MaxPlus.ActionFactory.Create(
26  'Do something', 'Python demo', doSomething)
27 printAction(action)
28 
29 assert(not somethingHappened)
30 action.Execute()
31 assert(somethingHappened)
32 action.Execute()
33 assert(somethingHappened)