簡體   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