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

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

      <tfoot id='pEsUY'></tfoot>

    1. <small id='pEsUY'></small><noframes id='pEsUY'>

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

        <legend id='pEsUY'><style id='pEsUY'><dir id='pEsUY'><q id='pEsUY'></q></dir></style></legend>
      1. 如何在 kivy-python 中使用具有多線程的時鐘對象更

        How to update progressbar using Clock Object with Multithreading in kivy-python?(如何在 kivy-python 中使用具有多線程的時鐘對象更新進度條?)

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

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

          • <legend id='vcacs'><style id='vcacs'><dir id='vcacs'><q id='vcacs'></q></dir></style></legend>
              <bdo id='vcacs'></bdo><ul id='vcacs'></ul>

                  <tbody id='vcacs'></tbody>
                • 本文介紹了如何在 kivy-python 中使用具有多線程的時鐘對象更新進度條?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在 kivy 中制作一個應用程序,因為我正在使用 linux.我在使用 python-kivy 中的多線程時鐘對象更新進度條 gui 時遇到問題.我正在使用這兩個文件 .kv &.py 文件運行應用程序.

                  I am making an app in kivy for that i am using linux. i am getting a problem to update the progress bar gui using clock object with multithreading in python-kivy. i am using both files .kv & .py file run the app.

                  我的 main.py 文件:

                  my main.py file:

                  from kivy.app import App
                  from kivy.uix.label import Label
                  from kivy.uix.boxlayout import BoxLayout
                  from kivy.uix.progressbar import ProgressBar
                  from kivy.uix.button import Button
                  from kivy.uix.popup import Popup
                  from kivy.clock import Clock
                  import sys, threading, os, time
                  from socket import *
                  
                  class Out_Come(BoxLayout):
                  
                  
                      def Input_manager(self, *args):
                          try:
                              t = self.ids.nd.text
                              I=socket.gethostbyname(t)
                              st = self.ids.ti.text
                              et = self.ids.it.text
                              st1=int(st)
                              et1=int(et)
                              while st1<=et1:
                                  work=my_function(I,st1)
                                  work.start()
                                  Clock.schedule_once(lambda dt: work.run, 1)
                                  st1=st1+1
                                  self.ids.pb.value=self.ids.pb.value+1
                      except:
                          "Error"
                  class my_function(threading.Thread):
                      def __init__(self,n, d):
                          threading.Thread.__init__(self)
                          self.n = n
                              self.d = d
                      def run(self):
                          try:
                              get = socket(AF_INET, SOCK_STREAM)
                              get.settimeout(4)
                              get.connect((gethostbyname(self.n), int(self.d)))
                              print"done", self.d
                              get.close()
                          except:
                              print"not done", self.d
                  
                  class Example_app(App):
                  
                      def build(self):
                          return Out_Come()
                  
                  
                  if __name__ == '__main__':
                      Example_app().run()
                  

                  我的 .kv 文件:

                  <Out_Come>:
                      GridLayout:
                          orientation:'vertical'
                          rows:2
                          cols:2
                          padding:10
                          spacing:10
                          Label:
                              text:"[b]Enter value:[b]"
                              markup:True
                              size_hint:.3,.3
                          TextInput:
                              id:nd
                              text: ""
                              height:40 
                              multiline:False
                  
                          GridLayout:
                              orientation: 'vertical'
                              rows:2
                              cols:4
                              padding:10
                              spacing:10
                              Label:
                                  text:"[b]First:[b]"
                                  height:40
                                  size_hint:.25,.25
                                  markup:True
                              TextInput:
                                  id:ti
                                  text:""
                                  height: 40
                                  size_hint:.25,.25
                                  multiline:False
                              Label:
                                  text:"[b]last[b]"
                                  height:40
                                  size_hint:.25,.25
                                  markup:True
                              TextInput:
                                  id:it
                                  text:""
                                  height:40
                                  size_hint:.25,.25
                                  multiline:False
                  
                          GridLayout:
                              orientation: 'vertical'
                              rows:1
                              cols:2
                              padding:10
                              spacing:10
                              Button:
                                  id:get
                                  text:'Start'
                                  size_hint:.3,.3
                                  on_press: root.Input_manager()
                          ProgressBar:
                              id:pb
                              max:100
                              value:0
                  

                  進度條是否完美更新?我想在實時更新它.請告訴我執行此代碼的更好方法.提前致謝.

                  Is the progress bar perfectly updating? i want upate it prefectly in live time. Please tell me the better way to execute this code. Thanks in advance.

                  推薦答案

                  你的代碼有幾個問題:

                  您的 UI 線程中有一個循環(這將停止 UI 更新)

                  You have a loop in your UI thread (which will stop the UI updating)

                          while st1<=et1:
                              work=my_function(I,st1)
                              work.start()
                              Clock.schedule_once(lambda dt: work.run, 1)
                              st1=st1+1
                              self.ids.pb.value=self.ids.pb.value+1
                  

                  您需要像這樣將循環傳遞到您的線程中:

                  You need to pass the loop into your thread like this:

                     ...
                     def Input_manager(self, *args):
                          ...
                          st1=int(st)
                          et1=int(et)
                  
                          work=my_function(I,st1, est1,
                                           #sending a thread safe update progress bar function
                                           lambda : Clock.schedule_once(self.update_bar))
                          work.start()
                  
                     def update_bar(self, dt=None):
                        self.ids.pb.value=self.ids.pb.value+1
                  
                  class my_function(threading.Thread):
                      def __init__(self,n, st, et, update_bar):
                          threading.Thread.__init__(self)
                          self.n = n
                          self.st = st
                          self.et = et
                          self.update_bar = update_bar
                      def run(self):
                          for din range(self.st1, self.et1+1):
                              try:
                                  get = socket(AF_INET, SOCK_STREAM)
                                  get.settimeout(4)
                                  get.connect((gethostbyname(self.n), int(d)))
                                  print"done", d
                                  get.close()
                              except:
                                  print"not done", d
                              finally:
                                  self.update_bar() #this is our callback to update the bar!
                  

                  還有更多的修復需要完成(風格方面),但這超出了上下文

                  There are more fixes to be done (style wise) but that is outside the context

                  注意 - 這未經任何測試...

                  Note - this was not tested by any means...

                  這篇關于如何在 kivy-python 中使用具有多線程的時鐘對象更新進度條?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                  Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)

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

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

                            <tfoot id='UJOVD'></tfoot>
                            主站蜘蛛池模板: av中文在线观看 | 九九视频在线观看视频6 | 精品三区 | 国产福利91精品 | 中文字幕国产一区 | 久久极品 | 日韩欧美二区 | 人人操日日干 | 成人免费视频 | 亚洲91精品 | 国产成人免费视频网站视频社区 | h视频在线免费 | 国色天香综合网 | 在线观看免费国产 | 欧美日本一区 | 亚洲精选一区二区 | 精品欧美一区二区精品久久 | 久久麻豆精品 | 日本人做爰大片免费观看一老师 | 99re6在线视频 | 一级欧美一级日韩片免费观看 | 久久精品视频在线观看 | 成年网站在线观看 | 欧美成人hd | 午夜免费观看体验区 | 成人在线中文字幕 | 网站黄色av | 国产高清自拍视频在线观看 | 国产女人与拘做受视频 | 亚洲人精品午夜 | 91综合网 | 亚洲成人精品久久久 | 中文字幕日韩欧美 | 在线视频一区二区 | 久久久久九九九九 | 97久久久| 亚洲a网 | 午夜精品久久久久久不卡欧美一级 | 女女爱爱视频 | 一级全黄少妇性色生活免费看 | 亚洲视频一区在线 |