Esempio n. 1
0
 def show_clip_list_window(self, clips):
     """ Show all received clips in a Windows with a Listview and allow
         user select and copy an entry
     """
     # TODO: Show Only preview of Clip to reduce length
     layout = [
         [
             sg.Listbox(
                 values=clips,
                 size=(60, 6),
                 select_mode="LISTBOX_SELECT_MODE_SINGLE",
                 key="sel_clip",
             )
         ],
         [sg.Button("Copy to clipboard", size=(20, 1)), sg.Cancel(size=(20, 1))],
     ]
     window = sg.Window(
         title=f"{Config.APP_NAME} - Your Clips",
         layout=layout,
         size=(600, 300),
         icon=Config.ICON_B64,
     )
     event, values = window.read()
     if event in (sg.WIN_CLOSED, "Cancel"):
         log.debug("List Clips selection canceled")
         pass
     elif event == "Copy to clipboard":
         Api.paste(values.get("sel_clip")[0])
     window.close()
Esempio n. 2
0
def SendTC(file_name, instrument_type, note):

    flights = [
        'FLOATS_51', 'FLOATS_52', 'FLOATS_53', 'RACHuTS_51', 'RACHuTS_52',
        'RACHuTS_53', 'LPC_51', 'LPC_52', 'LPC_53'
    ]

    flight_layout = [[
        sg.Listbox(values=flights,
                   key='_param_',
                   tooltip='Select balloon/instrument to send TC to',
                   size=(20, 6),
                   font=Font)
    ]]
    layout_config_TC = [
        [sg.Frame('Select Instrument/Flight: ', flight_layout, font=Font)],
        #[sg.Frame('Input new value: ', value_layout, font = Font)],
        [
            sg.Submit(font=Font, pad=(10, 10)),
            sg.Cancel(font=Font, pad=(10, 10))
        ]
    ]
    param_window = sg.Window('Select Flight', layout_config_TC)
    event, values = param_window.Read()
    param_window.Close()
    instrument = values['_param_'][0]
    print(instrument)
    print(event)

    if event == 'Submit':
        curl_cmnd(instrument, file_name, note)
Esempio n. 3
0
def rclonewindow():
    layout = [[sg.Text("What is the Drive you want to access?")],
              [sg.Input("Drive")],
              [sg.Text("What is the folder you want to see?")], [sg.Input()],
              [sg.Cancel(), sg.OK()]]
    window = sg.Window("rclone", layout=layout)
    event, values = window.Read()
    window.Close()
    return event, values
Esempio n. 4
0
def getInputOutputWindow(titletext="Select File"):
    layout = [[sg.Text('Input File')],
              [sg.Input(), sg.FileBrowse(initial_folder=home)],
              [sg.Text('Output File')],
              [sg.Input(), sg.FileSaveAs(initial_folder=home)],
              [sg.OK(), sg.Cancel()]]
    window = sg.Window(titletext, layout)
    event, values = window.Read()
    return event, values
Esempio n. 5
0
def getInputWindow(titletext="Inputfile"):
    layout = [[sg.Text("Select a file to convert:")],
              [sg.Input(),
               sg.FileBrowse("Select File", initial_folder=home)],
              [sg.OK(), sg.Cancel()]]
    window = sg.Window(titletext, layout)
    event, values = window.Read()
    window.Close()
    return event, values
Esempio n. 6
0
def getFolderInputWindow(titletext="Inputfolder", initial_folder=home):
    layout = [[sg.Text("Select a folder:")],
              [
                  sg.Input(),
                  sg.FolderBrowse("Select Folder",
                                  initial_folder=initial_folder)
              ], [sg.OK(), sg.Cancel()]]
    window = sg.Window(titletext, layout)
    event, values = window.Read()
    window.Close()
    return event, values
Esempio n. 7
0
def getOutputWindow(titletext="Outputfile", prefill=""):
    layout = [[sg.Text("Where should it be saved?")],
              [
                  sg.Text("Save under:"),
                  sg.Input(),
                  sg.FileSaveAs(initial_folder=prefill)
              ], [sg.OK(), sg.Cancel()]]
    window = sg.Window(titletext, layout)
    event, values = window.Read()
    window.Close()
    return event, values
Esempio n. 8
0
def test1():
    layout = [[sg.Text(' 输入文字.')],
                     [sg.InputText()],
              [sg.InputText()],
              [sg.Submit(), sg.Cancel()]]

    window = sg.Window('Window 标题', layout)

    event, values = window.Read()
    window.Close()

    text_input = values[0]
    print(text_input)
Esempio n. 9
0
    def get_passphrase(self, msg):
        logger.debug('In get_passphrase')
        layout = [[sg.Text(msg)], [sg.InputText(password_char='*', key='pin')],
                  [sg.Submit(), sg.Cancel()]]
        window = sg.Window('Satochip-Bridge: PIN required',
                           layout,
                           icon=self.satochip_icon)
        event, values = window.read()
        window.close()
        del window

        is_PIN = True if event == 'Submit' else False
        pin = values['pin']
        # logger.debug("Type of pin from getpass:"******"Type of event from getpass:"+str(type(event))+str(event))
        return (is_PIN, pin)
Esempio n. 10
0
    def rearrange_layout_of_tab(self) -> None:
        form_rows = [[sg.Text('Enter File Paths:')],
                     [
                         sg.Text('Path to images used as exercises',
                                 size=(15, 1)),
                         sg.InputText(key=self.exercise_dir_key),
                         sg.FolderBrowse(target=self.exercise_dir_key)
                     ],
                     [
                         sg.Text('Path to images used as solutions',
                                 size=(15, 1)),
                         sg.InputText(key=self.solution_dir_key),
                         sg.FolderBrowse(target=self.solution_dir_key)
                     ], [sg.Submit(), sg.Cancel()]]

        self.rows = form_rows
Esempio n. 11
0
def pick_an_instrument():
    ''' Select the instrument to generate TC files for'''

    instruments = ['LPC', 'RACHuTS', 'FLOATS']

    instrument_layout = [[
        sg.InputCombo(values=instruments, key='_inst_', font=Font)
    ]]
    layout_pick_instrument = [[
        sg.Frame('Select Instrument: ', instrument_layout, font=Font)
    ], [sg.Submit(font=Font), sg.Cancel(font=Font)]]

    instrument_window = sg.Window('Select Instrument', layout_pick_instrument)
    event, values = instrument_window.Read()
    instrument_window.Close()

    if event is None or event == 'Cancel':
        return None
    if event == 'Submit':
        print(values['_inst_'])
        return values['_inst_']
