當前位置: 首頁>>代碼示例>>Python>>正文


Python PySimpleGUI.FileBrowse方法代碼示例

本文整理匯總了Python中PySimpleGUI.FileBrowse方法的典型用法代碼示例。如果您正苦於以下問題:Python PySimpleGUI.FileBrowse方法的具體用法?Python PySimpleGUI.FileBrowse怎麽用?Python PySimpleGUI.FileBrowse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PySimpleGUI的用法示例。


在下文中一共展示了PySimpleGUI.FileBrowse方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: PlayerChooseSongGUI

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import FileBrowse [as 別名]
def PlayerChooseSongGUI(self):

        # ---------------------- DEFINION OF CHOOSE WHAT TO PLAY GUI ----------------------------

        layout = [[sg.Text('MIDI File Player', font=("Helvetica", 15), size=(20, 1), text_color='green')],
                  [sg.Text('File Selection', font=("Helvetica", 15), size=(20, 1))],
                  [sg.Text('Single File Playback', justification='right'), sg.InputText(size=(65, 1), key='midifile'), sg.FileBrowse(size=(10, 1), file_types=(("MIDI files", "*.mid"),))],
                  [sg.Text('Or Batch Play From This Folder', auto_size_text=False, justification='right'), sg.InputText(size=(65, 1), key='folder'), sg.FolderBrowse(size=(10, 1))],
                  [sg.Text('_' * 250, auto_size_text=False, size=(100, 1))],
                  [sg.Text('Choose MIDI Output Device', size=(22, 1)),
                   sg.Listbox(values=self.PortList, size=(30, len(self.PortList) + 1), key='device')],
                  [sg.Text('_' * 250, auto_size_text=False, size=(100, 1))],
                  [sg.SimpleButton('PLAY', size=(12, 2), button_color=('red', 'white'), font=("Helvetica", 15), bind_return_key=True), sg.Text(' ' * 2, size=(4, 1)), sg.Cancel(size=(8, 2), font=("Helvetica", 15))]]

        window = sg.Window('MIDI File Player', auto_size_text=False, default_element_size=(30, 1), font=("Helvetica", 12)).Layout(layout)
        self.Window = window
        return window.Read() 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:19,代碼來源:Demo_MIDI_Player.py

示例2: GetFilesToCompare

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import FileBrowse [as 別名]
def GetFilesToCompare():
    form_rows = [[sg.Text('Enter 2 files to comare')],
                 [sg.Text('File 1', size=(15, 1)), sg.InputText(key='file1'), sg.FileBrowse()],
                 [sg.Text('File 2', size=(15, 1)), sg.InputText(key='file2'), sg.FileBrowse(target='file2')],
                 [sg.Submit(), sg.Cancel()]]

    window = sg.Window('File Compare')
    event, values = window.Layout(form_rows).Read()
    return event, values 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:11,代碼來源:Demo_Compare_Files.py

示例3: GetFilesToCompare

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import FileBrowse [as 別名]
def GetFilesToCompare():
    form_rows = [[sg.Text('Enter 2 files to comare')],
                 [sg.Text('File 1', size=(15, 1)),
                    sg.InputText(key='-file1-'), sg.FileBrowse()],
                 [sg.Text('File 2', size=(15, 1)), sg.InputText(key='-file2-'),
                  sg.FileBrowse(target='-file2-')],
                 [sg.Submit(), sg.Cancel()]]

    window = sg.Window('File Compare', form_rows)
    event, values = window.read()
    window.close()
    return event, values 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:14,代碼來源:Demo_Compare_Files.py

示例4: main

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import FileBrowse [as 別名]
def main():
    sg.theme('LightGreen')

    layout = [[sg.Text('PyInstaller EXE Creator', font='Any 15')],
              [sg.Text('Source Python File'), sg.Input(key='-sourcefile-', size=(45, 1)),
               sg.FileBrowse(file_types=(("Python Files", "*.py"),))],
              [sg.Text('Icon File'), sg.Input(key='-iconfile-', size=(45, 1)),
               sg.FileBrowse(file_types=(("Icon Files", "*.ico"),))],
              [sg.Frame('Output', font='Any 15', layout=[
                        [sg.Output(size=(65, 15), font='Courier 10')]])],
              [sg.Button('Make EXE', bind_return_key=True),
               sg.Button('Quit', button_color=('white', 'firebrick3')) ],
              [sg.Text('Made with PySimpleGUI (www.PySimpleGUI.org)', auto_size_text=True, font='Courier 8')]]

    window = sg.Window('PySimpleGUI EXE Maker', layout, auto_size_text=False, auto_size_buttons=False, default_element_size=(20,1), text_justification='right')
    # ---===--- Loop taking in user input --- #
    while True:

        event, values = window.read()
        if event in ('Exit', 'Quit', None):
            break

        source_file = values['-sourcefile-']
        icon_file = values['-iconfile-']

        icon_option = '-i "{}"'.format(icon_file) if icon_file else ''
        source_path, source_filename = os.path.split(source_file)
        workpath_option = '--workpath "{}"'.format(source_path)
        dispath_option = '--distpath "{}"'.format(source_path)
        specpath_option = '--specpath "{}"'.format(source_path)
        folder_to_remove = os.path.join(source_path, source_filename[:-3])
        file_to_remove = os.path.join(source_path, source_filename[:-3]+'.spec')
        command_line = 'pyinstaller -wF --clean "{}" {} {} {} {}'.format(source_file, icon_option, workpath_option, dispath_option, specpath_option)

        if event == 'Make EXE':
            try:
                print(command_line)
                print('Making EXE...the program has NOT locked up...')
                window.refresh()
                # print('Running command {}'.format(command_line))
                out, err = runCommand(command_line, window=window)
                shutil.rmtree(folder_to_remove)
                os.remove(file_to_remove)
                print('**** DONE ****')
            except:
                sg.PopupError('Something went wrong', 'close this window and copy command line from text printed out in main window','Here is the output from the run', out)
                print('Copy and paste this line into the command prompt to manually run PyInstaller:\n\n', command_line) 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:49,代碼來源:pysimplegui-exemaker.py

