imports:
from kivy.lang import Builder
from kivy.uix.textinput import TextInput
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import StringProperty
from kivy.properties import ObjectProperty
from kivy.uix.label import Label
from kivy.core.window import Window
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.video import Video
kv = '''
<V>
BoxLayout:
spacing: 10
padding: 20
orientation: "vertical"
width: root.width,root.height
Button:
text: " [Login-Screen] "
background_color: (1,1,1,1)
color: (1,0,0,1)
bold: True
font_size: 17
size_hint: (None,None)
width: 200
height: 50
on_release:
root.manager.current = "Login"
root.manager.transition.direction = "up"
<Login>
ben: benName.text
pw: passwort.text
knopf: btn
knopff: btnn
GridLayout:
cols: 1
size: root.width,root.height
GridLayout:
cols: 2
Label:
text: "Username"
font_size: 25
TextInput:
id: benName
multiline: False
font_size: 30
Label:
text: "Password"
font_size: 25
bold: True
TextInput:
password: True
id: passwort
multiline: False
font_size: 40
Button:
size_hint: (1.,1.10)
text:" Start "
id: btn
font_size: 40
on_release:
Button:
size_hint: (1.,1.10)
text: " Exit "
id: btnn
font_size: 40
on_release: app.stop()
'''
MyApp
class:
class Login(Screen):
ben = StringProperty()
pw = StringProperty()
knopf = ObjectProperty()
class MyApp(App):
Builder.load_string(kv)
def build(self):
ms = ScreenManager()
ms.add_widget(V(name='V'))
ms.add_widget(Login(name='login'))
self.title = "MyApp"
return ms
class V(Screen):
def logo(self):
video = Video(source='loding_4K.mp4')
video.state='play'
video.options = {'eos': 'loop'}
video.allow_stretch=True
return video
if __name__ == '__main__':
MyApp().run()
Your are not calling logo() method. This is how you can do it in the kv file which is easier.
from kivy.lang import Builder
from kivy.uix.textinput import TextInput
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import StringProperty
from kivy.properties import ObjectProperty
from kivy.uix.label import Label
from kivy.core.window import Window
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.video import Video
kv = '''
<V>
BoxLayout:
spacing: 10
padding: 20
orientation: "vertical"
width: root.width,root.height
Video:
source: "loding_4K.mp4"
state: "play"
options: {'eos': 'loop'}
allow_stretch: True
Button:
text: " [Login-Screen] "
background_color: (1,1,1,1)
color: (1,0,0,1)
bold: True
font_size: 17
size_hint: (None,None)
width: 200
height: 50
on_release:
root.manager.current = "Login"
root.manager.transition.direction = "up"
<Login>
ben: benName.text
pw: passwort.text
knopf: btn
knopff: btnn
GridLayout:
cols: 1
size: root.width,root.height
GridLayout:
cols: 2
Label:
text: "Username"
font_size: 25
TextInput:
id: benName
multiline: False
font_size: 30
Label:
text: "Password"
font_size: 25
bold: True
TextInput:
password: True
id: passwort
multiline: False
font_size: 40
Button:
size_hint: (1.,1.10)
text:" Start "
id: btn
font_size: 40
on_release:
Button:
size_hint: (1.,1.10)
text: " Exit "
id: btnn
font_size: 40
on_release: app.stop()
'''
class Login(Screen):
ben = StringProperty()
pw = StringProperty()
knopf = ObjectProperty()
class MyApp(App):
Builder.load_string(kv)
def build(self):
ms = ScreenManager()
ms.add_widget(V(name='V'))
ms.add_widget(Login(name='login'))
self.title = "MyApp"
return ms
class V(Screen):
pass
if __name__ == '__main__':
MyApp().run()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.