Ejemplo n.º 1
0
def searchRouteByLocationWindow(location):
    layoutOperation = [[sg.Text('What place do you want to explore ?')],
                       [sg.InputText(location)], [],
                       [sg.Text('By what do you want to travel ?')],
                       [
                           sg.Checkbox('Personal car'),
                           sg.Checkbox('On foot', default=True),
                           sg.Checkbox("Public transportation")
                       ], [sg.Text('What are your interests ?')],
                       [
                           sg.Checkbox('Arts'),
                           sg.Checkbox('Arhitectural'),
                           sg.Checkbox("Entertainment")
                       ], [sg.Button('Search for me'),
                           sg.Button('Cancel')]]
    windowOperation = sg.Window('Text it out').Layout(layoutOperation)

    while True:
        eventOperation, valuesOperation = windowOperation.Read()
        if eventOperation in (None, 'Cancel'):
            windowOperation.close()
            main()
            break
        elif eventOperation in ('Search for me'):
            windowOperation.close()

            print(valuesOperation)
            searchRouteByLocationAlgorithm(valuesOperation[0], valuesOperation)
Ejemplo n.º 2
0
def app():
    # global vvv

    # print(xxx)
    global vehicle_graph
    global vehicle_path_graph
    global vehicle_current_order
    window = sg.Window('OpenTCS Web Client', layout, web_ip='0.0.0.0', web_port=8089, finalize=True)
    window.Finalize()
    for i in points_pose:
        graph_elem.draw_circle((i[1],i[2]), 1, fill_color='black', line_color='red')
    for i in path_list:
        graph_elem.draw_line(points_dic[i[0]], points_dic[i[1]], color='black', width=1)
    for i in vehicles:
        vehicle_graph = graph_elem.draw_circle(points_dic[i[-2]], 5, fill_color='green', line_color='green')
    # draw_order()
    action_dic = {'无':"NOP", '卸货':"UNLOAD",'载货':'LOAD', '充电':'CHARGE'}
    while True:
        event, values = window.read(timeout=1)
        if event == '添加':
            vvv.append([len(vvv),values['Target'], values['action']])
            window['transport'].Update(values=vvv)
        if event == '下单':
            print('下单'+values['Target']+values['action'])
            tcs.creat_order(locations=[[values['Target'], action_dic[values['action']]]])
Ejemplo n.º 3
0
def openWindowImageSearch():
    print('Image search')
    ROOT_DIR = os.path.dirname(
        os.path.abspath(__file__))[0:-7] + "\\data\\blohsaved.png"
    print(ROOT_DIR)
    image_elem = sg.Image(ROOT_DIR)
    layoutOperation = [[
        sg.Text('An image says what a thousand words can\'t..')
    ], [sg.Text('The image :'),
        sg.InputText('path'),
        sg.FileBrowse()], [image_elem],
                       [sg.Button('Search for me'),
                        sg.Button('Cancel')]]
    windowOperation = sg.Window('Text it out').Layout(layoutOperation)

    while True:
        eventOperation, valuesOperation = windowOperation.Read(timeout=50)
        if eventOperation in (None, 'Cancel'):
            windowOperation.close()
            main()
            break
        elif eventOperation in ('Search for me'):
            windowOperation.close()
            searchByImageAlgorithm(valuesOperation[0])

        if valuesOperation[0] != "path":
            image_elem.update(valuesOperation[0])
Ejemplo n.º 4
0
def main():
    dictionary_of_figures = {
        'Axis Grid': create_axis_grid,
        'Subplot 3D': create_subplot_3d,
        'Scales': create_pyplot_scales,
        'Basic Figure': create_figure
    }

    layout = [
        [sg.T('Matplotlib Example', font='Any 20')],
        [
            sg.Listbox(dictionary_of_figures.keys(), size=(15, 5), key='-LB-'),
            sg.Image(key='-IMAGE-')
        ],
        [sg.B('Draw'), sg.B('Exit')],
    ]

    window = sg.Window('Title', layout, finalize=True)

    image_element = window['-IMAGE-']  # type: sg.Image

    while True:
        event, values = window.read()
        if event == 'Exit' or event == sg.WIN_CLOSED:
            break
        if event == 'Draw':
            func = dictionary_of_figures[values['-LB-'][0]]
            draw_figure(func(), image_element)
    window.close()
