Need Technical Support

22 views
Skip to first unread message

Aladdin Hammodi

unread,
Jun 15, 2017, 3:32:10 PM6/15/17
to Kivy users support
hello 
im trying to write a kivy app 
when i try to run the .py file this is leading to not respond the python 
this is my main.py 
=============
#main.py
import kivy
kivy.require("1.9.1")

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.popup import Popup
from kivy.core.window import Window
from kivy.uix.textinput import TextInput
from kivy.properties import ObjectProperty
from kivy.lang import Builder

Builder.load_file(main.kv)


# Create a class for all screens in which you can include
# helpful methods specific to that screen
class ScreenOne(Screen):
    pass
 
 
class ScreenTwo(Screen):
    pass
 
 
# The ScreenManager controls moving between screens
screen_manager = ScreenManager()
 
# Add the screens to the manager and then supply a name
# that is used to switch screens
screen_manager.add_widget(ScreenOne(name="screen_one"))
screen_manager.add_widget(ScreenTwo(name="screen_two"))
 
class MainApp(App):
 
    def build(self):
        return screen_manager
 
sample_app = MainApp()
sample_app.run()

=======
# main.kv file 

<ScreenOne>:
    FloatLayout:
        canvas:
            source:'image1'  # making this picture as screen background
        Label:
            text:'Hello\n Welcome to my app\n'
            font_size: 40

        Button:
            text: 'Next'
            pos: 0,1
            font_size:20
            hint_size:0.1,0.05
            on_press:root.manager.current.'screen_two'

<ScreenTwo>:
    FloatLayout:
        canvas:
            source:'image1'
        Label:
            text:'Please insert your name'
            text:'Please insert your Password'
            font_size: 40

        Button:
            text: 'Next'
            pos: 0,1
            font_size:20
            hint_size:0.1,0.05
            on_press:root.manager.current.'screen_one'


Please help me find out what is my problem 



Leonardo Rodriguez

unread,
Jun 15, 2017, 6:56:08 PM6/15/17
to Kivy users support
I don't know if there is another bug, but first of all is this line:

Builder.load_file(main.kv)

it should be 

Builder.load_file("main.kv")

Hope it helps

John Anderson

unread,
Jun 15, 2017, 8:29:17 PM6/15/17
to Kivy users support
"hint_size" should be "size_hint".
To get your background image you need a Rectangle in the Canvas, like this:

        canvas:
            Rectangle:
                source: "image1"  # making this picture as screen background
                pos: self.pos
                size: self.size

Your "on_press" methods need to set a value like:
    on_press:root.manager.current='screen_two'

Your Label on screen 2 has two text properties. only the last will have effect. You can use two labels with different text properties, or
one label with a multiline text property like:
    text:'Please insert your name\nPlease insert your Password'

Hope this helps.
Reply all
Reply to author
Forward
0 new messages