【问题标题】:Create a dropdown menu at the top of the window在窗口顶部创建一个下拉菜单
【发布时间】:2017-10-28 13:24:30
【问题描述】:

如何在 Kivy 的窗口顶部创建下拉菜单(如“文件”、“编辑”和“工具”)?

【问题讨论】:

    标签: python kivy kivy-language


    【解决方案1】:

    ActionBar怎么样

    from kivy.app import App
    from kivy.lang import Builder
    
    kv_str = Builder.load_string('''
    ActionBar:
        pos_hint: {'top':1}
        ActionView:
            use_separator: True
            ActionPrevious:
                title: 'Example App'
                with_previous: False
            ActionButton:
                text: 'File'
            ActionButton:
                text: 'Edit'
            ActionGroup:
                text: 'Tools' 
                mode: 'spinner'
                ActionButton:
                    text: 'Tool1'
                ActionButton:
                    text: 'Tool2'
                ActionButton:
                    text: 'Tool3'
                ActionButton:
                    text: 'Tool4'
    ''')
    
    
    class ExampleApp(App):
        def build(self):
            return kv_str
    
    if __name__ =='__main__':
        ExampleApp().run()
    

    【讨论】:

      猜你喜欢
      • 2018-12-16
      • 2017-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-31
      • 2017-02-28
      • 1970-01-01
      相关资源
      最近更新 更多