Ejemplo n.º 1
0
	def __init__(self,
			context,
			outline,
			menuRootID=None,
			title='',
			closeAction='_',
			scale=.07,
			pos=(-.8,0,.8),
			parent=aspect2d,
			style = None,
			tipe = 'vertical'):
		self.context = context
		if menuRootID == None: self.menuRootID = newID()
		else: self.menuRootID = menuRootID
		self.scale=scale
		self.style=style
		t = indent2tree(outline)
		if tipe=='titleBar':
			t=[{'itmTxt':title+delimiter, 'children':t[:]}, {'itmTxt':'X'+delimiter+' kind=close, closeAction='+closeAction}]
		root = self.makeMenu('root', t, PandaNode('ehh'), tipe)
		self.np=parent.attachNewNode(root)
		self.np.setScale(scale)
		firstItemPath = self.np.find('-PGItem')
		f= firstItemPath.node().getPythonTag('extras').getFFrame()
		self.np.setPos(pos[0],pos[0],pos[2]-f[3]*scale)
		self.showing=False
		self.menu_Click=False
		self.clickBlock=False
		self.showIt()
Ejemplo n.º 2
0
 def __init__(self,
              context,
              outline,
              menuRootID=None,
              title='',
              closeAction='_',
              scale=.07,
              pos=(-.8, 0, .8),
              parent=aspect2d,
              style=None,
              tipe='vertical'):
     self.context = context
     if menuRootID == None: self.menuRootID = newID()
     else: self.menuRootID = menuRootID
     self.scale = scale
     self.style = style
     t = indent2tree(outline)
     if tipe == 'titleBar':
         t = [{
             'itmTxt': title + delimiter,
             'children': t[:]
         }, {
             'itmTxt':
             'X' + delimiter + ' kind=close, closeAction=' + closeAction
         }]
     root = self.makeMenu('root', t, PandaNode('ehh'), tipe)
     self.np = parent.attachNewNode(root)
     self.np.setScale(scale)
     firstItemPath = self.np.find('-PGItem')
     f = firstItemPath.node().getPythonTag('extras').getFFrame()
     self.np.setPos(pos[0], pos[0], pos[2] - f[3] * scale)
     self.showing = False
     self.menu_Click = False
     self.clickBlock = False
     self.showIt()
Ejemplo n.º 3
0
def menuItemParse(strng, isParent):
    """
	strng can be:
			"menuText" : makes a parent item if there are children, otherwise an 'info' item.
			"menuText|| kind=button, someClickFunction(arg,.. argn)" : makes a button with a click action.
			"menuText|| kind=checkBox, someClickFunction(arg,.. argn)" : makes a checkBox with a click action.
			"menuText|| kind=radioBTN, someClickFunction(arg,.. argn), groupID=radioBTNGroupID" :
				A  radioBTN that interacts with radioBTNs that have the same groupID .
			"menuText|| kind=<whatever>" : makes an item without a click action.
	Given strng = "menuText|| kind=kind, clickFunction(arg,.. argn), class=val1 val2 valn, key=val, key=val,..."
	where
			menuText is what shows in the menu,
			'delimiter' and what follows are options to guide the menu item response:
				* kind can be one of {'parent', 'button', 'checkBox', 'radioBTN', etc.}
				* clickFunction is the name of the function to call,
				* and arg(s) are the variable names of arguments for the function.
				* Use any key=value(s) to suit your app (separate multiple values with spaces, no commas except after last)
				* for radio buttons, use key,val groupID=<grpId> to identify their group,
				* for css id selector use key,val id=<uniqueID> (used by styler and your menu modification code)
				* for css class selectors use key,val class=className1 className2 ... (remember: spaces, no commas except after last)
	"""
    p = splitOn(strng, delimiter)  # txt, rest
    r = {'txt': p[0], 'kind': 'info', 'id': newID(), 'args': None}
    if len(p) > 1:  # if not just txt
        leftnright = p[1]
        if '\n' in leftnright:  # the odd multiLine case with function etc attached
            t = leftnright.split('\n', 1)
            r['txt'] += '\n' + t[1]  # append rest of multiLines
            leftnright = t[0]  # extract the kind, function, args.

        if len(leftnright) > 1:
            leftnFargs = leftnright.split('(')
            left = splitOn(leftnFargs[0], ',')
            right = []
            if len(leftnFargs) > 1:
                fargsnright = splitOn(leftnFargs[1], ')')
                if len(fargsnright) > 0:
                    if fargsnright[0][0] == ',':
                        right = splitOn(fargsnright[0], ',')
                    else:
                        r['args'] = fargsnright[0]
                if len(fargsnright) > 1:
                    right = splitOn(fargsnright[1], ',')
                r['func'] = left[-1]  # get the func
                left = left[:-1]  #minus the func
            leftnright = left + right  # concat
        if leftnright > 0:
            for p in leftnright:
                kw, val = splitOn(p, '=')
                r[kw] = val
    if isParent: r['kind'] = 'parent'
    elif r['txt'][:3] == '---': r['kind'] = 'separator'
    return r
