<legend id='n65yP'><style id='n65yP'><dir id='n65yP'><q id='n65yP'></q></dir></style></legend>

<tfoot id='n65yP'></tfoot>

      <small id='n65yP'></small><noframes id='n65yP'>

        • <bdo id='n65yP'></bdo><ul id='n65yP'></ul>
        <i id='n65yP'><tr id='n65yP'><dt id='n65yP'><q id='n65yP'><span id='n65yP'><b id='n65yP'><form id='n65yP'><ins id='n65yP'></ins><ul id='n65yP'></ul><sub id='n65yP'></sub></form><legend id='n65yP'></legend><bdo id='n65yP'><pre id='n65yP'><center id='n65yP'></center></pre></bdo></b><th id='n65yP'></th></span></q></dt></tr></i><div id='n65yP'><tfoot id='n65yP'></tfoot><dl id='n65yP'><fieldset id='n65yP'></fieldset></dl></div>

        在 python 中为移动应用程序创建主菜单

        时间:2023-10-09

        <small id='UNGJt'></small><noframes id='UNGJt'>

        <legend id='UNGJt'><style id='UNGJt'><dir id='UNGJt'><q id='UNGJt'></q></dir></style></legend>

              <tbody id='UNGJt'></tbody>
              <tfoot id='UNGJt'></tfoot>
              • <bdo id='UNGJt'></bdo><ul id='UNGJt'></ul>
                <i id='UNGJt'><tr id='UNGJt'><dt id='UNGJt'><q id='UNGJt'><span id='UNGJt'><b id='UNGJt'><form id='UNGJt'><ins id='UNGJt'></ins><ul id='UNGJt'></ul><sub id='UNGJt'></sub></form><legend id='UNGJt'></legend><bdo id='UNGJt'><pre id='UNGJt'><center id='UNGJt'></center></pre></bdo></b><th id='UNGJt'></th></span></q></dt></tr></i><div id='UNGJt'><tfoot id='UNGJt'></tfoot><dl id='UNGJt'><fieldset id='UNGJt'></fieldset></dl></div>

                1. 本文介绍了在 python 中为移动应用程序创建主菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我不知道如何开始显示主菜单的代码.我希望这个主菜单显示 5 个不同的选项,当单击其中一个选项时,它会打开该页面/选项.我也安装了 Kivy,总体目标是制作一个移动应用程序.我的 python 经验很低,所以我实际上并没有为此目标编写任何代码,但我有一个完整的布局,我希望应用程序看起来像.

                  更新:

                  这是我目前所拥有的.

                  mainMenu = {}mainMenu ['1'] = '选项 1'mainMenu ['2'] = '选项 2'mainMenu ['3'] = '选项 3'mainMenu ['4'] = '选项 4'mainMenu ['5'] = '选项 5'打印(主菜单)而真:选择 = 输入()如果选择 == '1':print('第 1 页')elif 选择 == '2':打印('第 2 页')elif 选择 == '3':打印('第 3 页')elif 选择 == '4':print('第 4 页')elif 选择 == '5':print('第 5 页')休息

                  解决方案

                  请参考下面的示例并根据您的要求进行修改.我建议阅读大量文档

                  I'm have trouble figuring out how to begin a code that displays a main menu. I want this main menu to display 5 different options that when on of them is clicked, it open that page/option. I also have Kivy installed, and the overall goal is to make a mobile app. My python experience is low, so I haven't actually written out any code for this goal but I have a full layout of what I want the app to look like.

                  Updated:

                  This is what I have so far.

                  mainMenu = {}
                  mainMenu ['1'] = 'Option 1'
                  mainMenu ['2'] = 'Option 2'
                  mainMenu ['3'] = 'Option 3'
                  mainMenu ['4'] = 'Option 4'
                  mainMenu ['5'] = 'Option 5'
                  
                  print(mainMenu)
                  while True:
                      selection = input()
                      if selection == '1':
                          print('Page 1')
                      elif selection == '2':
                          print('Page 2')
                      elif selection == '3':
                          print('Page 3')
                      elif selection == '4':
                          print('Page 4')
                      elif selection == '5':
                          print('Page 5')
                          break
                  

                  解决方案

                  Please refer to the example below and modify it as per your requirementst. I recommend reading the documentation abound Kivy Dropdown list.

                  Example

                  main.py

                  from kivy.app import App
                  from kivy.uix.dropdown import DropDown
                  from kivy.uix.floatlayout import FloatLayout
                  from kivy.config import Config
                  
                  
                  class SubMenu(DropDown):
                      pass
                  
                  
                  class MainMenu(FloatLayout):
                  
                      def display_selected_submenu(self, instance, x):
                          print("Page " + x)
                  
                  
                  class TestApp(App):
                      title = "Kivy Drop-Down List Demo"
                      Config.set("graphics", "width", "800")
                      Config.set("graphics", "height", "480")
                  
                      def build(self):
                          return MainMenu()
                  
                  
                  if __name__ == '__main__':
                      TestApp().run()
                  

                  test.kv

                  #:kivy 1.10.0
                  #:import Factory kivy.factory.Factory
                  
                  <CustomButton@Button>:
                      size_hint_y: None
                      height: 40
                      font_size: 18
                  
                  
                  <SubMenu>:
                      on_select: app.root.display_selected_submenu(self, args[1])
                  
                      CustomButton:
                          id: button1
                          text: 'Open'
                          txt: "1"
                          on_release: root.select(self.txt)
                  
                      CustomButton:
                          id: button2
                          text: 'Save'
                          txt: "2"
                          on_release: root.select(self.txt)
                  
                      CustomButton:
                          id: button3
                          text: 'Exit'
                          txt: "3"
                          on_release: root.select(self.txt)
                  
                  <MainMenu>:
                      canvas.before:
                          Color:
                              rgba: 0.5, 0.5, 0.5, 0.5
                          Rectangle:
                              pos: 0,0
                              size: self.width, self.height
                  
                      Button:
                          id: mainbutton
                          text: "File Menu"
                          font_size: 20
                          size_hint: None, None
                          size: 150, 50
                          top: root.top
                          on_release: Factory.SubMenu().open(self)
                  

                  Output

                  这篇关于在 python 中为移动应用程序创建主菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Kivy - 为 reStructuredText 创建样式按钮 下一篇:在kivy中的触摸事件上旋转对象

                  相关文章

                  最新文章

                  1. <tfoot id='UMP5v'></tfoot>
                  2. <i id='UMP5v'><tr id='UMP5v'><dt id='UMP5v'><q id='UMP5v'><span id='UMP5v'><b id='UMP5v'><form id='UMP5v'><ins id='UMP5v'></ins><ul id='UMP5v'></ul><sub id='UMP5v'></sub></form><legend id='UMP5v'></legend><bdo id='UMP5v'><pre id='UMP5v'><center id='UMP5v'></center></pre></bdo></b><th id='UMP5v'></th></span></q></dt></tr></i><div id='UMP5v'><tfoot id='UMP5v'></tfoot><dl id='UMP5v'><fieldset id='UMP5v'></fieldset></dl></div>

                      <small id='UMP5v'></small><noframes id='UMP5v'>

                      <legend id='UMP5v'><style id='UMP5v'><dir id='UMP5v'><q id='UMP5v'></q></dir></style></legend>
                      • <bdo id='UMP5v'></bdo><ul id='UMP5v'></ul>