Exemplo n.º 1
0
import PySimpleGUI as sg
from binaryTree import Node

# GUI for Task Organizer

layout = [
            [sg.Text('Task Organizer')],
            [sg.Text('Task Name: ', size=(15,1)), sg.InputText()],
            [sg.Text('Priority: ', size=(15,1)), sg.InputCombo(['LOW', 'MEDIUM', 'HIGH'], size=(20,3))],
            [sg.Button('Add'), sg.Button('Done')]
        ]

window = sg.Window('Task Organizer App').Layout(layout)
root = Node(None)

dict = {'LOW': 1, 'MEDIUM': 2, 'HIGH': 3}

while True:
    event, values = window.Read()
    if event is not None and event == 'Add':
        print(event, dict[values[1]])
        root.insert(dict[values[1]])
    if event == 'Done' or event is None:
        print('SIZE:')
        print(root.getSize())
        print('TREE:')
        root.PrintTree()
        break

window.Close()
Exemplo n.º 2
0
# GUI for Task Organizer

layout = [[sg.Text('Task Organizer')],
          [sg.Text('Task Name: ', size=(15, 1)),
           sg.InputText()],
          [
              sg.Text('Priority: ', size=(15, 1)),
              sg.InputCombo(['LOW', 'MEDIUM', 'HIGH'], size=(20, 3))
          ], [sg.Button('Add'), sg.Button('Done')], [sg.Output(size=(80, 10))]]

window = sg.Window('Task Organizer App').Layout(layout)
root = Node(None, None)

dict = {'LOW': 1, 'MEDIUM': 2, 'HIGH': 3}

while True:
    event, values = window.Read()
    if event is None:
        break
    elif event == 'Add':
        print(values[0], dict[values[1]])
        root.insert(values[0], dict[values[1]])
    elif event == 'Done':
        print('SIZE:')
        print(root.getSize())
        print('TREE:')
        root.PrintTree()

window.Close()
Exemplo n.º 3
0
from binaryTree import Node


def reverse(node):
    """
    二叉树翻转
    :param node: 根节点
    :return:
    """
    node.left, node.right = node.right, node.left
    if node.left:
        reverse(node.left)
    if node.right:
        reverse(node.right)


if __name__ == '__main__':
    node = Node(6)
    data = [9, 5, 2, 1, 3, 4, 7]
    for i in data:
        node.insert(i)
    node.treeGraph(indent=0)
    node.inOrder()
    print
    node.postOrder()
    print
    reverse(node)
    node.treeGraph(indent=0)
    node.inOrder()
    print
    node.postOrder()
Exemplo n.º 4
0
    [sg.Text('Task Name: ', size=(15, 1)),
     sg.InputText(do_not_clear=False)],
    #do_not_clear=False clears the input box everytime event is True
    [sg.Text('Priority: ', size=(15, 1)),
     sg.InputText(do_not_clear=False)],
    [sg.Button('Add'), sg.Button('Done'),
     sg.Button('Clear')],
    [sg.Output(size=(80, 10))]
]

window = sg.Window('Task Organizer App').Layout(layout)
root = Node(None, None)

#dict = {'LOW': 1, 'MEDIUM': 2, 'HIGH': 3}

while True:
    event, values = window.Read()
    if event is None:
        break
    elif event == 'Add':
        print(values[0], values[1])
        root.insert(values[0], int(values[1]))
    elif event == 'Done':
        print('SIZE:')
        print(root.getSize())
        print('TREE:')
        root.PrintTree()
    #elif event == 'Clear': #clear the console print screen

window.Close()