New options for PopupGetFile (save_as, no_window), added key to buttons, New Demo_Fill_form from JFong
This commit is contained in:
parent
ab92627916
commit
16b1c8310d
|
@ -1,52 +1,75 @@
|
|||
# from tkinter.filedialog import asksaveasfilename, askopenfilename
|
||||
import pickle
|
||||
import PySimpleGUI as sg
|
||||
|
||||
"""
|
||||
Show a complex form, save the initial values
|
||||
When the "Fill" button is clicked, the form will reset to the initial values
|
||||
"""
|
||||
|
||||
def save(values):
|
||||
sfilename = sg.PopupGetFile('Save Settings', save_as=True, no_window=True)
|
||||
if not sfilename:
|
||||
return
|
||||
with open(sfilename, 'wb') as sf:
|
||||
pickle.dump(values, sf)
|
||||
|
||||
|
||||
def load(form):
|
||||
dfilename = sg.PopupGetFile('Load Settings', no_window=True)
|
||||
if not dfilename:
|
||||
return
|
||||
with open(dfilename, 'rb') as df:
|
||||
form.Fill(pickle.load(df))
|
||||
|
||||
|
||||
def Everything():
|
||||
sg.ChangeLookAndFeel('Dark')
|
||||
sg.ChangeLookAndFeel('TanBlue')
|
||||
|
||||
|
||||
column1 = [[sg.Text('Column 1', background_color='black', 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')]]
|
||||
column1 = [
|
||||
[sg.Text('Column 1', background_color=sg.DEFAULT_BACKGROUND_COLOR, justification='center', size=(10, 1))],
|
||||
[sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1', key='spin1')],
|
||||
[sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 2', key='spin2')],
|
||||
[sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 3', key='spin3')]]
|
||||
|
||||
layout = [
|
||||
[sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25))],
|
||||
[sg.Text('Here is some text.... and a place to enter text')],
|
||||
[sg.InputText('This is my text')],
|
||||
[sg.Checkbox('Checkbox'), sg.Checkbox('My second checkbox!', default=True)],
|
||||
[sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")],
|
||||
[sg.Multiline(default_text='This is the default Text should you decide not to type anything', size=(35, 3)),
|
||||
sg.Multiline(default_text='A second multi-line', size=(35, 3))],
|
||||
[sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(20, 1)),
|
||||
sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85)],
|
||||
[sg.InputOptionMenu(('Menu Option 1', 'Menu Option 2', 'Menu Option 3'))],
|
||||
[sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3)),
|
||||
sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25),
|
||||
sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75),
|
||||
sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10, key='slider'),
|
||||
sg.Column(column1, background_color='black')],
|
||||
[sg.InputText('This is my text', key='in1', do_not_clear=True)],
|
||||
[sg.Checkbox('Checkbox', key='cb1'), sg.Checkbox('My second checkbox!', key='cb2', default=True)],
|
||||
[sg.Radio('My first Radio! ', "RADIO1", key='rad1', default=True),
|
||||
sg.Radio('My second Radio!', "RADIO1", key='rad2')],
|
||||
[sg.Multiline(default_text='This is the default Text should you decide not to type anything', size=(35, 3),
|
||||
key='multi1', do_not_clear=True),
|
||||
sg.Multiline(default_text='A second multi-line', size=(35, 3), key='multi2', do_not_clear=True)],
|
||||
[sg.InputCombo(('Combobox 1', 'Combobox 2'), key='combo', size=(20, 1)),
|
||||
sg.Slider(range=(1, 100), orientation='h', size=(34, 20), key='slide1', default_value=85)],
|
||||
[sg.InputOptionMenu(('Menu Option 1', 'Menu Option 2', 'Menu Option 3'), key='optionmenu')],
|
||||
[sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3), key='listbox'),
|
||||
sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25, key='slide2', ),
|
||||
sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75, key='slide3', ),
|
||||
sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10, key='slide4'),
|
||||
sg.Column(column1, background_color='gray34')],
|
||||
[sg.Text('_' * 80)],
|
||||
[sg.Text('Choose A Folder', size=(35, 1))],
|
||||
[sg.Text('Your Folder', size=(15, 1), auto_size_text=False, justification='right'),
|
||||
sg.InputText('Default Folder'), sg.FolderBrowse()],
|
||||
[sg.ReadFormButton('Fill'), sg.Cancel()]
|
||||
sg.InputText('Default Folder', key='folder', do_not_clear=True), sg.FolderBrowse()],
|
||||
[sg.ReadFormButton('Exit'),
|
||||
sg.Text(' ' * 40), sg.ReadFormButton('SaveSettings'), sg.ReadFormButton('LoadSettings')]
|
||||
]
|
||||
|
||||
form = sg.FlexForm('Form Fill Demonstration', default_element_size=(40, 1))
|
||||
# button, values = form.LayoutAndRead(layout, non_blocking=True)
|
||||
form.Layout(layout)
|
||||
button, initial_values = form.ReadNonBlocking()
|
||||
|
||||
while True:
|
||||
button, values = form.Read()
|
||||
if button in (None, 'Cancel'):
|
||||
|
||||
if button is 'SaveSettings':
|
||||
save(values)
|
||||
elif button is 'LoadSettings':
|
||||
load(form)
|
||||
elif button in ['Exit', None]:
|
||||
break
|
||||
form.Fill(initial_values) # fill form with whatever initial values were
|
||||
|
||||
sg.Popup('Title', 'The results of the form.', 'The button clicked was "{}"'.format(button), 'The values are', values)
|
||||
# form.CloseNonBlockingForm()
|
||||
|
||||
Everything()
|
||||
|
||||
if __name__ == '__main__':
|
||||
Everything()
|
||||
|
|
|
@ -1510,64 +1510,64 @@ T = Text
|
|||
# return Text(display_text, scale=scale, size=size, auto_size_text=auto_size_text, font=font, text_color=text_color, justification=justification)
|
||||
|
||||
# ------------------------- FOLDER BROWSE Element lazy function ------------------------- #
|
||||
def FolderBrowse(target=(ThisRow, -1), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, pad=None):
|
||||
return Button(BUTTON_TYPE_BROWSE_FOLDER, target=target, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, pad=pad)
|
||||
def FolderBrowse(target=(ThisRow, -1), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, pad=None, key=None):
|
||||
return Button(BUTTON_TYPE_BROWSE_FOLDER, target=target, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, pad=pad, key=key)
|
||||
|
||||
# ------------------------- FILE BROWSE Element lazy function ------------------------- #
|
||||
def FileBrowse(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, pad=None):
|
||||
return Button(BUTTON_TYPE_BROWSE_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, pad=pad)
|
||||
def FileBrowse(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, pad=None, key=None):
|
||||
return Button(BUTTON_TYPE_BROWSE_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, pad=pad, key=key)
|
||||
|
||||
# ------------------------- FILES BROWSE Element (Multiple file selection) lazy function ------------------------- #
|
||||
def FilesBrowse(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, pad=None):
|
||||
return Button(BUTTON_TYPE_BROWSE_FILES, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, pad=pad)
|
||||
def FilesBrowse(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, pad=None, key=None):
|
||||
return Button(BUTTON_TYPE_BROWSE_FILES, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, pad=pad, key=key)
|
||||
|
||||
# ------------------------- FILE BROWSE Element lazy function ------------------------- #
|
||||
def FileSaveAs(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Save As...', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, pad=None):
|
||||
return Button(BUTTON_TYPE_SAVEAS_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, pad=pad)
|
||||
def FileSaveAs(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Save As...', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, pad=None, key=None):
|
||||
return Button(BUTTON_TYPE_SAVEAS_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, pad=pad, key=key)
|
||||
|
||||
# ------------------------- SAVE AS Element lazy function ------------------------- #
|
||||
def SaveAs(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Save As...', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, pad=None):
|
||||
return Button(BUTTON_TYPE_SAVEAS_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, pad=pad)
|
||||
def SaveAs(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Save As...', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, pad=None, key=None):
|
||||
return Button(BUTTON_TYPE_SAVEAS_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, pad=pad, key=key)
|
||||
|
||||
# ------------------------- SAVE BUTTON Element lazy function ------------------------- #
|
||||
def Save(button_text='Save', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True,font=None, focus=False, pad=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color,font=font, bind_return_key=bind_return_key, focus=focus, pad=pad)
|
||||
def Save(button_text='Save', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True,font=None, focus=False, pad=None, key=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color,font=font, bind_return_key=bind_return_key, focus=focus, pad=pad, key=key)
|
||||
|
||||
# ------------------------- SUBMIT BUTTON Element lazy function ------------------------- #
|
||||
def Submit(button_text='Submit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True,font=None, focus=False, pad=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color,font=font, bind_return_key=bind_return_key, focus=focus, pad=pad)
|
||||
def Submit(button_text='Submit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True,font=None, focus=False, pad=None, key=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color,font=font, bind_return_key=bind_return_key, focus=focus, pad=pad, key=key)
|
||||
|
||||
# ------------------------- OPEN BUTTON Element lazy function ------------------------- #
|
||||
def Open(button_text='Open', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True,font=None, focus=False, pad=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color,font=font, bind_return_key=bind_return_key, focus=focus, pad=pad)
|
||||
def Open(button_text='Open', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True,font=None, focus=False, pad=None, key=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color,font=font, bind_return_key=bind_return_key, focus=focus, pad=pad, key=key)
|
||||
|
||||
# ------------------------- OK BUTTON Element lazy function ------------------------- #
|
||||
def OK(button_text='OK', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, font=None,focus=False, pad=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color,font=font, bind_return_key=bind_return_key, focus=focus, pad=pad)
|
||||
def OK(button_text='OK', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, font=None,focus=False, pad=None, key=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color,font=font, bind_return_key=bind_return_key, focus=focus, pad=pad, key=key)
|
||||
|
||||
# ------------------------- YES BUTTON Element lazy function ------------------------- #
|
||||
def Ok(button_text='Ok', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, font=None,focus=False, pad=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad)
|
||||
def Ok(button_text='Ok', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, font=None,focus=False, pad=None, key=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad, key=key)
|
||||
|
||||
# ------------------------- CANCEL BUTTON Element lazy function ------------------------- #
|
||||
def Cancel(button_text='Cancel', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False, pad=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad)
|
||||
def Cancel(button_text='Cancel', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False, pad=None, key=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad, key=key)
|
||||
|
||||
# ------------------------- QUIT BUTTON Element lazy function ------------------------- #
|
||||
def Quit(button_text='Quit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False, pad=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad)
|
||||
def Quit(button_text='Quit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False, pad=None, key=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad, key=key)
|
||||
|
||||
# ------------------------- Exit BUTTON Element lazy function ------------------------- #
|
||||
def Exit(button_text='Exit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False, pad=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad)
|
||||
def Exit(button_text='Exit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False, pad=None, key=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad, key=key)
|
||||
|
||||
# ------------------------- YES BUTTON Element lazy function ------------------------- #
|
||||
def Yes(button_text='Yes', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None,font=None, bind_return_key=True, focus=False, pad=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad)
|
||||
def Yes(button_text='Yes', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None,font=None, bind_return_key=True, focus=False, pad=None, key=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad, key=key)
|
||||
|
||||
# ------------------------- NO BUTTON Element lazy function ------------------------- #
|
||||
def No(button_text='No', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None,font=None, bind_return_key=False, focus=False, pad=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad)
|
||||
def No(button_text='No', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None,font=None, bind_return_key=False, focus=False, pad=None, key=None):
|
||||
return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad, key=key)
|
||||
|
||||
# ------------------------- GENERIC BUTTON Element lazy function ------------------------- #
|
||||
# this is the only button that REQUIRES button text field
|
||||
|
@ -2024,7 +2024,6 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
|||
element.TKListbox.insert(tk.END, item)
|
||||
if element.DefaultValues is not None and item in element.DefaultValues:
|
||||
element.TKListbox.selection_set(index)
|
||||
# element.TKListbox.selection_set(0,0)
|
||||
if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT:
|
||||
element.TKListbox.configure(background=element.BackgroundColor)
|
||||
if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT:
|
||||
|
@ -2036,6 +2035,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
|||
element.TKListbox.pack(side=tk.LEFT)
|
||||
vsb.pack(side=tk.LEFT, fill='y')
|
||||
listbox_frame.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1])
|
||||
element.TKListbox.bind('<Return>', element.ReturnKeyHandler)
|
||||
# ------------------------- INPUT MULTI LINE element ------------------------- #
|
||||
elif element_type == ELEM_TYPE_INPUT_MULTILINE:
|
||||
default_text = element.DefaultText
|
||||
|
@ -2183,7 +2183,8 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
|||
tkscale.config(highlightthickness=0)
|
||||
if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT:
|
||||
tkscale.configure(background=element.BackgroundColor)
|
||||
tkscale.config(troughcolor=DEFAULT_SCROLLBAR_COLOR)
|
||||
if DEFAULT_SCROLLBAR_COLOR != COLOR_SYSTEM_DEFAULT:
|
||||
tkscale.config(troughcolor=DEFAULT_SCROLLBAR_COLOR)
|
||||
if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT:
|
||||
tkscale.configure(fg=text_color)
|
||||
tkscale.pack(side=tk.LEFT, padx=element.Pad[0],pady=element.Pad[1])
|
||||
|
@ -2948,10 +2949,21 @@ GetFile = GetFileBox
|
|||
AskForFile = GetFileBox
|
||||
|
||||
|
||||
def PopupGetFile(message, default_path='', file_types=(("ALL Files", "*.*"),), button_color=None, size=(None, None)):
|
||||
def PopupGetFile(message, save_as=False, no_window=False, default_path='', file_types=(("ALL Files", "*.*"),), button_color=None, size=(None, None)):
|
||||
if no_window:
|
||||
if save_as:
|
||||
return tk.filedialog.asksaveasfilename(filetypes=file_types) # show the 'get file' dialog box
|
||||
else:
|
||||
return tk.filedialog.askopenfilename(filetypes=file_types) # show the 'get file' dialog box
|
||||
|
||||
if save_as:
|
||||
browse_button = SaveAs(file_types=file_types)
|
||||
else:
|
||||
browse_button = FileBrowse(file_types=file_types)
|
||||
|
||||
with FlexForm(title=message, auto_size_text=True, button_color=button_color) as form:
|
||||
layout = [[Text(message, auto_size_text=True)],
|
||||
[InputText(default_text=default_path, size=size), FileBrowse(file_types=file_types)],
|
||||
[InputText(default_text=default_path, size=size), browse_button],
|
||||
[Ok(), Cancel()]]
|
||||
|
||||
(button, input_values) = form.LayoutAndRead(layout)
|
||||
|
@ -2961,6 +2973,7 @@ def PopupGetFile(message, default_path='', file_types=(("ALL Files", "*.*"),), b
|
|||
path = input_values[0]
|
||||
return path
|
||||
|
||||
|
||||
# ============================== GetTextBox =========#
|
||||
# Get a single line of text #
|
||||
# ===================================================#
|
||||
|
|
Loading…
Reference in New Issue