Ejemplo n.º 4
0
def menuItemParse(strng, isParent):
	"""
	strng can be:
			"menuText" : makes a parent item if there are children, otherwise an 'info' item.
			"menuText|| kind=button, someClickFunction(arg,.. argn)" : makes a button with a click action.
			"menuText|| kind=checkBox, someClickFunction(arg,.. argn)" : makes a checkBox with a click action.
			"menuText|| kind=radioBTN, someClickFunction(arg,.. argn), groupID=radioBTNGroupID" :
				A  radioBTN that interacts with radioBTNs that have the same groupID .
			"menuText|| kind=<whatever>" : makes an item without a click action.
	Given strng = "menuText|| kind=kind, clickFunction(arg,.. argn), class=val1 val2 valn, key=val, key=val,..."
	where
			menuText is what shows in the menu,
			'delimiter' and what follows are options to guide the menu item response:
				* kind can be one of {'parent', 'button', 'checkBox', 'radioBTN', etc.}
				* clickFunction is the name of the function to call,
				* and arg(s) are the variable names of arguments for the function.
				* Use any key=value(s) to suit your app (separate multiple values with spaces, no commas except after last)
				* for radio buttons, use key,val groupID=<grpId> to identify their group,
				* for css id selector use key,val id=<uniqueID> (used by styler and your menu modification code)
				* for css class selectors use key,val class=className1 className2 ... (remember: spaces, no commas except after last)
	"""
	p =splitOn(strng, delimiter)# txt, rest
	r = {'txt': p[0], 'kind':'info', 'id': newID(), 'args':None}
	if len(p)>1: # if not just txt
			leftnright=p[1]
			if '\n' in leftnright: # the odd multiLine case with function etc attached
				t = leftnright.split('\n',1)
				r['txt']+= '\n'+t[1]    # append rest of multiLines
				leftnright=t[0]         # extract the kind, function, args.

			if len(leftnright) > 1:
				leftnFargs = leftnright.split('(')
				left = splitOn(leftnFargs[0], ',')
				right = []
				if len(leftnFargs) > 1:
					fargsnright = splitOn(leftnFargs[1], ')')
					if len(fargsnright)>0:
						if fargsnright[0][0]==',':
								right = splitOn(fargsnright[0], ',')
						else: r['args'] = fargsnright[0]
					if len(fargsnright) > 1:
						right = splitOn(fargsnright[1], ',')
					r['func'] = left[-1]               # get the func
					left = left[:-1] #minus the func
				leftnright = left+right       # concat
			if leftnright > 0:
				for p in leftnright:
					kw, val = splitOn(p, '=')
					r[kw] = val
	if isParent: r['kind']='parent'
	elif r['txt'][:3] == '---': r['kind']='separator'
	return r