Python kivy multiscreen找不到id
总之,在我的kivy代码中,我不能将goi传递到VQCIA类中的函数submit_goi中。如果有人能修改代码,我将不胜感激。print self.goi.text()语句报告了一个问题,它说AttributeError:'NoneType'对象没有属性'text'。真奇怪Python kivy multiscreen找不到id,python,kivy,textinput,Python,Kivy,Textinput,总之,在我的kivy代码中,我不能将goi传递到VQCIA类中的函数submit_goi中。如果有人能修改代码,我将不胜感激。print self.goi.text()语句报告了一个问题,它说AttributeError:'NoneType'对象没有属性'text'。真奇怪 # ---------- vqcia.py ---------- from kivy.app import App from kivy.uix.boxlayout import BoxLayout from kivy.pr
# ---------- vqcia.py ----------
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ObjectProperty
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
Builder.load_string("""
<HelloVQCIA>:
BoxLayout:
Button:
text: "Welcome to VQCIA"
on_press:
# You can define the duration of the change
# and the direction of the slide
root.manager.transition.direction = 'left'
root.manager.transition.duration = 1
root.manager.current = 'screen_two'
<VQCIA>:
BoxLayout:
orientation: "vertical"
goi: g_o_i
padding: 10
spacing: 10
size: 400, 200
pos: 200, 200
size_hint:None,None
BoxLayout:
Label:
text: "Enter gene of interest with TAIR ID:"
font_size: '25sp'
BoxLayout:
TextInput:
id: g_o_i
hint_text: 'AT3G20770'
multiline: False
font_size: '25sp'
BoxLayout:
Button:
text: "Submit"
size_hint_x: 15
on_press:
root.submit_goi()
""")
class HelloVQCIA(Screen):
pass
class VQCIA(Screen):
# Connects the value in the TextInput widget to these
# fields
goi = ObjectProperty()
def submit_goi(self):
print self.goi.text
# The ScreenManager controls moving between screens
screen_manager = ScreenManager()
# Add the screens to the manager and then supply a name
# that is used to switch screens
screen_manager.add_widget(HelloVQCIA(name="screen_one"))
screen_manager.add_widget(VQCIA(name="screen_two"))
class VQCIAApp(App):
def build(self):
return screen_manager
dbApp = VQCIAApp()
dbApp.run()
#------------vqcia.py----------
从kivy.app导入应用程序
从kivy.uix.boxlayout导入boxlayout
从kivy.properties导入ObjectProperty
从kivy.lang导入生成器
从kivy.uix.screenmanager导入screenmanager,屏幕
生成器。加载\u字符串(“”)
:
盒子布局:
按钮:
文字:“欢迎来到VQCIA”
新闻界:
#您可以定义更改的持续时间
#以及滑动的方向
root.manager.transition.direction='left'
root.manager.transition.duration=1
root.manager.current='screen\u two'
:
盒子布局:
方向:“垂直”
goi:g_o_i
填充:10
间距:10
尺寸:400200
位置:200200
大小提示:无,无
盒子布局:
标签:
文本:“输入TAIR ID为的感兴趣基因:”
字体大小:“25sp”
盒子布局:
文本输入:
id:g_o_i
提示文字:“AT3G20770”
多行:False
字体大小:“25sp”
盒子布局:
按钮:
案文:“提交”
尺寸提示:15
新闻界:
root.submit_goi()
""")
HelloVQCIA类(屏幕):
通过
VQCIA类(屏幕):
#将TextInput小部件中的值连接到这些
#田地
goi=ObjectProperty()
def提交_goi(自我):
打印self.goi.text
#ScreenManager控制屏幕之间的移动
屏幕管理器=屏幕管理器()
#将屏幕添加到manager,然后提供名称
#这是用来切换屏幕的
screen\u manager.add\u小部件(HelloVQCIA(name=“screen\u one”))
screen\u manager.add\u小部件(VQCIA(name=“screen\u two”))
VQCIAApp类(应用程序):
def生成(自):
返回屏幕管理器
dbApp=VQCIAApp()
dbApp.run()
我想做一个多屏幕应用程序,第一页是欢迎页面。第二个页面是用户可以提交表单的主页面。谢谢。在kv文件中,将
goi:g_o_i
移至课后规则,:
:
goi:g_o_i
盒子布局:
方向:“垂直”
<VQCIA>:
goi: g_o_i
BoxLayout:
orientation: "vertical"