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


Python PySimpleGUI.Cancel方法代码示例

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


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

示例1: custom_meter_example

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Cancel [as 别名]
def custom_meter_example():
    # layout the form
    layout = [[sg.Text('A typical custom progress meter')],
              [sg.ProgressBar(1, orientation='h', size=(20,20), key='progress')],
              [sg.Cancel()]]

    # create the form`
    window = sg.Window('Custom Progress Meter').Layout(layout)
    progress_bar = window.FindElement('progress')
    # loop that would normally do something useful
    for i in range(10000):
        # check to see if the cancel button was clicked and exit loop if clicked
        event, values = window.Read(timeout=0)
        if event == 'Cancel' or event == None:
            break
        # update bar with loop value +1 so that bar eventually reaches the maximum
        progress_bar.UpdateBar(i+1, 10000)
    # done with loop... need to destroy the window as it's still open
    window.Close() 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:21,代码来源:Demo_Progress_Meters.py

示例2: CustomMeter

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Cancel [as 别名]
def CustomMeter():
    # layout the form
    layout = [[sg.Text('A custom progress meter')],
              [sg.ProgressBar(1000, orientation='h', size=(20,20), key='progress')],
              [sg.Cancel()]]

    # create the form`
    window = sg.Window('Custom Progress Meter').Layout(layout)
    progress_bar = window.FindElement('progress')
    # loop that would normally do something useful
    for i in range(1000):
        # check to see if the cancel button was clicked and exit loop if clicked
        event, values = window.Read(timeout=0, timeout_key='timeout')
        if event == 'Cancel' or event == None:
            break
        # update bar with loop value +1 so that bar eventually reaches the maximum
        progress_bar.UpdateBar(i+1)
    # done with loop... need to destroy the window as it's still open
    window.CloseNonBlocking() 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:21,代码来源:Demo_Machine_Learning.py

示例3: custom_meter_example

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Cancel [as 别名]
def custom_meter_example():
    # layout the form
    layout = [[sg.Text('A typical custom progress meter')],
              [sg.ProgressBar(1, orientation='h', size=(20, 20), key='progress')],
              [sg.Cancel()]]

    # create the form`
    window = sg.Window('Custom Progress Meter', layout)
    progress_bar = window['progress']
    # loop that would normally do something useful
    for i in range(10000):
        # check to see if the cancel button was clicked and exit loop if clicked
        event, values = window.read(timeout=0)
        if event == 'Cancel' or event == None:
            break
        # update bar with loop value +1 so that bar eventually reaches the maximum
        progress_bar.update_bar(i+1, 10000)
    # done with loop... need to destroy the window as it's still open
    window.close() 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:21,代码来源:Demo_Progress_Meters.py

示例4: PlayerChooseSongGUI

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

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Cancel [as 别名]
def sg_show_hex_buffer(buf):
    import PySimpleGUI as sg
    layout = [ [sg.OK(), sg.Cancel()],
               [sg.Multiline(buf.dump(),
                             enter_submits=True,
                             disabled=True, 
                             size=(80, 25))]
             ]
    sg.Window(str(buf), layout, font=('monospace', 12)).Read() 
开发者ID:pynvme,项目名称:pynvme,代码行数:11,代码来源:test_utilities.py

示例6: PopupDropDown

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Cancel [as 别名]
def PopupDropDown(title, text, values):
    window = sg.Window(title).Layout([[sg.Text(text)],
                                      [sg.DropDown(values, key='_DROP_')],
                                      [sg.OK(), sg.Cancel()]])
    event, values = window.Read()
    return None if event != 'OK' else values['_DROP_']


# -----------------------  Calling your PopupDropDown function ----------------------- 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:11,代码来源:Demo_Popup_Custom.py

示例7: MachineLearningGUI

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

示例8: GetFilesToCompare

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

示例9: layout3

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Cancel [as 别名]
def layout3():
    # in terms of formatting, the layout to the RIGHT of the = sign looks like a 2-line GUI (ignore the layout +=
    layout =  [[sg.Button(i) for i in range(4)]]
    layout += [[sg.OK()]]               # this row is better than, but is the same as
    layout.append([sg.Cancel()])        # .. this row in that they both add a new ROW with a button on it

    window = sg.Window('Generated Layouts', layout)

    event, values = window.Read()

    print(event, values)
    window.Close() 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:14,代码来源:Demo_Layout_Generation.py

示例10: PopupDropDown

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Cancel [as 别名]
def PopupDropDown(title, text, values):
    window = sg.Window(title,
        [[sg.Text(text)],
        [sg.DropDown(values, key='-DROP-')],
        [sg.OK(), sg.Cancel()]
    ])
    event, values = window.read()
    return None if event != 'OK' else values['-DROP-']

# -----------------------  Calling your PopupDropDown function ----------------------- 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:12,代码来源:Demo_Popup_Custom.py

示例11: GetFilesToCompare

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

示例12: layout3

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Cancel [as 别名]
def layout3():
    # in terms of formatting, the layout to the RIGHT of the = sign looks like a 2-line GUI (ignore the layout +=
    layout = [[sg.Button(i) for i in range(4)]]
    # this row is better than, but is the same as
    layout += [[sg.OK()]]
    # .. this row in that they both add a new ROW with a button on it
    layout.append([sg.Cancel()])

    window = sg.Window('Generated Layouts', layout)

    event, values = window.read()

    print(event, values)
    window.close() 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:16,代码来源:Demo_Layout_Generation.py

示例13: main

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

    layout = [[sg.T('Enter width, height of graph')],
              [sg.In(size=(6, 1)), sg.In(size=(6, 1))],
              [sg.Ok(), sg.Cancel()]]

    window = sg.Window('Enter graph size').Layout(layout)
    b,v = window.Read()
    if b is None or b == 'Cancel':
        sys.exit(69)
    w, h = int(v[0]), int(v[1])
    CANVAS_SIZE = (w,h)

    # start ping measurement thread

    sg.ChangeLookAndFeel('Black')
    sg.SetOptions(element_padding=(0,0))

    layout = [  [sg.Button('Quit', button_color=('white','black'))],
               [sg.Graph(CANVAS_SIZE, (0,0), (SAMPLES,SAMPLE_MAX),background_color='black', key='graph')],]

    window = sg.Window('Canvas test', grab_anywhere=True, background_color='black', no_titlebar=False, use_default_focus=False).Layout(layout).Finalize()
    graph = window.FindElement('graph')

    prev_response_time = None
    i=0
    prev_x, prev_y = 0, 0
    graph_value = 250
    while True:
        # time.sleep(.2)
        event, values = window.Read(timeout=0)
        if event == 'Quit' or event is None:
            break
        graph_offset = random.randint(-10, 10)
        graph_value = graph_value + graph_offset
        if graph_value > SAMPLE_MAX:
            graph_value = SAMPLE_MAX
        if graph_value < 0:
            graph_value = 0
        new_x, new_y = i, graph_value
        prev_value = graph_value
        if i >= SAMPLES:
            graph.Move(-STEP_SIZE,0)
            prev_x = prev_x - STEP_SIZE
        graph.DrawLine((prev_x, prev_y), (new_x, new_y), color='white')
        # window.FindElement('graph').DrawPoint((new_x, new_y), color='red')
        prev_x, prev_y = new_x, new_y
        i += STEP_SIZE if i < SAMPLES else 0 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:51,代码来源:Demo_Graph_Noise.py

示例14: MachineLearningGUI

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Cancel [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.Cancel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。