コード例 #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)
コード例 #2
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])
コード例 #3
0
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()
コード例 #4
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)
コード例 #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
コード例 #6
0
ファイル: Web_Simple.py プロジェクト: senseidevs/Coding
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()
コード例 #7
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)
コード例 #8
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)
コード例 #9
0
ファイル: gui.py プロジェクト: 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
コード例 #10
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)
コード例 #11
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])
コード例 #12
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)
コード例 #13
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])
コード例 #14
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])
コード例 #15
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()
コード例 #16
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)
コード例 #17
0
ファイル: Web_Color_Names.py プロジェクト: senseidevs/Coding
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
コード例 #18
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
コード例 #19
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
コード例 #20
0
#masterdec = [sdec for sdec in master['dec']]
#masterzvi = [szvi for szvi in master['zvi']]
mag = fits.open('FullSample3028Objs_query_for_SDSSMags.fits')[1].data

masterrmag = np.zeros(len(masternames))
for i in range(len(masternames)):
    xx = np.where(mag['Name'] == masternames[i])[0]
    if len(xx) > 0:
        masterrmag[i] = mag['modelMag_r'][xx[0]]

masterrmag = ['{0:3.3f}'.format(srmag) for srmag in masterrmag]

# The GUI layout
layout = [
    [
        sg.Text('', size=(50, 1)),
        sg.Text('', size=(10, 1)),
        sg.Text('SDSS BAL Factory: Visual Inspection',
                size=(140, 2),
                font=('Comic sans ms', 40),
                text_color='red')
    ],
    [
        sg.Text('', size=(50, 1)),
        sg.Image(
            filename=
            '/Users/vzm83/SDSSIV_BALQSO/pngtree-creative-simple-dividing-line.png',
            visible=True)
    ],
    [
        sg.Text('', size=(30, 1)),
コード例 #21
0
            self.arena_balls.append(ball)
            area.space.add(ball.body, ball.shape)
            ball.gui_circle_figure = graph_elem.draw_circle((x, y),
                                                            r,
                                                            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)
コード例 #22
0
ファイル: allinone.py プロジェクト: Frenz86/PySimpleGUIweb
    ['File', ['Open', 'Save', 'Exit', 'Properties']],
    [
        'Edit',
        ['Paste', [
            'Special',
            'Normal',
        ], 'Undo'],
    ],
    ['Help', 'About...'],
]

# ------ Column Definition ------ #
column1 = [
    [
        sg.Text('Column 1',
                background_color='#F7F3EC',
                justification='center',
                size=(10, 1))
    ], [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1')],
    [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 2')],
    [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 3')]
]

layout = [
    [sg.Menu(menu_def, tearoff=True)],
    [
        sg.Text('All graphic widgets in one window!',
                size=(30, 1),
                justification='center',
                font=("Helvetica", 25),
                relief=sg.RELIEF_RIDGE)
    ], [sg.Text('Here is some text.... and a place to enter text')],
コード例 #23
0
        eventOperation, valuesOperation = windowOperation.Read()
        if eventOperation in (None, 'Cancel'):
            windowOperation.close()
            main()
            break
        else:
            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:
コード例 #24
0
#Credit to aminusfu : https://github.com/cherrypy/cherrypy/blob/0857fa81eb0ab647c7b59a019338bab057f7748b/cherrypy/process/wspbus.py#L305
startup_cwd = os.getcwd()  #Used in do_execv, to swap between projects

#------------- Context Manager ------------#

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:
コード例 #25
0
    'size': (7, 2),
    'font': ('Franklin Gothic Book', 24),
    'button_color': ("black", "#F1EABC")
}
bo: dict = {
    'size': (15, 2),
    'font': ('Franklin Gothic Book', 24),
    'button_color': ("black", "#ECA527"),
    'focus': True
}

##-----WINDOW AND LAYOUT---------------------------------##
layout: list = [[
    sg.Text('',
            size=(50, 1),
            justification='right',
            background_color="#272533",
            text_color='white',
            font=('Franklin Gothic Book', 14, 'bold'))
],
                [
                    sg.Text('0.0000',
                            size=(18, 3),
                            justification='right',
                            background_color='black',
                            text_color='red',
                            font=('Digital-7', 48),
                            relief='sunken',
                            key="_DISPLAY_")
                ],
                [
                    sg.Button('C', **bt),
コード例 #26
0
fontsize = 12  # initial and smallest font size to show

layout = [[
    sg.Spin([sz for sz in range(6, 172)],
            size=(6, 1),
            font=('Helvetica 20'),
            initial_value=fontsize,
            change_submits=True,
            key='spin'),
    sg.Slider(range=(6, 172),
              orientation='h',
              size=(10, 20),
              change_submits=True,
              key='slider',
              font=('Helvetica 20')),
    sg.Text("Aa", size=(2, 1), font="Helvetica " + str(fontsize), key='text')
]]

window = sg.Window("Font size selector", layout)

while True:  # the event loop
    event, values = window.read()
    if event is None or event == 'Quit':
        break

    if int(values['spin']) != fontsize:
        fontsize = int(values['spin'])
    else:
        fontsize = int(values['slider'])

    window['text'].update(font="Helvetica " + str(fontsize))
コード例 #27
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
コード例 #28
0
            default_value=types[0]),
    sg.Input('0', size=(10, 1), key='ADR_NEW', tooltip='enter data address'),
    sg.Input('data_alias',
             size=(20, 1),
             key='ALIAS_NEW',
             tooltip='enter data alias'),
    sg.Drop(values=intervals,
            key='INTERVAL_NEW',
            size=(6, 1),
            tooltip='select acquisition interval',
            readonly=True,
            default_value=intervals[3]),
    sg.Checkbox('Active', key='ACTIVATE_NEW')
]
column0 = [
    [sg.Text('New entry', font=("Helvetica", 25))],
    [
        sg.Text(
            'Update below fields with desiered configuration to fetch data from PLC'
        )
    ],
    data_row.copy(), [sg.Button("Add"), sg.Button('Clear')],
    [sg.Text('Edit actual entries', font=("Helvetica", 25))],
    [
        sg.Text(
            'Select PLC IP address to get configured data aliases, then choose one to get all parameters connected with it'
        )
    ]
]

plc_list = []
コード例 #29
0
import PySimpleGUIWeb as sg
import datetime

DEFAULT_BASE64_ICON = b'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'


sg.ChangeLookAndFeel('GreenTan')

layout =  [
            [sg.Text('PySimpleGUIWeb running on the web and in your browser!', size=(60,1), font=('Comic sans ms', 20), text_color='red')],
            [sg.Text('This program has been running for... ', size=(30,1)),sg.Text('', size=(30,1), key='_DATE_')],
            [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()
コード例 #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