Permalink
Browse files

Minor changes to menuengine.py and test.py

  • Loading branch information...
batok committed Feb 3, 2009
1 parent f45687d commit 36fc4fd7069bdac8de4f326d11e94626d1049d4f
Showing with 11 additions and 6 deletions.
  1. +7 −5 menuengine.py
  2. +4 −1 test.py
View
@@ -19,12 +19,16 @@ def flatten_menutag(val):
enable = False
except:
pass
+
user = val.attrs.get("user", "")
group = val.attrs.get("group", "")
+
if user and user != menuengine.user:
return msg
+
if group and group not in menuengine.groups:
return msg
+
try:
mf.mb
except:
@@ -42,8 +46,7 @@ def flatten_menutag(val):
mf.am.AppendSeparator()
if val.name == "menuitem":
- mi = wx.MenuItem( parentMenu = mf.am, id = wx.ID_ANY, text = label, kind=wx.ITEM_NORMAL, subMenu = None)
-
+ mi = wx.MenuItem( parentMenu = mf.am, id = wx.ID_ANY, text = label, kind = wx.ITEM_NORMAL, subMenu = None)
m = mf.am.AppendItem( mi )
mi.Enable( enable )
if val.attrs.get("bind", ""):
@@ -61,9 +64,9 @@ def flatten_menutag(val):
class MainFrame( wx.Frame ):
def __init__(self):
- wx.Frame.__init__(self , None, -1, "Testing Menu Engine", size = ( 500,400))
+ wx.Frame.__init__(self , None, -1, "Testing Menu Engine", size = ( 500,400 ))
menuengine.frame = self
- c = menubar[ menu[ "File", menuitem( bind = "OnNotReady" )["Open"], menuitem["Save"] , menusep[""], menuitem( bind = "OnExit" )["Exit"] ] ]
+ c = menubar[ menu[ "File", menuitem( bind = "OnNotReady" )["Open"], menuitem["Save"] , menusep[""], menuitem( bind = "OnExit" )["Exit"] ] ]
flatten( c )
def OnExit( self, event ):
@@ -72,7 +75,6 @@ def OnExit( self, event ):
def OnNotReady(self, event):
wx.MessageBox("Not ready", "Hey" )
-
if __name__ == "__main__":
app = wx.PySimpleApp()
f = MainFrame()
View
@@ -1,3 +1,6 @@
+"""
+This script needs python 2.6 or above because uses the "with" statement.
+"""
import wx
from menuengine import *
import wx.lib.sized_controls as sc
@@ -52,7 +55,7 @@ def Clone( self):
def Validate(self, win):
textCtrl = self.GetWindow()
text = textCtrl.GetValue()
- # a warning. setting SetBackgroundColour in mac os x is useless, because the background color remains the same.
+ # a warning. setting SetBackgroundColour in mac os x is useless, because the background color of the TextCtrl can not change.
if len(text) == 0:
wx.MessageBox("{0} can't be empty!".format(self.name), caption="Validation Error")
textCtrl.SetBackgroundColour("pink")

0 comments on commit 36fc4fd

Please sign in to comment.