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


Python PySimpleGUI.Popup方法代码示例

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


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

示例1: update_text_box

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Popup [as 别名]
def update_text_box(self, window, msg, is_hide):
        """ Update text elements """
        best_move = None
        msg_str = str(msg)

        if not 'bestmove ' in msg_str:
            if 'info_all' in msg_str:
                info_all = ' '.join(msg_str.split()[0:-1]).strip()
                msg_line = '{}\n'.format(info_all)
                window.FindElement('search_info_all_k').Update(
                        '' if is_hide else msg_line)
        else:
            # Best move can be None because engine dies
            try:
                best_move = chess.Move.from_uci(msg.split()[1])
            except Exception:
                logging.exception('Engine sent {}.'.format(best_move))
                sg.Popup('Engine error, it sent a {} bestmove.\n'.format(
                    best_move) + 'Back to Neutral mode, it is better to '
                                 'change engine {}.'.format(
                    self.opp_id_name), icon=ico_path[platform]['pecg'],
                    title=BOX_TITLE)

        return best_move 
开发者ID:fsmosca,项目名称:Python-Easy-Chess-GUI,代码行数:26,代码来源:python_easy_chess_gui.py

示例2: binary_search

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Popup [as 别名]
def binary_search():
    l = sorted_names[:]                                 
    lo = 0
    hi = len(l)-1
    found = False           
    while lo <= hi:
        mid = (lo + hi) //2     
        if l[mid] == value['_binary_']:    
            sg.Popup('Binary search\n' + l[mid] + ' found.')
            found = True            
            break                   
        elif l[mid] < value['_binary_']:
            lo = mid + 1            
        else:
            hi = mid - 1            
    if not found:           
        sg.Popup('Binary search\n' +(value['_binary_'] + ' was not found')) 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:19,代码来源:6c PSG (search text preloaded).py

示例3: main

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

示例4: linear_search

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Popup [as 别名]
def linear_search():
    l = names[:]
    found = False
    for l in l:
        if l == value['_linear_']:            
            found = True
            sg.Popup('Linear search\n' + l + ' found.')
            break
    if not found:
        sg.Popup('Linear search\n' +(value['_linear_'] + ' was not found'))

#Binary Search - only works for ordered lists 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:14,代码来源:6c PSG (search text preloaded).py

示例5: pong

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Popup [as 别名]
def pong():
    layout = [[sg.Graph(GAMEPLAY_SIZE, (0,GAMEPLAY_SIZE[1]), (GAMEPLAY_SIZE[0],0), background_color=BACKGROUND_COLOR, key='_GRAPH_')],
              [sg.T(''), sg.Button('Exit'), sg.T('Speed'), sg.Slider((0,20),default_value=10, orientation='h', enable_events=True, key='_SPEED_')]]

    window = sg.Window('Pong', layout, return_keyboard_events=True).Finalize()

    graph_elem = window.FindElement('_GRAPH_')                  # type: sg.Graph

    bat_1 = PongBat(graph_elem, 'red', 30)
    bat_2 = PongBat(graph_elem, 'blue', 670)

    ball_1 = Ball(graph_elem, bat_1, bat_2, 'green1')
    sleep_time = 10

    while True:
        ball_1.draw()
        bat_1.draw()
        bat_2.draw()

        event, values = window.Read(timeout=sleep_time)         # type: str, str
        if event is None or event == 'Exit':
            break
        elif event.startswith('Up') or event.endswith('Up'):
            bat_2.up(5)
        elif event.startswith('Down') or event.endswith('Down'):
            bat_2.down(5)
        elif event == 'w':
            bat_1.up(5)
        elif event == 's':
            bat_1.down(5)
        elif event == '_SPEED_':
            sleep_time = int(values['_SPEED_'])

        if ball_1.win_loss_check():
            sg.Popup('Game Over', ball_1.win_loss_check() + ' won!!')
            break
    window.Close() 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:39,代码来源:Demo_Pong_Multiple_Platforms.py

示例6: FindDuplicatesFilesInFolder

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Popup [as 别名]
def FindDuplicatesFilesInFolder(path):
    shatab = []
    total = 0
    small_count, dup_count, error_count = 0,0,0
    pngdir = path
    if not os.path.exists(path):
        sg.Popup('Duplicate Finder', '** Folder doesn\'t exist***', path)
        return
    pngfiles = os.listdir(pngdir)
    total_files = len(pngfiles)
    for idx, f in enumerate(pngfiles):
        if not sg.OneLineProgressMeter('Counting Duplicates', idx + 1, total_files, 'Counting Duplicate Files'):
            break
        total += 1
        fname = os.path.join(pngdir, f)
        if os.path.isdir(fname):
            continue
        x = open(fname, "rb").read()

        m = hashlib.sha256()
        m.update(x)
        f_sha = m.digest()
        if f_sha in shatab:
            # uncomment next line to remove duplicate files
            # os.remove(fname)
            dup_count += 1
            # sg.Print(f'Duplicate file - {f}')    # cannot current use sg.Print with Progress Meter
            continue
        shatab.append(f_sha)

    msg = '{} Files processed\n {} Duplicates found'.format(total_files, dup_count)
    sg.Popup('Duplicate Finder Ended', msg)

