简体   繁体   中英

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. But now i have to give the user the option to select the date from where the information to make the graph is taken.

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 . I suggest you begin with a Hello World App and comeback with a more precise question.

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. But now i have to give the user the option to select the date from where the information to make the graph is taken.

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?
  • How can I update my graph?

Is that what you wanted to say?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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