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


Python PySimpleGUI.Spin方法代码示例

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


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

示例1: MachineLearningGUI

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

示例2: get_layout

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Spin [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

示例3: get_layout

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Spin [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

示例4: HowDoI

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

示例5: Everything

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Spin [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

示例6: main

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Spin [as 别名]
def main():
    global g_interval,  g_procs, g_exit

    # ----------------  Create Form  ----------------
    sg.ChangeLookAndFeel('Black')
    layout = [[sg.Text('', size=(8,1), font=('Helvetica', 20),text_color=sg.YELLOWS[0],
                       justification='center', key='text')],
                 [sg.Text('', size=(30, 8), font=('Courier New', 12),text_color='white', justification='left', key='processes')],
                 [sg.Exit(button_color=('white', 'firebrick4'), pad=((15,0), 0), size=(9,1)),
                  sg.Spin([x+1 for x in range(10)], 3, key='spin')],]

    window = sg.Window('CPU Utilization',
                       no_titlebar=True,
                       keep_on_top=True,
                       alpha_channel=.8,
                       grab_anywhere=True).Layout(layout)

    # start cpu measurement thread
    thread = Thread(target=CPU_thread,args=(None,))
    thread.start()
    timeout_value = 1             # make first read really quick
    g_interval = 1
    # ----------------  main loop  ----------------
    while (True):
        # --------- Read and update window --------
        event, values = window.Read(timeout=timeout_value, timeout_key='Timeout')
        # --------- Do Button Operations --------
        if event is None or event == 'Exit':
            break

        timeout_value = int(values['spin']) * 1000

        cpu_percent = g_cpu_percent
        display_string = ''
        if g_procs:
            # --------- Create list of top % CPU porocesses --------
            try:
                top = {proc.name() : proc.cpu_percent() for proc in g_procs}
            except: pass


            top_sorted = sorted(top.items(), key=operator.itemgetter(1), reverse=True)
            if top_sorted:
                top_sorted.pop(0)
            display_string = ''
            for proc, cpu in top_sorted:
                display_string += '{:2.2f} {}\n'.format(cpu/10, proc)

        # --------- Display timer and proceses in window --------
        window.FindElement('text').Update('CPU {}'.format(cpu_percent))
        window.FindElement('processes').Update(display_string)

    g_exit = True
    thread.join() 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:56,代码来源:Demo_Desktop_Widget_CPU_Utilization.py

示例7: main

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Spin [as 别名]
def main():
    global g_interval,  g_procs, g_exit

    # ----------------  Create Form  ----------------
    sg.theme('Black')
    layout = [
        [sg.Text('', size=(8, 1), font=('Helvetica', 20),
              text_color=sg.YELLOWS[0], justification='center', key='text')],
        [sg.Text('', size=(30, 8), font=('Courier New', 12),
              text_color='white', justification='left', key='processes')],
        [sg.Text('Update every '),
         sg.Spin([x+1 for x in range(10)], 3, key='spin'), sg.T('seconds       '),
         sg.Text('❎', enable_events=True, key='Exit')
         ]
    ]

    window = sg.Window('Top CPU Processes', layout,
                       no_titlebar=True, keep_on_top=True, use_default_focus=False, alpha_channel=.8, grab_anywhere=True)

    # start cpu measurement thread
    thread = Thread(target=CPU_thread, args=(None,))
    thread.start()
    timeout_value = 1             # make first read really quick
    g_interval = 1
    # ----------------  main loop  ----------------
    while True:
        # --------- Read and update window --------
        event, values = window.read(timeout_value)
        # --------- Do Button Operations --------
        if event in (sg.WIN_CLOSED, 'Exit'):
            break

        timeout_value = int(values['spin']) * 1000      # for now on, use spinner for timeout

        cpu_percent = g_cpu_percent
        display_string = ''
        if g_procs:
            # --------- Create list of top % CPU porocesses --------
            try:
                top = {proc.name(): proc.cpu_percent() for proc in g_procs}
            except:
                pass

            top_sorted = sorted(
                top.items(), key=operator.itemgetter(1), reverse=True)
            if top_sorted:
                top_sorted.pop(0)
            display_string = ''
            for proc, cpu in top_sorted:
                display_string += '{:2.2f} {}\n'.format(cpu/10, proc)

        # --------- Display timer and proceses in window --------
        window['text'].update('CPU ' + str(cpu_percent))
        window['processes'].update(display_string)

    g_exit = True
    thread.join()

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

示例8: get_layout

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


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