久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

      1. <small id='CstQc'></small><noframes id='CstQc'>

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

          <bdo id='CstQc'></bdo><ul id='CstQc'></ul>
      2. Kivy - 在 .py 文件中的另一個屏幕中使用來自一個

        Kivy - Use text from TextInput of one screen in another screen in .py file(Kivy - 在 .py 文件中的另一個屏幕中使用來自一個屏幕的 TextInput 的文本)
          <tbody id='pvrrk'></tbody>

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

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

                <tfoot id='pvrrk'></tfoot>

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

                  本文介紹了Kivy - 在 .py 文件中的另一個屏幕中使用來自一個屏幕的 TextInput 的文本的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我的第一個屏幕上有一個 TextInput,我想在第二個屏幕的標(biāo)簽中使用接收到的文本.我怎樣才能做到這一點(diǎn)?由于可以有不同的玩家,我創(chuàng)建了一個類 Players ,它為每個玩家存儲一個名字和他/她的分?jǐn)?shù).在第二個屏幕中,我還嘗試創(chuàng)建一個可以編輯點(diǎn)(標(biāo)簽文本)的按鈕,但是當(dāng)我單擊它時,什么也沒有發(fā)生.(我也是新手.)

                  I have a TextInput on my first screen and I want to use the received text in a Label on my second screen. How can I do this? Since there can be different players, I created a class Players which stores for every player a name and his/her points. In the second screen, I also tried to create a button which can edit the points (text of Label), but when I click it, nothing happens. (I am also new to classes.)

                  在下面的代碼中,我標(biāo)記了相關(guān)的行.

                  In the code below, I marked the relevant lines.

                  所以概述:

                  • 第一個屏幕:使用 textInput 提取用戶名 + 使用 Player 類創(chuàng)建播放器實(shí)例

                  • First screen: extract user name(s) with textInput + create player instances with Player class

                  第二個屏幕:在標(biāo)簽中使用玩家名稱 + 在標(biāo)簽中使用玩家點(diǎn) + 創(chuàng)建 2 個按鈕,從這個點(diǎn)"標(biāo)簽中添加/減去點(diǎn)

                  Second screen: Use player name in a Label + use player points in Label + create 2 Buttons that add/subtract points from this 'point' Label

                  我知道這里有類似的情況,但它對我的 .py 文件沒有幫助:如何在 Kivy/Python 的另一個屏幕中引用 TextInput?

                  I know there is a similar case here, but it doesn't help me for my .py file: How to ref a TextInput from one screen in another screen in Kivy/Python?

                  from kivy.app import App
                  from kivy.lang import Builder
                  from kivy.uix.screenmanager import ScreenManager, Screen
                  from kivy.uix.textinput import TextInput
                  from kivy.uix.gridlayout import GridLayout
                  from kivy.uix.button import Button
                  from kivy.uix.label import Label
                  from kivy.properties import ObjectProperty, NumericProperty
                  
                  
                  class Player:
                      def __init__(self, name):
                          self.name = name
                          self.points = 0
                  
                      def reset_points(self):
                          self.points = 0
                  
                      def add_point(self, *args):
                          self.points += 1
                  
                      def subtract_point(self, *args):
                          self.points -= 1
                  
                  
                  class WelcomeWindow(Screen):
                      # Introduce names of the 4 players
                  
                      def __init__(self, **kwargs):
                          super(WelcomeWindow, self).__init__(**kwargs)
                          self.name = "welcomewindow"
                          self.layout = "layout_welcome_window"
                  
                          global_layout = GridLayout(rows=3)
                          self.add_widget(global_layout)
                  
                          label_player_i = Label(text="Name Player ")
                          global_layout.add_widget(label_player_i)
                  
                          name_input_player_i = TextInput(id="player ", text="player", multiline=False) # <--- user inputs name here
                          global_layout.add_widget(name_input_player_i)
                  
                          self.player1 = Player(name_input_player_i.text) # <--- name is assigned to player here
                  
                          # Create button to go to next screen
                          go_further_button = Button(text="Go to first round")
                          go_further_button.bind(on_release=self.go_further)
                          global_layout.add_widget(go_further_button)
                  
                      def go_further(self, *args):
                          self.manager.current = "firstround"
                          self.manager.transition.direction = "left"
                  
                  class FirstRound(Screen):
                      #Give explanation of first round + option to add points for every player
                  
                      def __init__(self, **kwargs):
                          super(FirstRound, self).__init__(**kwargs)
                          self.name = "firstround"
                          self.layout = "layout_first_round"
                  
                          #Create layout
                          global_layout = GridLayout(rows=4)
                          self.add_widget(global_layout)
                  
                          #Create Labels
                          label_player_name_i = Label(text=WelcomeWindow().player1.name) # <--- Label should get the name of the player here
                          global_layout.add_widget(label_player_name_i)
                  
                          label_player_points_i = Label(text=str(WelcomeWindow().player1.points)) # <--- Label should get points of player
                          global_layout.add_widget((label_player_points_i))
                  
                          #Create Buttons
                          button_minus = Button(text="-", font_size=100, id="minus_button")
                          button_minus.bind(on_release=WelcomeWindow().player1.subtract_point) # <--- When button pushed: should subtract point
                          global_layout.add_widget(button_minus)
                  
                          button_plus = Button(text="+", font_size=100, id="plus_button")
                          button_plus.bind(on_release=WelcomeWindow().player1.add_point) # <--- When button pushed: should add point
                          global_layout.add_widget(button_plus)
                  
                  
                  WindowManager = ScreenManager()
                  WindowManager.add_widget(WelcomeWindow())
                  WindowManager.add_widget(FirstRound())
                  
                  class KingenApp(App):
                  
                      def build(self):
                          return WindowManager
                  
                  if __name__ == "__main__":
                      KingenApp().run()
                  

                  推薦答案

                  你的代碼有幾個問題:

                  • 當(dāng)您創(chuàng)建該 Widget 的實(shí)例時,將調(diào)用任何 Widget__init__() 方法.所以 FirstRound__init__() 方法在 WindowManager.add_widget(FirstRound()) 行被調(diào)用.那個時候,WelcomeWindowTextInput是不能輸入文字的,因此您無法獲得當(dāng)時的玩家名稱.
                  • Player 實(shí)例的創(chuàng)建 (self.player1 = Player(name_input_player_i.text)) 在用戶創(chuàng)建 Player 實(shí)例之前有機(jī)會輸入玩家姓名.
                  • FirstRound__init__()方法中使用WelcomeWindow()會創(chuàng)建一個新的WelcomeWindow 與您的 GUI 中的那個無關(guān).所以從那個實(shí)例中提取的任何信息都是沒有用的.
                  • 在您的 FirstRound 中,玩家點(diǎn)標(biāo)簽在創(chuàng)建 Label 時從 Player 類實(shí)例獲取其數(shù)據(jù).之后更改 Playerpoints 屬性將不會影響 Label.
                  • The __init__() method of any Widget is called when you create an instance of that Widget. So the __init__() method of FirstRound is called at the line WindowManager.add_widget(FirstRound()). At that time no text can have been entered into the TextInput of WelcomeWindow , so you cannot get the player name at that time.
                  • The creation of the Player instance (self.player1 = Player(name_input_player_i.text)) creates the Player instance before the user has a chance to enter a player name.
                  • The use of WelcomeWindow() in the __init__() method of FirstRound creates a new instance of WelcomeWindow that is unrelated to the one in your GUI. So any info extracted from that instance is of no use.
                  • In your FirstRound, the player points label gets its data from the Player class instance at the time that the Label is created. Changing the the points attribute of Player after that will have no effect on the Label.

                  第一個問題可以通過將大部分代碼移出 FirstRound__init__() 方法,并將其放在 on_enter() 顯示該 Screen 時運(yùn)行的方法.

                  The first issue can be handled by moving most of your code out of the __init__() method of FirstRound, and place it in an on_enter() method that is run when that Screen is displayed.

                  第二個問題可以通過將 Player 實(shí)例的創(chuàng)建移到 go_further() 方法中來處理,因?yàn)樗鼤陔x開 WelcomeWindow<時執(zhí)行/代碼>.

                  The second issue can be handled by moving the creation of the Player instance into the go_further() method, since it gets executed when leaving the WelcomeWindow.

                  第三個問題可以通過將 WelcomeWindow() 的那些用法替換為 self.manager.get_screen('welcomewindow') 來處理 的實(shí)際實(shí)例>WelcomeWindow 在您的 GUI 中.

                  The third issue can be handled by replacing those uses of WelcomeWindow() with self.manager.get_screen('welcomewindow') to access the actual instance of WelcomeWindow that is in your GUI.

                  這是您的代碼的修改版本,它可以完成這三件事:

                  Here is a modified version of your code that does those three things:

                  from kivy.app import App
                  from kivy.uix.screenmanager import ScreenManager, Screen
                  from kivy.uix.textinput import TextInput
                  from kivy.uix.gridlayout import GridLayout
                  from kivy.uix.button import Button
                  from kivy.uix.label import Label
                  
                  
                  class Player:
                      def __init__(self, name):
                          self.name = name
                          self.points = 0
                  
                      def reset_points(self):
                          self.points = 0
                  
                      def add_point(self, *args):
                          self.points += 1
                  
                      def subtract_point(self, *args):
                          self.points -= 1
                  
                  
                  class WelcomeWindow(Screen):
                      # Introduce names of the 4 players
                  
                      def __init__(self, **kwargs):
                          super(WelcomeWindow, self).__init__(**kwargs)
                          self.name = "welcomewindow"
                          self.layout = "layout_welcome_window"
                  
                          global_layout = GridLayout(rows=3)
                          self.add_widget(global_layout)
                  
                          label_player_i = Label(text="Name Player ")
                          global_layout.add_widget(label_player_i)
                  
                          self.name_input_player_i = TextInput(id="player ", text="player", multiline=False) # <--- user inputs name here
                          global_layout.add_widget(self.name_input_player_i)
                  
                          # Create button to go to next screen
                          go_further_button = Button(text="Go to first round")
                          go_further_button.bind(on_release=self.go_further)
                          global_layout.add_widget(go_further_button)
                  
                      def go_further(self, *args):
                          self.player1 = Player(self.name_input_player_i.text) # <--- name is assigned to player here
                          self.manager.current = "firstround"
                          self.manager.transition.direction = "left"
                  
                  
                  class FirstRound(Screen):
                      #Give explanation of first round + option to add points for every player
                  
                      def __init__(self, **kwargs):
                          super(FirstRound, self).__init__(**kwargs)
                          self.name = "firstround"
                          self.layout = "layout_first_round"
                  
                      def on_enter(self, *args):
                          #Create layout
                          global_layout = GridLayout(rows=4)
                          self.add_widget(global_layout)
                  
                          #Create Labels
                          welcome_window = self.manager.get_screen('welcomewindow')  # get a reference to the WelcomeWindow instance
                          label_player_name_i = Label(text=welcome_window.player1.name) # <--- Label should get the name of the player here
                          global_layout.add_widget(label_player_name_i)
                  
                          label_player_points_i = Label(text=str(welcome_window.player1.points)) # <--- Label should get points of player
                          global_layout.add_widget((label_player_points_i))
                  
                          #Create Buttons
                          button_minus = Button(text="-", font_size=100, id="minus_button")
                          button_minus.bind(on_release=welcome_window.player1.subtract_point) # <--- When button pushed: should subtract point
                          global_layout.add_widget(button_minus)
                  
                          button_plus = Button(text="+", font_size=100, id="plus_button")
                          button_plus.bind(on_release=welcome_window.player1.add_point) # <--- When button pushed: should add point
                          global_layout.add_widget(button_plus)
                  
                  
                  WindowManager = ScreenManager()
                  WindowManager.add_widget(WelcomeWindow())
                  WindowManager.add_widget(FirstRound())
                  
                  
                  class KingenApp(App):
                  
                      def build(self):
                          return WindowManager
                  
                  
                  if __name__ == "__main__":
                      KingenApp().run()
                  

                  第四個問題值得自己提出一個問題,但可能涉及使用 kivy 語言.

                  The fourth issue deserves a question of its own, but likely involves using kivy language.

                  這篇關(guān)于Kivy - 在 .py 文件中的另一個屏幕中使用來自一個屏幕的 TextInput 的文本的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機(jī)器人?)
                  Discord bot isn#39;t responding to commands(Discord 機(jī)器人沒有響應(yīng)命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關(guān)于我嗎?Discord 機(jī)器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機(jī)器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)
                    <tbody id='q8q0C'></tbody>
                  • <bdo id='q8q0C'></bdo><ul id='q8q0C'></ul>
                  • <i id='q8q0C'><tr id='q8q0C'><dt id='q8q0C'><q id='q8q0C'><span id='q8q0C'><b id='q8q0C'><form id='q8q0C'><ins id='q8q0C'></ins><ul id='q8q0C'></ul><sub id='q8q0C'></sub></form><legend id='q8q0C'></legend><bdo id='q8q0C'><pre id='q8q0C'><center id='q8q0C'></center></pre></bdo></b><th id='q8q0C'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='q8q0C'><tfoot id='q8q0C'></tfoot><dl id='q8q0C'><fieldset id='q8q0C'></fieldset></dl></div>
                        • <tfoot id='q8q0C'></tfoot>

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

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

                          1. 主站蜘蛛池模板: 嫩草研究影院 | 欧美精品1区 | www狠狠干| 视频一区在线观看 | 欧美国产激情二区三区 | 日本91av视频 | 欧美日韩久久 | 免费久久99精品国产婷婷六月 | 天天操天天干天天曰 | 久久精品一区 | jav成人av免费播放 | 中文日韩在线 | 日韩手机视频 | 色综合视频 | 99综合在线 | 毛片av免费在线观看 | 午夜在线| 日韩在线精品 | 91在线网 | 福利片在线观看 | 久久亚洲一区 | a国产一区二区免费入口 | 久久久www成人免费无遮挡大片 | 婷婷狠狠 | 国产成人一区在线 | 成年人黄色小视频 | 伊人狠狠 | 日韩高清中文字幕 | 亚洲a在线观看 | 18成人在线观看 | 国产九九精品视频 | 国产福利资源在线 | 欧美成人高清视频 | 国产极品车模吞精高潮呻吟 | 欧美激情一区二区三区 | k8久久久一区二区三区 | 黄色大片免费看 | 国产精品久久久久久久久久久久久久 | 精品久久久久一区二区国产 | 国产美女在线观看 | 中文字幕视频在线观看 |