Ejemplo n.º 5
0
def get_poop_description(previous=None):
    colours = ['πράσινα', 'καφέ', 'κίτρινα', 'μαύρα']
    consistencies = ['υγρά', 'στέρεα', 'σποράκια', 'βλέννα', 'αίμα']
    attributes = colours + consistencies
    if previous is None:
        default_attr = {k: False for k in attributes}
    else:
        default_attr = {k: k in previous for k in attributes}
    win = sg.Window(
        'Κακά',
        layout=(
            [[sg.CBox(k, default=v, key=k)] for k, v in default_attr.items()] +
            [[sg.Text('Άλλο:'), sg.Input(key='comment_text')],
             [sg.Button('OK', key='ok'), sg.Button('Άκυρο', key='cancel')]]))
    event, values = win.Read()
    if event == 'ok':
        desc = values.pop('comment_text', '')
        if len(desc) > 0:
            output_list = [desc] + [k for k, v in values.items() if v]
        else:
            output_list = [k for k, v in values.items() if v]
        output_str = ', '.join(output_list)
    else:
        output_str = None
    win.Close()
    return output_str
def main():
    global g_interval,  g_procs, g_exit

    # ----------------  Create Form  ----------------
    sg.change_look_and_feel('Black')
    layout = [[sg.Text('', size=(8, 1), font=('Helvetica', 20), text_color=sg.YELLOWS[0],
                    justification='center', key='text')],
              [sg.Text('', size=(30, 8), font=('Courier New', 12),
                    text_color='white', justification='left', key='processes')],
              [sg.Exit(button_color=('white', 'firebrick4'),
                       pad=((15, 0), 0), size=(9, 1)), ]
              ]

    window = sg.Window('CPU Utilization', layout,
           no_titlebar=True, keep_on_top=True, alpha_channel=.8, grab_anywhere=True)

    # start cpu measurement thread
    thread = Thread(target=CPU_thread, args=(None,), daemon=True)
    thread.start()
    timeout_value = 1             # make first read really quick
    g_interval = 1
    # ----------------  main loop  ----------------
    while True:
        # --------- Read and update window --------
        event, values = window.read(
            timeout=timeout_value, timeout_key='Timeout')
        # --------- Do Button Operations --------
        if event in (None, 'Exit'):
            break

        timeout_value = 1000

        cpu_percent = g_cpu_percent
        display_string = ''
        if g_procs:
            # --------- Create list of top % CPU porocesses --------
            try:
                top = {proc.name(): proc.cpu_percent() for proc in g_procs}
            except:
                pass

            top_sorted = sorted(
                top.items(), key=operator.itemgetter(1), reverse=True)
            if top_sorted:
                top_sorted.pop(0)
            display_string = ''
            for proc, cpu in top_sorted:
                display_string += '{:2.2f} {}\n'.format(cpu/10, proc)

        # --------- Display timer and proceses in window --------
        window['text'].update('CPU {}'.format(cpu_percent))
        window['processes'].update(display_string)

    window.close()
Ejemplo n.º 7
0
 def __add_task(self):
     layout1 = [[sg.Text("Write the task title:")], [sg.InputText()],
                [sg.Button("Next")]]
     window1 = sg.Window("To-Do app", layout1, resizable=True)
     while True:
         event, values = window1.read()
         if event == sg.WIN_CLOSED:
             return
         if event == "Next":
             break
     new_task = Task()
     new_task.title_ = values[0]
     window1.close()
     date_list = sg.popup_get_date()
     new_task.date_ = date(date_list[2], date_list[0], date_list[1])
     str1 = "Is it a frog?"  # + emoji.emojize(':frog:')
     layout2 = [[sg.Text(str1)],
                [
                    sg.Text("About 'Eat the frog' method.",
                            text_color='#0645AD',
                            enable_events=True,
                            key='-LINK-')
                ], [sg.Button("Yes")], [sg.Button("No")]]
     window2 = sg.Window("To-Do app", layout2, resizable=True)
     while True:
         event, values = window2.read()
         if event == sg.WIN_CLOSED:
             return
         if event == '-LINK-':
             webbrowser.open(
                 r'https://todoist.com/productivity-methods/eat-the-frog')
         if event == "Yes":
             new_task.is_frog_ = True
             break
         if event == "No":
             new_task.is_frog_ = False
             break
     window2.close()
     if not (new_task.date_ in self.undone_tasks_):
         self.undone_tasks_[new_task.date_] = []
     self.undone_tasks_[new_task.date_].append(new_task)
