# -*- encoding:utf-8 -*-
"""
@作者:ven
@文件名:2.py
@时间:2023-06-21 11:55
@文档说明:
"""
import threading
import time
import PySimpleGUI as sg
"""
Threaded Demo - Uses Window.write_event_value communications
Requires PySimpleGUI.py version 4.25.0 and later
This is a really important demo to understand if you're going to be using multithreading in PySimpleGUI.
Older mechanisms for multi-threading in PySimpleGUI relied on polling of a queue. The management of a communications
queue is now performed internally to PySimpleGUI.
The importance of using the new window.write_event_value call cannot be emphasized enough. It will hav a HUGE impact, in
a positive way, on your code to move to this mechanism as your code will simply "pend" waiting for an event rather than polling.
Copyright 2020 PySimpleGUI.org
"""
THREAD_EVENT = '-THREAD-'
cp = sg.cprint
def the_thread(window):
"""
The thread that communicates with the application through the window's events.
Once a second wakes and sends a new event and associated value to the window
"""
i = 0
while True:
time.sleep(3)
window.write_event_value('-THREAD-', (threading.current_thread
print语句输出到Multiline
于 2023-06-22 11:31:56 首次发布
本文介绍了Python中如何使用print语句进行多行输出,包括直接使用换行符和利用三引号字符串的方式,详细解释了每种方法的工作原理,并通过示例代码展示了其实现过程。
摘要由CSDN通过智能技术生成