There are a number of issues with the example code, details below.
There are a number of ways to center a Widget. In a RelativeLayout or a FloatLayout, use a pos_hint. A Screen is a ReleativeLayout.
You could also put the widget in an AnchorLayout.
If you want to set the size of a widget, you must "turn off" the size_hint by setting it to None. If this is not done the size hint defaults to 1, 1 and the size is ignored.
See the comments in the code.
from kivy.app import App
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.uix.screenmanager import Screen
Window.size = (450, 750)
Code = """
ScreenManager: # this is the root widget
EzHomeScreen:
<EzHomeScreen>:
name: 'EzHome'
# canvas.before: #<--- This does not make sense here.... no canvas instructions
BoxLayout:
pos_hint: {'center_x': 0.5, 'center_y': 0.5}
size_hint: None, None
size: 322, 680
Image:
source: 'Images\main.png'
Button:
# background_color: 1, 0 ,0, 0 # <- setting alpha to zero makes button invisible
pos_hint: {'center_x': 0.5, 'center_y': 0.5}
text: 'Button'
size_hint: None, None
size: 200, 48
# Image: <--- Image was filling screen over button, put widgets in layouts
# source: 'Images\launch.png'
# pos: self.pos
"""
class EzHomeScreen(Screen):
pass
# sm = ScreenManager() #### This is redundant with the KV code.
# sm.add_widget(EzHomeScreen(name='EzHome'))
class Tester(App):
def build(self):
scr = Builder.load_string(Code)
return scr
if __name__ == '__main__':
Tester().run()