本文整理汇总了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()
示例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
示例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
示例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)
示例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')
示例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)),
]