Exemplo n.º 1
0
    def _show_preferences(self):
        layout = [[sg.Text("Settings:")],
                  [sg.Text("Speech recognition engine:"), sg.Drop(self._view_model.possible_engines, readonly=True,
                                                                  default_value=self._view_model.get_engine(),
                                                                  key=ENGINE_DROP, enable_events=True)],
                  [sg.Text("Sound device:"), sg.Drop(self._view_model.get_sound_devices(), readonly=True,
                                                     default_value=self._view_model.get_audio_device(),
                                                     key=DEVICE_DROP)],
                  [sg.Text("Result path:"), sg.In(disabled=True, key=PATH_INPUT,
                                                  default_text=self._view_model.get_result_path()), sg.FolderBrowse()],
                  [sg.Text("Engine specific settings:")],
                  [sg.Text("API key:"), sg.In(key=KEY_INPUT, default_text=self._view_model.get_key(),
                                              password_char='*')],
                  [sg.Text("Language:"), sg.Drop(self._view_model.possible_languages, key=LANGUAGE_DROP,
                                                 default_value=self._view_model.get_language())],
                  [sg.Text("Region (optional):"), sg.In(key=REGION_INPUT, default_text=self._view_model.get_region())],
                  [sg.Button(APPLY_BUTTON)]]

        window = sg.Window("Preferences", layout)

        while True:
            event, values = window.read()

            if event == ENGINE_DROP:
                window.find_element(LANGUAGE_DROP).update(self._view_model.get_language(values[ENGINE_DROP]))
                window.find_element(REGION_INPUT).update(self._view_model.get_region(values[ENGINE_DROP]))
                window.find_element(KEY_INPUT).update(self._view_model.get_key(values[ENGINE_DROP]))
            elif event == APPLY_BUTTON:
                self._view_model.update_settings(values)
                break
            elif event == sg.WIN_CLOSED:
                break

        window.close()
Exemplo n.º 2
0
 def __init__(self):
     self.result = ""
     self.layout = [
         [sg.Text("Enter the linear equation"),
          sg.In(key="lneq")],
         [sg.Button("Evaluate", enable_events=True, key="eval")],
         [sg.Text("Result:"),
          sg.Text(text="", key="result")],
     ]
Exemplo n.º 3
0
def Window():
    col_prop = [
        [
            sg.T(' k [W/(m·K)]', size=(10, 1)),
            sg.In('', size=(15, 1), justification='right', key='-k-'),
            sg.Button('Temperature Dependant', size=(18, 1), key='-loadk-'),
            sg.Button('📊', size=(4, 1), key='-plotk-')
        ],
    ]

    menu_def = [['File', ['Load', 'Save', 'Exit']], ['Help', ['About']]]

    layout = [[sg.Menu(menu_def)], [sg.Column(col_prop)]]
    window = sg.Window('Name!', layout)

    kparams = np.array([['', '']])

    while True:
        event, values = window.read()
        if event in (None, 'Exit'):
            break
        if event == '-loadk-':
            try:
                tpar = kWindow(kparams)
                if tpar is not None: kparams = tpar
            except:
                pass
        if event == '-plotk-':
            if kparams[0, 0] == '' and values['-k-'] == '':
                sg.PopupOK(
                    'You need to define the «Thermal Conductivity» first!',
                    title='Warning')
            elif values['-k-'] != '':
                plotk(float(values['-k-']))
            else:
                plotk(kparams)
    window.close()
