9

I am writing a program in Python using kivy, and I am unable to change the size of the buttons that transition back and forth between two screens

I can't think of any reason why I'm unable to change its size with something like "size: 75, 50" is it because the class is inherited from Screen instead of Button?

Python File:

import kivy
from kivy.app import App
kivy.require("1.10.1")
from kivy.uix.label import Label
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen
from kivy.uix.screenmanager import ScreenManager

class ScreenRoot(Screen):   
    pass

class OtherScreen(Screen):   
    pass

class ScreenUpkeep(ScreenManager):    
    pass

view = Builder.load_file("main.kv")

    class MainApp(App):
        def build(self):
            return view

if __name__ == "__main__":
    MainApp().run()

Corresponding .kv file:

ScreenUpkeep:
    ScreenRoot:
    OtherScreen:    

<ScreenRoot>:
    name: "rootmain"
    Button:
        text: "Next Screen"
        font_size: 40
        on_release: app.root.current = "other"
        size: 75, 50
<OtherScreen>:
    name: "other"
    Button:
        text: "Return"
        font_size: 40
            on_release: app.root.current = "rootmain"

I just want to be able to change the size of the button to be able to include more things like text and pictures on each screen.

Hamza Faisal
  • 115
  • 1
  • 1
  • 4

1 Answers1

12

You have to disable the size_hint, to visualize it better I will change the font of the button:

Button:
    text: "Next Screen"
    font_size: 12
    on_release: app.root.current = "other"
    size: 75, 50
    size_hint: None, None # <---

enter image description here

eyllanesc
  • 235,170
  • 19
  • 170
  • 241