Esempio n. 12
0
    def create_cred_layout(self):
        """ Layouts in simplepyguy cannot be reused
            need to create new one when (re)-opening windows
            if valid, use configured credentials as default values
        """

        if Config.SERVER and Config.USER and Config.PW:
            self.def_server = Config.SERVER
            self.def_user = Config.USER
            self.def_pw = Config.PW

        layout = [
            [
                sg.Text("Server address: ", size=(30, 1)),
                sg.InputText(default_text=self.def_server, key="server", size=(25, 1)),
            ],
            [
                sg.Text("Disable SSL certificate check: ", size=(30, 1)),
                sg.Checkbox(
                    "(only check if using your own server)",
                    default=not Config.VERIFY_SSL_CERT,
                    key="ignore_cert",
                ),
            ],
            [
                sg.Text("Username: "******"user", size=(25, 1)),
            ],
            [
                sg.Text("Password: "******"pw", size=(25, 1)),
            ],
            [sg.Text("")],
            [
                sg.Button("Login", size=(18, 1)),
                sg.Button("Register", size=(18, 1)),
                sg.Cancel(size=(18, 1)),
            ],
        ]
        return layout
Esempio n. 13
0
def main():
    sg.theme('Reddit')

    layout = [[sg.Text('', font=('Times', 12), key='timer')],
              [
                  sg.Text('Input Audio', size=(10, 1), font='Times 14'),
                  sg.InputText(key="audioIN", size=(50, 1)),
                  sg.FileBrowse(initial_folder="/home", target="audioIN")
              ],
              [
                  sg.Text('Input Data', size=(10, 1), font='Times 14'),
                  sg.InputText(key="dataIN", size=(50, 1)),
                  sg.FileBrowse(initial_folder="/home", target="dataIN")
              ],
              [
                  sg.Text('Encode To', size=(10, 1), font='Times 14'),
                  sg.InputText(key="audioOUT", size=(50, 1)),
                  sg.FolderBrowse(initial_folder="/home", target="audioOUT")
              ],
              [
                  sg.Submit('Encode', size=(10, 1)),
                  sg.Submit('Datafy', size=(10, 1)),
                  sg.Cancel('Quit', size=(10, 1))
              ]]

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

    ####### Main Event Loop ########
    while True:
        event, values = window.read()
        if event == sg.WIN_CLOSED or event == "Quit":
            break

        ######### When User hits "Encode" button #########
        if event == "Encode":
            ## Get time for timing encoding
            start_time = int(round(time.time() * 100))

            ## Get variables for encodeMP3 call
            input_audio = values["audioIN"]
            input_data = values["dataIN"]
            output_audio = values["audioOUT"]
            output_data = get_file(input_data)

            ## Update window to prepare for processing
            window['timer'].Update('Processing...')
            window.Refresh()

            ## Call ffmpeg to encode to mp3
            emp3.encodeMP3(input_audio, output_data, output_audio)

            ## Calculate and report encoding completion time
            final_time = int(round(time.time() * 100)) - start_time
            format_time = '{:02d}:{:02d}.{:02d}'.format(
                (final_time // 100) // 60, (final_time // 100) % 60,
                final_time % 100)

            window['timer'].update(f"Encoded in {format_time}.")

        ######### When User hits "Datafy" button #########
        if event == "Datafy":
            ## Get time for timing encoding
            start_time = int(round(time.time() * 100))

            ## Get variables for dataMP3 call
            input_audio = values["audioIN"]
            input_data = values["dataIN"]
            output_audio = values["audioOUT"]

            ## Update window to prepare for processing
            window['timer'].Update('Processing...')
            window.Refresh()

            if values["audioIN"] == values["audioOUT"]:
                window['timer'].update(
                    "WARNING: Output file cannot be same as input.")
                window.Refresh()

            else:
                ## Make ffmpeg-readable data file
                output_data = get_file(input_data)

                ## Call ffmpeg to add data to mp3
                emp3.dataMP3(input_audio, output_data, output_audio)

                ## Calculate and report encoding completion time
                final_time = int(round(time.time() * 100)) - start_time
                format_time = '{:02d}:{:02d}.{:02d}'.format(
                    (final_time // 100) // 60, (final_time // 100) % 60,
                    final_time % 100)

                window['timer'].update(f"Data added in {format_time}.")

    window.close()
    ],
    [
        sg.Text('Threshold'),
        sg.Slider(range=(0, 10),
                  orientation='h',
                  resolution=1,
                  default_value=3,
                  size=(15, 15),
                  key='threshold'),
        sg.T('  ', key='_THRESH_OUT_')
    ],
    [sg.Text(' ' * 8),
     sg.Checkbox('Use webcam', key='_WEBCAM_')],
    [sg.Text(' ' * 8),
     sg.Checkbox('Write to disk', key='_DISK_')],
    [sg.OK(), sg.Cancel(), sg.Stretch()],
]

win = sg.Window('YOLO Video',
                default_element_size=(21, 1),
                text_justification='right',
                auto_size_text=False).Layout(layout)
event, values = win.Read()
if event is None or event == 'Cancel':
    exit()
write_to_disk = values['_DISK_']
use_webcam = values['_WEBCAM_']
args = values

win.Close()
Esempio n. 15
0
                      default_value=25,
                      tick_interval=25),
            sg.Slider(range=(1, 100), orientation='v', default_value=75),
            sg.Slider(range=(1, 100), orientation='v', default_value=10),
            sg.Column(column1, background_color='lightblue')
        ]],
                 background_color='black'),
        sg.Stretch()
    ], [sg.Text('_' * 50, justification='c')], [sg.Text('Choose A Folder')],
    [
        sg.Text('Your Folder'),
        sg.InputText('Default Folder', size=(300, 22)),
        sg.FolderBrowse(),
        sg.Stretch()
    ], [sg.Submit(tooltip='Click to submit this form', ),
        sg.Cancel()]
]

window = sg.Window('Everything bagel',
                   grab_anywhere=False,
                   font=('Helvetica', 12),
                   no_titlebar=False,
                   alpha_channel=1,
                   keep_on_top=False,
                   element_padding=(2, 3),
                   default_element_size=(100, 23),
                   default_button_element_size=(120, 30)).Layout(layout)
