2016-08-16 48 views
0

现在我通过kivy创建应用程序GUI其他部件之上显示ContextMenuTextItem,和我有一个问题如下:如何Kivy

当我点击标题上的“作业”,有一个菜单,问题是菜单被其他组件重叠(textinput ...)。我怎么能在textinput上显示这个菜单?请参阅图片了解更多详情。

Problem

#: import main todo 
    #: import ListAdapter kivy.adapters.listadapter.ListAdapter 
    #: import ListItemButton kivy.uix.listview.ListItemButton 
    Root: 
     task_input: task_input_view 
     task_list: tasks_list_view 
     text_input: text_input 
     BoxLayout: 
      orientation: 'vertical' 
      id: layout 

      AppMenu: 
       id: app_menu 
       top: root.height 
       cancel_handler_widget: layout 
       AppMenuTextItem: 
        text: "Job" 
        ContextMenu: 
         ContextMenuTextItem: 
           text: "Open" 
           on_release: root.show_load() 
         ContextMenuTextItem: 
           text: "Save" 
           on_release: root.show_save() 
         ContextMenuTextItem: 
           text: "SaveAs" 
         ContextMenuDivider: 
         ContextMenuTextItem: 
           text: "Exec" 

      BoxLayout: 
       size_hint_y: None 
       height: "40dp" 

       TextInput: 
        id: task_input_view 
        size_hint_x: 70 
       Button: 
        text: "Add" 
        size_hint_x: 15 
        on_press: root.add_task() 
       Button: 
        text: "Del" 
        size_hint_x: 15 
        on_press: root.del_task() 

      ListView: 
       id: tasks_list_view 
       adapter: 
        ListAdapter(data=[], cls=main.TaskButton) 

     TextInput: 
       id: text_input 
       text: '' 

回答

0

如何让这种类型的菜单有一个以上的解决方案,但基本上你需要的东西,将每个插件(或者你想在后台的小部件)的顶部显示。这可以在BoxLayout中实现,但效率不高。而不是Box,使其成为FloatLayout并添加处理您的菜单(该面板)作为最后一个小部件的小部件 - 这样它就会在它之前添加的每个小部件的顶部,并且菜单应该像所期望的那样行为。