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


Python PySimpleGUI.Submit方法代码示例

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


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

示例1: main

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Submit [as 别名]
def main():
    button, values = GetFilesToCompare()
    f1 = values['file1']
    f2 = values['file2']

    if any((button != 'Submit', f1 =='', f2 == '')):
        sg.PopupError('Operation cancelled')
        sys.exit(69)

    # --- This portion of the code is not GUI related ---
    with open(f1, 'rb') as file1:
        with open(f2, 'rb') as file2:
            a = file1.read()
            b = file2.read()

        for i, x in enumerate(a):
            if x != b[i]:
                sg.Popup('Compare results for files', f1, f2, '**** Mismatch at offset {} ****'.format(i))
                break
        else:
            if len(a) == len(b):
                sg.Popup('**** The files are IDENTICAL ****') 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:24,代码来源:Demo_Compare_Files.py

示例2: main

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

    button, values = GetFilesToCompare()
    f1, f2 = values['-file1-'], values['-file2-']

    if any((button != 'Submit', f1 == '', f2 == '')):
        sg.popup_error('Operation cancelled')
        return

    # --- This portion of the code is not GUI related ---
    with open(f1, 'rb') as file1:
        with open(f2, 'rb') as file2:
            a = file1.read()
            b = file2.read()

        for i, x in enumerate(a):
            if x != b[i]:
                sg.popup('Compare results for files', f1, f2,
                         '**** Mismatch at offset {} ****'.format(i))
                break
        else:
            if len(a) == len(b):
                sg.popup('**** The files are IDENTICAL ****') 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:25,代码来源:Demo_Compare_Files.py

示例3: MachineLearningGUI

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

示例4: GetFilesToCompare

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

示例5: GetFilesToCompare

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

示例6: main

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

示例7: MachineLearningGUI

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Submit [as 别名]
def MachineLearningGUI():
    sg.set_options(text_justification='right')

    flags = [[sg.CB('Normalize', size=(12, 1), default=True), sg.CB('Verbose', size=(20, 1))],
             [sg.CB('Cluster', size=(12, 1)), sg.CB(
                 'Flush Output', size=(20, 1), default=True)],
             [sg.CB('Write Results', size=(12, 1)), sg.CB(
                 'Keep Intermediate Data', size=(20, 1))],
             [sg.CB('Normalize', size=(12, 1), default=True),
              sg.CB('Verbose', size=(20, 1))],
             [sg.CB('Cluster', size=(12, 1)), sg.CB(
                 'Flush Output', size=(20, 1), default=True)],
             [sg.CB('Write Results', size=(12, 1)), sg.CB('Keep Intermediate Data', size=(20, 1))], ]

    loss_functions = [[sg.Rad('Cross-Entropy', 'loss', size=(12, 1)), sg.Rad('Logistic', 'loss', default=True, size=(12, 1))],
                      [sg.Rad('Hinge', 'loss', size=(12, 1)),
                       sg.Rad('Huber', 'loss', size=(12, 1))],
                      [sg.Rad('Kullerback', 'loss', size=(12, 1)),
                       sg.Rad('MAE(L1)', 'loss', size=(12, 1))],
                      [sg.Rad('MSE(L2)', 'loss', size=(12, 1)), sg.Rad('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.Input(default_text='6', size=(8, 1)), sg.Text('nn', size=(8, 1)),
                           sg.Input(default_text='10', size=(10, 1))],
                          [sg.Text('q', size=(8, 1)), sg.Input(default_text='ff', size=(8, 1)), sg.Text('ngram', size=(8, 1)),
                           sg.Input(default_text='5', size=(10, 1))],
                          [sg.Text('l', size=(8, 1)), sg.Input(default_text='0.4', size=(8, 1)), sg.Text('Layers', size=(8, 1)),
                           sg.Drop(values=('BatchNorm', 'other'))], ]

    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()]]

    sg.set_options(text_justification='left')

    window = sg.Window('Machine Learning Front End',
                       layout, font=("Helvetica", 12))
    button, values = window.read()
    window.close()
    print(button, values) 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:45,代码来源:Demo_Machine_Learning.py


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