Ejemplo n.º 8
0
def main():
    layout = [[sg.Text('Matplotlib Simple Plot', font='Any 20')],
              [sg.Image(key='-IMAGE-')], [sg.Button('Exit')]]

    window = sg.Window('Matplotlib Example', layout, finalize=True)

    fig = plt.figure()
    x = np.arange(0, 5, 0.1)
    y = np.sin(x)
    plt.plot(x, y)
    draw_figure(fig, window['-IMAGE-'])

    window.read(close=True)
Ejemplo n.º 9
0
def main():

    ComputeStrLayout = [[
        sg.Multiline(key='computeStr',
                     background_color='black',
                     text_color='yellow',
                     font="any 30",
                     size=(60, 4))
    ]]
    numsBtLayout = [[
        sg.Button(i * 3 + j,
                  size=(4, 2),
                  button_color=('white', 'green'),
                  key=i * 3 + j) for j in range(1, 4)
    ] for i in range(0, 3)]
    comBtLayout1= [[sg.Button('0',size=(4,2),key=0),sg.Button('.',size=(4,2),key='.')],\
        [sg.Button('(',size=(4,2),key='('),sg.Button('C',size=(4,2),key='C')],\
        [sg.Button(')',size=(4,2),key=')'),sg.Button('<=',size=(4,2),key='BackDel')],\
        ]
    comBtLayout2=[\
        [sg.Button('+',size=(4,2),key='+'),\
         sg.Button('-',size=(4,2),key='-'),\
         sg.Button('×',size=(4,2),key='*'),\
        sg.Button('÷',size=(4,2),key='/'),\
        sg.Button('=',size=(4,2),key='=')]\
    ]
    mainLayout=[[sg.Frame('',ComputeStrLayout)],\
                 [sg.Frame('',numsBtLayout),\
    sg.Column(comBtLayout1)],\
    [sg.Frame('',comBtLayout2)],\
    ]

    window = sg.Window('计算器', mainLayout)
    while True:
        event, values = window.read()
        if event in (sg.WIN_CLOSED, 'Exit'):
            #最后从屏幕上移除
            window.close()
            break
        if event in list(
                range(10)) or event in ['.', '(', ')', '+', '-', '*', '/']:
            window['computeStr'].update(values['computeStr'] + str(event))
        elif event == 'C':
            window['computeStr'].update('')
        elif event == '=':
            window['computeStr'].update("%.2f" %
                                        computeResult(values['computeStr']))
        elif event == 'BackDel':
            window['computeStr'].update(values['computeStr'][:-1])
Ejemplo n.º 10
0
 def __init__(self):
     self.theme = sg.theme('DarkAmber')
     self.layout = [[sg.Text('Search Term', size=(10,1)), 
                     sg.Input(size=(45,1), focus=True, key="TERM"),
                     sg.Radio('Contains', group_id='choice', key='CONTAINS', default=True),
                     sg.Radio("Starts With", group_id='choice', key="STARTSWITH"),
                     sg.Radio("Ends With", group_id='choice', key="ENDSWITH")],
                     [sg.Text('Root Path', size=(10,1)), 
                     sg.Input('C:/', size=(45,1), key="PATH"), 
                     sg.FolderBrowse('Browse', size=(10,1)), 
                     sg.Button('Re-Index', size=(10,1), key="_INDEX_"), 
                     sg.Button('Search', size=(10,1), bind_return_key=True, key="_SEARCH_")],
                     [sg.Output(size=(50,100))]]
     
     self.window = sg.Window('File Search Engine').Layout(self.layout)
