當前位置: 首頁>>代碼示例>>Python>>正文


Python PySimpleGUI.Listbox方法代碼示例

本文整理匯總了Python中PySimpleGUI.Listbox方法的典型用法代碼示例。如果您正苦於以下問題:Python PySimpleGUI.Listbox方法的具體用法?Python PySimpleGUI.Listbox怎麽用?Python PySimpleGUI.Listbox使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PySimpleGUI的用法示例。


在下文中一共展示了PySimpleGUI.Listbox方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: PlayerChooseSongGUI

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Listbox [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() 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:19,代碼來源:Demo_MIDI_Player.py

示例2: test_get_dell_smart_attributes

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Listbox [as 別名]
def test_get_dell_smart_attributes(nvme0):
    import PySimpleGUI as sg
    
    smart = d.Buffer()
    nvme0.getlogpage(0xCA, smart, 512).waitdone()

    l = []
    l.append('Byte |  Value  | Attribute')
    l.append('   0 |  %5d  | Re-Assigned Sector Count' % smart.data(0))
    l.append('   1 |  %5d  | Program Fail Count (Worst Case Component)' % smart.data(1))
    l.append('   2 |  %5d  | Program Fail Count (SSD Total)' % smart.data(2))
    l.append('   3 |  %5d  | Erase Fail Count (Worst Case Component)' % smart.data(3))
    l.append('   4 |  %5d  | Erase Fail Count (SSD Total)' % smart.data(4))
    l.append('   5 |  %5d  | Wear Leveling Count' % smart.data(5))
    l.append('   6 |  %5d  | Used Reserved Block Count (Worst Case Component)' % smart.data(6))
    l.append('   7 |  %5d  | Used Reserved Block Count (SSD Total)' % smart.data(7))
    l.append('11:8 |  %5d  | Reserved Block Count (SSD Total)' % smart.data(11, 8))

    layout = [[sg.Listbox(l, size=(70, 10))]]
    sg.Window("Dell SMART Attributes",
              layout+[[sg.OK()]],
              font=('monospace', 16)).Read() 
開發者ID:pynvme,項目名稱:pynvme,代碼行數:24,代碼來源:test_utilities.py

示例3: autocomplete_popup_show

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Listbox [as 別名]
def autocomplete_popup_show(text_list ):
    autocomplete_popup_layout = [[sg.Listbox(values=text_list,
                                             size=(100,20*len(text_list)) if QT else (15, len(text_list)),
                                             change_submits=True,
                                             bind_return_key=True,
                                             auto_size_text=True,
                                             key='_FLOATING_LISTBOX_', enable_events=True)]]

    autocomplete_popup = sg.Window("Borderless Window",
                                   default_element_size=(12, 1),
                                   auto_size_text=False,
                                   auto_size_buttons=False,
                                   no_titlebar=True,
                                   grab_anywhere=True,
                                   return_keyboard_events=True,
                                   keep_on_top=True,
                                   background_color='black',
                                   location=(1320,622),
                                   default_button_element_size=(12, 1))

    window = autocomplete_popup.Layout(autocomplete_popup_layout).Finalize()
    return window 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:24,代碼來源:Demo_Input_Auto_Complete.py

示例4: PlayerChooseSongGUI

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Listbox [as 別名]
def PlayerChooseSongGUI(self):

        # ---------------------- DEFINION OF CHOOSE WHAT TO PLAY GUI ----------------------------

        helv = ("Helvetica", 15)
        layout = [[sg.Text('MIDI File Player', font=helv15, size=(20, 1), text_color='green')],
                  [sg.Text('File Selection', font=helv15, 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), default_values=(self.PortList[0],), key='device')],
                  [sg.Text('_' * 250, auto_size_text=False, size=(100, 1))],
                  [sg.SimpleButton('PLAY', size=(12, 2), button_color=('red', 'white'), font=helv15, bind_return_key=True),
                      sg.Text(' ' * 2, size=(4, 1)),
                      sg.Cancel(size=(8, 2), font=helv15)]]

        window = sg.Window('MIDI File Player', layout, auto_size_text=False, default_element_size=(30, 1), font=helv)
        self.Window = window
        return window.read() 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:26,代碼來源:Demo_MIDI_Player.py

示例5: Launcher2

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Listbox [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) 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:36,代碼來源:Demo_Script_Launcher.py

示例6: autocomplete_popup_show

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Listbox [as 別名]
def autocomplete_popup_show(text_list):
    layout = [[ sg.Listbox(values=text_list,
                            size=(15, len(text_list)),
                            change_submits=True, bind_return_key=True,
                            key='-FLOATING-LISTBOX-', enable_events=True) ]]
    return sg.Window("Borderless Window",
                                   layout,
                                   default_element_size=(12, 1),
                                   auto_size_text=False, keep_on_top=True,
                                   no_titlebar=True, grab_anywhere=True,
                                   return_keyboard_events=True,
                                   auto_size_buttons=False,
                                   background_color='black',
                                   default_button_element_size=(12, 1),
                                   location=(1320, 622), finalize=True) 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:17,代碼來源:Demo_Input_Auto_Complete.py

示例7: Launcher2

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Listbox [as 別名]
def Launcher2():
    sg.theme('GreenTan')

    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.CBox('Wait for program to complete', default=False, key='wait')],
        [sg.Button('Run'), sg.Button('Shortcut 1'), sg.Button('Fav Program'), sg.Button('EXIT')],
    ]

    window = sg.Window('Script launcher', 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)

    window.close() 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:42,代碼來源:Demo_Script_Launcher.py

示例8: get_layout

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Listbox [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) 
開發者ID:mrmin123,項目名稱:kcauto,代碼行數:28,代碼來源:config_scheduler.py

示例9: get_layout

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Listbox [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

示例10: get_layout

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Listbox [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

示例11: get_layout

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Listbox [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

示例12: get_layout

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Listbox [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

示例13: get_layout

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Listbox [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

示例14: get_layout

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Listbox [as 別名]
def get_layout(cls, node_selects):
        return [
            [
                sg.Text('Node Selects', font=cls.FONT_10),
            ],
            [
                sg.Listbox(
                    key='node_selects',
                    values=node_selects,
                    font=cls.FONT_10,
                    size=(21, 6),
                    enable_events=True),
            ],
            [
                cls.generate_remove_btn(
                    'node_selects', 'remove node select'),
                cls.generate_clear_btn('node_selects', 'clear node selects'),
            ],
            [
                sg.Combo(
                    [
                        x.display_name for x in NamedNodeEnum
                        if x.display_name not in [y[0] for y in node_selects]],
                    key='node_1_combo',
                    font=cls.FONT_10,
                    size=(4, 1)),
                sg.Text(' to ', font=cls.FONT_10),
                sg.Combo(
                    [x.display_name for x in NamedNodeEnum],
                    key='node_2_combo',
                    font=cls.FONT_10,
                    size=(4, 1)),
                cls.generate_add_btn('node_selects', 'add', size=(5, 1)),
            ],
            [
                sg.Button('Save and Close', key='save'),
                sg.Button('Cancel', key='cancel'),
            ]
        ] 
開發者ID:mrmin123,項目名稱:kcauto,代碼行數:41,代碼來源:config_combat_node_select_popup.py

示例15: Everything

# 需要導入模塊: import PySimpleGUI [as 別名]
# 或者: from PySimpleGUI import Listbox [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() 
開發者ID:PySimpleGUI,項目名稱:PySimpleGUI,代碼行數:56,代碼來源:Demo_Fill_Form.py


注:本文中的PySimpleGUI.Listbox方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。