繁体   English   中英

如何使用下拉列表启动 kivy 应用程序,该应用程序选择我将处理的数据,具体取决于从下拉列表中选择的选项?

[英]How to start a kivy app with a dropdown list that selects the data i will be working on, depending the selected option from te dropdown?

我有一个使用 ScreeManager 制作的 kivy 应用程序,该应用程序采用数据集,并根据用户选择的按钮显示不同的图形。 但现在我必须让用户选择 select 获取制作图表的信息的日期。

我认为最好的方法是使用下拉列表启动应用程序,让用户选择日期。 例如制作列表一月-二月-三月等等。 并在每个选项中提供每个月的信息。 让我向您展示一些我到现在为止的代码。

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen

Builder.load_string("""

<Menu>:
    BoxLayout:
        orientation: 'vertical'
        Button:
            text: 'alcohol'
            on_press:
                root.manager.transition.direction = 'left'
                root.manager.current = 'menu_alcohol'
        Button:
            text: 'sodas'
            on_press:
                root.manager.transition.direction = 'left'
                root.manager.current = 'menu_sodas'
        Button:
            text: 'juice'
            on_press:
                root.manager.transition.direction = 'left'
                root.manager.current = 'menu_juice'    
                   
<menu_alcohol>:
    BoxLayout:
        orientation: 'vertical'
        Button:
            text: 'first graph'
            on_press:
                root.manager.transition.direction = 'left'
                root.manager.current = '1_graph'                
        Button:
            text: 'second graph'
            on_press:
                root.manager.transition.direction = 'left'
                root.manager.current = '2_graph'
        Button:
            text: 'third graph'
            on_press:
                root.manager.transition.direction = 'left'
                root.manager.current = '3_graph'
        Button:
            text: 'return'
            on_press:
                root.manager.transition.direction = 'right'
                root.manager.current = 'Menu'

 <menu_sodas>:
    BoxLayout:
        orientation: 'vertical'
        Button:
            text: 'first graph'
            on_press:
                root.manager.transition.direction = 'left'
                root.manager.current = '1_graph'                
        Button:
            text: 'second graph'
            on_press:
                root.manager.transition.direction = 'left'
                root.manager.current = '2_graph'
        Button:
            text: 'third graph'
            on_press:
                root.manager.transition.direction = 'left'
                root.manager.current = '3_graph'
        Button:
            text: 'return'
            on_press:
                root.manager.transition.direction = 'right'
                root.manager.current = 'Menu'     
                
<menu_juice>:
    BoxLayout:
        orientation: 'vertical'
        Button:
            text: 'first graph'
            on_press:
                root.manager.transition.direction = 'left'
                root.manager.current = '1_graph'                
        Button:
            text: 'second graph'
            on_press:
                root.manager.transition.direction = 'left'
                root.manager.current = '2_graph'
        Button:
            text: 'third graph'
            on_press:
                root.manager.transition.direction = 'left'
                root.manager.current = '3_graph'
        Button:
            text: 'return'
            on_press:
                root.manager.transition.direction = 'right'
                root.manager.current = 'Menu'
                
""")

如您所见,我想在开始时添加下拉列表,为每个月提供选项。

我在这方面真的很新,所以您可能需要的任何额外信息都不要犹豫。

如果我们无法复制/粘贴您的代码,我们将无法帮助您,因为这意味着您不知道自己想要什么。 现在,你甚至不使用App 我建议您从Hello World 应用程序开始,然后再提出一个更精确的问题。

太多的文字和没有足够的工作示例。 专注,我们会帮助你。

我有一个使用 ScreeManager 制作的 kivy 应用程序,该应用程序采用数据集,并根据用户选择的按钮显示不同的图形。 但现在我必须让用户选择 select 获取制作图表的信息的日期。

我认为最好的方法是使用下拉列表启动应用程序,让用户选择日期。 例如制作列表一月-二月-三月等等。 并在每个选项中提供每个月的信息。 让我向您展示一些我到现在为止的代码。

如果我将您的文本重做为有效的反思,它将是:

  • 如何创建下拉菜单?
  • 如何为我的下拉列表赋值?
  • 当用户在下拉列表中选择一个值时,如何编译 function?
  • 如何更新我的图表?

这就是你想说的吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM