Beispiel #1
0
def test_7():
    from PLLParser import parsePLL

    (node, h) = parsePLL('''
			mainWindow
				*menubar
					align=left
					flow  =  99
					--------------
					not an option
				*layout
					life=  42
					meaning   =42
			''')

    menubar = h['menubar']
    assert menubar
    assert isinstance(menubar, TreeNode)
    hOptions1 = menubar.getOptions()
    assert hOptions1 == {
        'align': 'left',
        'flow': '99',
    }

    layout = h['layout']
    assert layout
    assert isinstance(layout, TreeNode)
    hOptions2 = layout.getOptions()
    assert hOptions2 == {
        'life': '42',
        'meaning': '42',
    }
Beispiel #2
0
def compile(turtleCode):
	# --- returns Python Code as a string

	assert type(turtleCode) == str
	(tNode, hSubTrees) = parsePLL(turtleCode, TurtleNode)
	assert isinstance(tNode, TurtleNode)

	pNode = tNode.pythonify()
	assert isinstance(pNode, PythonNode)
	return pNode.asString()
Beispiel #3
0
    def __init__(self, appDesc):
        global root

        if root:
            raise Exception("You can only create one GUIApplication")
        self.hWidgets = {}  # widgets saved by name

        # --- Parse the app description into an appNode, and a hash
        #     holding any tagged subtrees
        (appNode, hSubTrees) = parsePLL(appDesc)

        root = self.getMainWindow(appNode, hSubTrees)
        self.mainWindow = root

        if getattr(self, 'centerWindow', None):
            self.centerWindow()
Beispiel #4
0
def test_8():
    from PLLParser import parsePLL

    # --- Note that this regexp allows no space before the colon
    #     and requires at least one space after the colon
    reWithColon = re.compile(r'^(\S+):\s+(.*)$')
    (node, h) = parsePLL('''
			mainWindow
				*menubar
					align: left
					flow:    99
					notAnOption : text
					notAnOption:moretext
					--------------
					not an option
				*layout
					life:  42
					meaning:   42
			''')

    menubar = h['menubar']
    assert menubar
    assert isinstance(menubar, TreeNode)
    hOptions1 = menubar.getOptions(re=reWithColon)
    assert hOptions1 == {
        'align': 'left',
        'flow': '99',
    }

    layout = h['layout']
    assert layout
    assert isinstance(layout, TreeNode)
    hOptions2 = layout.getOptions(re=reWithColon)
    assert hOptions2 == {
        'life': '42',
        'meaning': '42',
    }
Beispiel #5
0
s = '''
	*menubar
		size = 23
		file
			new
			open
		edit
			undo
	*layout
		row
			EditField
			SelectField
'''

(tree, hSubTrees) = parsePLL(s, debug=False)

print("Keys in main node:")
for (key, value) in tree.items():
    print(f"   {key}")

if hSubTrees:
    print("Sub Trees:")
    for key in hSubTrees.keys():
        print(f"   {key}")

menubar = hSubTrees['menubar']
print("MENUBAR:")
menubar.printTree()
if menubar:
    n = menubar.numChildren()
Beispiel #6
0
 def appendChild(self, text):
     (node, hSubTrees) = parsePLL(text, PythonNode)
     self.appendChildNode(node)
     return self  # allow chaining