Ejemplo n.º 11
0
def main():

    layout = [
        [sg.T('Matplotlib Example', font='Any 20')],
        [sg.Image(key='-IMAGE-')],
        [sg.B('Draw'), sg.B('Exit')],
    ]

    window = sg.Window('Title', layout)

    while True:
        event, values = window.read()
        if event == 'Exit' or event == sg.WIN_CLOSED:
            break
        if event == 'Draw':
            draw_figure(create_figure(), window['-IMAGE-'])
    window.close()
Ejemplo n.º 12
0
def openWindowRoutesSearch():
    print('Route search')
    layoutOperation = [[sg.Text('What place do you want to explore ?')],
                       [sg.InputText('location')],
                       [sg.Button('HERE !'),
                        sg.Button('Cancel')]]
    windowOperation = sg.Window('Where ?').Layout(layoutOperation)

    while True:
        eventOperation, valuesOperation = windowOperation.Read()
        if eventOperation in (None, 'Cancel'):
            windowOperation.close()
            main()
            break
        else:
            windowOperation.close()
            searchRouteByLocationWindow(valuesOperation[0])
Ejemplo n.º 13
0
def searchByLocationRouteResult(param):
    layout = [[sg.Text('We found an amazing route for you..')],
              [sg.Listbox(values=param, size=(30, 3))],
              [sg.Button("Show me on map"),
               sg.Button('Cancel')]]

    windowTextResults = sg.Window('HOLIday').Layout(layout)
    while True:
        event, values = windowTextResults.Read()
        if event in (None, 'Cancel'):
            windowTextResults.close()
            main()
            print("Goodbye")
            break
        elif event in ("Show me on map"):
            windowTextResults.close()
            showMeTheMap(param)
Ejemplo n.º 14
0
def searchByTextResultWindow(locations):
    layout = [[sg.Text('We found some great places for you..')],
              [sg.Listbox(values=locations, size=(30, 3))],
              [sg.Button("Find visiting route"),
               sg.Button('Cancel')]]

    windowTextResults = sg.Window('HOLIday').Layout(layout)
    while True:
        event, values = windowTextResults.Read()
        if event in (None, 'Cancel'):
            windowTextResults.close()
            main()
            print("Goodbye")
            break
        elif event in ("Find visiting route"):
            windowTextResults.close()
            searchRouteByLocationWindow(values[0])
Ejemplo n.º 15
0
def openWindowTextSearch():
    print('Text search')
    layoutOperation = [[sg.Text('A few words to guide us..')],
                       [sg.InputText('Couple of words')],
                       [sg.Button('Search for me'),
                        sg.Button('Cancel')]]
    windowOperation = sg.Window('Text it out').Layout(layoutOperation)

    while True:
        eventOperation, valuesOperation = windowOperation.Read()
        if eventOperation in (None, 'Cancel'):
            windowOperation.close()
            main()
            break
        else:
            windowOperation.close()
            searchByTextAlgorithm(valuesOperation[0])
Ejemplo n.º 16
0
Archivo: gui.py Proyecto: tawfiqfm/Hack
def gui_attributes():
    optionRace = ["American Indian", "Asian", "Black", "Hispanic", "White"]
    optionGender = ["Male", "Female", "Other"]

    # Options inside gui
    layout = [
        [psg.Text("Race"), psg.Combo(optionRace)],
        [psg.Text("Gender"), psg.Combo(optionGender)],
        [psg.Text("History knowledge:     "), psg.Slider(range=(0, 100), orientation='h', resolution=5, key="HistorySlider", enable_events=True),
         psg.Text('', key='historyValue')],
        [psg.Text("Film knowledge:  "), psg.Slider(range=(0, 100), orientation='h', resolution=5, key="FilmSlider", enable_events=True),
         psg.Text('', key='filmValue')],
        [psg.Text("Sport knowledge: "), psg.Slider(range=(0, 100), orientation='h', resolution=5, key="SportsSlider", enable_events=True),
         psg.Text('', key='sportsValue')],
         [psg.Text('Progress: ', key='progressValue')],
        [psg.Button("Done")]
        ]

    window = psg.Window("Attribute Questions", layout)

    inputs = []

    add = 0
    event, values = window.read()
    values['HistorySlider'] = 0
    values['FilmSlider'] = 0
    values['SportsSlider'] = 0
    while True:
        event, values = window.read()

        window['historyValue'].Update(value=values['HistorySlider'])
        window['filmValue'].Update(value=values['FilmSlider'])
        window['sportsValue'].Update(value=values['SportsSlider'])
        add = int(values["HistorySlider"]) + int(values["FilmSlider"]) + int(values["SportsSlider"])
        window['progressValue'].Update(value=("Total: " + str(add) + "%"))

        if event in (None, "Done"):  # only activates once done or exit is pressed
            if add == 100:
                for i in values:
                    inputs.append(values[i])
                break

    window.close()

    return inputs
