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

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

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

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

      包裝 Kivy 標(biāo)簽的文本

      Wrapping the text of a Kivy Label(包裝 Kivy 標(biāo)簽的文本)

        <small id='1J9v0'></small><noframes id='1J9v0'>

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

                <tbody id='1J9v0'></tbody>
            • <legend id='1J9v0'><style id='1J9v0'><dir id='1J9v0'><q id='1J9v0'></q></dir></style></legend>
              1. 本文介紹了包裝 Kivy 標(biāo)簽的文本的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問(wèn)題描述

                所以我正在使用 Kivy GUI 編寫程序,我真的不想使用 .kv 文件,而是將其全部寫入 python 文件.問(wèn)題是在 MainScreen 類中,我想添加一些標(biāo)簽,但我無(wú)法根據(jù)窗口大小的變化使它們的文本換行.當(dāng)我嘗試 self.size 時(shí),我只得到 100x100.我已經(jīng)嘗試了 Kivy 教程書中的所有建議,但沒(méi)有任何效果.我知道我可以使用 使文本多行或設(shè)置標(biāo)準(zhǔn)標(biāo)簽大小,但這不是一個(gè)真正的解決方案.我需要標(biāo)簽大小和文本來(lái)跟隨整個(gè)窗口的變化和要換行的文本.

                So I am writting a program using the Kivy GUI and I really don't want to use a .kv file but write it all in the python file. The problem is that inside the MainScreen Class i want to add some Labels but i cannot make their text to wrap according to window size changes. When i try self.size I only get 100x100. I have tried all the suggestions from the Kivy tutorial book but nothing worked. I know i could just make the text multiline using or set a standard Label size, but that wouldn't be a real solution. I need the Label size and text to follow the whole window changes and the text to be wrapped.

                我已經(jīng)簡(jiǎn)化了程序,只關(guān)注這個(gè)問(wèn)題.

                I have simplified the program to focus just on this issue.

                代碼如下:

                from kivy.app import App
                from kivy.uix.floatlayout import FloatLayout
                from kivy.uix.label import Label
                from kivy.graphics import Rectangle, Color
                
                
                class MainScreen(FloatLayout):
                    """MAIN WINDOW CLASS"""
                
                    def __init__(self, **kwargs):
                        super(MainScreen, self).__init__(**kwargs)
                
                        with self.canvas.before:
                            Color(0.988, 0.725, 0.074, 1, mode='rgba')
                            self.rect = Rectangle(pos=self.pos, size=self.size)
                        self.bind(size=self.update_rect)
                
                
                        #TITLE LABEL
                        self.add_widget(Label(text="A very Long Sentence that needs to be wrapped.",
                                              bold = True,
                                              font_size="20sp",
                                              pos_hint={'center_x': 0.5, 'center_y': .85},
                                              size_hint=(None, None),
                                              halign="center",
                                              color=(0.055, 0.235, 0.541, 1)))
                
                    def update_rect(self, *args):
                        """FUNCTION TO UPDATE THE RECATANGLE OF CANVAS TO FIT THE WHOLE SCREEN OF MAINSCREEN ALWAYS"""
                        self.rect.pos = self.pos
                        self.rect.size = self.size
                
                class main(App):
                    """BUILDING THE APP"""
                    def build(self):
                        return MainScreen()
                
                if __name__ == "__main__":
                    main().run()
                

                謝謝.

                推薦答案

                所以在對(duì)我的問(wèn)題進(jìn)行了深思熟慮并嘗試了不同的方法之后,我最終得到了一個(gè)合適的僅 python"解決方案.

                So after giving my problem a lot of thought and experimenting with different approaches i ended up with a proper "just python" solution.

                首先我的回答是基于 1) 官方 Kivy 教程建議,2) 畫布方法的常用操作和 3) 對(duì)變量范圍的謹(jǐn)慎處理.

                First of all my answer is based on 1) the official Kivy Tutorials suggestions, 2) the usual manipulation of canvas approach and 3) careful handling on variable scope.

                因此標(biāo)簽設(shè)置類似于 Kivy 教程書中建議的設(shè)置.需要有一個(gè)函數(shù)來(lái)更新標(biāo)簽位置及其文本大小(此處為 setting_function)以與標(biāo)簽大小綁定.此外,我將 Label 分配給一個(gè)變量,以便以后可以輕松引用它.

                So the Label settings are similar to the ones suggested by the Kivy tutorial book. There needs to be a function that updates the Label position and it's text size (the setting_function here) to bind with the Label size. Also I assigned the Label to a variable so I could easily refer to it later.

                在所有這些更改之后,我的代碼如下所示:

                After all those changes my code looks like this:

                from kivy.app import App
                from kivy.uix.floatlayout import FloatLayout
                from kivy.uix.label import Label
                from kivy.graphics import Rectangle, Color
                
                
                class MainScreen(FloatLayout, Label):
                    """MAIN WINDOW CLASS"""
                
                    def __init__(self, **kwargs):
                        super(MainScreen, self).__init__(**kwargs)
                
                        with self.canvas.before:
                            Color(0.988, 0.725, 0.074, 1, mode='rgba')
                            self.rect = Rectangle(pos=self.pos, size=self.size)
                        self.bind(size=self.update_rect)
                
                        #TITLE LABEL
                        self.titlos = Label(text="A very Long Sentence that needs to be wrapped.",
                                              bold = True,
                                              text_size=(None,None),
                                              font_size="20sp",
                                              pos_hint={'center_x': 0.5, 'center_y': .85},
                                              size_hint_y=None,
                                              size = self.size,
                                              height=self.texture_size[1],
                                              halign="center",
                                              valign = "middle",
                                              color=(0.055, 0.235, 0.541, 1))
                
                        self.add_widget(self.titlos)
                        self.titlos.bind(size=self.setting_function)
                
                    def setting_function(self, *args):
                        """FUNCTION TO UPDATE THE LABEL TO ADJUST ITSELF ACCORDING TO SCREEN SIZE CHANGES"""
                        self.titlos.pos_hint = {'center_x': 0.5, 'center_y': .85}
                        self.titlos.text_size=self.size
                
                    def update_rect(self, *args):
                        """FUNCTION TO UPDATE THE RECATANGLE OF CANVAS TO FIT THE WHOLE SCREEN OF MAINSCREEN ALWAYS"""
                        self.rect.pos = self.pos
                        self.rect.size = self.size
                
                
                class main(App):
                    """BUILDING THE APP"""
                    def build(self):
                        return MainScreen()
                
                if __name__ == "__main__":
                    main().run()
                

                上面的代碼確實(shí)符合我在問(wèn)題中設(shè)置的要求.很容易將它用于您自己的項(xiàng)目.只需注意變量的范圍并使用大量打印消息進(jìn)行檢查.

                The above code does meet the requirements I set in my question. It is easy to use it to your own projects. Just take care of the variables' scopes and use lots of print messages for checking.

                最后我想只使用 Python 來(lái)解決這個(gè)問(wèn)題(而不僅僅是使用 kivy 語(yǔ)言來(lái)處理這些問(wèn)題就像小菜一碟)的原因是我想要在運(yùn)行時(shí)動(dòng)態(tài)更改變量,即用作標(biāo)簽參數(shù).而且我只需要找出答案,因?yàn)槲液芄虉?zhí).

                Finally the reason I wanted to use just Python to solve this problem (and not just use kivy language which handles those issues like a piece of cake) is that I want to have variables that are dynamically changed during the run time, that are used as the Label parameters. And also I just had to find out because I am stubborn.

                謝謝.

                這篇關(guān)于包裝 Kivy 標(biāo)簽的文本的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(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ī)器人沒(méi)有響應(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)更改角色顏色)

                • <tfoot id='gTuT4'></tfoot>

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

                    1. <legend id='gTuT4'><style id='gTuT4'><dir id='gTuT4'><q id='gTuT4'></q></dir></style></legend>
                      • <bdo id='gTuT4'></bdo><ul id='gTuT4'></ul>
                          <tbody id='gTuT4'></tbody>

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

                          主站蜘蛛池模板: 视频在线一区二区 | 欧美阿v | 亚洲精品小视频在线观看 | 亚洲国产成人精 | 亚洲欧美中文字幕在线观看 | 高清成人免费视频 | 久久精品黄色 | 日本精品视频在线观看 | 91成人在线视频 | 国产精彩视频一区 | 中文字幕 国产精品 | 国产电影一区二区在线观看 | 亚洲综合色视频在线观看 | av二区三区 | 日本电影韩国电影免费观看 | 欧美视频成人 | 日本电影免费完整观看 | 亚洲在线 | 久久久青草婷婷精品综合日韩 | 九九热视频这里只有精品 | 免费久久久 | 久久久精品视频免费 | 黄色大片免费看 | 久久黄色精品视频 | 在线亚洲一区二区 | 九九免费在线视频 | 欧美精品一区二区三区在线 | 亚洲精品久久久一区二区三区 | 天堂色网 | 九九热热九九 | 国产黄a一级 | 亚洲精品一区二区三区丝袜 | 新超碰97 | 亚洲免费观看 | 91视频网 | 日韩欧美一级精品久久 | 可以免费观看的av片 | 黄网站涩免费蜜桃网站 | 亚洲成av人片在线观看 | 日本视频在线播放 | 午夜精品福利视频 |