当前位置: 首页>>代码示例>>Python>>正文


Python PySimpleGUI.Combo方法代码示例

本文整理汇总了Python中PySimpleGUI.Combo方法的典型用法代码示例。如果您正苦于以下问题:Python PySimpleGUI.Combo方法的具体用法?Python PySimpleGUI.Combo怎么用?Python PySimpleGUI.Combo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySimpleGUI的用法示例。


在下文中一共展示了PySimpleGUI.Combo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_settings_window

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Combo [as 别名]
def create_settings_window(settings):
    sg.theme(settings['theme'])

    def TextLabel(text): return sg.Text(text+':', justification='r', size=(15,1))

    layout = [  [sg.Text('Settings', font='Any 15')],
                [TextLabel('Max Users'), sg.Input(key='-MAX USERS-')],
                [TextLabel('User Folder'),sg.Input(key='-USER FOLDER-'), sg.FolderBrowse(target='-USER FOLDER-')],
                [TextLabel('Zipcode'),sg.Input(key='-ZIPCODE-')],
                [TextLabel('Theme'),sg.Combo(sg.theme_list(), size=(20, 20), key='-THEME-')],
                [sg.Button('Save'), sg.Button('Exit')]  ]

    window = sg.Window('Settings', layout, keep_on_top=True, finalize=True)

    for key in SETTINGS_KEYS_TO_ELEMENT_KEYS:   # update window with the values read from settings file
        try:
            window[SETTINGS_KEYS_TO_ELEMENT_KEYS[key]].update(value=settings[key])
        except Exception as e:
            print(f'Problem updating PySimpleGUI window from settings. Key = {key}')

    return window

########################################## Main Program Window & Event Loop ########################################## 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:25,代码来源:Demo_Settings_Save_Load.py

