久久久久久久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 中的多處理的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時(shí)送ChatGPT賬號(hào)..

                  如何在沒有多線程的情況下在 python 中運(yùn)行多個(gè)進(jìn)程?例如考慮以下問題:-

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

                  我們必須制作一個(gè) Gui,它有一個(gè)開始按鈕,用于啟動(dòng)一個(gè)函數(shù)(例如,打印所有整數(shù)),還有一個(gè)停止按鈕,這樣點(diǎn)擊它就會(huì)停止函數(shù).

                  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 中做到這一點(diǎn)?

                  How to do this in Tkinter?

                  推薦答案

                  然后您需要將 Button 小部件與啟動(dòng)工作線程的函數(shù)綁定.例如:

                  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 方法,您只能通過更改線程的值來優(yōu)雅地結(jié)束線程.請(qǐng)注意,使用多個(gè)線程可以避免在執(zhí)行 printints 時(shí)阻塞 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 部分通信的場(chǎng)景.例如:在渲染某些圖像時(shí)填充進(jìn)度條.

                  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.

                  但是,正如評(píng)論中所指出的那樣,這種方法對(duì)于僅打印數(shù)字來說太復(fù)雜了.

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

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

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

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

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

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

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

                  相關(guān)文檔推薦

                  What exactly is Python multiprocessing Module#39;s .join() Method Doing?(Python 多處理模塊的 .join() 方法到底在做什么?)
                  Passing multiple parameters to pool.map() function in Python(在 Python 中將多個(gè)參數(shù)傳遞給 pool.map() 函數(shù))
                  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 多進(jìn)程池.當(dāng)其中一個(gè)工作進(jìn)程確定不再需要完成工作時(shí),如何退出腳本?) - IT屋-程序員
                  How do you pass a Queue reference to a function managed by pool.map_async()?(如何將隊(duì)列引用傳遞給 pool.map_async() 管理的函數(shù)?)
                  yet another confusion with multiprocessing error, #39;module#39; object has no attribute #39;f#39;(與多處理錯(cuò)誤的另一個(gè)混淆,“模塊對(duì)象沒有屬性“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 | 欧美日韩免费一区二区三区 | 国产一区欧美一区 | 国产精品一二区 | 国产欧美一区二区三区在线看蜜臀 | 欧美成人精品一区二区三区 | 亚洲精品中文在线 | 日本a视频 | 欧美多人在线 | 99久久国产综合精品麻豆 | 秋霞电影一区二区 | 久久久久久久久久久久久9999 | 精品国产乱码久久久久久老虎 | 久久久久久网 | 嫩草视频免费 | 欧美精品黄 | 国产最新视频在线 | 一区二区三区视频在线观看 | 国产精品视频网 | 久久国产精品精品 | 国产成人精品免高潮在线观看 | 福利视频亚洲 | 精品日韩一区二区三区 | 欧美精品一区二区免费 | 国产精品久久久久久久模特 | 黄视频免费观看 | 亚洲一区二区在线视频 | 亚洲午夜精品一区二区三区 | 亚洲精品乱码久久久久久久久久 | 日韩美香港a一级毛片免费 国产综合av | 男人天堂免费在线 | 黄色免费在线网址 | 精品久久影院 | 91精品国产综合久久久久久 | 欧美在线观看一区 | av免费网址 | 成人精品一区二区三区 | 午夜在线小视频 | 精品国产乱码久久久久久闺蜜 | 欧美一区二区三区在线观看 |