event, values = window.Read()
print(event, values)
window.Close()
Esempio n. 16
0
def rename_dialog(src: str):
    import PySimpleGUIQt as G
    ske = PySimpleGUISpecialKeyEvent()
    conf_file = real_join_path('~', '.config/rename_dialog.json')
    root = 'root'
    fname = 'fname'
    ext = 'ext'
    key_new_root = 'key_new_root'
    key_new_base = 'key_new_base'
    ok = 'OK'
    cancel = 'Cancel'
    pattern = 'pattern'
    replace = 'replace'
    substitute = 'substitute'
    save_replace = 'save_replace'
    save_pattern = 'save_pattern'
    add_root = 'add_root'
    rename_info_file = 'rename_info_file'
    bytes_count = 'bytes_count'
    title = 'Rename - {}'.format(src)
    h = None

    conf = read_json_file(conf_file, default={pattern: [''], replace: ['']})
    tmp_pl = conf[pattern] or ['']
    tmp_rl = conf[replace] or ['']
    old_root, old_base = os.path.split(src)
    old_fn, old_ext = os.path.splitext(old_base)
    info_file_base = [
        f for f in os.listdir(old_root) if f.endswith('.info') and (
            f.startswith(old_fn) or old_fn.startswith(f.rstrip('.info')))
    ]
    has_info = True if info_file_base else False

    @deco_factory_retry(Exception, 0, enable_default=True, default=None)
    def re_sub():
        return re.sub(data[pattern], data[replace], data[fname] + data[ext])

    def count_name_bytes(name: str):
        d = {}
        try:
            c, b = encode_default_locale(name)
            d[c] = len(b)
        except UnicodeEncodeError:
            pass
        u8 = 'utf-8'
        if u8 not in d:
            try:
                c, b = encode_default_locale(name, u8)
                d[c] = len(b)
            except UnicodeEncodeError:
                pass
        return f'Basename Length: {len(name)}, {", ".join([f"{k.upper()} {v} bytes" for k, v in d.items()])}'

    # sg.theme('SystemDefaultForReal')
    layout = [[G.T(src, key='src')], [G.HorizontalSeparator()],
              [
                  G.I(old_fn, key=fname, focus=True),
                  G.I(old_ext, key=ext, size=(42, h))
              ],
              [
                  G.I(old_root, key=root),
                  G.B('+', key=add_root, size=(20, h)),
                  G.FolderBrowse('...',
                                 target=root,
                                 initial_folder=old_root,
                                 size=(20, h))
              ], [G.HorizontalSeparator()],
              [G.T('Regular Expression Pattern & Replacement')],
              [
                  G.T(size=(0, h)),
                  G.Drop(tmp_pl,
                         key=pattern,
                         enable_events=True,
                         text_color='blue'),
                  G.CB('',
                       default=True,
                       key=save_pattern,
                       enable_events=True,
                       size=(15, h)),
                  G.Drop(tmp_rl,
                         key=replace,
                         enable_events=True,
                         text_color='blue'),
                  G.CB('',
                       default=True,
                       key=save_replace,
                       enable_events=True,
                       size=(15, h)),
                  G.B('Go', key=substitute, size=(25, h))
              ], [G.HorizontalSeparator()], [G.I(old_root, key=key_new_root)],
              [G.I(old_base, key=key_new_base)],
              [
                  G.Submit(ok, size=(10, 1)),
                  G.Stretch(),
                  G.T(count_name_bytes(old_base), key=bytes_count),
                  G.Stretch(),
                  G.Cancel(cancel, size=(10, 1))
              ]]
    if has_info:
        info_file_base = info_file_base[0]
        info_filepath = os.path.join(old_root, info_file_base)
        with open(info_filepath, encoding='utf8') as f:
            info = f.read()
        layout.insert(2, [
            G.CB(info_file_base,
                 default=True,
                 key=rename_info_file,
                 enable_events=True)
        ])
        layout.insert(2, [G.ML(info, key='ML')])
        layout.insert(4, [G.HorizontalSeparator()])

    ensure_sigint_signal()
    window = G.Window(title,
                      layout,
                      return_keyboard_events=True,
                      finalize=True,
                      font='arial 10',
                      element_padding=(1, 1))
    window.bring_to_front()
    ml = window.find_element('ML', silent_on_error=True)
    if ml:
        ml.update(readonly=True)

    loop = True
    data = {
        fname: old_fn,
        ext: old_ext,
        pattern: tmp_pl[0],
        replace: tmp_rl[0],
        root: old_root,
        key_new_root: '',
        key_new_base: ''
    }

    while loop:
        dst_from_data = os.path.join(data[key_new_root], data[key_new_base])
        try:
            tmp_fname = re_sub() or data[fname] + data[ext]
            dst = os.path.realpath(os.path.join(data[root], tmp_fname))
        except TypeError:
            dst = src
        if dst != dst_from_data:
            nr, nb = os.path.split(dst)
            window[key_new_root].update(nr)
            window[key_new_base].update(nb)
            window[bytes_count].update(count_name_bytes(nb))

        event, data = window.read()
        for k in (root, fname, ext, key_new_root, key_new_base):
            window[k].update(text_color=None)
        cur_p = data[pattern]
        cur_r = data[replace]

        if event == ske.esc:
            loop = False
        elif event == add_root:
            os.makedirs(data[root], exist_ok=True)
        elif event == substitute:
            data[fname], data[ext] = os.path.splitext(
                re_sub() or data[fname] + data[ext])
            window[fname].update(data[fname])
            window[ext].update(data[ext])
        elif event == save_pattern:
            if data[save_pattern]:
                conf[pattern].insert(0, cur_p)
                conf[pattern] = dedup_list(conf[pattern])
            else:
                conf[pattern] = remove_from_list(conf[pattern], [cur_p])
        elif event == save_replace:
            if data[save_replace]:
                conf[replace].insert(0, cur_r)
                conf[replace] = dedup_list(conf[replace])
            else:
                conf[replace] = remove_from_list(conf[replace], [cur_r])
        elif event == pattern:
            window[save_pattern].update(value=cur_p in conf[pattern])
        elif event == replace:
            window[save_replace].update(value=cur_r in conf[replace])
        elif event == ok:
            try:
                shutil.move(src, dst)
                if has_info:
                    if data[rename_info_file]:
                        shutil.move(info_filepath,
                                    os.path.splitext(dst)[0] + '.info')
                loop = False
            except FileNotFoundError:
                for k in (root, fname, ext):
                    window[k].update(text_color='red')
            except FileExistsError:
                for k in (key_new_root, key_new_base):
                    window[k].update(text_color='red')
            except OSError as e:
                G.PopupError(str(e))
        elif event in (None, cancel):
            loop = False
        else:
            ...
    else:
        write_json_file(conf_file, conf, indent=0)

    window.close()
