本文整理匯總了Python中PySimpleGUI.InputText方法的典型用法代碼示例。如果您正苦於以下問題:Python PySimpleGUI.InputText方法的具體用法?Python PySimpleGUI.InputText怎麽用?Python PySimpleGUI.InputText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PySimpleGUI
的用法示例。
在下文中一共展示了PySimpleGUI.InputText方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PlayerChooseSongGUI
# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import InputText [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: sample_layout
# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import InputText [as 別名]
def sample_layout(theme_name, colors, description):
name = 'Dark' if theme_name.startswith('D') else 'Light'
name += "".join(description[:2])
layout = [[sg.Text('Text element', size=(12,1)), sg.InputText(' '.join(colors),text_color='#000000' ),sg.Radio('',theme+'1', key='-INPUT_RAD0-'+theme, default=True, metadata='#000000'),
sg.Slider((0,10),size=(10,20), orientation='h')],
[sg.T(size=(12,1)), sg.InputText(colors[0], text_color='#FFFFFF'),sg.Radio('',theme+'1', key='-INPUT_RAD1-'+theme, metadata='#FFFFFF')],
[sg.T(size=(12,1)), sg.InputText(colors[0], text_color=colors[0]),sg.Radio('',theme+'1', key='-INPUT_RAD2-'+theme, metadata=colors[0])],
[sg.T(size=(12,1)),sg.InputText(colors[3], text_color=colors[3]),sg.Radio('',theme+'1', key='-INPUT_RAD3-'+theme, metadata=colors[3])],
[sg.T(', '.join(description)), sg.In(name, key='-NEW_THEME_NAME-'+theme)],
[sg.Button('OK'), sg.Radio('',theme+'2',key='-BTN_RAD1-'+theme, default=True, metadata=sg.DEFAULT_BUTTON_COLOR),
sg.Button('OK', button_color=('white', colors[0])),sg.Radio('',theme+'2',key='-BTN_RAD2-'+theme, metadata=('white', colors[0])),
sg.Button('OK', button_color=('black', colors[0])),sg.Radio('',theme+'2',key='-BTN_RAD9-'+theme, metadata=('black', colors[0])),
sg.Button('OK', button_color=('white', colors[3])),sg.Radio('', theme+'2', key='-BTN_RAD10-' + theme, metadata=('white', colors[3])),
sg.Button('OK', button_color=('black', colors[3])),sg.Radio('', theme+'2', key='-BTN_RAD11-' + theme, metadata=('black', colors[3]))],
[sg.Button('OK', button_color=(colors[0],colors[1])),sg.Radio('',theme+'2',key='-BTN_RAD3-'+theme, metadata=(colors[0], colors[1])),
sg.Button('OK', button_color=(colors[2],colors[1])),sg.Radio('',theme+'2',key='-BTN_RAD4-'+theme, metadata=(colors[2], colors[1])),
sg.Button('OK', button_color=(colors[3],colors[1])),sg.Radio('',theme+'2',key='-BTN_RAD5-'+theme, metadata=(colors[3], colors[1])),
sg.Button('OK', button_color=(colors[3],colors[0])),sg.Radio('',theme+'2',key='-BTN_RAD7-'+theme, metadata=(colors[3], colors[0])),
sg.Button('OK', button_color=(colors[0],colors[3])),sg.Radio('',theme+'2',key='-BTN_RAD8-'+theme, metadata=(colors[0], colors[3])),
sg.Button('Cancel', button_color=(colors[3], colors[2])),sg.Radio('',theme+'2',key='-BTN_RAD6-'+theme, metadata=(colors[3], colors[2])),
] ]
return layout
# layout = [[sg.Text('Here is list of some themes', font='Default 18', background_color=WINDOW_BACKGROUND)]]
示例3: __init__
# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import InputText [as 別名]
def __init__(self):
layout = [[sg.Text('Enter Text')],
[sg.Input(size=(17, 1), key='input1', do_not_clear=True)],
[sg.InputText(size=(17, 1), key='input2', do_not_clear=True)],
[sg.Button('on-screen keyboard', key='keyboard')],
[sg.Button('close', key='close')]]
self.mainWindow = sg.Window('On-screen test',
grab_anywhere=True,
no_titlebar=False,
).Layout(layout).Finalize()
location = self.mainWindow.CurrentLocation()
location = location[0]-200, location[1]+200
self.keyboard = keyboard(location)
self.focus = None
示例4: GetFilesToCompare
# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import InputText [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
示例5: update_value_and_return_it
# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import InputText [as 別名]
def update_value_and_return_it(input_text_element, value=None, fun_to_apply=None):
"""
1) Get the text in the `InputText` element `input_text_element`.
2) Apply the function `fun_to_apply` to it (if one is passed in).
3) Update the text back to the new value.
If `value` is passed in it will be used in place of the text from step 1)."""
if value is None:
value = input_text_element.Get()
if fun_to_apply:
value = fun_to_apply(value)
input_text_element.Update(value)
return value
示例6: __init__
# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import InputText [as 別名]
def __init__(self):
layout = [[sg.Text('Enter Text')],
[sg.Input('', size=(17, 1), key='input1')],
[sg.InputText('', size=(17, 1), key='input2')],
[sg.Button('on-screen keyboard', key='keyboard')],
[sg.Button('close', key='close')]]
self.mainWindow = sg.Window('On-screen test', layout,
grab_anywhere=True, no_titlebar=False, finalize=True)
location = self.mainWindow.current_location()
location = location[0]-200, location[1]+200
self.keyboard = keyboard(location)
self.focus = None
示例7: GetFilesToCompare
# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import InputText [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
示例8: sample_layout
# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import InputText [as 別名]
def sample_layout():
return [[sg.Text('Text element'), sg.InputText('Input data here', size=(15, 1))],
[sg.Button('Ok'), sg.Button('Cancel'), sg.Slider((1, 10), orientation='h', size=(10, 15))]]
示例9: ship_switcher_slot_generator
# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import InputText [as 別名]
def ship_switcher_slot_generator(cls, slot_id):
return [
sg.Text(f'Slot {slot_id} Rules', **cls.LABEL_SETTINGS),
sg.InputText(
key=f'ship_switcher.slot_{slot_id}_rule',
font=cls.FONT_10,
size=(30, 1),
disabled=True),
cls.generate_edit_btn(
f'ship_switcher.slot_{slot_id}_rule'),
cls.generate_clear_btn(
f'ship_switcher.slot_{slot_id}_rule')
]
示例10: expedition_line_generator
# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import InputText [as 別名]
def expedition_line_generator(cls, fleet_id):
return [
sg.Text(f'Fleet {fleet_id}', **cls.LABEL_SETTINGS),
sg.InputText(
key=f'expedition.fleet_{fleet_id}',
font=cls.FONT_10,
size=(30, 1),
disabled=True),
cls.generate_edit_btn(f'expedition.fleet_{fleet_id}'),
cls.generate_clear_btn(f'expedition.fleet_{fleet_id}')
]
示例11: Everything
# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import InputText [as 別名]
def Everything():
sg.ChangeLookAndFeel('TanBlue')
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', 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', key='folder', do_not_clear=True), sg.FolderBrowse()],
[sg.Button('Exit'),
sg.Text(' ' * 40), sg.Button('SaveSettings'), sg.Button('LoadSettings')]
]
window = sg.Window('Form Fill Demonstration', default_element_size=(40, 1), grab_anywhere=False)
# button, values = window.LayoutAndRead(layout, non_blocking=True)
window.Layout(layout)
while True:
event, values = window.Read()
if event == 'SaveSettings':
filename = sg.PopupGetFile('Save Settings', save_as=True, no_window=True)
window.SaveToDisk(filename)
# save(values)
elif event == 'LoadSettings':
filename = sg.PopupGetFile('Load Settings', no_window=True)
window.LoadFromDisk(filename)
# load(form)
elif event in ('Exit', None):
break
# window.CloseNonBlocking()
示例12: main
# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import InputText [as 別名]
def main():
global colors
global reverse
build_reverse_dict()
list_of_colors = [c for c in colors]
printable = '\n'.join(map(str, list_of_colors))
# show_all_colors_on_buttons()
sg.SetOptions(element_padding=(0,0))
while True:
# ------- Form show ------- #
layout = [[sg.Text('Find color')],
[sg.Text('Demonstration of colors')],
[sg.Text('Enter a color name in text or hex #RRGGBB format')],
[sg.InputText(key='hex')],
[sg.Listbox(list_of_colors, size=(20, 30), bind_return_key=True, key='listbox'), sg.T('Or choose from list')],
[sg.Submit(), sg.Button('Many buttons', button_color=('white', '#0e6251'), key='Many buttons'), sg.ColorChooserButton( 'Chooser', target=(3,0), key='Chooser'), sg.Quit(),],
]
# [g.Multiline(DefaultText=str(printable), Size=(30,20))]]
event, values = sg.Window('Color Demo', auto_size_buttons=False).Layout(layout).Read()
# ------- OUTPUT results portion ------- #
if event == 'Quit' or event is None:
exit(0)
elif event == 'Many buttons':
show_all_colors_on_buttons()
drop_down_value = values['listbox']
hex_input = values['hex']
if hex_input == '' and len(drop_down_value) == 0:
continue
if len(hex_input) != 0:
if hex_input[0] == '#':
color_hex = hex_input.upper()
color_name = get_name_from_hex(hex_input)
else:
color_name = hex_input
color_hex = get_hex_from_name(color_name)
elif drop_down_value is not None and len(drop_down_value) != 0:
color_name = drop_down_value[0]
color_hex = get_hex_from_name(color_name)
complementary_hex = get_complementary_hex(color_hex)
complementary_color = get_name_from_hex(complementary_hex)
layout = [[sg.Text('That color and it\'s compliment are shown on these buttons. This form auto-closes')],
[sg.CloseButton(button_text=color_name, button_color=(color_hex, complementary_hex))],
[sg.CloseButton(button_text=complementary_hex + ' ' + complementary_color, button_color=(complementary_hex , color_hex), size=(30, 1))],
]
sg.Window('Color demo', default_element_size=(100, 1), auto_size_text=True, auto_close=True, auto_close_duration=5, icon=MY_WINDOW_ICON).Layout(layout).Read()
示例13: main
# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import InputText [as 別名]
def main():
global colors
global reverse
build_reverse_dict()
list_of_colors = [c for c in colors]
printable = '\n'.join(map(str, list_of_colors))
# show_all_colors_on_buttons()
sg.set_options(element_padding=(0,0))
while True:
# ------- Form show ------- #
layout = [[sg.Text('Find color')],
[sg.Text('Demonstration of colors')],
[sg.Text('Enter a color name in text or hex #RRGGBB format')],
[sg.InputText(key='hex')],
[sg.Listbox(list_of_colors, size=(20, 30), bind_return_key=True, key='listbox'), sg.Text('Or choose from list')],
[sg.Submit(), sg.Button('Many buttons', button_color=('white', '#0e6251'), key='Many buttons'), sg.ColorChooserButton( 'Chooser', target=(3,0), key='Chooser'), sg.Quit(),],
]
# [g.Multiline(DefaultText=str(printable), Size=(30,20))]]
event, values = sg.Window('Color Demo', layout, auto_size_buttons=False).read()
# ------- OUTPUT results portion ------- #
if event == 'Quit' or event == sg.WIN_CLOSED:
exit(0)
elif event == 'Many buttons':
show_all_colors_on_buttons()
drop_down_value = values['listbox']
hex_input = values['hex']
if hex_input == '' and len(drop_down_value) == 0:
continue
if len(hex_input) != 0:
if hex_input[0] == '#':
color_hex = hex_input.upper()
color_name = get_name_from_hex(hex_input)
else:
color_name = hex_input
color_hex = get_hex_from_name(color_name)
elif drop_down_value is not None and len(drop_down_value) != 0:
color_name = drop_down_value[0]
color_hex = get_hex_from_name(color_name)
complementary_hex = get_complementary_hex(color_hex)
complementary_color = get_name_from_hex(complementary_hex)
layout = [[sg.Text('That color and it\'s compliment are shown on these buttons. This form auto-closes')],
[sg.CloseButton(button_text=color_name, button_color=(color_hex, complementary_hex))],
[sg.CloseButton(button_text=complementary_hex + ' ' + complementary_color, button_color=(complementary_hex , color_hex), size=(30, 1))],
]
sg.Window('Color demo', layout, default_element_size=(100, 1),
auto_close=True, auto_close_duration=5).read()
示例14: get_layout
# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import InputText [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)),
]