# ====____====____==== Pseudo-MAIN program ====____====____==== #
# This is our main-alike piece of code                          #
#   + Starts up the GUI                                         #
#   + Gets values from GUI                                      #
#   + Runs DeDupe_folder based on GUI inputs                    #
# ------------------------------------------------------------- # 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:41,代码来源:Demo_DuplicateFileFinder.py

示例7: main

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Popup [as 别名]
def main():
    # folder = r'C:\Python\PycharmProjects\GooeyGUI\Uno Cards'
    folder=''
    folder = sg.PopupGetFolder('Source folder for images\nImages will be encoded and results saved to %s'%OUTPUT_FILENAME,
                               title='Base64 Encoder',
                               default_path=folder, initial_folder=folder )

    if folder is None or folder == '':
        sg.PopupCancel('Cancelled - No valid folder entered')
        return
    try:
        namesonly = [f for f in os.listdir(folder) if f.endswith('.png') or f.endswith('.ico') or f.endswith('.gif')]
    except:
        sg.PopupCancel('Cancelled - No valid folder entered')
        return

    outfile = open(os.path.join(folder, OUTPUT_FILENAME), 'w')

    for i, file in enumerate(namesonly):
        contents = open(os.path.join(folder, file), 'rb').read()
        encoded = base64.b64encode(contents)
        outfile.write('\n{} = {}\n\n'.format(file[:file.index(".")], encoded))
        sg.OneLineProgressMeter('Base64 Encoding', i+1, len(namesonly),key='_METER_')

    outfile.close()
    sg.Popup('Completed!', 'Encoded %s files'%(i+1)) 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:28,代码来源:Demo_Base64_Image_Encoder.py

示例8: callback_function1

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Popup [as 别名]
def callback_function1():
    sg.Popup('In Callback Function 1')
    print('In the callback function 1') 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:5,代码来源:Demo_Button_Func_Calls.py

示例9: callback_function2

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Popup [as 别名]
def callback_function2():
    sg.Popup('In Callback Function 2')
    print('In the callback function 2') 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:5,代码来源:Demo_Button_Func_Calls.py

示例10: main

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Popup [as 别名]
def main():
    RemoteControlExample_NoGraphics()
    # Uncomment to get the fancy graphics version.  Be sure and download the button images!
    RemoteControlExample()
    # sg.Popup('End of non-blocking demonstration') 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:7,代码来源:Demo_Pi_Robotics.py

示例11: the_gui

# 需要导入模块: import PySimpleGUI [as 别名]
# 或者: from PySimpleGUI import Popup [as 别名]
def the_gui():
    gui_queue = queue.Queue()  # queue used to communicate between the gui and long-running code

    layout = [[sg.Text('Multithreaded Work Example')],
              [sg.Text('Click Go to start a long-running function call')],
              [sg.Text('', size=(25, 1), key='_OUTPUT_')],
              [sg.Text('', size=(25, 1), key='_OUTPUT2_')],
              [sg.Graph((10,10),(0,0),(10,10),background_color='black',key=i) for i in range(20)],
              [sg.Button('Go'), sg.Button('Popup'), sg.Button('Exit')], ]

    window = sg.Window('Multithreaded Window').Layout(layout)
    # --------------------- EVENT LOOP ---------------------
    work_id = 0
    while True:
        event, values = window.Read(timeout=100)  # wait for up to 100 ms for a GUI event
        if event is None or event == 'Exit':
            break
        if event == 'Go':           # clicking "Go" starts a long running work item by starting thread
            window.Element('_OUTPUT_').Update('Starting long work %s'%work_id)
            window.Element(work_id).Update(background_color='red')
            # LOCATION 2
            # STARTING long run by starting a thread
            thread_id = threading.Thread(target=long_function_wrapper, args=(work_id, gui_queue,), daemon=True)
            thread_id.start()
            work_id = work_id+1 if work_id < 19 else 0
        # --------------- Read next message coming in from threads ---------------
        try:
            message = gui_queue.get_nowait()    # see if something has been posted to Queue
        except queue.Empty:                     # get_nowait() will get exception when Queue is empty
            message = None                      # nothing in queue so do nothing

        # if message received from queue, then some work was completed
        if message is not None:
            # LOCATION 3
            # this is the place you would execute code at ENDING of long running task
            # You can check the completed_work_id variable to see exactly which long-running function completed
            completed_work_id = int(message[:message.index(' :::')])
            window.Element('_OUTPUT2_').Update('Complete Work ID "{}"'.format(completed_work_id))
            window.Element(completed_work_id).Update(background_color='green')

        if event == 'Popup':
            sg.Popup('This is a popup showing that the GUI is running')
    # if user exits the window, then close the window and exit the GUI func
    window.Close()

############################# Main ############################# 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:48,代码来源:Demo_Threaded_Work.py


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