Esempio n. 17
0
def get_settings(min_df_val, max_df_val, label_words_val, folder_val,
                 stopwords_path):
    layout2 = [[sg.Text('Parameter Settings', font=("Ariel", 12))],
               [
                   sg.Text('min_df', size=(15, 1), font=("Ariel", 12)),
                   sg.InputText(str(min_df_val),
                                font=("Ariel", 12),
                                key='min_df_val')
               ],
               [
                   sg.Text('max_df', size=(15, 1), font=("Ariel", 12)),
                   sg.InputText(str(max_df_val),
                                font=("Ariel", 12),
                                key='max_df_val')
               ],
               [
                   sg.Text('Number of Label Words',
                           size=(15, 1),
                           font=("Ariel", 12)),
                   sg.InputText(str(label_words_val),
                                font=("Ariel", 12),
                                key='label_words_val')
               ],
               [
                   sg.Txt('Output Folder:', size=(10, 1), font=("Ariel", 12)),
                   sg.InputText(str(folder_val),
                                size=(30, 1),
                                font=("Ariel", 12),
                                key='folder_val'),
                   sg.FolderBrowse(font=("Ariel", 12))
               ],
               [
                   sg.Txt('Stopwords file:', size=(10, 1), font=("Ariel", 12)),
                   sg.InputText(str(stopwords_path),
                                size=(30, 1),
                                font=("Ariel", 12),
                                key='stopwords_path'),
                   sg.FileBrowse(font=("Ariel", 12))
               ],
               [sg.Submit(font=("Ariel", 12)),
                sg.Cancel(font=("Ariel", 12))]]

    settingswdw = sg.Window('Settings', grab_anywhere=False,
                            resizable=False).Layout(layout2)

    #settingswdw.Refresh()

    while True:  # Event Loop
        event, values = settingswdw.Read()
        print(event, values)
        if event is None or event == 'Cancel':
            print('None or Exit event')
            break
        elif event == 'Submit':

            if not RepresentsInt(values['min_df_val']) or not RepresentsInt(
                    values['max_df_val']) or not RepresentsInt(
                        values['label_words_val']):
                sg.PopupError('Values must be integers, please correct.')
            elif not os.path.exists(folder_val) or not os.path.isdir(
                    folder_val):
                sg.PopupError('Folder not valid, please correct.')
            elif not os.path.exists(stopwords_path) or not os.path.isfile(
                    stopwords_path):
                sg.PopupError('Stopwords file not valid, please correct.')
            else:
                min_df_val = values['min_df_val']
                max_df_val = values['max_df_val']
                label_words_val = values['label_words_val']
                folder_val = values['folder_val']
                stopwords_path = values['stopwords_path']
                #print('min_df_val: ' + min_df_val + '  max_df_val:' + max_df_val + '  label_words_val:' + label_words_val + '  output_folder_val: ' + folder_val)

                break

    print('min_df_val: ' + min_df_val + '  max_df_val:' + max_df_val +
          '  label_words_val:' + label_words_val + '  output_folder_val: ' +
          folder_val + '  stopwords_path: ' + stopwords_path)
    settingswdw.Close()
    return min_df_val, max_df_val, label_words_val, folder_val, stopwords_path
Esempio n. 18
0
    def gui(dark=False):
        if 'win' in sys.platform:
            titlebar = True
        else:
            titlebar = False
        if dark:
            background_color = "#262626"
            input_elements_background_color = "#262626"
            button_color = ('white', '#171717')
            text_color = "white"
            text_element_background_color = "#262626"
            input_text_color = "white"
        else:
            background_color = 'white'
            input_elements_background_color = '#474747'
            button_color = ('black', 'white')
            text_color = 'black'
            text_element_background_color = 'white'
            input_text_color = 'black'
        g.SetOptions(
            background_color=background_color,
            input_elements_background_color=input_elements_background_color,
            button_color=button_color,
            text_color=text_color,
            text_element_background_color=text_element_background_color,
            border_width=0,
            input_text_color=input_text_color,
            auto_size_buttons=True,
            auto_size_text=True)
        layout = [[g.T('EasyModels', font=('Arial', 15))],
                  [g.T('Please pick a category from below:')]]
        cat_json = Categories.get_all_categories()
        titles = []
        cat_to_id = {
            'Computer Vision': 'computer-vision',
            'Natural Language Processing': 'natural-language-processing',
            'Generative Models': 'generative-models',
            'Reinforcement Learning': 'reinforcement-learning',
            'Unsupervised Learning': 'unsupervised-learning',
            'Audio and Speech': 'audio-speech'
        }
        for k, v in cat_json.items():
            titles.append([v['title']])
        for title in titles:
            layout.append([g.Button(str(title[0]), key=cat_to_id[title[0]])])
        layout.append([g.Cancel('Close')])

        window = g.Window('EasyModels',
                          layout=layout,
                          keep_on_top=True,
                          grab_anywhere=True,
                          no_titlebar=titlebar)

        while True:
            event, values = window.Read()
            print(event)
            if event == 'Close':
                exit()
            else:
                category_info = Categories.get_category_info(event)
                new_layout = [[g.T('Available Projects', font=('Arial', 15))]]
                col1, col2 = GUI.category_to_layout(category_info)
                new_layout.append([g.Column(col2), g.Column(col1)])
                new_layout.append([g.Cancel('Close')])
                new_window = g.Window('Projects',
                                      layout=new_layout,
                                      keep_on_top=True,
                                      grab_anywhere=True,
                                      no_titlebar=titlebar)
                while True:
                    event1, values1 = new_window.Read()
                    if event1 == 'Close':
                        new_window.Close()
                        break
                    else:
                        open_new_tab(event1)
Esempio n. 19
0
import sys
import PySimpleGUIQt as sg

layout = [[sg.Image(filename="/Users/netbox-wangdong/Downloads/42-logo.png")],
          [sg.Text(' 请登录')], [sg.InputText()], [sg.InputText()],
          [sg.Button("ok"), sg.Cancel()]]

window = sg.Window('登录', layout)

event, values = window.Read()
window.Close()

text_input = values[1]
print(text_input)
Esempio n. 20
0
# https://www.raspberrypi.org/forums/viewtopic.php?t=219201
"""
import PySimpleGUI27 as sg

sg.Popup('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!')
"""

#import PySimpleGUI as sg
import PySimpleGUIQt as sg
#import PySimpleGUIWeb as sg

layout = [[sg.Text('Filename', text_color='red')],
          [sg.Input(), sg.FileBrowse()], [sg.OK(), sg.Cancel()]]
#event, values = sg.Window('Get filename example').Layout(layout).Read()
window = sg.Window('Get filename example').Layout(layout)

# The Event Loop
while True:
    event, values = window.Read()
    if event is None:
        break
    if event == 'OK':
        print(values[0])
import PySimpleGUIQt as sg

layout = [[
    sg.Text("Some text of Row 1",
            font="DejaVu Sans 18",
            text_color="blue",
            background_color="green")
], [sg.OK(), sg.Cancel()]]

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

while True:
    event, values = window.Read()
    if event in (None, "Cancel"):
        print("Cancel is pressed.")
        print("I will break now.")
        break

