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.
In order to customize the Button size, we can use the width and height property of the button widget.
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 # <---
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With