Python 按钮的字体大小根据其小部件(按钮)的大小而变化

Python 按钮的字体大小根据其小部件(按钮)的大小而变化,python,kivy-language,Python,Kivy Language,##背景: FloatLayout: canvas.before: Color: rgb: .59, .74, .20 Rectangle: size: self.size pos: self.pos Button: id : butt pos_hint: {'center_x':.8, 'center_y':.1} size_

##背景:

FloatLayout:
    canvas.before:
        Color:
            rgb: .59, .74, .20
        Rectangle:
            size: self.size
            pos: self.pos

    Button:
        id : butt
        pos_hint: {'center_x':.8, 'center_y':.1}
        size_hint: .2, .07
        background_normal: ''
        background_color: 1, 1, .8, 1
        color: 0.15, .5, 0.2, 1
        text: "NEXT"
        font_size: 0.15 * self.width
        on_press:
            print("pressed, navigating to next screen")"
我正在设计一个布局,并决定使布局中按钮的字体大小根据按钮的宽度而变化(其大小也随画布/布局而变化)

##问题:

FloatLayout:
    canvas.before:
        Color:
            rgb: .59, .74, .20
        Rectangle:
            size: self.size
            pos: self.pos

    Button:
        id : butt
        pos_hint: {'center_x':.8, 'center_y':.1}
        size_hint: .2, .07
        background_normal: ''
        background_color: 1, 1, .8, 1
        color: 0.15, .5, 0.2, 1
        text: "NEXT"
        font_size: 0.15 * self.width
        on_press:
            print("pressed, navigating to next screen")"
这很好,直到按钮宽度变大,字体大小也变大,超过按钮大小。这就是我想要避免的

##我想做的事:

FloatLayout:
    canvas.before:
        Color:
            rgb: .59, .74, .20
        Rectangle:
            size: self.size
            pos: self.pos

    Button:
        id : butt
        pos_hint: {'center_x':.8, 'center_y':.1}
        size_hint: .2, .07
        background_normal: ''
        background_color: 1, 1, .8, 1
        color: 0.15, .5, 0.2, 1
        text: "NEXT"
        font_size: 0.15 * self.width
        on_press:
            print("pressed, navigating to next screen")"
我的想法是,当字体大小超过某个值时,停止根据按钮的宽度改变字体大小。问题是,我不知道如何实现它

//如果标题有误导性,我真的很抱歉,但是idk还有什么标题,英语不是我的母语

##我试过做什么:

FloatLayout:
    canvas.before:
        Color:
            rgb: .59, .74, .20
        Rectangle:
            size: self.size
            pos: self.pos

    Button:
        id : butt
        pos_hint: {'center_x':.8, 'center_y':.1}
        size_hint: .2, .07
        background_normal: ''
        background_color: 1, 1, .8, 1
        color: 0.15, .5, 0.2, 1
        text: "NEXT"
        font_size: 0.15 * self.width
        on_press:
            print("pressed, navigating to next screen")"
我试过这样做:“self.font\u size”、“font\u size”和“butt.font\u size”

(获取字体大小的值并将其放入“if”语句中)

但我不知道如何获取值,也不知道如何在kvlang中使用if语句

##生成器文件:

FloatLayout:
    canvas.before:
        Color:
            rgb: .59, .74, .20
        Rectangle:
            size: self.size
            pos: self.pos

    Button:
        id : butt
        pos_hint: {'center_x':.8, 'center_y':.1}
        size_hint: .2, .07
        background_normal: ''
        background_color: 1, 1, .8, 1
        color: 0.15, .5, 0.2, 1
        text: "NEXT"
        font_size: 0.15 * self.width
        on_press:
            print("pressed, navigating to next screen")"