i_vid = r'videos\car_chase_01.mp4'
o_vid = r'output\car_chase_01_out.mp4'
y_path = r'yolo-coco'
sg.ChangeLookAndFeel('LightGreen')
layout = [
    [
        sg.Text('YOLO Video Player',
                size=(22, 1),
                font=('Any', 18),
                text_color='#1c86ee',
                justification='left')
    ],
    [
        sg.Text('Path to input video'),
        sg.In(i_vid, size=(40, 1), key='input'),
        sg.FileBrowse()
    ],
    [
        sg.Text('Optional Path to output video'),
        sg.In(o_vid, size=(40, 1), key='output'),
        sg.FileSaveAs()
    ],
    [
        sg.Text('Yolo base path'),
        sg.In(y_path, size=(40, 1), key='yolo'),
        sg.FolderBrowse()
    ],
    [
        sg.Text('Confidence'),
        sg.Slider(range=(0, 10),
Exemplo n.º 5
0
                                   default_button_element_size=(12, 1))

    window = autocomplete_popup.Layout(autocomplete_popup_layout).Finalize()
    return window


def predict_text(input, lista):
    pattern = re.compile('.*' + input + '.*')
    return [w for w in lista if re.match(pattern, w)]


choices = ['ABC' + str(i) for i in range(30)]  # dummy data

layout = [
    [sg.Text('Your typed chars appear here:')],
    [sg.In(key='_INPUT_', size=(10, 1), do_not_clear=True)],
    [sg.Button('Show'), sg.Button('Exit')],
]

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

sel_item = -1
skip_event = False
while True:  # Event Loop
    event, values = window.Read(timeout=500)
    if event is None or event == 'Exit':
        break
    if event != sg.TIMEOUT_KEY:
        # print(f'ev1 {event}')
        in_val = values['_INPUT_']
        prediction_list = predict_text(str(in_val), choices)
                    url_index = get_index(url)
                    self.matched.titles += [titles[url_index]]
                    if(update_index and url_index < self.current_index):
                        count+=1
            if (update_index):
                self.current_index = count

LISTBOX_SMALL = 3
LISTBOX_BIG = 5

first_session = session_manager(session(loaded))
second_session = session_manager(None)
search_info = search_manager()

layout = [[sg.Text('Session to add from')],
          [sg.In(default_text=get_session(), size=(80, 1), key='Session2'),
           sg.FileBrowse(), sg.Button('Choose', key="Choose Second")],

          [sg.Listbox(values=[], size=(30, LISTBOX_SMALL), select_mode=sg.LISTBOX_SELECT_MODE_EXTENDED, key='_WIN2', enable_events=True),
           sg.Listbox(values=[], size=(60, LISTBOX_SMALL), select_mode=sg.LISTBOX_SELECT_MODE_EXTENDED, key='_TAB2', enable_events=True),
           sg.Listbox(values=[], size=(30, LISTBOX_SMALL), select_mode=sg.LISTBOX_SELECT_MODE_EXTENDED, key='_HIS2', enable_events=True)],

          [sg.Button('Add Window(s)'), sg.Button(
              'Add Tab(s)'), sg.Button('Add History')],


          [sg.Text('Session to add to')],
          [sg.In(default_text=get_session(), size=(80, 1), key='Session1'),
           sg.FileBrowse(), sg.Button('Choose')],

          [sg.Listbox(values=first_session.m_session.window_listbox, size=(30, LISTBOX_BIG), select_mode=sg.LISTBOX_SELECT_MODE_EXTENDED, key='_WIN', enable_events=True),
Exemplo n.º 7
0
o_sound = 'Enter path to output'
yoloModelPath = Path().parent.absolute()
yoloModelPath = str(yoloModelPath) + "/yoloModel/"
sg.ChangeLookAndFeel('LightGrey')

layout1 = [
    [
        sg.Text('Perform YOLO Object Detection',
                size=(50, 1),
                font=('Any', 18),
                text_color='#1c86ee',
                justification='left')
    ],
    [
        sg.Text('Path to input video'),
        sg.In(i_vid, size=(40, 1), key='input'),
        sg.FileBrowse(size=(75, 30))
    ],
    [
        sg.Text('Path to output video'),
        sg.In(o_vid, size=(40, 1), key='output'),
        sg.FileSaveAs(size=(75, 30))
    ],
    [
        sg.Text('Confidence'),
        sg.Slider(range=(0, 10),
                  orientation='h',
                  resolution=1,
                  default_value=5,
                  size=(15, 15),
                  key='confidence'),
def openGUI(mode):

    # Define URL as global so we can change the value in the updater thread too
    global URL

    # Path to loginusers.vdf file which contains list of all Steam accounts on PC
    steamUsers = get_reg(r"SteamPath", REG_STEAM) + "/config/loginusers.vdf"

    # Extract the currently used profile from the windows registry (if it exists)
    defaultProfile = get_reg(r"SteamUser", REG_AMONG_US) 

    # Dictionary which will store Steam Alias & ID used for config directory path
    userKey = {}

    # Array containing a list of all Steam Aliases - Used to lookup above dictionary
    userVal = []

    # Set the overall theme of the window to "Dark Blue"
    sg.theme('DarkBlue')

    # Open the config file that contains list of all Steam accounts and extract required info
    with open(steamUsers) as f:
        lines = f.readlines()
        i = 0
        for line in lines:
            if "PersonaName" in line:
                userKey[(line.replace('\t\t"PersonaName"\t\t', '').replace('"','').replace('\n', ''))] = int(lines[i - 3].replace('\t','').replace('"', '')) - STEAMID64
                userVal.append(line.replace('\t\t"PersonaName"\t\t', '').replace('"','').replace('\n', ''))
            i += 1

    # Define the layout of our GUI and the conditions required
    layout = [
        [sg.Text("Steam Profile to use:")],
        [sg.Combo(userVal, default_value=defaultProfile, enable_events=True, key='-PROFILE-', readonly=True, size=(30,1), disabled=True if mode == "BACKGROUND" else False)],
        [sg.Text(size=(30,0.5))],
        [sg.Text("REST Endpoint to upload Statistics to:")],
        [sg.In(URL, size=(30, 1), enable_events=True, key="-REST-")],
        [sg.Button('Test Endpoint',size=(10,1), disabled=True, button_color=('grey', 'lightgrey')),sg.Text(key="-STATUS-")],
        [sg.Text(size=(30,0.5))],
        [sg.Button('Apply' if mode == "BACKGROUND" else "Install"), sg.Button('Close' if mode == 'BACKGROUND' else 'Exit')]
    ]

    layoutPopup = [
        [sg.Text('Steam will be closed while\nchanges are made.\n\nWould you like to continue?\n')],
        [sg.Button('Yes'), sg.Button('No')]
    ]

    layoutPopup2 = [
        [sg.Text('You can now play Among us as normal.\n\nClick OK to exit setup.')],
        [sg.Button('OK')]
    ]

    # Create the window
    window = sg.Window(APP_NAME, layout, auto_size_buttons=True, resizable=False, disable_close=False, disable_minimize=True, icon=ICON)
    
    # Create an event loop
    while True:
        event, values = window.read()

        # If Exit/Close or the X are pressed, exit the GUI loop
        if event == "Exit" or event == "Close" or event == sg.WIN_CLOSED:
            break

        # If any change is detected to the Steam Profile dropdown, re-enable the Install button
        if event == "-PROFILE-":
            window['Install' if mode == 'INTERACTIVE' else 'Apply'].update(disabled=False)
            window['Install' if mode == 'INTERACTIVE' else 'Apply'].update(button_color=('black', 'white'))

        # If the Test Endpoint button is pressed, Disable button & ping endpoint.
        if event == "Test Endpoint":
            window['Test Endpoint'].update(disabled=True)
            window['Test Endpoint'].update(button_color=('grey', 'lightgrey'))

            try:
                response = requests.post(values['-REST-'])
                if response.status_code == 200:
                    window['-STATUS-'].update('Success', text_color='green')
                else:
                    window['-STATUS-'].update('Failed', text_color='red')
            except requests.exceptions.RequestException as e:
                log('The following error occured while trying to test the REST Endpoint:')
                log(values['-REST-'])
                log(e)

        # If change detected to the -REST- string then re-enable install & test buttons
        if event == "-REST-":
            window['Test Endpoint'].update(disabled=False)
            window['Test Endpoint'].update(button_color=('black', 'white'))
            window['Install' if mode == 'INTERACTIVE' else 'Apply'].update(disabled=False)
            window['Install' if mode == 'INTERACTIVE' else 'Apply'].update(button_color=('black', 'white'))

        # If Install/Update selected then update all relevant values to registry
        if event == "Install" or event == "Apply":
            
            steamOpen = False

            # Disable Install/Update button to stop spam
            window['Install' if mode == 'INTERACTIVE' else 'Apply'].update(disabled=True)
            window['Install' if mode == 'INTERACTIVE' else 'Apply'].update(button_color=('grey', 'lightgrey'))
            
            # If Steam is running and application running in interactive mode, close it first
            if mode == "INTERACTIVE" and process_running(STEAM_EXE):
                warningPopup = sg.Window("Alert!", layoutPopup, auto_size_buttons=True, resizable=False, disable_close=False, disable_minimize=True, icon=ICON)
                closeSteam = warningPopup.read() 
                warningPopup.close()
                if closeSteam[0] == 'Yes':
                    subprocess.call(["TASKKILL","/F","/IM",STEAM_EXE], shell=True)
                    time.sleep(2)
                    steamOpen = True
                else:
                    continue

            set_reg(r"Install Path", APP_EXE, REG_AMONG_US)
            set_reg(r"SteamUser", values['-PROFILE-'], REG_AMONG_US)
            set_reg(r"SteamDir", str(userKey[values['-PROFILE-']]), REG_AMONG_US)
            set_reg(r"REST Endpoint", values['-REST-'], REG_AMONG_US)
            set_reg(r"Version", VERSION, REG_AMONG_US)

            URL = values['-REST-']

            updateConfig(STEAM_CONFIG_PATH.format(userKey[values['-PROFILE-']]))

            if mode == "INTERACTIVE":
                sg.Window("Script has been Installed!", layoutPopup2, auto_size_buttons=True, resizable=False, disable_close=False, disable_minimize=True, icon=ICON).read()
                if steamOpen:
                    subprocess.Popen(STEAM_EXE_PATH)
                break
            else:
                sg.popup("Settings have been successfully applied.")

    window.close()
Exemplo n.º 9
0
old usage: yolo_video.py [-h] -i INPUT -o OUTPUT -y YOLO [-c CONFIDENCE]
                     [-t THRESHOLD]
"""

# import the necessary packages
import numpy as np
import argparse
import time
import cv2
import os
import PySimpleGUIQt as sg

layout = 	[
		[sg.Text('YOLO')],
		[sg.Text('Path to image'), sg.In(r'C:/Python/PycharmProjects/YoloObjectDetection/images/baggage_claim.jpg',size=(40,1), key='image'), sg.FileBrowse()],
		[sg.Text('Yolo base path'), sg.In(r'yolo-coco',size=(40,1), key='yolo'), sg.FolderBrowse()],
		[sg.Text('Confidence'), sg.Slider(range=(0,10),orientation='h', resolution=1, default_value=5, size=(15,15), key='confidence')],
		[sg.Text('Threshold'), sg.Slider(range=(0,10), orientation='h', resolution=1, default_value=3, size=(15,15), key='threshold')],
		[sg.OK(), sg.Cancel(), sg.Stretch()]
			]

win = sg.Window('YOLO',
				default_element_size=(14,1),
				text_justification='right',
				auto_size_text=False).Layout(layout)
event, values = win.Read()
args = values
win.Close()
# construct the argument parse and parse the arguments
# ap = argparse.ArgumentParser()