Ejemplo n.º 17
0
 def __manage(self):
     date_list = sg.popup_get_date()
     find_date = date(date_list[2], date_list[0], date_list[1])
     if not (find_date in self.undone_tasks_):
         sg.popup("No tasks at this date!")
         return
     current_tasks = self.undone_tasks_[find_date]
     is_open = False
     while True:
         if len(current_tasks) == 0:
             del self.undone_tasks_[find_date]
             sg.popup("No tasks left for today!")
             if is_open:
                 window.close()
             return
         layout = [[sg.Text("Tasks for " + str(find_date))]]
         i = 0
         for task in current_tasks:
             i += 1
             temp = [
                 sg.Text(str(i) + ")"),
                 sg.Text(task.title_, font=tkinter.font.ITALIC),
                 sg.Text("Is frog? ")
             ]
             if task.is_frog_:
                 temp.append(sg.Text("Yes", text_color='#00FF00'))
             else:
                 temp.append(sg.Text("No", text_color='#FF0000'))
             temp.append(sg.Button("Delete", key=i))
             layout.append(temp)
         layout.append([sg.Button("Return")])
         window = sg.Window("Manage", layout)
         is_open = True
         event, value = window.read()
         if event == "Return" or sg.WIN_CLOSED:
             window.close()
             return
         print(event)
         if 1 <= event <= len(current_tasks):
             self.undone_tasks_[find_date].pop(event - 1)
             sg.popup("Task was successfully deleted.")
             window.close()
             is_open = False
             continue
Ejemplo n.º 18
0
def main():
    layout = [[sg.Text('This is a text element')], [
        sg.Input()
    ], [
        sg.Combo(['Combo 1'])
    ], [sg.Text('If you close the browser tab, the app will exit gracefully')],
              [sg.InputText('Source')], [sg.InputText('Dest')],
              [sg.Ok(), sg.Cancel()]]

    window = sg.Window('Demo window..', layout)
    i = 0
    while True:
        event, values = window.read(timeout=1)
        if event != sg.TIMEOUT_KEY:
            print(event, values)
        if event is None:
            break
        i += 1
    window.close()
Ejemplo n.º 19
0
    def __init__(self):
        # initialize controller parameters (in dict)
        self.params = self.initialize_params()

        # FIWARE parameters
        self.cb_url = os.getenv("CB_URL", "http://localhost:1026")
        self.entity_id = None  # will be read on the web GUI
        self.entity_type = "PID_Controller"
        self.service = os.getenv("FIWARE_SERVICE", '')
        self.service_path = os.getenv("FIWARE_SERVICE_PATH", '')

        # Create the fiware header
        fiware_header = FiwareHeader(service=self.service,
                                     service_path=self.service_path)

        # Create orion context broker client
        self.ORION_CB = ContextBrokerClient(url=self.cb_url,
                                            fiware_header=fiware_header)

        # initial pid controller list
        self.controller_list = []
        try:
            self.refresh_list()
        except:
            pass

        # initialize gui window
        sg.theme("DarkBlue")
        pid_id_bar = [[
            sg.Text("Controller ID", size=(10, 1)),
            sg.Combo(self.controller_list, key="controller_list"),
            sg.Button("Refresh")
        ]]
        param_bars = [[
            sg.Text(param.capitalize(), size=(10, 1)),
            sg.InputText(self.params[param], key=param)
        ] for param in self.params.keys()]
        io_bars = [[sg.Button("Send"), sg.Button("Read")]]
        layout = pid_id_bar + param_bars + io_bars
        self.window = sg.Window("PID controller",
                                layout,
                                web_port=80,
                                web_start_browser=True)
