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

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

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

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

      1. 在 python 端動態(tài)調(diào)整 kivy 標(biāo)簽(和按鈕)的大小

        Dynamically resizing a kivy label (and button) on the python side(在 python 端動態(tài)調(diào)整 kivy 標(biāo)簽(和按鈕)的大小)
          <bdo id='JtX0o'></bdo><ul id='JtX0o'></ul>
          <tfoot id='JtX0o'></tfoot>

            <tbody id='JtX0o'></tbody>
          <legend id='JtX0o'><style id='JtX0o'><dir id='JtX0o'><q id='JtX0o'></q></dir></style></legend>
        • <small id='JtX0o'></small><noframes id='JtX0o'>

                  <i id='JtX0o'><tr id='JtX0o'><dt id='JtX0o'><q id='JtX0o'><span id='JtX0o'><b id='JtX0o'><form id='JtX0o'><ins id='JtX0o'></ins><ul id='JtX0o'></ul><sub id='JtX0o'></sub></form><legend id='JtX0o'></legend><bdo id='JtX0o'><pre id='JtX0o'><center id='JtX0o'></center></pre></bdo></b><th id='JtX0o'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='JtX0o'><tfoot id='JtX0o'></tfoot><dl id='JtX0o'><fieldset id='JtX0o'></fieldset></dl></div>
                  本文介紹了在 python 端動態(tài)調(diào)整 kivy 標(biāo)簽(和按鈕)的大小的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  如何在運行時根據(jù)文本量動態(tài)調(diào)整標(biāo)簽或按鈕的大小,尤其是 text_size 和 height?

                  How do I dynamically resize the a label or button, in particular, the text_size and height, depending on the amount of text, at run-time?

                  我知道這個問題已經(jīng)以一種方式回答了這個問題:

                  I am aware that this question has already been answered in one way with this question:

                  動態(tài)調(diào)整滾動視圖中標(biāo)簽的大小?

                  我在部分代碼中反映了該示例.

                  And I reflect that example in part of my code.

                  問題是在運行時動態(tài)調(diào)整標(biāo)簽和按鈕的大小.使用,例如:

                  The problem is dynamically resizing the labels and buttons at run-time. Using, for example:

                  btn = Button(text_size=(self.width, self.height), text='blah blah')
                  

                  ...等等,只會讓程序認(rèn)為(并且在邏輯上如此)self"指的是包含按鈕的類.

                  ...and so on, only makes the program think (and logically so) that the "self" is referring to the class which is containing the button.

                  那么,我如何在python語言中動態(tài)調(diào)整這些屬性的大小,而不是kivy?

                  So, how do I dynamically resize these attributes in the python language, not kivy?

                  我的示例代碼:

                  import kivy
                  kivy.require('1.7.2') # replace with your current kivy version !
                  
                  from kivy.app import App
                  from kivy.uix.screenmanager import ScreenManager, Screen
                  from kivy.properties import ObjectProperty
                  from kivy.uix.button import Button
                  from kivy.uix.gridlayout import GridLayout
                  
                  i = range(20)
                  
                  long_text = 'sometimes the search result could be rather long 
                  sometimes the search result could be rather long 
                  sometimes the search result could be rather long '
                  
                  class ButtonILike(Button):
                  
                      def get_text(self):
                          return long_text
                  
                  class HomeScreen(Screen):
                      scroll_view = ObjectProperty(None)
                  
                      def __init__(self, *args, **kwargs):
                          super(HomeScreen, self).__init__(*args, **kwargs)
                          layout1 = GridLayout(cols=1, spacing=0, size_hint=(1, None), 
                              row_force_default=False, row_default_height=40)
                          layout1.bind(minimum_height=layout1.setter('height'),
                                       minimum_width=layout1.setter('width'))
                          layout1.add_widget(ButtonILike())
                  
                          for result in i:
                  
                                  btn1 = Button(font_name="data/fonts/DejaVuSans.ttf", 
                                      size_hint=(1, None), valign='middle',)#, 
                                      #height=self.texture_size[1], text_size=(self.width-10, None))
                                  btn1.height = btn1.texture_size[1]
                                  btn1.text_size = (btn1.width-20, layout1.row_default_height)
                                  btn1.text = long_text
                  
                                  btn2 = Button(font_name="data/fonts/DejaVuSans.ttf", 
                                      size_hint=(1, None), valign='middle')
                  
                                  btn2.bind(text_size=(btn2.width-20, None))
                                  btn2.text = 'or short'
                  
                                  layout1.add_widget(btn1)
                                  layout1.add_widget(btn2)
                  
                  
                          scrollview1 = self.scroll_view
                          scrollview1.clear_widgets()
                          scrollview1.add_widget(layout1)
                  
                  
                  class mybuttonsApp(App):
                  
                      def build(self):
                  
                          return HomeScreen()
                  
                  
                  
                  if __name__ == '__main__':
                      mybuttonsApp().run()
                  

                  還有kv文件:

                  #:kivy 1.7.2
                  
                  <ButtonILike>:
                      text_size: self.width-10, None
                      size_hint: (1, None)
                      height: self.texture_size[1]
                      text: root.get_text()
                      #on_release: root.RunSearchButton_pressed()
                  
                  <HomeScreen>:
                      scroll_view: scrollviewID
                      AnchorLayout:
                          size_hint: 1, .1   
                          pos_hint: {'x': 0, 'y': .9}
                          anchor_x: 'center'
                          anchor_y: 'center'
                          Label:
                              text: 'Button Tester'
                  
                      ScrollView:
                          id: scrollviewID
                          orientation: 'vertical'
                          pos_hint: {'x': 0, 'y': 0}
                          size_hint: 1, .9
                          bar_width: '8dp'
                  

                  您可以看到我從 kv 文件中添加了按鈕,該按鈕在列表頂部顯示了我想要的所有行為.在運行時調(diào)整窗口大小,您可以看到它的神奇之處.當(dāng)然,更改 text_size 也可以讓我對齊文本.

                  You can see that I added the button from the kv file which displays all the behavior that I want at the top of the list. Resize your window while running it, and you can see the magic. And, of course, changing the text_size also makes it possible for me to align text.

                  我根本無法在 python 端實現(xiàn)相同的行為.我的應(yīng)用程序要求在運行時創(chuàng)建按鈕.我認(rèn)為答案可能在于bind()",盡管不可否認(rèn),我不確定我在嘗試中是否正確使用了它,或者我是否完全理解它.您可以看到我嘗試使用btn2",我認(rèn)為它會將文本扔到左側(cè)(因為 halign 默認(rèn)為左側(cè)),但似乎沒有做任何事情.

                  I simply have not been able to achieve the same behavior on the python side. My app requires that the buttons be created at run-time. I think the answer might lie with "bind()", though admittedly, I'm not sure I used it correctly in my attempts or that I understand it fully. You can see that I tried with "btn2", which I thought would've thrown the text to the left (since halign defaults to left), but didn't seem to do anything.

                  感謝您的幫助.

                  推薦答案

                  我覺得最好的辦法是把Label's/Button's size設(shè)置為texture_size:

                  I think the best way is to set Label's/Button's size to texture_size:

                  Label:
                      text: "test"
                      size_hint: None, None
                      size: self.texture_size
                  
                      canvas.before: # for testing purposes
                          Color:
                              rgb: 0, 1, 0
                          Rectangle:
                              pos: self.pos
                              size: self.size
                  

                  這篇關(guān)于在 python 端動態(tài)調(diào)整 kivy 標(biāo)簽(和按鈕)的大小的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                  Discord bot isn#39;t responding to commands(Discord 機器人沒有響應(yīng)命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關(guān)于我嗎?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. <small id='CHlml'></small><noframes id='CHlml'>

                  <legend id='CHlml'><style id='CHlml'><dir id='CHlml'><q id='CHlml'></q></dir></style></legend>
                    <tfoot id='CHlml'></tfoot>

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

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

                              <tbody id='CHlml'></tbody>
                            主站蜘蛛池模板: 国产福利小视频 | 国产一区二区 | 久草新在线 | 成人国产精品免费观看 | 97av视频在线 | 欧美成人视屏 | 亚洲午夜精品视频 | 黄色一级大片在线免费看产 | 国产精品96久久久久久 | 日韩色在线 | 国产在线观看 | 天天碰日日操 | 国产精品毛片 | 午夜欧美 | 天天天插 | 九九亚洲 | 免费黄色的视频 | 国产一区二区三区色淫影院 | 殴美成人在线视频 | 欧美中文字幕在线观看 | 亚洲人成人一区二区在线观看 | 91免费小视频 | 欧美高清成人 | 天天操天天插天天干 | 日本精品视频一区二区三区四区 | 999久久久国产精品 欧美成人h版在线观看 | 一区二区三区四区日韩 | 欧美一区二区综合 | 成人免费视频网站在线观看 | 亚洲欧美视频 | 亚洲高清在线 | 国产亚洲欧美另类一区二区三区 | 久久久久久久久久久久久9999 | 久久久精品综合 | 亚洲一区av | 欧美性受xxxx白人性爽 | 欧美在线网站 | 视频国产一区 | 91国在线观看 | 成人小视频在线免费观看 | 成人国产在线视频 |