无法在 kivy 中强制使用默认大小 python

can't force defualt size in kivy python

我一直在关注 python kivy 教程,我正在制作这个简单的应用程序,它在屏幕上显示一些文本,并希望将应用程序中除按钮之外的所有内容都变小,但是

self.top_grid = GridLayout(row_force_default=True,row_default_height=100,col_force_default=True,col_default_width=100)

我不知道该怎么做,谢谢

代码:

from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout


class MyGridLayout(GridLayout):
    #init infinete keyword
    def __init__(self,**kwargs):
        #call grid layout constructor
        super(MyGridLayout,self).__init__(**kwargs)
        self.cols = 1       
        self.top_grid.cols = 2
        self.press_count = 0
        self.top_grid = GridLayout(row_force_default=True,row_default_height=100,col_force_default=True,col_default_width=100)
        
        
        self.top_grid.add_widget(Label(text="name: ",font_size=30))
        self.name = TextInput(multiline=False)
        self.top_grid.add_widget(self.name)
        
        
        self.top_grid.add_widget(Label(text="age: ",font_size=30))
        self.age = TextInput(multiline=False)
        self.top_grid.add_widget(self.age)
        
        
        self.top_grid.add_widget(Label(text="how are you feeling: ",font_size=30))
        self.feel = TextInput(multiline=False)
        self.top_grid.add_widget(self.feel)
        
        
        self.add_widget(self.top_grid)
        #button
        self.button = Button(text="go!!!",font_size=32,size_hint_y=None,height=(100-self.press_count))
        self.button.bind(on_press=self.press)
        self.add_widget(self.button)
        
    def press(self, instance):
    
        name = self.name.text
        age = self.age.text
        feel = self.feel.text
        self.add_widget(Label(text=f"you are {name} and you are {age} and you are feeling {feel}",font_size=15))
        #print(f"you are {name} and you are {age} and you are feeling {feel}")
        
        
        self.name.text = ""
        self.age.text = ""
        self.feel.text = ""
        
        
        self.press_count +=10
        if not self.press_count == 20:
            self.button.height=(100-self.press_count)
            
            
class MyApp(App):
    def build(self):
        return MyGridLayout()
        
        
if __name__ == "__main__":
    MyApp().run()

美好的一天。请记住为添加到布局的小部件设置 size_hint=None,None。即标签小部件。