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

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

    <small id='7i2n5'></small><noframes id='7i2n5'>

    <legend id='7i2n5'><style id='7i2n5'><dir id='7i2n5'><q id='7i2n5'></q></dir></style></legend>

      • <bdo id='7i2n5'></bdo><ul id='7i2n5'></ul>

        從另一個線程更改 kivy 屬性

        Altering a kivy property from another thread(從另一個線程更改 kivy 屬性)

          • <bdo id='5ZwWN'></bdo><ul id='5ZwWN'></ul>

            <small id='5ZwWN'></small><noframes id='5ZwWN'>

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

                  本文介紹了從另一個線程更改 kivy 屬性的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試一些 kivy 代碼.我嘗試從使用線程庫創建的胎面修改 kivy 屬性(text_colour).程序運行正常,但線程沒有改變屬性.

                  I'm experimenting with some kivy code. I tried modifing a kivy property(text_colour) from a tread created with threading lib. Program works fine but the thread does not change the property.

                  我還嘗試在類中創建一個將值作為參數的方法,但也失敗了.

                  I also tried to create a method in class about which gets the value as an argument, which also failed.

                  from kivy.app import App
                  
                  from kivy.uix.boxlayout import BoxLayout
                  from kivy.properties import ListProperty
                  
                  
                  import threading
                  import random
                  import time
                  
                  
                  def zaaa():
                      import time
                      time.sleep(3)
                      ScatterTextWidget.text_colour = [0, 0, 1, 1]
                      print "function ran"   
                  
                  t = threading.Thread(target= zaaa)
                  t.start()
                  
                  
                  class ScatterTextWidget(BoxLayout):
                  
                      text_colour = ListProperty([1, 0, 0, 1])
                  
                      def change_label_colour(self, *args):
                          colour = [random.random() for i in xrange(3)] + [1]
                          self.text_colour = colour
                  
                      def press(self, *args):
                          self.text_colour = [1, 1, 1, 1]
                  
                  
                  class TataApp(App):
                      def build(self):
                          return ScatterTextWidget()
                  
                  
                  if __name__ == "__main__":
                      TataApp().run()
                  

                  輸出:

                  [INFO              ] Kivy v1.8.0
                  [INFO              ] [Logger      ] Record log in /home/mbp/.kivy/logs/kivy_14-02-26_44.txt
                  [INFO              ] [Factory     ] 157 symbols loaded
                  [DEBUG             ] [Cache       ] register <kv.lang> with limit=None, timeout=Nones
                  [DEBUG             ] [Cache       ] register <kv.image> with limit=None, timeout=60s
                  [DEBUG             ] [Cache       ] register <kv.atlas> with limit=None, timeout=Nones
                  [INFO              ] [Image       ] Providers: img_tex, img_dds, img_pygame, img_pil, img_gif 
                  [DEBUG             ] [Cache       ] register <kv.texture> with limit=1000, timeout=60s
                  [DEBUG             ] [Cache       ] register <kv.shader> with limit=1000, timeout=3600s
                  [DEBUG             ] [App         ] Loading kv </home/mbp/workspace/KiviPlay/tata.kv>
                  [DEBUG             ] [Window      ] Ignored <egl_rpi> (import error)
                  [INFO              ] [Window      ] Provider: pygame(['window_egl_rpi'] ignored)
                  libpng warning: iCCP: known incorrect sRGB profile
                  [DEBUG             ] [Window      ] Display driver x11
                  [DEBUG             ] [Window      ] Actual window size: 800x600
                  [DEBUG             ] [Window      ] Actual color bits r8 g8 b8 a8
                  [DEBUG             ] [Window      ] Actual depth bits: 24
                  [DEBUG             ] [Window      ] Actual stencil bits: 8
                  [DEBUG             ] [Window      ] Actual multisampling samples: 2
                  [INFO              ] [GL          ] OpenGL version <4.3.12618 Compatibility Profile Context 13.251>
                  [INFO              ] [GL          ] OpenGL vendor <ATI Technologies Inc.>
                  [INFO              ] [GL          ] OpenGL renderer <AMD Radeon HD 7700 Series>
                  [INFO              ] [GL          ] OpenGL parsed version: 4, 3
                  [INFO              ] [GL          ] Shading version <4.30>
                  [INFO              ] [GL          ] Texture max size <16384>
                  [INFO              ] [GL          ] Texture max units <32>
                  [DEBUG             ] [Shader      ] Fragment compiled successfully
                  [DEBUG             ] [Shader      ] Vertex compiled successfully
                  [DEBUG             ] [ImagePygame ] Load </usr/lib/python2.7/site-packages/Kivy-1.8.0-py2.7-linux-x86_64.egg/kivy/data/glsl/default.png>
                  [INFO              ] [Window      ] virtual keyboard not allowed, single mode, not docked
                  [INFO              ] [Text        ] Provider: pygame
                  [DEBUG             ] [Cache       ] register <kv.loader> with limit=500, timeout=60s
                  [INFO              ] [Loader      ] using a thread pool of 2 workers
                  [DEBUG             ] [Cache       ] register <textinput.label> with limit=None, timeout=60.0s
                  [DEBUG             ] [Cache       ] register <textinput.width> with limit=None, timeout=60.0s
                  [DEBUG             ] [Atlas       ] Load </usr/lib/python2.7/site-packages/Kivy-1.8.0-py2.7-linux-x86_64.egg/kivy/data/../data/images/defaulttheme.atlas>
                  [DEBUG             ] [Atlas       ] Need to load 1 images
                  [DEBUG             ] [Atlas       ] Load </usr/lib/python2.7/site-packages/Kivy-1.8.0-py2.7-linux-x86_64.egg/kivy/data/../data/images/defaulttheme-0.png>
                  [DEBUG             ] [ImagePygame ] Load </usr/lib/python2.7/site-packages/Kivy-1.8.0-py2.7-linux-x86_64.egg/kivy/data/../data/images/defaulttheme-0.png>
                  [INFO              ] [GL          ] NPOT texture support is available
                  [INFO              ] [OSC         ] using <multiprocessing> for socket
                  [DEBUG             ] [Base        ] Create provider from mouse
                  [DEBUG             ] [Base        ] Create provider from probesysfs
                  [DEBUG             ] [ProbeSysfs  ] using probsysfs!
                  [INFO              ] [Base        ] Start application main loop
                  <kivy.properties.ListProperty object at 0x124f870>
                  function ran
                  [INFO              ] [Base        ] Leaving application in progress...
                  

                  推薦答案

                  您不能從外部線程修改 kivy 屬性或執行任何與 OpenGL 相關的工作.

                  You cannot modify a kivy property or do any OpenGL related work from an external thread.

                  解決方案是用 kivy 的 Clock 來安排 callbacks 來調用一個函數來自 kivy 的主線程并為您完成工作.

                  The solution is to schedule callbacks with kivy's Clock that will call a function from kivy's main thread and do the work for you.

                  就個人而言,當我使用第二個線程時,我使用隊列進行線程間通信,如下所示:

                  Personally, when I use a second thread, I use a queue for the inter-thread comm as follows:

                  from Queue import Queue
                  
                   class KivyQueue(Queue):
                      '''
                      A Multithread safe class that calls a callback whenever an item is added
                      to the queue. Instead of having to poll or wait, you could wait to get
                      notified of additions.
                  
                      >>> def callabck():
                      ...     print('Added')
                      >>> q = KivyQueue(notify_func=callabck)
                      >>> q.put('test', 55)
                      Added
                      >>> q.get()
                      ('test', 55)
                  
                      :param notify_func: The function to call when adding to the queue
                      '''
                  
                      notify_func = None
                  
                      def __init__(self, notify_func, **kwargs):
                          Queue.__init__(self, **kwargs)
                          self.notify_func = notify_func
                  
                      def put(self, key, val):
                          '''
                          Adds a (key, value) tuple to the queue and calls the callback function.
                          '''
                          Queue.put(self, (key, val), False)
                          self.notify_func()
                  
                      def get(self):
                          '''
                          Returns the next items in the queue, if non-empty, otherwise a
                          :py:attr:`Queue.Empty` exception is raised.
                          '''
                          return Queue.get(self, False)
                  

                  第二個線程使用 put 將東西放入隊列.回調在調用時會使用 trigger.然后kivy的主線程調用的函數調用隊列的get函數并設置相應的屬性.

                  The second threads uses put to put things on the queue. And the callback, when called, schedules a kivy callback using a trigger. The function that the kivy's main thread then calls calls the get function of the queue and sets the appropriate property.

                  如果您需要設置許多屬性,這將很有幫助.如果您只需要設置一個屬性,我所做的就是從第二個線程中安排一個 callabck,它使用 partial 來使 value 成為函數的一部分.例如:

                  That is helpful if you need to set many properties. If you just need to set a single property, what I do is from the second thread I schedule a callabck that uses partial to make the value part of the function. E.g:

                  # this may only be called from the main kivy thread
                  def set_property(value, *largs):
                      self.kivy_property = value
                  
                  # the second thread does this when it wants to set self.kivy_property to 10
                  Clock.schedule_once(partial(set_property, 10))
                  

                  這篇關于從另一個線程更改 kivy 屬性的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 - 自動更改角色顏色)
                    1. <legend id='SZtzj'><style id='SZtzj'><dir id='SZtzj'><q id='SZtzj'></q></dir></style></legend>

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

                          <tfoot id='SZtzj'></tfoot>

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

                              <tbody id='SZtzj'></tbody>
                            <i id='SZtzj'><tr id='SZtzj'><dt id='SZtzj'><q id='SZtzj'><span id='SZtzj'><b id='SZtzj'><form id='SZtzj'><ins id='SZtzj'></ins><ul id='SZtzj'></ul><sub id='SZtzj'></sub></form><legend id='SZtzj'></legend><bdo id='SZtzj'><pre id='SZtzj'><center id='SZtzj'></center></pre></bdo></b><th id='SZtzj'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='SZtzj'><tfoot id='SZtzj'></tfoot><dl id='SZtzj'><fieldset id='SZtzj'></fieldset></dl></div>
                          • 主站蜘蛛池模板: 超碰地址 | 日本超碰 | 国产成人午夜电影网 | 精品一区二区三区四区外站 | 欧美在线a | 久久1区 | 免费看大片bbbb欧美 | 自拍偷拍精品 | 中国一级特黄真人毛片 | 欧美三区 | 国产精品久久久 | 精品欧美一区二区三区久久久 | 在线免费观看黄色网址 | 一区在线观看 | 999久久久久久久久6666 | 国产精品久久久久免费 | 不卡的av在线 | 中文字幕欧美一区 | 四虎永久免费地址 | 欧美日韩专区 | 欧美不卡在线 | 精品久久伊人 | 99re热这里只有精品视频 | 国产免费让你躁在线视频 | 国产毛片久久久久久久久春天 | 精品久久久久久久久久久下田 | 久久一本 | 久久黄视频 | 国产一区二区三区久久久久久久久 | 国产91一区 | 亚洲精品久久久久久国产精华液 | 日韩综合网 | 国产精品久久久久无码av | 美女视频网站久久 | 欧区一欧区二欧区三免费 | 欧美人妇做爰xxxⅹ性高电影 | 国产精品成人一区二区 | 久久久久久久久蜜桃 | 午夜精品一区二区三区在线视频 | 人碰人操 | 精品久久久久久久久久久久久 |