ยังไงจะเอาอวกาศระหว่างสองคน BoxLayouts ใน Kivy?

0

คำถาม

ฉันรัฐที่ผมต้องไปแล้วอ่านคำตอบของผู้ใช้อื่นนี้คำถามแต่ไม่ใช่เรื่องของพวกเขาช่วยฉัน ฉันกำลังพยายามโปรแกรมเครื่องคิดเลขในภาษาไพธอนกับ kivy ส่วนติดต่อผู้ใช้แบบส่วนติดต่อเขาปัญหาคือฉันไม่สามารถลบน พื้นที่เน้น ในสีแดงในห้องติดกับรูปภาพข้างล่างนี่ ฉันต้องไปแล้วพยายามด้วย: size_hint: None,None แล้ว size:root.size[0], "5dp" เพื่อปรับขนาดค BoxLayouts แต่มันไม่ทำงาน

         [1]: https://i.stack.imgur.com/y1ZwF.png


  BoxLayoutExample:
<BoxLayoutExample>:
    orientation: "vertical"
    Label:
        text: "0"
        font_size: "30dp"
    BoxLayout:
        orientation: "horizontal"
        Button:
            text: "7"
            size_hint: .1, .3
        Button:
            text: "4"
            size_hint: .1, .3
        Button:
            text: "1"
            size_hint: .1, .3

    BoxLayout:
        orientation: "horizontal"
        Button:
            text: ","
            size_hint: .1, .3
        Button:
            text: "0"
            size_hint: .1, .3
        Button:
            text: "="
            size_hint: .1, .3
       
calculator interface kivy python
2021-11-23 20:37:05
1

คำตอบที่ดีที่สุด

0

ปัญหาของคุณคือคุณการตั้งค่า size_hint ของปุ่มสัมพันธ์กับพ่อแม่ของมัน BoxLayout. ดังนั้นอยู่ในลูกเล่นของคุณ BoxLayout นกำลังขึ้น 1/3 ของว่างอวกาศ(เพราะมันมีสามคนในวิดเจ็ต BoxLayoutExample.

นี่คือวิธีที่จะซ่อมมัน:

<BoxLayoutExample>:
    orientation: "vertical"

    Label:
        text: "0"
        font_size: "30dp"
        size_hint: 1, .8

    BoxLayout:
        orientation: "horizontal"
        size_hint: 1, .1
        Button:
            text: "7"
        Button:
            text: "4"
        Button:
            text: "1"

    BoxLayout:
        orientation: "horizontal"
        size_hint: 1, .1
        Button:
            text: ","
        Button:
            text: "0"
        Button:
            text: "="

ปรับขนาด Label และ BoxLayout ได้ตามคาด

2021-11-23 23:34:56

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................

ดังอยู่ในนี้หมวดหมู่

ดังคำถามอยู่ในนี้หมวดหมู่