Ejemplo n.º 20
0
 def run(self):
     layout = [[sg.Text("Choose what to do:")], [sg.Button("Add task")],
               [sg.Button("Current tasks")], [sg.Button("Manage tasks")]]
     menu_window = sg.Window("To-Do app", layout, resizable=True)
     while True:
         event, values = menu_window.read()
         if event == sg.WIN_CLOSED:
             break
         if event == "Add task":
             menu_window.hide()
             self.__add_task()
         if event == "Current tasks":
             menu_window.hide()
             self.__current()
         if event == "Manage tasks":
             menu_window.hide()
             self.__manage()
         menu_window.UnHide()
     menu_window.close()
Ejemplo n.º 21
0
def main():
    minesInfo = getMineMap()
    mainLayout = [[
        sg.Button('?', size=(4, 2), key=(i, j), pad=(0, 0))
        for j in range(MAX_COLS)
    ] for i in range(MAX_ROWS)]

    window = sg.Window('扫雷', mainLayout)

    while True:
        event, values = window.read()
        if event in (sg.WIN_CLOSED, 'Exit'):
            break
        # window[(row, col)].update('New text')   # To change a button's text, use this pattern
        # For this example, change the text of the button to the board's value and turn color black
        window[event].update(minesInfo[event[0]][event[1]],
                             button_color=('Green', 'black'))

    #最后从屏幕上移除

    window.close()
Ejemplo n.º 22
0
def PopupOffsetWindow(main_string, first_pass_extra):
    first_pass = True
    found_valid = None
    while first_pass or not found_valid:
        offset_win = sg.Window('', layout=[
            [sg.Text(('' if first_pass else first_pass_extra) + main_string)],
            [sg.Input(default_text='0', key='add_new_entry_offset')],
            [sg.Ok()]
        ])
        event, values = offset_win.Read()
        offset_text = values['add_new_entry_offset']
        if offset_text == '':
            offset_text = '0'
        offset = re.findall(r'(\d+)', offset_text)
        found_valid = len(offset) == 1
        if found_valid:
            offset = int(offset[0])

        offset_win.Close()
        first_pass = False

    return dtt.timedelta(minutes=offset)
Ejemplo n.º 23
0
def detailed_view(window):
    layout2 = [
        [
            sg.Button(event,
                      button_color=('white', color_map[event]),
                      key=event,
                      tooltip=color_map[color]),
            sg.Button(event,
                      button_color=('black', color_map[event]),
                      key=event + '1',
                      tooltip=color_map[color])
        ],
        [
            sg.Text(
                'Hover over button to see color value. Click to clocse and return to main interface.'
            )
        ],
    ]
    sg.Window('Buttons with white and black text', layout2,
              keep_on_top=True).Read()
    window.close()
    return
Ejemplo n.º 24
0
def create_settings_window(settings):
    sg.theme(settings['theme'])

    def TextLabel(text):
        return sg.Text(text + ':', justification='r', size=(15, 1))

    layout = [[sg.Text('Settings', font='Any 15')],
              [
                  TextLabel('Theme'),
                  sg.Combo(sg.theme_list(), size=(20, 20), key='-THEME-')
              ], [sg.Button('Save'), sg.Button('Exit')]]

    window = sg.Window('Settings', layout, keep_on_top=True, finalize=True)

    for key in SETTINGS_KEYS_TO_ELEMENT_KEYS:  # update window with the values read from settings file
        try:
            window[SETTINGS_KEYS_TO_ELEMENT_KEYS[key]].update(
                value=settings[key])
        except Exception as e:
            print(
                f'Problem updating PySimpleGUI window from settings. Key = {key}'
            )

    return window