window.Close()
Esempio n. 22
0
def rename_dialog(src: str):
    import PySimpleGUIQt as sg
    ske = PySimpleGUISpecialKeyEvent()
    conf_file = real_join_path('~', '.config/rename_dialog.json')
    root = 'root'
    fname = 'fname'
    ext = 'ext'
    new_root = 'new_root'
    new_base = 'new_base'
    ok = 'OK'
    cancel = 'Cancel'
    pattern = 'pattern'
    replace = 'replace'
    substitute = 'substitute'
    save_replace = 'save_replace'
    save_pattern = 'save_pattern'
    add_root = 'add_root'
    title = 'Rename - {}'.format(src)
    h = .7

    conf = read_json_file(conf_file, default={pattern: [''], replace: ['']})
    tmp_pl = conf[pattern] or ['']
    tmp_rl = conf[replace] or ['']
    old_root, old_base = os.path.split(src)
    old_fn, old_ext = os.path.splitext(old_base)

    # sg.theme('SystemDefaultForReal')
    layout = [
        [sg.T(src, key='src')],
        [sg.HorizontalSeparator()],
        [sg.I(old_root, key=root),
         sg.B('+', key=add_root, size=(3, h)),
         sg.FolderBrowse('...', target=root, initial_folder=old_root, size=(6, h))],
        [sg.I(old_fn, key=fname, focus=True),
         sg.I(old_ext, key=ext, size=(6, h))],
        [sg.HorizontalSeparator()],
        [sg.T('Regular Expression Substitution Pattern & Replacement')],
        [sg.T(size=(0, h)),
         sg.Drop(tmp_pl, key=pattern, enable_events=True, text_color='blue'),
         sg.CB('', default=True, key=save_pattern, enable_events=True, size=(2, h)),
         sg.Drop(tmp_rl, key=replace, enable_events=True, text_color='blue'),
         sg.CB('', default=True, key=save_replace, enable_events=True, size=(2, h)),
         sg.B('Go', key=substitute, size=(3, h))],
        [sg.HorizontalSeparator()],
        [sg.I(old_root, key=new_root)],
        [sg.I(old_fn + old_ext, key=new_base)],
        [sg.Submit(ok, size=(10, 1)),
         sg.Stretch(),
         sg.Cancel(cancel, size=(10, 1))]]

    ensure_sigint_signal()
    window = sg.Window(title, return_keyboard_events=True).layout(layout).finalize()
    window.bring_to_front()

    loop = True
    data = {fname: old_fn, ext: old_ext, pattern: tmp_pl[0], replace: tmp_rl[0], root: old_root,
            new_root: '', new_base: ''}

    @decorator_factory_exception_retry(Exception, 0, enable_default=True, default=None)
    def re_sub():
        return re.sub(data[pattern], data[replace], data[fname] + data[ext])

    while loop:
        dst_from_data = os.path.join(data[new_root], data[new_base])
        try:
            tmp_fname = re_sub() or data[fname] + data[ext]
            dst = os.path.realpath(os.path.join(data[root], tmp_fname))
        except TypeError:
            dst = src
        if dst != dst_from_data:
            nr, nb = os.path.split(dst)
            window[new_root].update(nr)
            window[new_base].update(nb)

        event, data = window.read()
        f = window.find_element_with_focus()
        for k in (root, fname, ext, new_root, new_base):
            window[k].update(text_color=None)
        cur_p = data[pattern]
        cur_r = data[replace]

        if event == ske.esc:
            loop = False
        elif event == add_root:
            os.makedirs(data[root], exist_ok=True)
        elif event == substitute:
            data[fname], data[ext] = os.path.splitext(re_sub() or data[fname] + data[ext])
            window[fname].update(data[fname])
            window[ext].update(data[ext])
        elif event == save_pattern:
            if data[save_pattern]:
                conf[pattern].insert(0, cur_p)
                conf[pattern] = dedup_list(conf[pattern])
            else:
                conf[pattern] = remove_from_list(conf[pattern], [cur_p])
        elif event == save_replace:
            if data[save_replace]:
                conf[replace].insert(0, cur_r)
                conf[replace] = dedup_list(conf[replace])
            else:
                conf[replace] = remove_from_list(conf[replace], [cur_r])
        elif event == pattern:
            window[save_pattern].update(value=cur_p in conf[pattern])
        elif event == replace:
            window[save_replace].update(value=cur_r in conf[replace])
        elif event == ok:
            try:
                shutil.move(src, dst)
                loop = False
            except FileNotFoundError:
                for k in (root, fname, ext):
                    window[k].update(text_color='red')
            except FileExistsError:
                for k in (new_root, new_base):
                    window[k].update(text_color='red')
            except OSError as e:
                sg.PopupError(str(e))
        elif event in (None, cancel):
            loop = False
        else:
            ...
    else:
        write_json_file(conf_file, conf, indent=0)

    window.close()
