【问题标题】:how to add heading in label, textinput and other widgets in kivy python如何在 kivy python 中的标签、文本输入和其他小部件中添加标题
【发布时间】:2018-01-09 12:59:08
【问题描述】:

如何在 kivy python 中添加标题/标题。我正在使用 TabbedPanel。谁能建议我如何在标签、按钮、TextInput 等中放置标题。我想为不同的小部件放置不同的标题。

【问题讨论】:

    标签: python kivy title textinput heading


    【解决方案1】:

    每个TabbedPanelItem 都有一个确定标题的文本属性。 Label 本身,TextInput,...没有标题。

    from kivy.app import App
    from kivy.lang import Builder
    
    
    kvstr = Builder.load_string("""
    TabbedPanel:
        do_default_tab: False
        TabbedPanelItem:
            text: "first heading"
            BoxLayout:
                Label: 
                    text:"I am the Label in the first Tab"
                Label: 
                    text:"I am another Label in the first Tab"
        TabbedPanelItem:
            text: "second heading"
            Label:
                text:"I am the Label in the second Tab"
    """)
    
    
    
    
    class MyAppApp(App):
        def build(self):
            return kvstr
    
    
    if __name__ == '__main__':
        MyAppApp().run()
    

    【讨论】:

    • 假设一个 TabeedPanel 中有 Label、TextInput、Button。有没有办法在标签、文本输入、按钮中给出标题??
    • 您可以将标签中的某些文本加粗,或将其与 BoxLayout 中的另一个标签放在一起。在 kivy 中,标题的概念对我来说并没有真正意义,也许可以更多地解释你的意思
    • BoxLayout: 方向: 'vertical' 标签: 标记: True text:"[b]也许我是一个标题[/b]" Label: text:"我是第一个标签中的另一个标签"像这样吗?
    • “ReferenceError:弱引用对象不再存在”此错误出现在“标记:真”行中。实际上需要的是:为标签提供标题,为 TextInput 提供标题,为 Button 提供标题,就像这样..(所有 TabbedPanel 中的相同过程)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-19
    • 1970-01-01
    • 1970-01-01
    • 2016-01-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多