示例5: Launcher

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import FileBrowse [as 別名]
def Launcher():
    sg.ChangeLookAndFeel('LightGreen')

    layout =  [[sg.T('PyInstaller EXE Creator', font='Any 15')],
                [sg.T('Source Python File'), sg.In(key='_sourcefile_', size=(45,1)), sg.FileBrowse(file_types=(("Python Files", "*.py"),))],
                [sg.T('Icon File'), sg.In(key='_iconfile_', size=(45,1)), sg.FileBrowse(file_types=(("Icon Files", "*.ico"),))],
                [sg.Frame('Output', font='Any 15',layout= [[sg.Output(size=(65, 15), font='Courier 10')]])],
                [sg.ReadFormButton('Make EXE',bind_return_key=True),
                 sg.SimpleButton('Quit', button_color=('white','firebrick3')),]]

    window = sg.Window('PySimpleGUI EXE Maker',
                       auto_size_text=False,
                       auto_size_buttons=False,
                       default_element_size=(20,1,),
                       text_justification='right')

    window.Layout(layout)

    # ---===--- Loop taking in user input --- #
    while True:
        (button, values) = window.Read()
        if button in ('Quit', None):
            break           # exit button clicked

        source_file = values['_sourcefile_']
        icon_file = values['_iconfile_']

        icon_option = '-i "{}"'.format(icon_file) if icon_file else ''
        source_path, source_filename = os.path.split(source_file)
        workpath_option = '--workpath "{}"'.format(source_path)
        dispath_option = '--distpath "{}"'.format(source_path)
        specpath_option = '--specpath "{}"'.format(source_path)
        folder_to_remove = os.path.join(source_path,source_filename[:-3])
        file_to_remove = os.path.join(source_path, source_filename[:-3]+'.spec')
        command_line = 'pyinstaller -wF "{}" {} {} {} {}'.format(source_file, icon_option, workpath_option, dispath_option, specpath_option)

        if button == 'Make EXE':
            try:
                print(command_line)
                print('Making EXE... this will take a while.. the program has NOT locked up...')
                window.Refresh()
                # print('Running command {}'.format(command_line))
                runCommand(command_line)
                shutil.rmtree(folder_to_remove)
                os.remove(file_to_remove)
                print('**** DONE ****')
            except:
                sg.PopupError('Something went wrong') 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:50,代碼來源:Demo_EXE_Maker.py

示例6: get_layout

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import FileBrowse [as 別名]
def get_layout(cls):
        return [
            sg.Button(
                'save & overwrite',
                key='save',
                font=cls.FONT_10,
                pad=cls.PAD_BUTTON_CONTROLS),
            sg.FileSaveAs(
                'save as',
                key='save_as',
                font=cls.FONT_10,
                pad=cls.PAD_BUTTON_CONTROLS,
                target='save_cfg_path',
                file_types=(cls.JSON_FILETYPE, ),
                initial_folder=cls.INITIAL_CONFIG_FOLDER),
            sg.FileBrowse(
                'load',
                key='load',
                font=cls.FONT_10,
                pad=cls.PAD_BUTTON_CONTROLS,
                target='load_cfg_path',
                file_types=(cls.JSON_FILETYPE, ),
                initial_folder=cls.INITIAL_CONFIG_FOLDER),
            sg.InputText(
                key='save_cfg_path',
                enable_events=True,
                visible=False,
                disabled=True),
            sg.InputText(
                key='load_cfg_path',
                enable_events=True,
                visible=False,
                disabled=True),
            sg.InputText(
                cls.DEF_PATH,
                key='cfg_path',
                visible=False,
                disabled=True),
            sg.Text('loaded config:', pad=((5, 0), 0)),
            sg.Text(
                os.path.basename(cls.DEF_PATH),
                key='cfg_filename',
                font=('Courier New', 10),
                size=(30, 1)),
        ] 
開發者ID:mrmin123,項目名稱:kcauto,代碼行數:47,代碼來源:config_controls.py


注:本文中的PySimpleGUI.FileBrowse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。