久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <legend id='xzZ5J'><style id='xzZ5J'><dir id='xzZ5J'><q id='xzZ5J'></q></dir></style></legend><tfoot id='xzZ5J'></tfoot>
  • <small id='xzZ5J'></small><noframes id='xzZ5J'>

      <bdo id='xzZ5J'></bdo><ul id='xzZ5J'></ul>

  • <i id='xzZ5J'><tr id='xzZ5J'><dt id='xzZ5J'><q id='xzZ5J'><span id='xzZ5J'><b id='xzZ5J'><form id='xzZ5J'><ins id='xzZ5J'></ins><ul id='xzZ5J'></ul><sub id='xzZ5J'></sub></form><legend id='xzZ5J'></legend><bdo id='xzZ5J'><pre id='xzZ5J'><center id='xzZ5J'></center></pre></bdo></b><th id='xzZ5J'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='xzZ5J'><tfoot id='xzZ5J'></tfoot><dl id='xzZ5J'><fieldset id='xzZ5J'></fieldset></dl></div>

        Python tkinter 中的多處理

        Multiprocessing in Python tkinter(Python tkinter 中的多處理)

            <tbody id='Cnj3s'></tbody>
          1. <legend id='Cnj3s'><style id='Cnj3s'><dir id='Cnj3s'><q id='Cnj3s'></q></dir></style></legend>

                • <bdo id='Cnj3s'></bdo><ul id='Cnj3s'></ul>

                  <small id='Cnj3s'></small><noframes id='Cnj3s'>

                  <i id='Cnj3s'><tr id='Cnj3s'><dt id='Cnj3s'><q id='Cnj3s'><span id='Cnj3s'><b id='Cnj3s'><form id='Cnj3s'><ins id='Cnj3s'></ins><ul id='Cnj3s'></ul><sub id='Cnj3s'></sub></form><legend id='Cnj3s'></legend><bdo id='Cnj3s'><pre id='Cnj3s'><center id='Cnj3s'></center></pre></bdo></b><th id='Cnj3s'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Cnj3s'><tfoot id='Cnj3s'></tfoot><dl id='Cnj3s'><fieldset id='Cnj3s'></fieldset></dl></div>
                  <tfoot id='Cnj3s'></tfoot>
                  本文介紹了Python tkinter 中的多處理的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  如何在沒有多線程的情況下在 python 中運行多個進程?例如考慮以下問題:-

                  How to run multiple processes in python without multithreading? For example consider the following problem:-

                  我們必須制作一個 Gui,它有一個開始按鈕,用于啟動一個函數(例如,打印所有整數),還有一個停止按鈕,這樣點擊它就會停止函數.

                  We have to make a Gui,which has a start button which starts a function(say, prints all integers) and there is a stop button, such that clicking it stops the function.

                  如何在 Tkinter 中做到這一點?

                  How to do this in Tkinter?

                  推薦答案

                  然后您需要將 Button 小部件與啟動工作線程的函數綁定.例如:

                  Then you need to bind the Button widget with the function which starts the working thread. For example:

                  import time
                  import threading
                  import Tkinter as tk
                  
                  class App():
                      def __init__(self, root):
                          self.button = tk.Button(root)
                          self.button.pack()
                          self._resetbutton()
                      def _resetbutton(self):
                          self.running = False
                          self.button.config(text="Start", command=self.startthread)
                      def startthread(self):
                          self.running = True
                          newthread = threading.Thread(target=self.printints)
                          newthread.start()
                          self.button.config(text="Stop", command=self._resetbutton)
                      def printints(self):
                          x = 0
                          while self.running:
                              print(x)
                              x += 1
                              time.sleep(1) # Simulate harder task
                  

                  使用 self.running 方法,您只能通過更改線程的值來優雅地結束線程.請注意,使用多個線程可以避免在執行 printints 時阻塞 GUI.

                  With the self.running approach, you can end the thread gracefully only by changing its value. Note that the use of multiple threads serves to avoid blocking the GUI while printints is being executed.

                  我已閱讀 this previous question,我想您為什么在這里明確要求解決方案沒有多線程.在 Tkinter 中,此解決方案可用于其他線程必須與 GUI 部分通信的場景.例如:在渲染某些圖像時填充進度條.

                  I have read this previous question and I suppose why you explicitly asked here for a solution without multithreading. In Tkinter this solution can be used in a scenario where the other threads have to communicate with the GUI part. For example: filling a progressbar while some images are being rendered.

                  但是,正如評論中所指出的那樣,這種方法對于僅打印數字來說太復雜了.

                  However, as it has been pointed in the comments, this approach is too complex for just printing numbers.

                  這里您可以找到很多關于 Tkinter 的信息和更多示例.

                  Here you can find a lot of information and more examples about Tkinter.

                  由于您的新問題已關閉,我將在此處更改代碼以澄清最后一點.

                  Since your new question has been closed, I'll change the code here to clarify the last point.

                  這篇關于Python tkinter 中的多處理的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  What exactly is Python multiprocessing Module#39;s .join() Method Doing?(Python 多處理模塊的 .join() 方法到底在做什么?)
                  Passing multiple parameters to pool.map() function in Python(在 Python 中將多個參數傳遞給 pool.map() 函數)
                  multiprocessing.pool.MaybeEncodingError: #39;TypeError(quot;cannot serialize #39;_io.BufferedReader#39; objectquot;,)#39;(multiprocessing.pool.MaybeEncodingError: TypeError(cannot serialize _io.BufferedReader object,)) - IT屋-程序員軟件開
                  Python Multiprocess Pool. How to exit the script when one of the worker process determines no more work needs to be done?(Python 多進程池.當其中一個工作進程確定不再需要完成工作時,如何退出腳本?) - IT屋-程序員
                  How do you pass a Queue reference to a function managed by pool.map_async()?(如何將隊列引用傳遞給 pool.map_async() 管理的函數?)
                  yet another confusion with multiprocessing error, #39;module#39; object has no attribute #39;f#39;(與多處理錯誤的另一個混淆,“模塊對象沒有屬性“f)
                • <small id='ao3gT'></small><noframes id='ao3gT'>

                • <i id='ao3gT'><tr id='ao3gT'><dt id='ao3gT'><q id='ao3gT'><span id='ao3gT'><b id='ao3gT'><form id='ao3gT'><ins id='ao3gT'></ins><ul id='ao3gT'></ul><sub id='ao3gT'></sub></form><legend id='ao3gT'></legend><bdo id='ao3gT'><pre id='ao3gT'><center id='ao3gT'></center></pre></bdo></b><th id='ao3gT'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ao3gT'><tfoot id='ao3gT'></tfoot><dl id='ao3gT'><fieldset id='ao3gT'></fieldset></dl></div>

                      <tbody id='ao3gT'></tbody>

                    <tfoot id='ao3gT'></tfoot>

                    <legend id='ao3gT'><style id='ao3gT'><dir id='ao3gT'><q id='ao3gT'></q></dir></style></legend>

                          • <bdo id='ao3gT'></bdo><ul id='ao3gT'></ul>
                            主站蜘蛛池模板: 天天色图 | 成人在线视频免费看 | 成人国产精品免费观看 | 色射综合| 久久激情视频 | 久久精品一区二区三区四区 | 99精品欧美一区二区三区综合在线 | 午夜爽爽爽男女免费观看 | 精品日韩一区二区三区av动图 | 人人人人干 | 午夜小电影| 国产高清在线精品一区二区三区 | 国产japanhdxxxx麻豆 | 欧美日韩亚洲在线 | 99精品视频一区二区三区 | 久久免费精品视频 | 久久99精品国产麻豆婷婷 | 一级片在线免费播放 | 狠狠操电影 | 丁香婷婷综合激情五月色 | 伊人导航 | 久久不射电影网 | 美女久久久| 中文字幕在线一区二区三区 | 欧洲一区在线观看 | 精品无码久久久久国产 | 天天操天天插天天干 | 中文字幕国产视频 | 日本精品一区二区三区在线观看视频 | 国产精品日韩欧美一区二区 | 免费观看黄色片视频 | 亚洲精品久久久9婷婷中文字幕 | 羞羞在线观看视频 | 日韩乱码一二三 | 国产一区二区三区久久久久久久久 | 日韩电影一区二区三区 | 91大片| 激情的网站 | 国产1区2区3区 | 精品一二三区视频 | 武道仙尊动漫在线观看 |