本文整理汇总了Python中PySimpleGUI.Checkbox方法的典型用法代码示例。如果您正苦于以下问题:Python PySimpleGUI.Checkbox方法的具体用法?Python PySimpleGUI.Checkbox怎么用?Python PySimpleGUI.Checkbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySimpleGUI
的用法示例。
在下文中一共展示了PySimpleGUI.Checkbox方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: lbas_group_node_line_generator
# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Checkbox [as 别名]
def lbas_group_node_line_generator(cls, group_id):
return [
sg.Text(f'LBAS Group {group_id}', **cls.LABEL_SETTINGS),
sg.Checkbox(
'Enabled',
key=f'combat.lbas_group_{group_id}.enabled',
font=cls.FONT_10,
enable_events=True),
sg.Combo(
[''] + [x.display_name for x in NamedNodeEnum],
key=f'combat.lbas_group_{group_id}_node_1',
font=cls.FONT_10,
size=(4, 1)),
sg.Combo(
[''] + [x.display_name for x in NamedNodeEnum],
key=f'combat.lbas_group_{group_id}_node_2',
font=cls.FONT_10,
size=(4, 1)),
cls.generate_clear_btn(
f'combat.lbas_group_{group_id}_nodes')]
示例2: get_layout
# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Checkbox [as 别名]
def get_layout(cls):
return sg.Column(
[
[
sg.Text('PvP Module', **cls.LABEL_SETTINGS),
sg.Checkbox(
'Enabled',
key='pvp.enabled',
enable_events=True)
],
[
sg.Text('Fleet Preset', **cls.LABEL_SETTINGS),
sg.Combo(
[''] + [x for x in range(1, MAX_FLEET_PRESETS + 1)],
key='pvp.fleet_preset',
font=cls.FONT_10,
size=(13, 1))
]
],
key='config_pvp_col',
visible=False)
示例3: get_layout
# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Checkbox [as 别名]
def get_layout(cls):
return sg.Column(
[
[
sg.Text('Expedition Module', **cls.LABEL_SETTINGS),
sg.Checkbox(
'Enabled',
key='expedition.enabled',
enable_events=True)
],
cls.expedition_line_generator(2),
cls.expedition_line_generator(3),
cls.expedition_line_generator(4),
],
key='config_expedition_col',
visible=False)
示例4: MachineLearningGUI
# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Checkbox [as 别名]
def MachineLearningGUI():
sg.SetOptions(text_justification='right')
flags = [[sg.Checkbox('Normalize', size=(12, 1), default=True), sg.Checkbox('Verbose', size=(20, 1))],
[sg.Checkbox('Cluster', size=(12, 1)), sg.Checkbox('Flush Output', size=(20, 1), default=True)],
[sg.Checkbox('Write Results', size=(12, 1)), sg.Checkbox('Keep Intermediate Data', size=(20, 1))],
[sg.Checkbox('Normalize', size=(12, 1), default=True), sg.Checkbox('Verbose', size=(20, 1))],
[sg.Checkbox('Cluster', size=(12, 1)), sg.Checkbox('Flush Output', size=(20, 1), default=True)],
[sg.Checkbox('Write Results', size=(12, 1)), sg.Checkbox('Keep Intermediate Data', size=(20, 1))],]
loss_functions = [[sg.Radio('Cross-Entropy', 'loss', size=(12, 1)), sg.Radio('Logistic', 'loss', default=True, size=(12, 1))],
[sg.Radio('Hinge', 'loss', size=(12, 1)), sg.Radio('Huber', 'loss', size=(12, 1))],
[sg.Radio('Kullerback', 'loss', size=(12, 1)), sg.Radio('MAE(L1)', 'loss', size=(12, 1))],
[sg.Radio('MSE(L2)', 'loss', size=(12, 1)), sg.Radio('MB(L0)', 'loss', size=(12, 1))],]
command_line_parms = [[sg.Text('Passes', size=(8, 1)), sg.Spin(values=[i for i in range(1, 1000)], initial_value=20, size=(6, 1)),
sg.Text('Steps', size=(8, 1), pad=((7,3))), sg.Spin(values=[i for i in range(1, 1000)], initial_value=20, size=(6, 1))],
[sg.Text('ooa', size=(8, 1)), sg.In(default_text='6', size=(8, 1)), sg.Text('nn', size=(8, 1)),
sg.In(default_text='10', size=(10, 1))],
[sg.Text('q', size=(8, 1)), sg.In(default_text='ff', size=(8, 1)), sg.Text('ngram', size=(8, 1)),
sg.In(default_text='5', size=(10, 1))],
[sg.Text('l', size=(8, 1)), sg.In(default_text='0.4', size=(8, 1)), sg.Text('Layers', size=(8, 1)),
sg.Drop(values=('BatchNorm', 'other'), auto_size_text=True)],]
layout = [[sg.Frame('Command Line Parameteres', command_line_parms, title_color='green', font='Any 12')],
[sg.Frame('Flags', flags, font='Any 12', title_color='blue')],
[sg.Frame('Loss Functions', loss_functions, font='Any 12', title_color='red')],
[sg.Submit(), sg.Cancel()]]
window = sg.Window('Machine Learning Front End', font=("Helvetica", 12)).Layout(layout)
button, values = window.Read()
sg.SetOptions(text_justification='left')
print(button, values)
示例5: Launcher2
# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Checkbox [as 别名]
def Launcher2():
sg.ChangeLookAndFeel('GreenTan')
window = sg.Window('Script launcher')
filelist = glob.glob(LOCATION_OF_YOUR_SCRIPTS+'*.py')
namesonly = []
for file in filelist:
namesonly.append(ntpath.basename(file))
layout = [
[sg.Listbox(values=namesonly, size=(30, 19), select_mode=sg.SELECT_MODE_EXTENDED, key='demolist'), sg.Output(size=(88, 20), font='Courier 10')],
[sg.Checkbox('Wait for program to complete', default=False, key='wait')],
[sg.Button('Run'), sg.Button('Shortcut 1'), sg.Button('Fav Program'), sg.Button('EXIT')],
]
window.Layout(layout)
# ---===--- Loop taking in user input --- #
while True:
event, values = window.Read()
if event in ('EXIT', None):
break # exit button clicked
if event in ('Shortcut 1', 'Fav Program'):
print('Quickly launch your favorite programs using these shortcuts')
print('Or copy files to your github folder. Or anything else you type on the command line')
# copyfile(source, dest)
elif event == 'Run':
for index, file in enumerate(values['demolist']):
print('Launching %s'%file)
window.Refresh() # make the print appear immediately
if values['wait']:
execute_command_blocking(LOCATION_OF_YOUR_SCRIPTS + file)
else:
execute_command_nonblocking(LOCATION_OF_YOUR_SCRIPTS + file)
示例6: main
# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Checkbox [as 别名]
def main():
layout = [[sg.Text('Window Snapshot', key='-T-', font='Any 20', justification='c')],
[sg.Listbox(values=[' '], size=(50, 20), select_mode=sg.SELECT_MODE_EXTENDED, font=('Courier', 12), key='-PROCESSES-')],
[sg.Checkbox('Show only Python programs', default=True, key='-PYTHON ONLY-')],
[sg.Checkbox('Crop image', default=True, key='-CROP-')],
[sg.Multiline(size=(63, 10), font=('Courier', 10), key='-ML-')],
[sg.Text('Output folder:'), sg.In(os.path.dirname(__file__), key='-FOLDER-'), sg.FolderBrowse()],
[sg.Button('Refresh'),
sg.Button('Snapshot', button_color=('white', 'DarkOrange2')),
sg.Exit(button_color=('white', 'sea green'))]]
window = sg.Window('Window Snapshot', layout, keep_on_top=True, auto_size_buttons=False, default_button_element_size=(12, 1), finalize=True)
window['-T-'].expand(True, False, False) # causes text to center by expanding the element
sg.cprint_set_output_destination(window, '-ML-')
show_list_by_name(window, '-PROCESSES-', True)
# ---------------- main loop ----------------
while True:
# --------- Read and update window --------
event, values = window.read()
if event in (sg.WIN_CLOSED, 'Exit'):
break
# --------- Do Button Operations --------
if event == 'Refresh':
show_list_by_name(window, '-PROCESSES-', values['-PYTHON ONLY-'])
elif event == 'Snapshot':
for title in values['-PROCESSES-']:
sg.cprint('Saving: ', end='', c='white on red')
sg.cprint(title)
output_filename = os.path.join(values['-FOLDER-'], f'{title}.png')
save_win(output_filename, title, values['-CROP-'])
window.close()
示例7: get_layout
# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Checkbox [as 别名]
def get_layout(cls):
return sg.Column(
[
[
sg.Text('Scheduler', **cls.LABEL_SETTINGS),
sg.Checkbox(
'Enabled', key='scheduler.enabled', enable_events=True)
],
[
sg.Text('Scheduler Rules', **cls.LABEL_SETTINGS),
sg.Listbox(
key='scheduler.rules',
values=[],
font=cls.FONT_10,
size=(54, 4),
enable_events=True)
],
[
sg.Text('', **cls.LABEL_SETTINGS),
cls.generate_edit_btn('scheduler.rules', size=(20, 1)),
cls.generate_remove_btn('scheduler.rules', size=(20, 1)),
cls.generate_clear_btn('scheduler.rules', size=(20, 1)),
]
],
key='config_scheduler_col',
visible=False)
示例8: get_layout
# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Checkbox [as 别名]
def get_layout(cls):
return sg.Column(
[
[
sg.Text('Passive Repair', **cls.LABEL_SETTINGS),
sg.Checkbox(
'Enabled',
key='passive_repair.enabled',
enable_events=True)
],
[
sg.Text('Repair Threshold', **cls.LABEL_SETTINGS),
sg.Combo(
[
x.display_name for x in DamageStateEnum
if x in cls.VALID_DAMAGE_STATES],
default_value=DamageStateEnum.SCRATCH.display_name,
key='passive_repair.repair_threshold',
font=cls.FONT_10,
size=(13, 1))
],
[
sg.Text('Slots to Reserve', **cls.LABEL_SETTINGS),
sg.Spin(
[x for x in range(
cls.MIN_SLOTS_RESERVED,
cls.MAX_SLOTS_RESERVED + 1)],
0,
key='passive_repair.slots_to_reserve',
font=cls.FONT_10,
size=(5, 1))
]
],
key='config_passive_repair_col',
visible=False)
示例9: generate_quest_checkboxes
# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Checkbox [as 别名]
def generate_quest_checkboxes(cls, quests):
qlist = [[]]
for idx, q in enumerate(quests):
qlist[-1].append(sg.Checkbox(
q,
key=f'quest_c.q.{q}',
font=cls.FONT,
enable_events=True
))
if (idx + 1) % cls.QUESTS_PER_LINE == 0:
qlist.append([])
return qlist
示例10: get_layout
# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Checkbox [as 别名]
def get_layout(cls):
return sg.Column(
[
[
sg.Text('Event Reset Module', **cls.LABEL_SETTINGS),
sg.Checkbox(
'Enabled',
key='event_reset.enabled',
enable_events=True)
],
[
sg.Text('Reset Frequency', **cls.LABEL_SETTINGS),
sg.Spin(
[x for x in range(1, 11)],
2,
key='event_reset.frequency',
font=cls.FONT_10,
size=(4, 1))
],
[
sg.Text('Reset Difficulty', **cls.LABEL_SETTINGS),
sg.Combo(
[
x.display_name for x in EventDifficultyEnum
if x is not EventDifficultyEnum.NONE],
default_value=EventDifficultyEnum.NORMAL.display_name,
key='event_reset.reset_difficulty',
font=cls.FONT_10,
size=(8, 1))
],
[
sg.Text('Farm Difficulty', **cls.LABEL_SETTINGS),
sg.Combo(
[
x.display_name for x in EventDifficultyEnum
if x is not EventDifficultyEnum.NONE],
default_value=EventDifficultyEnum.EASY.display_name,
key='event_reset.farm_difficulty',
font=cls.FONT_10,
size=(8, 1))
]
],
key='config_event_reset_col',
visible=False)
示例11: HowDoI
# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Checkbox [as 别名]
def HowDoI():
'''
Make and show a window (PySimpleGUI form) that takes user input and sends to the HowDoI web oracle
Excellent example of 2 GUI concepts
1. Output Element that will show text in a scrolled window
2. Non-Window-Closing Buttons - These buttons will cause the form to return with the form's values, but doesn't close the form
:return: never returns
'''
# ------- Make a new Window ------- #
sg.ChangeLookAndFeel('GreenTan') # give our form a spiffy set of colors
layout = [
[sg.Text('Ask and your answer will appear here....', size=(40, 1))],
[sg.Output(size=(127, 30), font=('Helvetica 10'))],
[ sg.Spin(values=(1, 2, 3, 4), initial_value=1, size=(2, 1), key='Num Answers', font='Helvetica 15'),
sg.Text('Num Answers',font='Helvetica 15'), sg.Checkbox('Display Full Text', key='full text', font='Helvetica 15'),
sg.T('Command History', font='Helvetica 15'), sg.T('', size=(40,3), text_color=sg.BLUES[0], key='history')],
[sg.Multiline(size=(85, 5), enter_submits=True, key='query', do_not_clear=False),
sg.ReadButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0]), bind_return_key=True),
sg.Button('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]
]
window = sg.Window('How Do I ??',
default_element_size=(30, 2),
font=('Helvetica',' 13'),
default_button_element_size=(8,2),
icon=DEFAULT_ICON,
return_keyboard_events=True).Layout(layout)
# ---===--- Loop taking in user input and using it to query HowDoI --- #
command_history = []
history_offset = 0
while True:
(button, value) = window.Read()
if button == 'SEND':
query = value['query'].rstrip()
print(query)
QueryHowDoI(query, value['Num Answers'], value['full text']) # send the string to HowDoI
command_history.append(query)
history_offset = len(command_history)-1
window.FindElement('query').Update('') # manually clear input because keyboard events blocks clear
window.FindElement('history').Update('\n'.join(command_history[-3:]))
elif button in (None, 'EXIT'): # if exit button or closed using X
break
elif 'Up' in button and len(command_history): # scroll back in history
command = command_history[history_offset]
history_offset -= 1 * (history_offset > 0) # decrement is not zero
window.FindElement('query').Update(command)
elif 'Down' in button and len(command_history): # scroll forward in history
history_offset += 1 * (history_offset < len(command_history)-1) # increment up to end of list
command = command_history[history_offset]
window.FindElement('query').Update(command)
elif 'Escape' in button: # clear currently line
window.FindElement('query').Update('')
示例12: Everything
# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Checkbox [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()