Esempio n. 23
0
def pick_a_TC(instrument):
    ''' Graphical User interface - prompts the user for instrument, command and value
        then calls MakeTCfile to assemble the TC file based on the users choices '''
    params, enums, defaults, num_vals, val_max, val_min, notes = read_parameter_file(
        tc_filename, instrument)
    param_layout = [[
        sg.Listbox(values=params,
                   key='_param_',
                   tooltip='Select command to send',
                   size=(20, 6),
                   font=Font)
    ]]
    #param_layout = [[sg.InputCombo(values=params, key = '_param_',  font = Font)]]

    layout_pick_parameter = [
        [sg.Frame('Select Parameter to Update: ', param_layout, font=Font)],
        #[sg.Frame('Input new value: ', value_layout, font = Font)],
        [
            sg.Submit(font=Font, pad=(10, 10)),
            sg.Cancel(font=Font, pad=(10, 10))
        ]
    ]

    param_window = sg.Window('Select Parameter', layout_pick_parameter)
    event, values = param_window.Read()
    param_window.Close()

    tcString = values['_param_'][0]
    print(tcString)

    indx = 0
    enumeration = 999
    for words in params:
        if words == tcString:
            enumeration = enums[indx]
            break
        else:
            indx += 1

    if num_vals[indx] == 0:
        confirm_layout = [[sg.Text('Confirm: ' + notes[indx], font=Font)],
                          [
                              sg.Submit(pad=(10, 10), font=Font),
                              sg.Cancel(pad=(10, 10), font=Font)
                          ]]
        confirm_window = sg.Window('Confirm Command', confirm_layout)

        event, values = confirm_window.Read()
        confirm_window.Close()

        if event is None or event == 'Cancel':
            return None, None
        if event == 'Submit':
            filename = instrument + time.strftime("%Y%m%d-%H%M%S") + '.tc'
            cmnd = str(enumeration) + ';'
            MakeTCFile(filename, cmnd)

            send_layout = [[
                sg.Text('Command is valid: ' + cmnd + '. Save or send now',
                        font=Font)
            ],
                           [
                               sg.Button(button_text='Save TC File',
                                         pad=(10, 10),
                                         font=Font),
                               sg.Button(button_text='Send TC to CCMz',
                                         pad=(10, 10),
                                         font=Font)
                           ]]
            send_window = sg.Window('Send TC', send_layout)
            event, values = send_window.Read()
            send_window.Close()
            if event == 'Send TC to CCMz':
                desc = notes[indx].split(':')[0]
                SendTC(filename, instrument, desc)
            else:
                sg.Popup('Values within range \nWriting ' + cmnd + '\nTo: ' +
                         instrument + ' TC file: ' + filename,
                         font=Font)
        return True, 0, filename

    if num_vals[indx] == 1:
        value_layout = [
            [sg.Text(notes[indx], font=Font)],
            [sg.Text('Default Value ' + str(defaults[indx]), font=Font)],
            [sg.Text('Value:', font=Font),
             sg.InputText(key='_val_')]
        ]
        layout_enter_value = [[
            sg.Frame('Input new value: ', value_layout, font=Font)
        ],
                              [
                                  sg.Submit(font=Font, pad=(10, 10)),
                                  sg.Cancel(font=Font, pad=(10, 10))
                              ]]

        value_window = sg.Window('Enter Value', layout_enter_value)
        event, values = value_window.Read()
        value_window.Close()

        new_param_value = float(values['_val_'])
        print(new_param_value)

        if new_param_value < float(val_max[indx]) and new_param_value > float(
                val_min[indx]):
            print('New value is within range')
        else:
            sg.Popup('Value(s) out of Range!\nNo TC File Created', font=Font)
            print('New Value out of Range!')
            return 'error', 0

        filename = instrument + time.strftime("%Y%m%d-%H%M%S") + '.tc'
        cmnd = str(enumeration) + ',' + str(new_param_value) + ';'
        MakeTCFile(filename, cmnd)

        send_layout = [[
            sg.Text('Command is valid: ' + cmnd + '. Save or send now',
                    font=Font)
        ],
                       [
                           sg.Button(button_text='Save TC File',
                                     pad=(10, 10),
                                     font=Font),
                           sg.Button(button_text='Send TC to CCMz',
                                     pad=(10, 10),
                                     font=Font)
                       ]]
        send_window = sg.Window('Send TC', send_layout)
        event, values = send_window.Read()
        send_window.Close()
        if event == 'Send TC to CCMz':
            desc = notes[indx].split(':')[0] + ': ' + str(new_param_value)
            SendTC(filename, instrument, desc)
        else:
            sg.Popup('Values within range \nWriting ' + cmnd + '\nTo: ' +
                     instrument + ' TC file: ' + filename,
                     font=Font)
        return True, 1, filename

    if num_vals[indx] == 2:
        value_layout = [
            [sg.Text(notes[indx], font=Font)],
            [
                sg.Text('Default Value ' + str(defaults[indx]) +
                        'No Limit Checking for values!',
                        font=Font)
            ], [sg.Text('Value 1:', font=Font),
                sg.InputText(key='_val1_')],
            [sg.Text('Value 2:', font=Font),
             sg.InputText(key='_val2_')]
        ]

        layout_enter_value = [[
            sg.Frame('Input new value: ', value_layout, font=Font)
        ],
                              [
                                  sg.Submit(font=Font, pad=(10, 10)),
                                  sg.Cancel(font=Font, pad=(10, 10))
                              ]]

        value_window = sg.Window('Enter Value', layout_enter_value)
        event, values = value_window.Read()
        value_window.Close()

        new_param_value_1 = float(values['_val1_'])
        new_param_value_2 = float(values['_val2_'])

        if new_param_value_1 < int(val_max[indx]) and new_param_value_1 > int(
                val_min[indx]):
            print('Value one is within range')
        if new_param_value_2 < int(val_max[indx]) and new_param_value_2 > int(
                val_min[indx]):
            print('Value two is within range')
        else:
            sg.Popup('Value(s) out of Range!\nNo TC File Created', font=Font)
            print('Value out of Range!')
            return 'error', 0

        filename = instrument + time.strftime("%Y%m%d-%H%M%S") + '.tc'
        cmnd = str(enumeration) + ',' + str(new_param_value_1) + ',' + str(
            new_param_value_2) + ';'
        MakeTCFile(filename, cmnd)

        send_layout = [[
            sg.Text('Command is valid: ' + cmnd + 'save or send now',
                    font=Font)
        ],
                       [
                           sg.Button(button_text='Save TC File',
                                     pad=(10, 10),
                                     font=Font),
                           sg.Button(button_text='Send TC to CCMz',
                                     pad=(10, 10),
                                     font=Font)
                       ]]
        send_window = sg.Window('Send TC', send_layout)
        event, values = send_window.Read()
        send_window.Close()
        if event == 'Send TC to CCMz':
            desc = notes[indx].split(':')[0] + ': ' + str(
                new_param_value_1) + ',' + str(new_param_value_2)
            SendTC(filename, instrument, desc)
        else:
            sg.Popup('Values within range \nWriting ' + cmnd + '\nTo: ' +
                     instrument + ' TC file: ' + filename,
                     font=Font)
        return True, 2, filename

    if num_vals[indx] == 3:
        value_layout = [
            [sg.Text(notes[indx], font=Font)],
            [
                sg.Text('Default Value ' + str(defaults[indx]) +
                        'No Limit Checking for values!',
                        font=Font)
            ], [sg.Text('Value 1:', font=Font),
                sg.InputText(key='_val1_')],
            [sg.Text('Value 2:', font=Font),
             sg.InputText(key='_val2_')],
            [sg.Text('Value 3:', font=Font),
             sg.InputText(key='_val3_')]
        ]

        layout_enter_value = [[
            sg.Frame('Input new value: ', value_layout, font=Font)
        ],
                              [
                                  sg.Submit(font=Font, pad=(10, 10)),
                                  sg.Cancel(font=Font, pad=(10, 10))
                              ]]

        value_window = sg.Window('Enter Value', layout_enter_value)
        event, values = value_window.Read()
        value_window.Close()

        new_param_value_1 = int(values['_val1_'])
        new_param_value_2 = int(values['_val2_'])
        new_param_value_3 = int(values['_val3_'])

        if new_param_value_1 < int(val_max[indx]) and new_param_value_1 > int(
                val_min[indx]):
            print('Value one is within range')
        if new_param_value_2 < int(val_max[indx]) and new_param_value_2 > int(
                val_min[indx]):
            print('Value two is within range')
        if new_param_value_3 < int(val_max[indx]) and new_param_value_3 > int(
                val_min[indx]):
            print('Value three is within range')
        else:
            sg.Popup('Value(s) out of Range!\nNo TC File Created', font=Font)
            print('Value out of Range!')
            return 'error', 0

        filename = instrument + time.strftime("%Y%m%d-%H%M%S") + '.tc'
        cmnd = str(enumeration) + ',' + str(new_param_value_1) + ',' + str(
            new_param_value_2) + ',' + str(new_param_value_3) + ';'
        MakeTCFile(filename, cmnd)
        send_layout = [[
            sg.Text('Command is valid: ' + cmnd + '. Save or send now',
                    font=Font)
        ],
                       [
                           sg.Button(button_text='Save TC File',
                                     pad=(10, 10),
                                     font=Font),
                           sg.Button(button_text='Send TC to CCMz',
                                     pad=(10, 10),
                                     font=Font)
                       ]]
        send_window = sg.Window('Send TC', send_layout)
        event, values = send_window.Read()
        send_window.Close()
        if event == 'Send TC to CCMz':
            desc = notes[indx].split(':')[0] + ': ' + str(
                new_param_value_1) + ',' + str(new_param_value_2) + ',' + str(
                    new_param_value_3)
            SendTC(filename, instrument, desc)
        else:
            sg.Popup('Values within range \nWriting ' + cmnd + '\nTo: ' +
                     instrument + ' TC file: ' + filename,
                     font=Font)
        return True, 3, filename

    if num_vals[indx] == 4:
        value_layout = [
            [sg.Text(notes[indx], font=Font)],
            [
                sg.Text('Default Value ' + str(defaults[indx]) +
                        'No Limit Checking for values!',
                        font=Font)
            ], [sg.Text('Value 1:', font=Font),
                sg.InputText(key='_val1_')],
            [sg.Text('Value 2:', font=Font),
             sg.InputText(key='_val2_')],
            [sg.Text('Value 3:', font=Font),
             sg.InputText(key='_val3_')],
            [sg.Text('Value 4:', font=Font),
             sg.InputText(key='_val4_')]
        ]

        layout_enter_value = [[
            sg.Frame('Input new value: ', value_layout, font=Font)
        ],
                              [
                                  sg.Submit(font=Font, pad=(10, 10)),
                                  sg.Cancel(font=Font, pad=(10, 10))
                              ]]

        value_window = sg.Window('Enter Value', layout_enter_value)
        event, values = value_window.Read()
        value_window.Close()

        new_param_value_1 = int(values['_val1_'])
        new_param_value_2 = int(values['_val2_'])
        new_param_value_3 = int(values['_val3_'])
        new_param_value_4 = int(values['_val4_'])

        if new_param_value_1 < int(val_max[indx]) and new_param_value_1 > int(
                val_min[indx]):
            print('Value one is within range')
        if new_param_value_2 < int(val_max[indx]) and new_param_value_2 > int(
                val_min[indx]):
            print('Value two is within range')
        if new_param_value_3 < int(val_max[indx]) and new_param_value_4 > int(
                val_min[indx]):
            print('Value three is within range')
        if new_param_value_4 < int(val_max[indx]) and new_param_value_3 > int(
                val_min[indx]):
            print('Value four is within range')
        else:
            sg.Popup('Value(s) out of Range!\nNo TC File Created', font=Font)
            print('Value out of Range!')
            return False, 0

        filename = instrument + time.strftime("%Y%m%d-%H%M%S") + '.tc'
        cmnd = str(enumeration) + ',' + str(new_param_value_1) + ',' + str(
            new_param_value_2) + ',' + str(new_param_value_3) + ',' + str(
                new_param_value_4) + ';'
        MakeTCFile(filename, cmnd)
        send_layout = [[
            sg.Text('Command is valid: ' + cmnd + 'save or send now',
                    font=Font)
        ],
                       [
                           sg.Button(button_text='Save TC File',
                                     pad=(10, 10),
                                     font=Font),
                           sg.Button(button_text='Send TC to CCMz',
                                     pad=(10, 10),
                                     font=Font)
                       ]]
        send_window = sg.Window('Send TC', send_layout)
        event, values = send_window.Read()
        send_window.Close()
        if event == 'Send TC to CCMz':
            desc = notes[indx].split(':')[0] + ': ' + str(
                new_param_value_1) + ',' + str(new_param_value_2) + ',' + str(
                    new_param_value_3) + ',' + str(new_param_value_4)
            SendTC(filename, instrument, desc)

        else:
            sg.Popup('Values within range \nWriting ' + cmnd + '\nTo: ' +
                     instrument + ' TC file: ' + filename,
                     font=Font)
        return True, 4, filename

    if num_vals[indx] == 5:
        value_layout = [
            [sg.Text(notes[indx], font=Font)],
            [
                sg.Text('Default Value ' + str(defaults[indx]) +
                        'No Limit Checking for values!',
                        font=Font)
            ], [sg.Text('Value 1:', font=Font),
                sg.InputText(key='_val1_')],
            [sg.Text('Value 2:', font=Font),
             sg.InputText(key='_val2_')],
            [sg.Text('Value 3:', font=Font),
             sg.InputText(key='_val3_')],
            [sg.Text('Value 4:', font=Font),
             sg.InputText(key='_val4_')],
            [sg.Text('Value 5:', font=Font),
             sg.InputText(key='_val5_')]
        ]

        layout_enter_value = [[
            sg.Frame('Input new value: ', value_layout, font=Font)
        ],
                              [
                                  sg.Submit(font=Font, pad=(10, 10)),
                                  sg.Cancel(font=Font, pad=(10, 10))
                              ]]

        value_window = sg.Window('Enter Value', layout_enter_value)
        event, values = value_window.Read()
        value_window.Close()

        new_param_value_1 = int(values['_val1_'])
        new_param_value_2 = int(values['_val2_'])
        new_param_value_3 = int(values['_val3_'])
        new_param_value_4 = int(values['_val4_'])
        new_param_value_5 = int(values['_val5_'])

        if new_param_value_1 < int(val_max[indx]) and new_param_value_1 > int(
                val_min[indx]):
            print('Value one is within range')
        if new_param_value_2 < int(val_max[indx]) and new_param_value_2 > int(
                val_min[indx]):
            print('Value two is within range')
        if new_param_value_3 < int(val_max[indx]) and new_param_value_3 > int(
                val_min[indx]):
            print('Value three is within range')
        if new_param_value_4 < int(val_max[indx]) and new_param_value_4 > int(
                val_min[indx]):
            print('Value four is within range')
        if new_param_value_5 < int(val_max[indx]) and new_param_value_5 > int(
                val_min[indx]):
            print('Value four is within range')
        else:
            sg.Popup('Value(s) out of Range!\nNo TC File Created', font=Font)
            print('Value out of Range!')
            return False, 0

        filename = instrument + time.strftime("%Y%m%d-%H%M%S") + '.tc'
        cmnd = str(enumeration) + ',' + str(new_param_value_1) + ',' + str(
            new_param_value_2) + ',' + str(new_param_value_3) + ',' + str(
                new_param_value_4) + ',' + str(new_param_value_5) + ';'
        MakeTCFile(filename, cmnd)
        send_layout = [[
            sg.Text('Command is valid: ' + cmnd + '. Save or send now',
                    font=Font)
        ],
                       [
                           sg.Button(button_text='Save TC File',
                                     pad=(10, 10),
                                     font=Font),
                           sg.Button(button_text='Send TC to CCMz',
                                     pad=(10, 10),
                                     font=Font)
                       ]]
        send_window = sg.Window('Send TC', send_layout)
        event, values = send_window.Read()
        send_window.Close()
        if event == 'Send TC to CCMz':
            desc = notes[indx].split(':')[0] + ': ' + str(
                new_param_value_1) + ',' + str(new_param_value_2) + ',' + str(
                    new_param_value_3) + ',' + str(
                        new_param_value_4) + ',' + str(new_param_value_5)
            SendTC(filename, instrument, desc)
        else:
            sg.Popup('Values within range \nWriting ' + cmnd + '\nTo: ' +
                     instrument + ' TC file: ' + filename,
                     font=Font)
        return True, 5, filename
    def __init__(self, config):
        from monopolpy_companion.lib.common.run import opts_win_active
        import PySimpleGUIQt as qt
        # First we pull in the environment variables
        from monopolpy_companion.conf import conf as defaults
        import logging

        self.name = 'MonopolPyCompanion.GUI.OptionsWindow'
        log = logging.getLogger(self.name)
        log.debug(f'Logger started for {self.name}')
        self.log = log

        log.debug(f'Current active state: {opts_win_active}')
        opts_win_active = True
        log.debug(f'New active state: {opts_win_active}')
        self.active = opts_win_active

        conf = config
        self.conf = conf

        self.opts_playman_frame = [
            [qt.Button('Player Management', key='opts_playman_button')],
        ]

        self.opts_frame = [[
            qt.Checkbox('Grab anywhere',
                        default=self.is_grabby(),
                        key='grab_anywhere_box')
        ]]

        self.opts_main_frame = [[
            qt.Frame('Player Management:', self.opts_playman_frame)
        ], [qt.Frame('GUI Options', self.opts_frame)]]

        self.layout = [[
            qt.Frame('Monopolpy Companion Options:',
                     self.opts_main_frame,
                     background_color='#40bfdbae',
                     title_color='#ff000000',
                     title_location='TITLE_LOCATION_TOP',
                     relief='RELIEF_SUNKEN')
        ],
                       [
                           qt.Button('OK', key='opts_ok'),
                           qt.Cancel(key='opts_cancel'),
                           qt.Button('Apply', key='opts_apply')
                       ]]

        self.opts_win = qt.Window(
            'Monopolpy Companion Options',
            self.layout,
            grab_anywhere=self.conf['gui_settings']['grab_anywhere'],
            background_image='thing.png',
            size=(400, 200))
        from monopolpy_companion.lib.common.run import pm_active

        log.debug(
            f'Imported active state of the Player Manager window which is: {pm_active}'
        )

        while self.active:

            event, values = self.opts_win.read(timeout=100)

            if event == 'opts_ok' or event == 'opts_apply':
                log.debug('User is attempting to save config to file')
                from monopolpy_companion.lib.helpers.popup_man import nyi

                nyi('Save Config')

            if event == 'opts_ok':
                log.debug('User pressed OK in the options window')
                log.debug('Leaving window.')
                self.leave()

            if event == 'opts_playman_button' and not pm_active:
                from monopolpy_companion.lib.gui.models.windows.player_man import PlayerManagerWindow
                log.debug('User pressed the Player Manager button')
                play_man_win = PlayerManagerWindow()
                log.debug(
                    f'Player Manager active state was {play_man_win.active}')
                play_man_win.active = True

            if event is None or event == 'opts_cancel':
                log.debug('User pressed cancel in the options window')
                self.leave()
