我想在python中使用kivy和TabeedPanel制作GUI。一些问题将出现在标签的确切位置TextInput按钮上。我无法将多个标签,TextInput放在一起。这就是我在代码中评论的原因。我也试过GridLayout,但无法准确安排。 你能帮我吗?提前致谢。如何在Python中使用kivy在TabeedPanel中使用GridLayout
from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelItem
from kivy.lang import Builder
from kivy.uix.checkbox import CheckBox
from kivy.uix.button import Button
from kivy.app import App
from kivy.uix.textinput import TextInput
import json
Builder.load_string("""
<Test>:
do_default_tab: False
TabbedPanelItem:
text: 'page1'
BoxLayout:
Label:
text: 'label'
TextInput:
text: 'TextInput'
CheckBox:
text: 'CheckBox'
Button:
text: 'save'
#BoxLayout:
# orientation: 'vertical'
# BoxLayout:
# orientation: 'horizontal'
# Label:
# text: 'label'
TabbedPanelItem:
text: 'page2'
BoxLayout:
Label:
text: 'number1'
#TextInput:
# text: 'TextInput'
Label:
text: 'number2'
# TextInput:
# text: 'TextInput'
Button:
text: 'button'
""")
class Test(TabbedPanel):
pass
class MyApp(App):
def build(self):
test = Test()
return test
if __name__ == '__main__':
MyApp().run()
看起来不错。谢谢@Mox – crazyDelight
如何动态填充标签和TextInput?像这些值存储在一个变量中作为一个映射(键,值对),并以这样的json格式var ='{“a”:“Goc”,“b”:“Coc”,“c”:“Dow” }')在运行时,使用任何循环,标签和TextInput应该自动填充。 N.B:这里的'关键'数据应该在标签处显示,'值'在TextInput处。即:a:Goc,b:Coc,c:Dow。 SO a,b,c是标签,Goc,Coc,Dow是TextInput。 – crazyDelight
上面的东西只适用于“page1” – crazyDelight