# convenience tags


def flatten_checkbox(o):
    if o.attrs.get('checked', False):
        o.attrs['checked'] = 'checked'
    else:
        try:
            del o.attrs['checked']
        except KeyError:
            pass
    return flatten_tag(o)


checkbox = custom_tag('input',
                      'checkbox',
                      flatten_checkbox,
                      attrs={'type': 'checkbox'})


def flatten_option(o):
    if o.attrs.get('selected', False):
        o.attrs['selected'] = 'selected'
    else:
        try:
            del o.attrs['selected']
        except KeyError:
            pass
    return flatten_tag(o)


option = custom_tag('option', flattener=flatten_option)
Example #2
0
                menuengine._d_prebinds[id] = val.attrs.get("bind")
                mf.Bind(wx.EVT_MENU, prebind_wrapper, id=id)
            else:
                mf.Bind(wx.EVT_MENU, getattr(mf, val.attrs.get("bind")), m)

    if val.name == "menucheck":
        mf.am.AppendCheckItem(-1, label)

    if val.name == "menuradio":
        mf.am.AppendRadioItem(-1, label)

    return msg


menubar, menu, menusep, menuitem, menucheck, menuradio = [
    custom_tag(x, flattener=flatten_menutag)
    for x in "menubar menu menusep menuitem menucheck menuradio".split()
]


class MainFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          "Testing Menu Engine",
                          size=(500, 400))

        menuengine.frame = self
        menuengine.prebind = self.Logger
        c = menubar[menu["File",
Example #3
0

# convenience tags

def flatten_checkbox(o):
    if o.attrs.get('checked', False):
        o.attrs['checked'] = 'checked'
    else:
        try:
            del o.attrs['checked']
        except KeyError:
            pass
    return flatten_tag(o)


checkbox = custom_tag('input', 'checkbox', flatten_checkbox, attrs={'type': 'checkbox'})


def flatten_option(o):
    if o.attrs.get('selected', False):
        o.attrs['selected'] = 'selected'
    else:
        try:
            del o.attrs['selected']
        except KeyError:
            pass
    return flatten_tag(o)


option = custom_tag('option', flattener=flatten_option)
Example #4
0
		if val.attrs.get("bind", ""):
			if prebind:
				menuengine._d_prebinds[ id ] = val.attrs.get("bind")
				mf.Bind( wx.EVT_MENU, prebind_wrapper, id = id )
			else:
				mf.Bind( wx.EVT_MENU, getattr( mf, val.attrs.get("bind")), m )

	if val.name == "menucheck":
		mf.am.AppendCheckItem( -1 , label) 

	if val.name == "menuradio":
		mf.am.AppendRadioItem( -1 , label )

	return msg

menubar, menu, menusep, menuitem, menucheck, menuradio = [ custom_tag( x, flattener = flatten_menutag) for x in "menubar menu menusep menuitem menucheck menuradio".split() ]

class MainFrame( wx.Frame ):
	def __init__(self):
		wx.Frame.__init__(self , None, -1, "Testing Menu Engine", size = ( 500,400 ))

		menuengine.frame = self
		menuengine.prebind = self.Logger
		c = menubar[  menu[ "File",  menuitem( bind = "OnNotReady" )["Open"], menuitem( prebind = "True", bind = "OnNotReady" )["Save"] , menusep[""],  menuitem( bind = "OnExit" )["Exit"] ] ]
		flatten( c )

	def OnExit( self, event ):
		self.Close()

	def OnNotReady(self, event):
		wx.MessageBox("Not ready", "Hey" )