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

    <small id='3AJfo'></small><noframes id='3AJfo'>

      <bdo id='3AJfo'></bdo><ul id='3AJfo'></ul>
  • <tfoot id='3AJfo'></tfoot>

    <legend id='3AJfo'><style id='3AJfo'><dir id='3AJfo'><q id='3AJfo'></q></dir></style></legend>
    <i id='3AJfo'><tr id='3AJfo'><dt id='3AJfo'><q id='3AJfo'><span id='3AJfo'><b id='3AJfo'><form id='3AJfo'><ins id='3AJfo'></ins><ul id='3AJfo'></ul><sub id='3AJfo'></sub></form><legend id='3AJfo'></legend><bdo id='3AJfo'><pre id='3AJfo'><center id='3AJfo'></center></pre></bdo></b><th id='3AJfo'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='3AJfo'><tfoot id='3AJfo'></tfoot><dl id='3AJfo'><fieldset id='3AJfo'></fieldset></dl></div>
      1. 如何在微調(diào)器中允許無限整數(shù)值?

        How to allow infinite integer values in a spinner?(如何在微調(diào)器中允許無限整數(shù)值?)
        1. <i id='M1Wrj'><tr id='M1Wrj'><dt id='M1Wrj'><q id='M1Wrj'><span id='M1Wrj'><b id='M1Wrj'><form id='M1Wrj'><ins id='M1Wrj'></ins><ul id='M1Wrj'></ul><sub id='M1Wrj'></sub></form><legend id='M1Wrj'></legend><bdo id='M1Wrj'><pre id='M1Wrj'><center id='M1Wrj'></center></pre></bdo></b><th id='M1Wrj'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='M1Wrj'><tfoot id='M1Wrj'></tfoot><dl id='M1Wrj'><fieldset id='M1Wrj'></fieldset></dl></div>
            <legend id='M1Wrj'><style id='M1Wrj'><dir id='M1Wrj'><q id='M1Wrj'></q></dir></style></legend><tfoot id='M1Wrj'></tfoot>

                • <bdo id='M1Wrj'></bdo><ul id='M1Wrj'></ul>
                    <tbody id='M1Wrj'></tbody>
                • <small id='M1Wrj'></small><noframes id='M1Wrj'>

                  本文介紹了如何在微調(diào)器中允許無限整數(shù)值?的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我需要一個(gè) Spinner 小部件,其中用戶可以選擇 integer 具有特定步驟且沒有下限或上限的值(我的意思是,它們至少應(yīng)該在十億范圍內(nèi),所以沒有機(jī)會(huì)記住整個(gè)序列).

                  I need a Spinner widget in which the user can select integer values with a certain step and without lower or upper limits (I mean, they should be at least in the billion range, so no chance of memorizing the whole sequence).

                  我看到了 kivy 的 Spinner 小部件但我不認(rèn)為像 Spinner(values=itertool.count()) 這樣的事情會(huì)奏效.它也僅限于字符串值.

                  I saw kivy's Spinner widget but I don't think doing something like Spinner(values=itertool.count()) would work. Also it is limited to string values.

                  有沒有什么簡單的方法可以獲取類似于 QSpinBox 的東西Qt的?

                  Is there any simple way of obtaining something similar to QSpinBox of the Qt?

                  推薦答案

                  目前看來 kivy 沒有提供類似于 SpinnerSpinBox 的任何東西,但是你想調(diào)用它.可以使用的小部件是 Slider 但它看起來很糟糕,如果你想允許一個(gè)非常大的范圍但只有一小步,它就不是那么有用了.

                  It seems like kivy at the moment does not provide anything similar to a Spinner or SpinBox or however you want to call it. A widget that might be used instead is the Slider but it looks awful and it's not so useful if you want to allow a very big range but with a small step.

                  因此,我編寫了自己的 SpinBox 實(shí)現(xiàn):

                  Therefore I wrote my own implementation of a SpinBox:

                  class SpinBox(BoxLayout):
                      """A widget to show and take numeric inputs from the user.
                  
                      :param min_value: Minimum of the range of values.
                      :type min_value: int, float
                      :param max_value: Maximum of the range of values.
                      :type max_value: int, float
                      :param step: Step of the selection
                      :type step: int, float
                      :param value: Initial value selected
                      :type value: int, float
                      :param editable: Determine if the SpinBox is editable or not
                      :type editable: bool
                      """
                  
                      min_value = NumericProperty(float('-inf'))
                      max_value = NumericProperty(float('+inf'))
                      step = NumericProperty(1)
                      value = NumericProperty(0)
                      range = ReferenceListProperty(min_value, max_value, step)
                  
                      def __init__(self, btn_size_hint_x=0.2, **kwargs):
                          super(SpinBox, self).__init__(orientation='horizontal', **kwargs)
                  
                          self.value_label = Label(text=str(self.value))
                          self.inc_button = TimedButton(text='+')
                          self.dec_button = TimedButton(text='-')
                  
                          self.inc_button.bind(on_press=self.on_increment_value)
                          self.inc_button.bind(on_time_slice=self.on_increment_value)
                          self.dec_button.bind(on_press=self.on_decrement_value)
                          self.dec_button.bind(on_time_slice=self.on_decrement_value)
                  
                          self.buttons_vbox = BoxLayout(orientation='vertical',
                                                        size_hint_x=btn_size_hint_x)
                          self.buttons_vbox.add_widget(self.inc_button)
                          self.buttons_vbox.add_widget(self.dec_button)
                  
                          self.add_widget(self.value_label)
                          self.add_widget(self.buttons_vbox)
                  
                      def on_increment_value(self, btn_instance):
                          if float(self.value) + float(self.step) <= self.max_value:
                              self.value += self.step
                  
                      def on_decrement_value(self, btn_instance):
                          if float(self.value) - float(self.step) >= self.min_value:
                              self.value -= self.step
                  
                      def on_value(self, instance, value):
                          instance.value_label.text = str(value)
                  

                  實(shí)際上我使用的代碼略有不同,因?yàn)槲艺J(rèn)為子類化布局來實(shí)現(xiàn)小部件很丑,因此我將 Widget 子類化并添加了一個(gè)水平 BoxLayout 作為Widget 的唯一子項(xiàng),然后我 binded 每個(gè)大小和位置更改以更新此子項(xiàng)的大小和位置(請參閱 這個(gè)問題我為什么必須這樣做).

                  Actually the code I use is slightly different because I think it is ugly to subclass a layout to implement a widget and thus I subclassed Widget and added a horizontal BoxLayout as only children of the Widget, then I binded every size and position change to update the size and position of this child(see this question for why I had to do that).

                  TimedButtonButton 的子類,它允許長按,并且當(dāng)長按時(shí),每隔一定時(shí)間發(fā)出一個(gè) on_time_slice 事件毫秒數(shù)(因此用戶將能夠按住按鈕進(jìn)行連續(xù)增量).如果需要,您可以簡單地使用普通的 Button,刪除 bindon_time_slice 事件.

                  The TimedButton is a subclass of Button that allows long-presses and, when long-pressed, emits a on_time_slice event every a certain amount of millisecond(thus the user will be able to hold the button to do a continuous increment). You can simply use a normal Button if you want, removing the binds to on_time_slice event.

                  TimedButton源代碼是這樣的:

                  class TimedButton(Button):
                      """A simple ``Button`` subclass that produces an event at regular intervals
                      when pressed.
                  
                      This class, when long-pressed, emits an ``on_time_slice`` event every
                      ``time_slice`` milliseconds.
                  
                      :param long_press_interval: Defines the minimum time required to consider
                                                  the press a long-press.
                      :type long_press_interval: int
                      :param time_slice: The number of milliseconds of each slice.
                      :type time_slice: int
                      """
                  
                      def __init__(self, long_press_interval=550, time_slice=225, **kwargs):
                          super(TimedButton, self).__init__(**kwargs)
                  
                          self.long_press_interval = long_press_interval
                          self.time_slice = time_slice
                  
                          self._touch_start = None
                          self._long_press_callback = None
                          self._slice_callback = None
                  
                          self.register_event_type('on_time_slice')
                          self.register_event_type('on_long_press')
                  
                  
                      def on_state(self, instance, value):
                          if value == 'down':
                              start_time = time.time()
                              self._touch_start = start_time
                  
                              def callback(dt):
                                  self._check_long_press(dt)
                  
                              Clock.schedule_once(callback, self.long_press_interval / 1000.0)
                              self._long_press_callback = callback
                          else:
                              end_time = time.time()
                              delta = (end_time - (self._touch_start or 0)) * 1000
                              Clock.unschedule(self._slice_callback)
                              # Fixes the bug of multiple presses causing fast increase
                              Clock.unschedule(self._long_press_callback)
                              if (self._long_press_callback is not None and
                                  delta > self.long_press_interval):
                                  self.dispatch('on_long_press')
                              self._touch_start = None
                              self._long_press_callback = self._slice_callback = None
                  
                      def _check_long_press(self, dt):
                          delta = dt * 1000
                          if delta > self.long_press_interval and self.state == 'down':
                              self.dispatch('on_long_press')
                              self._long_press_callback = None
                  
                              def slice_callback(dt):
                                  self.dispatch('on_time_slice')
                                  return self.state == 'down'
                  
                              Clock.schedule_interval(slice_callback, self.time_slice / 1000.0)
                  
                              self._slice_callback = slice_callback
                  
                  
                      def on_long_press(self):
                          pass
                  
                      def on_time_slice(self):
                          pass
                  

                  請注意,我必須綁定 state 屬性,而不是使用 on_touch_downon_touch_up 因?yàn)樗鼈兲峁┝艘恍?奇怪的行為,即使在工作"時(shí),也會(huì)無緣無故地發(fā)生一些奇怪的事情(例如點(diǎn)擊遞減按鈕導(dǎo)致on_increment 被調(diào)用,即使 bindings 正確).

                  Note that I had to bind the state property instead of using on_touch_down and on_touch_up because they give some strange behaviour, and even when "working" there were some strange things happening by no reason(e.g. clicking the decrement button caused on_increment to be called even though the bindings where correct).

                  更新了 TimedButton 類,修復(fù)了一個(gè)小錯(cuò)誤(之前的實(shí)現(xiàn)在快速單擊多次然后按住按鈕會(huì)產(chǎn)生太多 on_time_slice 事件:當(dāng)狀態(tài)變?yōu)?'normal'

                  Updated the TimedButton class fixing a little bug(the previous implementation when clicked rapidly multiple times and then holding down the button would yield too many on_time_slice events: I'd forgot to "unschedule" the _long_press_callback when the state goes 'normal'

                  這篇關(guān)于如何在微調(diào)器中允許無限整數(shù)值?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

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

                  2. <legend id='BVTPE'><style id='BVTPE'><dir id='BVTPE'><q id='BVTPE'></q></dir></style></legend>

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

                          <bdo id='BVTPE'></bdo><ul id='BVTPE'></ul>
                          <tfoot id='BVTPE'></tfoot>
                          • 主站蜘蛛池模板: 亚洲一区亚洲二区 | 日韩欧美二区 | 在线看亚洲 | 91大神xh98xh系列全部 | 国产片侵犯亲女视频播放 | 国产欧美日韩 | 亚洲精品成人 | 91久久 | 狠狠综合久久av一区二区小说 | 欧美亚洲第一区 | 国产精品极品美女在线观看免费 | 亚洲国产一区二区在线 | 国产精品视频一 | 国产日韩一区二区三免费 | 伊人网综合| 这里精品 | 黑人性hd| 黄网站涩免费蜜桃网站 | 久久三区| 国产精品一区二区三区在线 | 91精品国产欧美一区二区 | 色伊人 | 中文字幕视频一区二区 | 亚洲国产精品久久久 | 久久久99精品免费观看 | 国产日韩精品视频 | 视频一区二区中文字幕 | 一区二区三区中文字幕 | 97起碰 | 成人在线观看欧美 | 涩涩视频在线观看免费 | 国产一区二| 国产精品视频在线免费观看 | 伊人网站在线观看 | 免费黄色录像视频 | 国产成人精品一区二区三区在线 | 日韩一区二区三区av | 中文字幕 在线观看 | 成年免费在线观看 | 一区二区三区四区电影 | 91综合网 |