示例2: lbas_group_node_line_generator

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Combo [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')] 
开发者ID:mrmin123,项目名称:kcauto,代码行数:22,代码来源:config_combat.py

示例3: get_layout

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Combo [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) 
开发者ID:mrmin123,项目名称:kcauto,代码行数:23,代码来源:config_pvp.py

示例4: get_layout

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Combo [as 别名]
def get_layout(cls, presets):
        return [
            [
                sg.Text('Combat Fleet Presets', font=cls.FONT_10),
            ],
            [
                sg.Listbox(
                    key='presets',
                    values=presets,
                    font=cls.FONT_10,
                    size=(19, 6),
                    enable_events=True),
            ],
            [
                cls.generate_remove_btn('presets', 'remove preset'),
                cls.generate_clear_btn('presets', 'clear presets'),
            ],
            [
                sg.Combo(
                    [str(x) for x in range(1, 15) if str(x) not in presets],
                    key='preset_combo',
                    font=cls.FONT_10,
                    size=(13, 1)),
                cls.generate_add_btn('presets', 'add', size=(5, 1)),
            ],
            [
                sg.Button('Save and Close', key='save'),
                sg.Button('Cancel', key='cancel'),
            ]
        ] 
开发者ID:mrmin123,项目名称:kcauto,代码行数:32,代码来源:config_combat_fleet_preset_popup.py

示例5: Launcher

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Combo [as 别名]
def Launcher():

    # def print(line):
    #     window.FindElement('output').Update(line)

    sg.ChangeLookAndFeel('Dark')

    namesonly = [f for f in os.listdir(ROOT_PATH) if f.endswith('.py') ]

    if len(namesonly) == 0:
        namesonly = ['test 1', 'test 2', 'test 3']

    sg.SetOptions(element_padding=(0,0), button_element_size=(12,1), auto_size_buttons=False)

    layout =  [[sg.Combo(values=namesonly, size=(35,30), key='demofile'),
                sg.Button('Run', button_color=('white', '#00168B')),
                sg.Button('Program 1'),
                sg.Button('Program 2'),
                sg.Button('Program 3', button_color=('white', '#35008B')),
                sg.Button('EXIT', button_color=('white','firebrick3'))],
                [sg.T('', text_color='white', size=(50,1), key='output')]]

    window = sg.Window('Floating Toolbar', no_titlebar=True, grab_anywhere=True, keep_on_top=True).Layout(layout)


    # ---===--- Loop taking in user input and executing appropriate program --- #
    while True:
        (event, values) = window.Read()
        if event == 'EXIT' or event is None:
            break           # exit button clicked
        if event == 'Program 1':
            print('Run your program 1 here!')
        elif event == 'Program 2':
            print('Run your program 2 here!')
        elif event == 'Run':
            file = values['demofile']
            print('Launching %s'%file)
            ExecuteCommandSubprocess('python', os.path.join(ROOT_PATH, file))
        else:
            print(event) 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:42,代码来源:Demo_Desktop_Floating_Toolbar.py

示例6: get_layout

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Combo [as 别名]
def get_layout(cls, fleet_id, expeditions, other_expeditions):
        return [
            [
                sg.Text(
                    f'Fleet {fleet_id} Expeditions',
                    font=cls.FONT_10),
            ],
            [
                sg.Listbox(
                    key='expeditions',
                    values=expeditions,
                    font=cls.FONT_10,
                    size=(34, 5),
                    enable_events=True)
            ],
            [
                cls.generate_remove_btn(
                    'expeditions', 'remove selected expedition', size=(20, 1)),
                cls.generate_clear_btn(
                    'expeditions', 'clear expeditions', size=(20, 1)),
            ],
            [
                sg.Combo(
                    [
                        x.display_name for x in ExpeditionEnum
                        if x.display_name
                        not in expeditions + other_expeditions],
                    key='expedition_combo',
                    font=cls.FONT_10,
                    size=(28, 1)),
                cls.generate_add_btn('expeditions', 'add', size=(5, 1)),
            ],
            [
                sg.Button('Save and Close', key='save'),
                sg.Button('Cancel', key='cancel'),
            ]
        ] 
开发者ID:mrmin123,项目名称:kcauto,代码行数:39,代码来源:config_expedition_popup.py

示例7: get_layout

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Combo [as 别名]
def get_layout(cls):
        return sg.Column(
            [
                [
                    sg.Text('JST Offset', **cls.LABEL_SETTINGS),
                    sg.Spin(
                        [x for x in range(MIN_JST_OFFSET, MAX_JST_OFFSET + 1)],
                        0,
                        key='general.jst_offset',
                        font=cls.FONT_10,
                        size=(3, 1),
                        enable_events=True)
                ],
                [
                    sg.Text('Interaction Mode', **cls.LABEL_SETTINGS),
                    sg.Combo(
                        [x.display_name for x in InteractionModeEnum],
                        key='general.interaction_mode',
                        font=cls.FONT_10,
                        size=(13, 1))
                ],
                [
                    sg.Text('Chrome Dev Port', **cls.LABEL_SETTINGS),
                    sg.Spin(
                        [x for x in range(MIN_PORT, MAX_PORT + 1)],
                        DEFAULT_CHROME_DEV_PORT,
                        key='general.chrome_dev_port',
                        font=cls.FONT_10,
                        size=(5, 1),
                        enable_events=True)
                ]
            ],
            key='config_general_col',
            visible=True) 
开发者ID:mrmin123,项目名称:kcauto,代码行数:36,代码来源:config_general.py

示例8: get_layout

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Combo [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) 
开发者ID:mrmin123,项目名称:kcauto,代码行数:37,代码来源:config_passive_repair.py

示例9: get_layout

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Combo [as 别名]
def get_layout(cls, node_formations):
        return [
            [
                sg.Text('Node Formations', font=cls.FONT_10),
            ],
            [
                sg.Listbox(
                    key='node_formations',
                    values=node_formations,
                    font=cls.FONT_10,
                    size=(32, 6),
                    enable_events=True),
            ],
            [
                cls.generate_remove_btn(
                    'node_formations', 'remove node formation'),
                cls.generate_clear_btn(
                    'node_formations', 'clear node formations'),
            ],
            [
                sg.Combo(
                    [
                        x.display_name for x in NodeEnum
                        if x.display_name
                        not in [y.split(':')[0] for y in node_formations]],
                    key='node_combo',
                    font=cls.FONT_10,
                    size=(4, 1)),
                sg.Text(' to ', font=cls.FONT_10),
                sg.Combo(
                    [x.display_name for x in FormationEnum],
                    key='formation_combo',
                    font=cls.FONT_10,
                    size=(15, 1)),
                cls.generate_add_btn('node_formations', 'add', size=(5, 1)),
            ],
            [
                sg.Button('Save and Close', key='save'),
                sg.Button('Cancel', key='cancel'),
            ]
        ] 
开发者ID:mrmin123,项目名称:kcauto,代码行数:43,代码来源:config_combat_node_formation_popup.py

示例10: get_layout

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Combo [as 别名]
def get_layout(cls, nodes):
        return [
            [
                sg.Text('Push Nodes', font=cls.FONT_10),
            ],
            [
                sg.Listbox(
                    key='nodes',
                    values=nodes,
                    font=cls.FONT_10,
                    size=(19, 6),
                    enable_events=True),
            ],
            [
                cls.generate_remove_btn('nodes', 'remove node'),
                cls.generate_clear_btn('nodes', 'clear nodes'),
            ],
            [
                sg.Combo(
                    [
                        x.display_name for x in NamedNodeEnum
                        if x.display_name not in nodes],
                    key='node_combo',
                    font=cls.FONT_10,
                    size=(13, 1)),
                cls.generate_add_btn('nodes', 'add', size=(5, 1)),
            ],
            [
                sg.Button('Save and Close', key='save'),
                sg.Button('Cancel', key='cancel'),
            ]
        ] 
开发者ID:mrmin123,项目名称:kcauto,代码行数:34,代码来源:config_combat_push_node_popup.py

示例11: get_layout

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Combo [as 别名]
def get_layout(cls, nodes):
        return [
            [
                sg.Text('Retreat Nodes', font=cls.FONT_10),
            ],
            [
                sg.Listbox(
                    key='nodes',
                    values=nodes,
                    font=cls.FONT_10,
                    size=(19, 6),
                    enable_events=True),
            ],
            [
                cls.generate_remove_btn('nodes', 'remove node'),
                cls.generate_clear_btn('nodes', 'clear nodes'),
            ],
            [
                sg.Combo(
                    [
                        x.display_name for x in NodeEnum
                        if x.display_name not in nodes],
                    key='node_combo',
                    font=cls.FONT_10,
                    size=(13, 1)),
                cls.generate_add_btn('nodes', 'add', size=(5, 1)),
            ],
            [
                sg.Button('Save and Close', key='save'),
                sg.Button('Cancel', key='cancel'),
            ]
        ] 
开发者ID:mrmin123,项目名称:kcauto,代码行数:34,代码来源:config_combat_retreat_node_popup.py

示例12: get_layout

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Combo [as 别名]
def get_layout(cls, node_nb):
        return [
            [
                sg.Text('Node Night Battles', font=cls.FONT_10),
            ],
            [
                sg.Listbox(
                    key='node_nb',
                    values=node_nb,
                    font=cls.FONT_10,
                    size=(28, 6),
                    enable_events=True),
            ],
            [
                cls.generate_remove_btn('node_nb', 'remove node night battle'),
                cls.generate_clear_btn('node_nb', 'clear node night battles'),
            ],
            [
                sg.Combo(
                    [
                        x.display_name for x in NamedNodeEnum
                        if x.display_name
                        not in [y.split(':')[0] for y in node_nb]],
                    key='node_combo',
                    font=cls.FONT_10,
                    size=(4, 1)),
                sg.Text(' to ', font=cls.FONT_10),
                sg.Combo(
                    [True, False],
                    key='nb_combo',
                    font=cls.FONT_10,
                    size=(5, 1)),
                cls.generate_add_btn('node_nb', 'add', size=(5, 1)),
            ],
            [
                sg.Button('Save and Close', key='save'),
                sg.Button('Cancel', key='cancel'),
            ]
        ] 
开发者ID:mrmin123,项目名称:kcauto,代码行数:41,代码来源:config_combat_node_nb_popup.py

示例13: main

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Combo [as 别名]
def main():

    MLINE_KEY = '-ML-'+sg.WRITE_ONLY_KEY        # multiline element's key. Indicate it's an output only element
    MLINE_KEY2 = '-ML2-'+sg.WRITE_ONLY_KEY        # multiline element's key. Indicate it's an output only element
    MLINE_KEY3 = '-ML3-'+sg.WRITE_ONLY_KEY        # multiline element's key. Indicate it's an output only element

    output_key = MLINE_KEY


    layout = [  [sg.Text('Multiline Color Print Demo', font='Any 18')],
                [sg.Multiline('Multiline\n', size=(80,20), key=MLINE_KEY)],
                [sg.Multiline('Multiline2\n', size=(80,20), key=MLINE_KEY2)],
                [sg.Text('Text color:'), sg.Combo(list(color_map.keys()), size=(12,20), key='-TEXT COLOR-'),
                 sg.Text('on Background color:'), sg.Combo(list(color_map.keys()), size=(12,20), key='-BG COLOR-')],
                [sg.Input('Type text to output here', size=(80,1), key='-IN-')],
                [sg.Button('Print', bind_return_key=True), sg.Button('Print short'),
                 sg.Button('Force 1'), sg.Button('Force 2'),
                 sg.Button('Use Input for colors'), sg.Button('Toggle Output Location'), sg.Button('Exit')]  ]

    window = sg.Window('Window Title', layout)

    sg.cprint_set_output_destination(window, output_key)

    while True:             # Event Loop
        event, values = window.read()
        if event == sg.WIN_CLOSED or event == 'Exit':
            break
        if event == 'Print':
            sg.cprint(values['-IN-'], text_color=values['-TEXT COLOR-'], background_color=values['-BG COLOR-'])
        elif event == 'Print short':
            sg.cprint(values['-IN-'], c=(values['-TEXT COLOR-'], values['-BG COLOR-']))
        elif event.startswith('Use Input'):
            sg.cprint(values['-IN-'], colors=values['-IN-'])
        elif event.startswith('Toggle'):
            output_key = MLINE_KEY if output_key == MLINE_KEY2 else MLINE_KEY2
            sg.cprint_set_output_destination(window, output_key)
            sg.cprint('Switched to this output element', c='white on red')
        elif event == 'Force 1':
            sg.cprint(values['-IN-'], c=(values['-TEXT COLOR-'], values['-BG COLOR-']), key=MLINE_KEY)
        elif event == 'Force 2':
            sg.cprint(values['-IN-'], c=(values['-TEXT COLOR-'], values['-BG COLOR-']), key=MLINE_KEY2)

    window.close() 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:45,代码来源:Demo_Multiline_cprint_Printing.py

示例14: DownloadSubtitlesGUI

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Combo [as 别名]
def DownloadSubtitlesGUI():
    sg.theme('Dark')

    combobox = sg.Combo(values=['', ], size=(10, 1), key='lang')
    layout = [
        [sg.Text('Subtitle Grabber', size=(40, 1), font=('Any 15'))],
        [sg.Text('YouTube Link'), sg.Input(default_text='', size=(60, 1), key='link')],
        [sg.Output(size=(90, 20), font='Courier 12')],
        [sg.Button('Get List')],
        [sg.Text('Language Code'), combobox, sg.Button('Download')],
        [sg.Button('Exit', button_color=('white', 'firebrick3'))]
    ]

    window = sg.Window('Subtitle Grabber launcher', layout,
                       text_justification='r',
                       default_element_size=(15, 1),
                       font=('Any 14'))

    # ---===--- Loop taking in user input and using it to query HowDoI --- #
    while True:
        event, values = window.read()
        if event in ('Exit', None):
            break           # exit button clicked
        link = values['link']
        if event == 'Get List':
            print('Getting list of subtitles....')
            window.refresh()
            command = [youtube_executable + f' --list-subs {link}']
            output = ExecuteCommandSubprocess(command, wait=True, quiet=True)
            lang_list = [o[:5].rstrip()
                         for o in output.split('\n') if 'vtt' in o]
            lang_list = sorted(lang_list)
            combobox.update(values=lang_list)
            print('Done')

        elif event == 'Download':
            lang = values['lang'] or 'en'
            print(f'Downloading subtitle for {lang}...')
            window.refresh()
            command = [youtube_executable + f' --sub-lang {lang} --write-sub {link}', ]
            print(ExecuteCommandSubprocess(command, wait=True, quiet=False))
            print('Done')
    window.close() 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:45,代码来源:Demo_Youtube-dl_Frontend.py

示例15: Launcher

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Combo [as 别名]
def Launcher():

    sg.theme('Dark')

    namesonly = [f for f in os.listdir(ROOT_PATH) if f.endswith('.py')]

    if len(namesonly) == 0:
        namesonly = ['test 1', 'test 2', 'test 3']

    sg.set_options(element_padding=(0, 0),
        button_element_size=(12, 1), auto_size_buttons=False)

    layout = [[sg.Combo(values=namesonly, size=(35, 30), key='demofile'),
               sg.Button('Run', button_color=('white', '#00168B')),
               sg.Button('Program 1'),
               sg.Button('Program 2'),
               sg.Button('Program 3', button_color=('white', '#35008B')),
               sg.Button('EXIT', button_color=('white', 'firebrick3'))],
              [sg.Text('', text_color='white', size=(50, 1), key='output')]]

    window = sg.Window('Floating Toolbar',
                       layout,
                       no_titlebar=True,
                       grab_anywhere=True,
                       keep_on_top=True)

    # ---===--- Loop taking in user input and executing appropriate program --- #
    while True:
        event, values = window.read()
        if event == 'EXIT' or event == sg.WIN_CLOSED:
            break           # exit button clicked
        if event == 'Program 1':
            print('Run your program 1 here!')
        elif event == 'Program 2':
            print('Run your program 2 here!')
        elif event == 'Run':
            file = values['demofile']
            print('Launching %s' % file)
            ExecuteCommandSubprocess('python', os.path.join(ROOT_PATH, file))
        else:
            print(event)

    window.close() 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:45,代码来源:Demo_Desktop_Floating_Toolbar.py


注:本文中的PySimpleGUI.Combo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。