Esempio n. 25
0
column1 = [
    [sg.Text('Column 1', background_color='lightblue', text_color='black', justification='center', size=(100, 22))],
    [sg.Spin((1, 10), size=(100, 22))],
    [sg.Spin((1, 10), size=(100, 22))],
    [sg.Spin((1, 10), size=(100, 22))], ]

if os.path.isfile('full collection.xlsx'):
    filename = 'full collection.xlsx'
else:
    filename = 'Default File'

layout = [
    [sg.Text('Select the file you want to format:')],
    [sg.Text('Your File'),
     sg.InputText(filename, size=(300, 50)), sg.FileBrowse(), sg.Stretch()],
    [sg.Submit(tooltip='Click to submit this form', ), sg.Cancel()]]

window = sg.Window('Collection Manager',
                   grab_anywhere=False,
                   font=('Helvetica', 12),
                   no_titlebar=False,
                   alpha_channel=1,
                   keep_on_top=False,
                   element_padding=(2, 3),
                   default_element_size=(100, 23),
                   default_button_element_size=(120, 30),
                   # background_image='colors.png',
                   ).Layout(layout)
event, values = window.Read()
print(event, values)
print(values[0].replace('file:///', ''))  # this gets rid of file:///
# import PySimpleGUI as sg          # Same program can be used with tkinter port
import PySimpleGUIQt as sg
use('qt5agg')
import matplotlib.pyplot as plt
"""
    Simultaneous PySimpleGUI Window AND a Matplotlib Interactive Window
    A number of people have requested the ability to run a normal PySimpleGUI window that
    launches a MatplotLib window that is interactive with the usual Matplotlib controls.
    It turns out to be a rather simple thing to do.  The secret is to add parameter block=False to plt.show()
"""


def draw_plot():
    plt.plot([0.1, 0.2, 0.5, 0.7])
    plt.show(block=False)


layout = [[sg.Button('Plot'), sg.Cancel(), sg.Button('Popup')]]

window = sg.Window('Have some Matplotlib....', layout)

while True:
    event, values = window.read()
    if event in (None, 'Cancel'):
        break
    elif event == 'Plot':
        draw_plot()
    elif event == 'Popup':
        sg.popup('Yes, your application is still running')
window.close()
Esempio n. 27
0
import sys
import PySimpleGUIQt as sg

layout = [[sg.T('用户名:'), sg.InputText(key='user')],
          [sg.T('密码:'), sg.InputText(key='pass')],
          [sg.Button('登录'), sg.Cancel('exit')]]
window = sg.Window('登录', layout)
while True:
    event, values = window.read()
    if event in (None, 'exit'):
        window.close()
        break
    print(event)
    print(values['user'])