Jun-19-2024, 02:00 AM
Are you trying to do something like this?
test.py
test.py
from kivy.app import App from kivy.lang import Builder from kivy.uix.screenmanager import ScreenManager, Screen from kivy.uix.videoplayer import VideoPlayer # define the Screens class Window1(Screen): pass class Window2(Screen): pass class Window3(Screen): pass class PlayVideo(Screen): pass class MyWidget(Screen): pass class WindowManager(ScreenManager): pass kv = Builder.load_file('my.kv') class MyApp(App): def build(self): return kv MyApp().run()my.kv
Output:WindowManager:
Window1:
Window2:
Window3:
PlayVideo:
MyWidget:
<PlayVideo>:
name: 'video_window'
BoxLayout:
orientation: 'vertical'
spacing: 50
VideoPlayer:
source: './videos/my.mp4'
state: 'stop'
size_hint_y: None
height: root.height - 125
GridLayout:
cols: 3
row_force_default: True
row_default_height: 40
col_force_default: True
col_default_width: 100
spacing: 10
padding: 10
Button:
text: 'Goto 1'
font_size: 20
on_release:
app.root.current = 'window1'
root.manager.transition.direction = 'up'
Button:
text: 'Goto 2'
font_size: 20
on_release:
app.root.current = 'window2'
root.manager.transition.direction = 'up'
Button:
text: 'Goto 3'
font_size: 20
on_release:
app.root.current = 'window3'
root.manager.transition.direction = 'up'
<Window1>:
name: 'window1'
canvas.before:
Color:
rgba: (180/255, 50/255, 30/255, 1)
Rectangle:
pos: self.pos
size: self.size
BoxLayout:
orientation: 'vertical'
spacing: 50
Label:
text: 'Window 1'
font_size: 32
size_hint_y: None
height: root.height - 125
GridLayout:
cols: 3
row_force_default: True
row_default_height: 40
col_force_default: True
col_default_width: 100
spacing: 10
padding: 10
Button:
text: 'Goto 2'
font_size: 20
on_release:
app.root.current = 'window2'
root.manager.transition.direction = 'left'
Button:
text: 'Goto 3'
font_size: 20
on_release:
app.root.current = 'window3'
root.manager.transition.direction = 'left'
Button:
text: 'Play Video'
font_size: 20
on_release:
app.root.current = 'video_window'
root.manager.transition.direction = 'down'
<Window2>:
name: 'window2'
canvas.before:
Color:
rgba: (10/255, 150/255, 330/255, 1)
Rectangle:
pos: self.pos
size: self.size
BoxLayout:
orientation: 'vertical'
size: root.width, root.height
Label:
text: 'Window 2'
font_size: 32
size_hint_y: None
height: root.height - 125
GridLayout:
cols: 3
row_force_default: True
row_default_height: 40
col_force_default: True
col_default_width: 100
spacing: 10
padding: 10
Button:
text: 'Goto 1'
font_size: 20
on_release:
app.root.current = 'window1'
root.manager.transition.direction = 'right'
Button:
text: 'Goto 3'
font_size: 20
on_release:
app.root.current = 'window3'
root.manager.transition.direction = 'left'
Button:
text: 'Play Video'
font_size: 20
on_release:
app.root.current = 'video_window'
root.manager.transition.direction = 'down'
<Window3>
name: 'window3'
canvas.before:
Color:
rgba: (10/255, 90/255, 30/255, 1)
Rectangle:
pos: self.pos
size: self.size
BoxLayout:
orientation: 'vertical'
size: root.width, root.height
Label:
text: 'Window 3'
font_size: 32
size_hint_y: None
height: root.height - 125
GridLayout:
cols: 3
row_force_default: True
row_default_height: 40
col_force_default: True
col_default_width: 100
spacing: 10
padding: 10
Button:
text: 'Goto 1'
font_size: 20
on_release:
app.root.current = 'window1'
root.manager.transition.direction = 'right'
Button:
text: 'Goto 2'
font_size: 20
on_release:
app.root.current = 'window2'
root.manager.transition.direction = 'right'
Button:
text: 'Play Video'
font_size: 20
on_release:
app.root.current = 'video_window'
root.manager.transition.direction = 'down'
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags