• <tfoot id='VCTdD'></tfoot>

    <legend id='VCTdD'><style id='VCTdD'><dir id='VCTdD'><q id='VCTdD'></q></dir></style></legend>
    1. <small id='VCTdD'></small><noframes id='VCTdD'>

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

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

        在第二个寡妇中单击按钮打印(文本)作为标签(更

        时间:2023-10-09
        <tfoot id='kcUP4'></tfoot>

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

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

                  <legend id='kcUP4'><style id='kcUP4'><dir id='kcUP4'><q id='kcUP4'></q></dir></style></legend>
                • 本文介绍了在第二个寡妇中单击按钮打印(文本)作为标签(更新标签)后,python和kivy在第一个窗口中输入文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想创建一个简单的应用程序,我是 python 新手,这个应用程序包含两个窗口,首先窗口有一个按钮(保存)和两个输入文本.在第二个窗口我们有四个标签.单击第一个窗口中的按钮后,第二个窗口中的标签(在此处打​​印用户名 1)根据第一个窗口中的文本输入而变化.

                  I want create simple app and I'm new in python, this app contain two windows , at first windows have one button (Save) and two input text. at the second windows we have four label. after click on button in first windows the label ( username 1 print here ) in second windows change according text input in first windows.enter image description here enter image description here

                  when I run my code the label not change, any one can help me what is wrong.

                  python code

                  from kivy.app import App
                  from kivy.uix.boxlayout import BoxLayout
                  from kivy.lang import Builder
                  from kivy.uix.screenmanager import Screen,ScreenManager
                  from kivy.properties import ObjectProperty
                  
                  class Main_windows(Screen):
                      f_user = ObjectProperty(None)
                      player = ObjectProperty(None)
                  
                      def btn_save(self):
                         self.player=self.f_user.text
                  class Second_windows(Screen):
                      pass
                  class Windows_manager(ScreenManager):
                      pass
                  kv=Builder.load_file("vop.kv")
                  
                  class Vop(App):
                      def build(self):
                      return kv
                  

                  kivy code :

                  ## Collect our windows to windows manager ##
                  Windows_manager:
                    Main_windows:
                    Second_windows:
                  
                  
                  <Main_windows>:
                    f_user:f_user
                  
                  
                  
                    name:"main_windows"
                    BoxLayout:
                      orientation:"vertical"
                      Label:
                          text: "Please insert Name of First Player"
                  
                      TextInput:
                          id: f_user
                          multiline:False
                      Label:
                          text: "please insert Name of Second Player"
                      TextInput:
                          id: s_user
                          multiline:False
                  
                      Button:
                          text:"Save"
                          on_release:
                  
                              app.root.current="second_windows"
                              root.manager.transition.direction="up"
                              root.btn_save()
                  
                  
                  <Second_Windows>:
                  
                    player:player
                  
                  
                    name:"second_windows"
                    BoxLayout:
                      orientation :"vertical"
                  
                      BoxLayout:
                          orientation:"horizontal"
                  
                          Label:
                              id:player
                              text:"User number one"
                          Label:
                              id:player2
                              text:"User number Two"
                      BoxLayout:
                          orientation:"horizontal"
                          Label:
                              text: "user name 1 print here"
                          Label:
                              text: "user name 2 print here"
                      Button:
                          text:"Back"
                          on_release:
                              app.root.current="main_windows"
                              root.manager.transition.direction="down"
                  

                  解决方案

                  In the code, the main objective is getting data from one class to the other. This method works only when we are dealing with Screen and ScreenManager. I'm also trying to figure out how we can transfer data between classes. If I figured out the other method, I will update my answer.

                  python code:

                  from kivy.app import App
                  from kivy.lang import Builder
                  from kivy.uix.screenmanager import Screen,ScreenManager
                  from kivy.properties import ObjectProperty
                  
                  class Main_windows(Screen):
                      f_user = ObjectProperty(None)
                         
                  class Second_windows(Screen):
                      player1 = ObjectProperty(None)
                  
                  class Windows_manager(ScreenManager):
                      pass
                  
                  class Vop(App):
                      def build(self):
                          return Builder.load_file("vop.kv")
                      
                  if __name__ == "__main__":
                      Vop().run()
                  

                  kivy code:

                  ## Collect our windows to windows manager ##
                  
                  #: kivy 2.0.0
                  
                  Windows_manager:
                      Main_windows:
                      Second_windows:
                  
                  <Main_windows>:
                      f_user:f_user
                  
                      name:"main_windows"
                  
                      BoxLayout:
                          orientation:"vertical"
                          Label:
                              text: "Please insert Name of First Player"
                  
                          TextInput:
                              id: f_user
                              multiline:False
                          Label:
                              text: "please insert Name of Second Player"
                          TextInput:
                              id: s_user
                              multiline:False
                  
                          Button:
                              text:"Save"
                              on_release:
                                  app.root.current="second_windows"
                                  root.manager.transition.direction="up"
                                  root.manager.get_screen('second_windows').player1.text = root.f_user.text
                  
                  <Second_Windows>:
                  
                      name:"second_windows"
                  
                      player1: player1
                  
                      BoxLayout:
                          orientation :"vertical"
                  
                          BoxLayout:
                              orientation:"horizontal"
                  
                              Label:
                                  text:"User number one"
                              Label:
                                  text:"User number Two"
                  
                          BoxLayout:
                              orientation:"horizontal"
                              Label:
                                  id: player1
                                  text: '' # change here
                              Label:
                                  id: player2
                                  text: "user name 2 print here"
                          Button:
                              text:"Back"
                              on_release:
                                  app.root.current="main_windows"
                                  root.manager.transition.direction="down"
                  
                  

                  App Screenshots

                  这篇关于在第二个寡妇中单击按钮打印(文本)作为标签(更新标签)后,python和kivy在第一个窗口中输入文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Kivy:AttributeError:“NoneType"对象在向下滚动并在 下一篇:kivy TextInput 是否有焦点丢失事件调度程序?

                  相关文章

                  最新文章

                  <small id='4icEW'></small><noframes id='4icEW'>

                  • <bdo id='4icEW'></bdo><ul id='4icEW'></ul>
                • <tfoot id='4icEW'></tfoot>

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

                      <legend id='4icEW'><style id='4icEW'><dir id='4icEW'><q id='4icEW'></q></dir></style></legend>