pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <i id='RvoqV'><tr id='RvoqV'><dt id='RvoqV'><q id='RvoqV'><span id='RvoqV'><b id='RvoqV'><form id='RvoqV'><ins id='RvoqV'></ins><ul id='RvoqV'></ul><sub id='RvoqV'></sub></form><legend id='RvoqV'></legend><bdo id='RvoqV'><pre id='RvoqV'><center id='RvoqV'></center></pre></bdo></b><th id='RvoqV'></th></span></q></dt></tr></i><div class="kgmqqym" id='RvoqV'><tfoot id='RvoqV'></tfoot><dl id='RvoqV'><fieldset id='RvoqV'></fieldset></dl></div>
    <tfoot id='RvoqV'></tfoot>
        <bdo id='RvoqV'></bdo><ul id='RvoqV'></ul>
    1. <small id='RvoqV'></small><noframes id='RvoqV'>

      <legend id='RvoqV'><style id='RvoqV'><dir id='RvoqV'><q id='RvoqV'></q></dir></style></legend>
      1. Kivy:從python代碼改變屏幕

        Kivy: changing screen from python code(Kivy:從python代碼改變屏幕)
        <tfoot id='pueHL'></tfoot>

        1. <i id='pueHL'><tr id='pueHL'><dt id='pueHL'><q id='pueHL'><span id='pueHL'><b id='pueHL'><form id='pueHL'><ins id='pueHL'></ins><ul id='pueHL'></ul><sub id='pueHL'></sub></form><legend id='pueHL'></legend><bdo id='pueHL'><pre id='pueHL'><center id='pueHL'></center></pre></bdo></b><th id='pueHL'></th></span></q></dt></tr></i><div class="00wqmuy" id='pueHL'><tfoot id='pueHL'></tfoot><dl id='pueHL'><fieldset id='pueHL'></fieldset></dl></div>
              <bdo id='pueHL'></bdo><ul id='pueHL'></ul>
              <legend id='pueHL'><style id='pueHL'><dir id='pueHL'><q id='pueHL'></q></dir></style></legend>
            • <small id='pueHL'></small><noframes id='pueHL'>

                    <tbody id='pueHL'></tbody>

                • 本文介紹了Kivy:從python代碼改變屏幕的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在組裝一個 Kivy 應用程序,但在解決如何在 python 代碼中任意選擇的點更改屏幕時遇到了一些問題.

                  I'm putting together a Kivy app and am having some problems working out how to change screens at an arbitrarily chosen point within the python code.

                  在下面的例子中,我想知道如何通過執行一個函數 my main.pyScreen2 切換回 Screen1文件.

                  In the following example, I would like to know how to switch from Screen2 back to Screen1 by executing a function my main.py file.

                  這是我的 main.py:

                  # -*- coding: utf-8 -*-
                  
                  from kivy.app import App
                  from kivy.uix.screenmanager import ScreenManager, Screen, NoTransition
                  from kivy.properties import ObjectProperty
                  from functools import partial
                  
                  import random
                  import time
                  
                  class ScreenOne(Screen):
                      pass
                  
                  class ScreenTwo(Screen):
                  
                      def __init__(self,**kwargs):
                          super(ScreenTwo, self).__init__(**kwargs)
                          self.displayScreenThenLeave()
                  
                      def displayScreenThenLeave(self):
                          # 'time.sleep(3)' is a stand-in for "execute some code here"
                          time.sleep(3)
                          self.changeScreen()
                  
                      # I want this function to send the user back to ScreenOne.
                      def changeScreen(self):
                          pass
                  
                  class Manager(ScreenManager):
                  
                      screen_one = ObjectProperty(None)
                      screen_two = ObjectProperty(None)
                  
                  class ScreensApp(App):
                  
                      def build(self):
                          m = Manager(transition=NoTransition())
                          return m
                  
                  if __name__ == "__main__":
                      ScreensApp().run()
                  

                  這是我的 screens.kv:

                  #:kivy 1.8.0
                  
                  <ScreenOne>:
                  
                      BoxLayout:
                          orientation: "vertical"
                          size: root.size
                          spacing: 20
                          padding: 20
                  
                          Label:
                              text: "Main Menu"
                          Button:
                              text: "Button 1"
                              on_release: root.manager.current = "screen2"
                  
                  <ScreenTwo>:        
                  
                      BoxLayout:
                          orientation: "vertical"
                          size: root.size
                          spacing: 20
                          padding: 20
                  
                          Label:
                              id: label
                              text: "Welcome to Screen 2, please wait three seconds"
                  
                  <Manager>:
                      id: screen_manager
                  
                      screen_one: screen_one
                      screen_two: screen_two
                  
                      ScreenOne:
                          id: screen_one
                          name: "screen1"
                          manager: screen_manager
                  
                      ScreenTwo:
                          id: screen_two
                          name: "screen2"
                          manager: screen_manager
                  

                  應該很明顯,我是 Kivy 的初學者,所以如果你能告訴我我需要更改的確切內容,包括應該使用的特定語法,我將不勝感激.

                  As should be pretty evident, I'm a total beginner at Kivy, so I'd really appreciate it if you could show me exactly what I need to change, including the specific syntax that should be used.

                  提前感謝您的時間和智慧.

                  Thanks in advance for your time and wisdom.

                  推薦答案

                  這是一個基于您的附加信息的簡單游戲"示例.當玩家進入游戲畫面時,他們的生命值正在流血.當池達到零時,它們被送回菜單屏幕.

                  Here is a simple 'game' example based on your additional info. When a player enters the game screen, their health points are bleeding. When the pool reaches zero, they are sent back to menu screen.

                  main.py:

                  #!/usr/bin/env python
                  # -*- coding: utf-8 -*-
                  
                  from kivy.app import App
                  from kivy.uix.screenmanager import ScreenManager, Screen, NoTransition
                  from kivy.properties import ObjectProperty, NumericProperty
                  
                  import time
                  import threading
                  
                  
                  class ScreenOne(Screen):
                      pass
                  
                  
                  class ScreenTwo(Screen):
                      health_points = NumericProperty(100)
                  
                      def __init__(self, **kwargs):
                          super(ScreenTwo, self).__init__(**kwargs)
                  
                      def on_health_points(self, instance, value):
                          if value < 1:
                              self.changeScreen()
                  
                      def on_enter(self, *args):
                          thread = threading.Thread(target=self.bleed)
                          thread.daemon = True
                          thread.start()
                  
                      def bleed(self, *args):
                          while self.health_points > 0:
                              self.health_points -= 5
                              time.sleep(0.1)
                  
                      def displayScreenThenLeave(self):
                          self.changeScreen()
                  
                      def changeScreen(self):
                          if self.manager.current == 'screen1':
                              self.manager.current = 'screen2'
                          else:
                              self.manager.current = 'screen1'
                  
                  
                  class Manager(ScreenManager):
                  
                      screen_one = ObjectProperty(None)
                      screen_two = ObjectProperty(None)
                  
                  
                  class ScreensApp(App):
                  
                      def build(self):
                          m = Manager(transition=NoTransition())
                          return m
                  
                  if __name__ == "__main__":
                      ScreensApp().run()
                  

                  screens.kv:

                  screens.kv:

                  #:kivy 1.8.0
                  
                  <ScreenOne>:
                  
                      BoxLayout:
                          orientation: "vertical"
                          size: root.size
                          spacing: 20
                          padding: 20
                  
                          Label:
                              text: "Main Menu"
                          Button:
                              text: "Button 1"
                              on_release:
                                  root.manager.current = "screen2"
                                  # reset health_points
                                  root.manager.ids.screen_two.health_points = 100
                  
                  <ScreenTwo>:        
                  
                      BoxLayout:
                          orientation: "vertical"
                          size: root.size
                          spacing: 20
                          padding: 20
                  
                          Label:
                              id: label
                              text: "health points: " + str(root.health_points)
                  
                  <Manager>:
                      id: screen_manager
                  
                      screen_one: screen_one
                      screen_two: screen_two
                  
                      ScreenOne:
                          id: screen_one
                          name: "screen1"
                          manager: screen_manager
                  
                      ScreenTwo:
                          id: screen_two
                          name: "screen2"
                          manager: screen_manager
                  

                  這篇關于Kivy:從python代碼改變屏幕的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                  Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)

                        <legend id='hvbvW'><style id='hvbvW'><dir id='hvbvW'><q id='hvbvW'></q></dir></style></legend>
                        <i id='hvbvW'><tr id='hvbvW'><dt id='hvbvW'><q id='hvbvW'><span id='hvbvW'><b id='hvbvW'><form id='hvbvW'><ins id='hvbvW'></ins><ul id='hvbvW'></ul><sub id='hvbvW'></sub></form><legend id='hvbvW'></legend><bdo id='hvbvW'><pre id='hvbvW'><center id='hvbvW'></center></pre></bdo></b><th id='hvbvW'></th></span></q></dt></tr></i><div class="aeueosq" id='hvbvW'><tfoot id='hvbvW'></tfoot><dl id='hvbvW'><fieldset id='hvbvW'></fieldset></dl></div>
                        <tfoot id='hvbvW'></tfoot>
                      1. <small id='hvbvW'></small><noframes id='hvbvW'>

                          <bdo id='hvbvW'></bdo><ul id='hvbvW'></ul>

                              <tbody id='hvbvW'></tbody>

                            主站蜘蛛池模板: 亮点云建站-网站建设制作平台 | 路面机械厂家 | 家德利门业,家居安全门,别墅大门 - 安徽家德利门业有限公司 | 高博医疗集团上海阿特蒙医院| 泰州物流公司_泰州货运公司_泰州物流专线-东鑫物流公司 | 欧盟ce检测认证_reach检测报告_第三方检测中心-深圳市威腾检验技术有限公司 | 钣金加工厂家-钣金加工-佛山钣金厂-月汇好| 阿米巴企业经营-阿米巴咨询管理-阿米巴企业培训-广东键锋企业管理咨询有限公司 | 首页_中夏易经起名网| 合肥制氮机_合肥空压机厂家_安徽真空泵-凯圣精机 | 液晶拼接屏厂家_拼接屏品牌_拼接屏价格_监控大屏—北京维康 | 电线电缆厂家|沈阳电缆厂|电线厂|沈阳英联塑力线缆有限公司 | 东莞市踏板石餐饮管理有限公司_正宗桂林米粉_正宗桂林米粉加盟_桂林米粉加盟费-东莞市棒子桂林米粉 | 爱佩恒温恒湿测试箱|高低温实验箱|高低温冲击试验箱|冷热冲击试验箱-您身边的模拟环境试验设备技术专家-合作热线:400-6727-800-广东爱佩试验设备有限公司 | 西安展台设计搭建_西安活动策划公司_西安会议会场布置_西安展厅设计西安旭阳展览展示 | 海鲜池-专注海鲜鱼缸、移动海鲜缸、饭店鱼缸设计定做-日晟水族厂家 | 磁力抛光机_磁力研磨机_磁力去毛刺机_精密五金零件抛光设备厂家-冠古科技 | 江苏大隆凯科技有限公司 | 济南玻璃安装_济南玻璃门_济南感应门_济南玻璃隔断_济南玻璃门维修_济南镜片安装_济南肯德基门_济南高隔间-济南凯轩鹏宇玻璃有限公司 | 电销卡_北京电销卡_包月电话卡-豪付网络 | 衡阳耐适防护科技有限公司——威仕盾焊接防护用品官网/焊工手套/焊接防护服/皮革防护手套 | B2B网站_B2B免费发布信息网站_B2B企业贸易平台 - 企资网 | 药品仓库用除湿机-变电站用防爆空调-油漆房用防爆空调-杭州特奥环保科技有限公司 | 氟塑料磁力泵-不锈钢离心泵-耐腐蚀化工泵厂家「皖金泵阀」 | 免费分销系统 — 分销商城系统_分销小程序开发 -【微商来】 | 品牌设计_VI设计_电影海报设计_包装设计_LOGO设计-Bacross新越品牌顾问 | 长沙发电机-湖南发电机-柴油发电机供应厂家-长沙明邦智能科技 | 专业的压球机生产线及解决方案厂家-河南腾达机械厂 | 水篦子|雨篦子|镀锌格栅雨水篦子|不锈钢排水篦子|地下车库水箅子—安平县云航丝网制品厂 | 胀套-锁紧盘-风电锁紧盘-蛇形联轴器「厂家」-瑞安市宝德隆机械配件有限公司 | 非小号行情 - 专业的区块链、数字藏品行情APP、金色财经官网 | 减速机三参数组合探头|TSM803|壁挂式氧化锆分析仪探头-安徽鹏宸电气有限公司 | 耐压仪-高压耐压仪|徐吉电气| 云南外加剂,云南速凝剂,云南外加剂代加工-普洱澜湄新材料科技有限公司 | 仪器仪表网 - 永久免费的b2b电子商务平台 | 伸缩节_伸缩器_传力接头_伸缩接头_巩义市联通管道厂 | 电渗析,废酸回收,双极膜-山东天维膜技术有限公司 | 沈阳建筑设计公司_加固改造设计_厂房设计_设计资质加盟【金辉设计】 | 多物理场仿真软件_电磁仿真软件_EDA多物理场仿真软件 - 裕兴木兰 | 南京和瑞包装有限公司| CTP磁天平|小电容测量仪|阴阳极极化_双液系沸点测定仪|dsj电渗实验装置-南京桑力电子设备厂 |