简体   繁体   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?

I have a kivy app that i made with ScreeManager, the app takes a dataset and it shows diferent graphs depending on the button the user selects.我有一个使用 ScreeManager 制作的 kivy 应用程序,该应用程序采用数据集,并根据用户选择的按钮显示不同的图形。 But now i have to give the user the option to select the date from where the information to make the graph is taken.但现在我必须让用户选择 select 获取制作图表的信息的日期。

I thought that the best way to do this is to start the app with a dropdown list that lets the user choose the date.我认为最好的方法是使用下拉列表启动应用程序,让用户选择日期。 For example making the list january - february - march and so on.例如制作列表一月-二月-三月等等。 And in each option give the information for each month.并在每个选项中提供每个月的信息。 Let me show you some of the code i have till now.让我向您展示一些我到现在为止的代码。

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'
                
""")

As you can see i want to the add the dropdown at the begining, giving options for each month.如您所见,我想在开始时添加下拉列表,为每个月提供选项。

I'm really new at this so any extra information you may need dont hesitate to ask.我在这方面真的很新,所以您可能需要的任何额外信息都不要犹豫。

If we can't copy/paste your code, we won't help you because it means you don't know what you want.如果我们无法复制/粘贴您的代码,我们将无法帮助您,因为这意味着您不知道自己想要什么。 Right now, you don't even use App .现在,你甚至不使用App I suggest you begin with a Hello World App and comeback with a more precise question.我建议您从Hello World 应用程序开始,然后再提出一个更精确的问题。

Too much text and not enough working example.太多的文字和没有足够的工作示例。 Focus and we will help you.专注,我们会帮助你。

I have a kivy app that i made with ScreeManager, the app takes a dataset and it shows diferent graphs depending on the button the user selects.我有一个使用 ScreeManager 制作的 kivy 应用程序,该应用程序采用数据集,并根据用户选择的按钮显示不同的图形。 But now i have to give the user the option to select the date from where the information to make the graph is taken.但现在我必须让用户选择 select 获取制作图表的信息的日期。

I thought that the best way to do this is to start the app with a dropdown list that lets the user choose the date.我认为最好的方法是使用下拉列表启动应用程序,让用户选择日期。 For example making the list january - february - march and so on.例如制作列表一月-二月-三月等等。 And in each option give the information for each month.并在每个选项中提供每个月的信息。 Let me show you some of the code i have till now.让我向您展示一些我到现在为止的代码。

If I redo your text into a valid reflexion it would be:如果我将您的文本重做为有效的反思,它将是:

  • How can I create a dropdown?如何创建下拉菜单?
  • How to give values to my dropdown?如何为我的下拉列表赋值?
  • How can I make a function compile when the user choose a value on a dropdown?当用户在下拉列表中选择一个值时,如何编译 function?
  • How can I update my graph?如何更新我的图表?

Is that what you wanted to say?这就是你想说的吗?

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

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