Ejemplo n.º 25
0
 def __current(self):
     current_index = 0
     is_open = False
     while True:
         today = date.today()
         frogs = []
         usual = []
         if not (today in self.undone_tasks_):
             sg.popup(
                 "Hooray! No tasks for today! You can chill and enjoy your life."
             )
             if is_open:
                 window.close()
             break
         for i in range(current_index, len(self.undone_tasks_[today])):
             x = self.undone_tasks_[today][i]
             if x.is_frog_:
                 frogs.append(x)
             else:
                 usual.append(x)
         for i in range(0, current_index):
             x = self.undone_tasks_[today][i]
             if x.is_frog_:
                 frogs.append(x)
             else:
                 usual.append(x)
         undone_amount = len(frogs) + len(usual)
         all_amount = undone_amount + (len(self.done_tasks_[today]) if
                                       (today in self.done_tasks_) else 0)
         layout = [[sg.Text("Today is " + str(today))]]
         if undone_amount == 0:
             sg.popup("Congratulations! You have done all tasks for today!")
             if is_open:
                 window.close()
             break
         else:
             layout.append([
                 sg.Text(
                     f'You have completed {all_amount - undone_amount} from {all_amount} tasks today.'
                     f' Good work!')
             ])
         if len(frogs) > 0:
             current_task = frogs[len(frogs) - 1]
         else:
             current_task = usual[len(usual) - 1]
         layout.append([sg.Text("Current task:")])
         layout.append(
             [sg.Text(current_task.title_, font=tkinter.font.ITALIC)])
         layout.append([sg.Text("Is frog?")])
         # print("Is frog?", emoji.emojize(':frog:'), end="")
         if current_task.is_frog_:
             layout.append([sg.Text("Yes", text_color='#00FF00')])
         else:
             layout.append([sg.Text("No", text_color='#FF0000')])
         layout.append([sg.Button("Done")])
         layout.append([sg.Button("Skip")])
         layout.append([sg.Button("Return")])
         window = sg.Window("Current wokflow", layout, resizable=True)
         is_open = True
         event, value = window.read()
         if event == "Done":
             if not (today in self.done_tasks_):
                 self.done_tasks_[today] = []
             self.done_tasks_[today].append(current_task)
             self.undone_tasks_[today].remove(current_task)
             if not self.undone_tasks_[today]:
                 del self.undone_tasks_[today]
             window.close()
             is_open = False
             continue
         if event == "Skip":
             if current_task.is_frog_:
                 sg.popup("You can't skip the frog!")
                 window.close()
                 continue
             current_index += 1
             current_index %= len(self.undone_tasks_[today])
             is_open = False
             window.close()
             continue
         if event == "Return" or event == sg.WIN_CLOSED:
             window.close()
             is_open = False
             break
Ejemplo n.º 26
0
                                                            fill_color='black',
                                                            line_color='red')


# -------------------  Build and show the GUI Window -------------------
graph_elem = sg.Graph((600, 400), (0, 400), (600, 0),
                      enable_events=True,
                      key='_GRAPH_',
                      background_color='lightblue')

layout = [[
    sg.Text('Ball Test'),
    sg.Text('My IP {}'.format(socket.gethostbyname(socket.gethostname())))
], [graph_elem], [sg.Button('Kick'), sg.Button('Exit')]]

window = sg.Window('Window Title', layout, finalize=True)
area = Playfield()
area.add_balls()

# ------------------- GUI Event Loop -------------------
while True:  # Event Loop
    event, values = window.read(timeout=0)
    # print(event, values)
    if event in (None, 'Exit'):
        break
    area.space.step(0.02)

    for ball in area.arena_balls:
        if event == 'Kick':
            ball.body.position = ball.body.position[
                0], ball.body.position[1] - random.randint(1, 200)
Ejemplo n.º 27
0
try:  #If started from COMMAND, user can choose his directory directly
    SELECTED_DIR = sys.argv[1]
except IndexError:
    SELECTED_DIR = ''

#If no system argument is provided, provide GUI to choose
if SELECTED_DIR == '':
    prompt_layout = [
        [sg.Combo(PROJECTS)],
        [sg.Button('Open')],
        [sg.Text(key='-INFO-', size=(20, 1))],
    ]

    prompt_window = sg.Window(
        'Select your project',
        prompt_layout,
        location=(80, 500),
    )

    while True:
        event, values = prompt_window.Read()
        if event in (None, 'Exit'):
            break
        if event == 'Open':
            for dir_name_from_combo in values.values():
                if dir_name_from_combo:
                    SELECTED_DIR = dir_name_from_combo
                    prompt_window.close()
                else:
                    prompt_window.Elem('-INFO-').Update(
                        'Please select a project')
Ejemplo n.º 28
0
            windowOperation.close()
            searchRouteByLocationWindow(valuesOperation[0])


sg.ChangeLookAndFeel('Dark')
sg.SetOptions(element_padding=(5, 5),
              button_element_size=(15, 2),
              auto_size_buttons=False,
              button_color=('white', 'firebrick4'))
layout = [[sg.Text('Let us plan an awesome holiday for you..')],
          [
              sg.Button('Search with text'),
              sg.Button('Search with image'),
              sg.Button('Create a route')
          ], [sg.Button('Cancel')]]
window = sg.Window('HOLIday').Layout(layout)


def main():
    # try:
    #     window.enable()
    # except(Exception):
    #     print("NOW")

    while True:
        event, values = window.Read()
        if event in (None, 'Cancel'):
            print("Goodbye")
            break

        if event in ('Search with text'):
Ejemplo n.º 29
0
            [sg.Text('', size=(30,1), key='_TEXT_')],
            [sg.Input('Single Line Input', do_not_clear=True, enable_events=True, size=(30,1))],
            [sg.Multiline('Multiline Input', do_not_clear=True, size=(40,4), enable_events=True)],
            [sg.Multiline('Multiline Output', size=(80,8),  key='_MULTIOUT_', font='Courier 12')],
            [sg.Checkbox('Checkbox 1', enable_events=True, key='_CB1_'), sg.Checkbox('Checkbox 2', default=True, enable_events=True, key='_CB2_')],
            [sg.Combo(values=['Combo 1', 'Combo 2', 'Combo 3'], default_value='Combo 2', key='_COMBO_',enable_events=True, readonly=False, tooltip='Combo box', disabled=False, size=(12,1))],
            [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(10,3))],
            [sg.Slider((1,100), default_value=80, key='_SLIDER_', visible=True, enable_events=True, orientation='h')],
            [sg.Spin(values=(1,2,3),initial_value=2, size=(4,1))],
            [sg.Image(filename=r'dot:logo.jpg')],
            [sg.OK(), sg.Button('Exit', button_color=('white', 'red'))]
          ]

window = sg.Window('My PySimpleGUIWeb Window',
                   default_element_size=(30,1),
                   font='Helvetica 18',
                   background_image=r'dot:logo.jpg'
                   ).Layout(layout)

start_time = datetime.datetime.now()
while True:
    event, values = window.Read(timeout=10)
    if event != sg.TIMEOUT_KEY:
        print(event, values)
        window.Element('_MULTIOUT_').Update(str(event) + '\n' + str(values), append=True)
    if event in (None, 'Exit'):
        break
    window.Element('_DATE_').Update(str(datetime.datetime.now()-start_time))

window.Close()
Ejemplo n.º 30
0
 |_|   \___/| .__/ \__,_| .__/ 
            |_|         |_|  

A Popup demonstration. A "Popup" window is shown over the main
window.  Clicking OK will close the Popup and you return to main again.
"""

print('Starting up...')

layout = [[
    sg.Text('Your typed chars appear here:'),
    sg.Text('', key='_OUTPUT_')
], [sg.Input('', key='_IN_')],
          [sg.Button('Show'),
           sg.Button('Exit'),
           sg.Button('Blank')]]

window = sg.Window('Window Title', layout)

while True:  # Event Loop
    print('in event loop')
    event, values = window.read()

    print(event, values)
    if event in (None, 'Exit'):
        break
    if event == 'Show':
        sg.popup('A popup!', ' You typed ', values['_IN_'])

window.close()