All my program works up-to a point and I'm road blocked by it.
My program loads some starter screens in the main app.
Based on user input the program loads a completely different sub app.
Problem occurs when trying to change screens in the loaded sub app
Here is the code where the problem exists:
The .py file:
import kivy
kivy.require('1.10.0')
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen, ScreenManager, FadeTransition
from kivy.uix.button import Button
from kivy.uix.label import Label
chClass = ""
class ScreenManage(ScreenManager):
pass
class Home(ScreenManager):
pass
class TitleScreen(Screen):
pass
class GameScreen(Screen):
pass
class ClassScreen(Screen):
pass
class Warrior1(Screen):
def GetChClass(self, ch):
return ch
def build(self):
ExecuteW().run()
class Acrobat1(Screen):
def GetChClass(self, ch):
return ch
class Spell1(Screen):
def GetChClass(self, ch):
return ch
class HomeScreen(Screen):
pass
class WarriorStats(Screen):
pass
class AcrobatStats(Screen):
pass
class SpellCasterStats(Screen):
pass
class ExecuteW(App):
def build(self):
return Home()
class RevengeApp(App):
def build(self):
return ScreenManage()
if __name__ == '__main__':
print chClass
RevengeApp().run()
revenge.kv:
#: import sm kivy.uix.screenmanager
#: import Factory kivy.factory.Factory
#: import builder kivy.lang.Builder
<ScreenManage>
transition: sm.FadeTransition()
TitleScreen:
ClassScreen:
GameScreen:
Warrior1:
Acrobat1:
Spell1:
WarriorStats:
<TitleScreen>
on_touch_down: app.root.current = 'Game'
canvas:
Rectangle:
size: self.size
pos: self.pos
source: 'KnightArmor.jpg'
BoxLayout:
orientation: 'vertical'
Label:
font_size: '30sp'
color: 1,0,0,1
text: "Warrior's Revenge"
Label:
color: 1,0,0,1
text: "Click to Continue:"
<GameScreen>
name: 'Game'
canvas:
Rectangle:
size: self.size
pos: self.pos
source: 'KnightArmor.jpg'
BoxLayout:
Button:
size_hint: .5,.1
text: "New Game"
on_release: app.root.current = 'Class'
Button:
size_hint: .5,.1
text: "Load Game"
<ClassScreen>
name: 'Class'
BoxLayout:
orientation: 'vertical'
Label:
text: "Choose Your Path"
Button:
text: "Warrior"
on_release: app.root.current = "Warrior1"
Button:
text: "Acrobat"
on_release: app.root.current = "Acrobat1"
Button:
text: "Spell Caster"
on_release: app.root.current = "Spell1"
<Warrior1>
name: "Warrior1"
canvas:
Rectangle:
size: self.size
pos: self.pos
source: "Warrior.jpg"
BoxLayout:
orientation: 'vertical'
Label:
font_size: "20sp"
text: "Warrior's are physically strong"
color: 0,.5,1,1
Label:
font_size: "20sp"
text: "experts in hand to hand combat,"
color: 0,.5,1,1
Label:
font_size: "20sp"
text: "and knowledgeable in the ways of"
color: 0,.5,1,1
Label:
font_size: "20sp"
text: "arms and armor"
color: 0,.5,1,1
BoxLayout:
orientation: 'horizontal'
Button:
text: "Cancel"
on_release: app.root.current = "Class"
Button:
name: "warrior_confirm"
text: "Confirm"
on_release: chClass = root.GetChClass('Warrior')
on_release: root.build()
executew.kv:
#: import sm kivy.uix.screenmanager
<Home>:
transition: sm.FadeTransition()
HomeScreen:
WarriorStats:
<HomeScreen>
name: 'Home'
AnchorLayout:
Button:
text: "Stats"
on_release: app.root.current = 'WStats'
<WarriorStats>
name: 'WStats'
canvas:
Rectangle:
size: self.size
pos: self.pos
source: "Warrior.jpg"
The problem:
When clicking the stats button on the home screen in executew the WarriorStats screen named 'WStats' should be loaded, but I get the error "no screen with name 'WStats'"
Answer that I figured out on my own
class HomeScreen(Screen):
def switch(self):
self.manager.current = "WStats"
And in executew:
<HomeScreen>
Button:
text: "Stats"
on_release: root.switch()
Related
I am pretty new to the kivy language and faced this problem when try to run the following code. it just runs without any errors. But it just only generate a blank application. without any widgets.
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager
from kivy.uix.gridlayout import GridLayout
from kivymd.uix.boxlayout import MDBoxLayout
kv = """
<SCManager>:
Screen:
c_screen:
<c_screen>:
cols: 2
canvas.before:
Color:
rgba: 1,0,0,1
Rectangle:
pos: self.pos
size: self.size
MDBoxLayout:
md_bg_color: (1, 1, 1 ,1)
padding: 10
adaptive_height: True
MDLabel:
text: "helow 2"
color: (0.0003, 0.34, 0.60,1)
font_style: "H6"
halign: "left"
adaptive_height: True
<navigator>:
canvas.before:
Color:
rgba: 1,1,0,1
Rectangle:
pos: self.pos
size: self.size
orientation: "vertical"
MDLabel:
text: "hellow"
adaptive_height: True
MDList:
OneLineAvatarListItem:
text : "Dashboard"
IconLeftWidgetWithoutTouch:
icon: "view-dashboard"
OneLineAvatarListItem:
text : "Manage Users"
IconLeftWidgetWithoutTouch:
icon: "account"
MDRoundFlatIconButton:
text: "bye"
font_size: 11
"""
class SCManager(ScreenManager):
pass
class navigator(MDBoxLayout):
pass
class c_screen(GridLayout):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.n = navigator()
self.add_widget(self.n)
class test(MDApp):
def build(self):
Builder.load_string(kv)
return SCManager()
if __name__ == '__main__':
test().run()
But if i add another widget(a label) to Screen from kv string, it works fine or if i use add_widget(c_screen) in SCManager it works fine.But i need to add c_screen class from the kv string. Is there any way to add widgets without adding any widgets to Screen??
here is the working code
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager
from kivy.uix.gridlayout import GridLayout
from kivymd.uix.boxlayout import MDBoxLayout
kv = """
<SCManager>:
Screen:
MDLabel:
text: "helow 2"
adaptive_height: True
c_screen:
<c_screen>:
cols: 2
canvas.before:
Color:
rgba: 1,0,0,1
Rectangle:
pos: self.pos
size: self.size
MDBoxLayout:
md_bg_color: (1, 1, 1 ,1)
adaptive_height: True
MDLabel:
text: "helow 2"
adaptive_height: True
<navigator>:
canvas.before:
Color:
rgba: 1,1,0,1
Rectangle:
pos: self.pos
size: self.size
orientation: "vertical"
MDLabel:
text: "hellow"
adaptive_height: True
MDList:
OneLineAvatarListItem:
text : "Dashboard"
IconLeftWidgetWithoutTouch:
icon: "view-dashboard"
OneLineAvatarListItem:
text : "Manage Users"
IconLeftWidgetWithoutTouch:
icon: "account"
MDRoundFlatIconButton:
text: "bye"
font_size: 11
"""
class SCManager(ScreenManager):
pass
class navigator(MDBoxLayout):
pass
class c_screen(GridLayout):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.n = navigator()
self.add_widget(self.n)
class test(MDApp):
def build(self):
Builder.load_string(kv)
return SCManager()
if __name__ == '__main__':
test().run()
I am trying to type in text from one screen. Press a button and move to another screen and have that text be shown in a label. I've seen a few questions that are similar to mine, but have not been able to figure out how to use the posted solutions and have been stuck for hours (Link One, Link Two, Link Three). I believe that I need to use the __init__ method somewhere because this is an instance? I tried using the first link, but the label ends up blank (the code does run). Any Advice?
main.py
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.app import App
from kivy.lang.builder import Builder
class SecondWindow(Screen):
def get_unique_text(self):
x = self.manager.get_screen("first")
y = x.ids.unique.text
return str(y)
class FirstWindow(Screen):
pass
class MainWindow(Screen):
pass
class WindowManager(ScreenManager):
pass
kv_main = Builder.load_file('main.kv')
class MyApp(App):
def build(self):
return kv_main
if __name__ == '__main__':
MyApp().run()
main.kv
#:include First.kv
#:include Second.kv
WindowManager:
MainWindow:
FirstWindow:
SecondWindow:
<MainWindow>
name: "main"
BoxLayout:
Button:
text: "Press"
on_release:
app.root.current = "first"
First.kv
<FirstWindow#Screen>:
name: "first"
BoxLayout:
orientation: "vertical"
Label:
text: "Enter Unique Text for Saving"
font_size: 20
text_size: self.width, None
halign: 'center'
TextInput:
id: unique
hint_text: 'example: Stand25'
Button:
text: "Press"
on_release:
app.root.current = "second"
Second.kv
<SecondWindow#Screen>:
name: "second"
BoxLayout:
orientation: "vertical"
Label:
text: "Unique Text"
font_size: 20
text_size: self.width, None
halign: 'center'
Label:
text: root.get_unique_text()
font_size: 16
canvas.before:
Color:
rgba: 1,1,1,1
Rectangle:
pos: self.pos
size: self.size
color: 0,0,0,1
Button:
text: "Go Back"
on_release:
app.root.current = "first"
Another approach is to use the on_enter() method of a Screen in order to fetch the text. This also requires an id for the unique Label:
<SecondWindow#Screen>:
name: "second"
BoxLayout:
orientation: "vertical"
Label:
text: "Unique Text"
font_size: 20
text_size: self.width, None
halign: 'center'
Label:
id: unique # added id
# text: root.get_unique_text()
font_size: 16
canvas.before:
Color:
rgba: 1,1,1,1
Rectangle:
pos: self.pos
size: self.size
color: 0,0,0,1
Button:
text: "Go Back"
on_release:
app.root.current = "first"
Just add an on_enter() method to the SecondWindow class:
class SecondWindow(Screen):
def on_enter(self, *args):
self.ids.unique.text = self.get_unique_text()
def get_unique_text(self):
x = self.manager.get_screen("first")
y = x.ids.unique.text
return str(y)
In your Second.kv you can reference the text of the TextInput in the First.kv by making a couple changes to the kv files. First, in the main.kv, add an id for the FirstWindow (and eliminate the SecondWindow for now):
WindowManager:
MainWindow:
FirstWindow:
id: first # added id
# SecondWindow: # this gets added later
<MainWindow>
name: "main"
BoxLayout:
Button:
text: "Press"
on_release:
app.root.current = "first"
Then, in the Second.kv, set up the reference to the text of the TextInput:
<SecondWindow#Screen>:
name: "second"
BoxLayout:
orientation: "vertical"
Label:
text: "Unique Text"
font_size: 20
text_size: self.width, None
halign: 'center'
Label:
text: app.root.ids.first.ids.unique.text # reference to unique text
font_size: 16
canvas.before:
Color:
rgba: 1,1,1,1
Rectangle:
pos: self.pos
size: self.size
color: 0,0,0,1
Button:
text: "Go Back"
on_release:
app.root.current = "first"
Since the kv for SecondWindow uses app.root, it will cause an error if SecondWindow is instantiated before the root widget of the App is assigned. To avoid that, add the SecondWindow after a slight delay:
class MyApp(App):
def build(self):
Clock.schedule_once(self.add_second_screen)
return kv_main
def add_second_screen(self, dt):
self.root.add_widget(SecondWindow())
I am trying to add an action bar on top in the first screen of my project. I tried using screenmanager widget and sending the action bar as it's children like how to manage/get both of the screens. At first I tried just adding the action bar code in root.widget in the first screen, but they are showing the class for this as an invalid class.
How to add both of them? Also I can't show the buttons from top to bottom even though I added orientation : 'vertical'
import kivy
kivy.require('1.10.1')
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from kivy.uix.gridlayout import GridLayout
from kivy.uix.screenmanager import ScreenManager,Screen,FadeTransition
class SomeLayout_GridLayout(Screen):
pass
class FirstScreen(Screen):
pass
class SecondScreen(Screen):
pass
class ScreenManager(ScreenManager):
pass
root_widget = Builder.load_string('''
ScreenManager:
FirstScreen:
SecondScreen:
SomeLayout_GridLayout:
<FirstScreen>:
name: 'first'
<SomeLayout_GridLayout>:
cols: 1
rows: 2
row_force_default: True
rows_minimum: {0: ActionBar.height, 1: self.height - ActionBar.height}
SomeMenu_ActionBar:
id: ActionBar
<SomeMenu_ActionBar#ActionBar>:
ActionView:
id: ActionView
ActionGroup:
id: App_ActionGroup
mode: 'spinner'
text: 'App'
ActionButton:
text: 'Settings'
on_press: app.open_settings()
ActionButton:
text: 'Quit'
on_press: app.get_running_app().stop()
ActionGroup:
id: File_ActionGroup
mode: 'spinner'
text: 'File'
ActionButton:
text: 'Open'
ActionButton:
text: 'Save'
<HiddenIcon_ActionPrevious#ActionPrevious>:
title: app.title if app.title is not None else 'Action Previous'
with_previous: False
app_icon: ''
app_icon_width: 0
app_icon_height: 0
size_hint_x: None
width: len(self.title) * 10
<HiddenText_ActionPrevious#ActionPrevious>: #
with_previous: False
on_press: print(self)
title: ''
<Hidden_ActionPrevious#ActionPrevious>:
with_previous: False
on_press: print(self)
title: ''
size_hint: None, None
size: 0, 0
BoxLayout:
orientation: 'horizontal'
BoxLayout:
Button:
text: 'Crime Prediction'
font_size: 30
on_release: app.root.current = 'second'
Button:
text: 'Forum'
font_size: 30
on_release: app.root.current = 'second'
Button:
text: 'Probable Suspect'
font_size: 30
on_release: app.root.current = 'second'
<SecondScreen>:
name: 'second'
BoxLayout:
orientation: 'vertical'
Label:
text: 'Predict Crime Nigga!'
font_size: 50
BoxLayout:`enter code here`
Button:
text: 'Back to Main Menu'
font_size: 30
on_release: app.root.current = 'first'
Button:
text: 'get random colour screen'
font_size: 30
on_release: app.root.current = 'first'
''')
class ScreenManagerApp(App):
def build(self):
return root_widget
ScreenManagerApp().run()
Kivy App with ActionBar & ScreenManager
Declare a root widget with inheritance of BoxLayout
Add ActionBar as child of root widget
Add ScreenManager as child of root widget, and with id: sm
Snippets
BoxLayout:
orientation: 'vertical'
ActionBar:
...
ScreenManager:
id: sm
FirstScreen:
SecondScreen:
Example
main.py
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
class WelcomeScreen(Screen):
pass
class FirstScreen(Screen):
pass
class SecondScreen(Screen):
pass
class ScreenManager(ScreenManager):
pass
class CrimePrevention(BoxLayout):
pass
Builder.load_file("main.kv")
class TestApp(App):
title = 'Kivy ScreenManager & ActionBar Demo'
def build(self):
return CrimePrevention()
if __name__ == '__main__':
TestApp().run()
main.kv
#:kivy 1.11.0
#:import sp kivy.metrics.sp
#:import dp kivy.metrics.dp
<CrimePrevention>:
orientation: 'vertical'
canvas.before:
Color:
rgb: .6, .6, .6
Rectangle:
pos: self.pos
size: self.size
# source: 'data/background.png'
SomeMenu_ActionBar:
id: ActionBar
ScreenManager:
id: sm
WelcomeScreen:
FirstScreen:
SecondScreen:
<SomeMenu_ActionBar#ActionBar>:
ActionView:
id: ActionView
HiddenIcon_ActionPrevious:
ActionGroup:
id: App_ActionGroup
mode: 'spinner'
text: 'Jump to Screen'
ActionButton:
text: 'Crime Prediction'
on_release: app.root.ids.sm.current = 'second'
ActionButton:
text: 'Forum'
on_release: app.root.ids.sm.current = 'second'
ActionButton:
text: 'Probable Suspect'
on_release: app.root.ids.sm.current = 'second'
ActionGroup:
id: App_ActionGroup
mode: 'spinner'
text: 'App'
ActionButton:
text: 'Settings'
on_press: app.open_settings()
ActionButton:
text: 'Quit'
on_press: app.get_running_app().stop()
ActionGroup:
id: File_ActionGroup
mode: 'spinner'
text: 'File'
ActionButton:
text: 'Open'
ActionButton:
text: 'Save'
<HiddenIcon_ActionPrevious#ActionPrevious>:
title: '' # app.title if app.title is not None else 'Action Previous'
with_previous: False
app_icon: ''
app_icon_width: 0
app_icon_height: 0
size_hint_x: None
width: len(self.title) * 10
<WelcomeScreen>:
name: 'welcome'
Label:
text: 'Welcome Screen'
font_size: sp(50)
<FirstScreen>:
name: 'first'
Label:
text: 'First Screen'
<SecondScreen>:
name: 'second'
BoxLayout:
orientation: 'vertical'
Label:
text: 'Predict Crime'
font_size: 50
BoxLayout:
Button:
text: 'Back to Main Menu'
font_size: 30
on_release: app.root.ids.sm.current = 'first'
Button:
text: 'get random colour screen'
font_size: 30
on_release: app.root.ids.sm.current = 'first'
Output
I'm currently trying to create a simple Slider that will control the size of text in my application. The problem I'm running into though is that even though the slider functions as I intended, it seems to create another version of itself beneath the first slider that can't be moved. You can see how it looks in the provided image here [alt text: a screenshot of a rudimentary user interface showing a kivy slider. The slider has been moved forward behind it there is another copy in the default position] (as you can see the Label text inside the BoxLayout is also getting overlapped). I'm currently using Kivy 1.10.1 and Python 3.7.2.
Here is my Python script:
# -*- coding: utf-8 -*-
import kivy
kivy.require('1.10.1')
from kivy.app import App
from kivy.core.window import Window
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ObjectProperty
from kivy.uix.actionbar import ActionBar
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
from kivy.graphics.vertex_instructions import (Rectangle, Ellipse, Line)
from kivy.graphics.context_instructions import Color
from kivy.uix.checkbox import CheckBox
from kivy.uix.slider import Slider
#Window.size = (360/1.2,740/1.2)
class HomeScreen(Screen):
pass
class OptionsScreen(Screen):
pass
class TutorialScreen(Screen):
pass
class ScreenController(ScreenManager):
pass
look = Builder.load_file('main.kv')
class MainApp(App):
def build(self):
return look
if __name__ == '__main__':
MainApp().run()
And here is the relevant piece of Kivy language meant to create the slider on my
<OptionsScreen>
name: 'option'
BoxLayout:
orientation:'vertical'
BoxLayout:
orientation:'horizontal'
size_hint_y: 1/3
Label:
text:'Text size'
font_size: textsize.value
size_hint_x:.5
Slider:
id:textsize
min: 5
max: 25
value:15
step: 1
size_hint_x:.5
Though if you want to read the entire Kivy language document I'm posting it here as well.
#: import FadeTransition kivy.uix.screenmanager.FadeTransition
# Reference main.py
#: import main main
#: import Slider kivy.uix.slider
#: import ActionBar kivy.uix.actionbar
#: import Window kivy.core.window
ScreenController:
transition: FadeTransition()
HomeScreen:
OptionsScreen:
TutorialScreen:
<HomeScreen>
name: 'home'
BoxLayout:
id:'hem'
orientation:'vertical'
BoxLayout:
size_hint_x: 1
orientation:'horizontal'
canvas:
Color:
rgba: 0,1,0,1
Rectangle
size: self.size
pos: self.pos
BoxLayout:
orientation:'horizontal'
BoxLayout:
size_hint_x: .5
orientation:'horizontal'
canvas:
Color:
rgba: 1,0,1,1
Rectangle
size: self.size
pos: self.pos
BoxLayout:
size_hint_x: .5
orientation:'horizontal'
canvas:
Color:
rgba: 1,1,0,1
Rectangle
size: self.size
pos: self.pos
ActionBar:
pos_hint: {'top':1}
ActionView:
use_separator: True
ActionPrevious:
title: 'Fredde & Kribbas kivy'
with_previous: False
ActionOverflow:
ActionGroup:
text: 'Group1'
ActionButton:
text: 'home'
on_touch_down: app.root.current = 'home'
ActionButton:
text: 'Options'
on_touch_down: app.root.current = 'option'
ActionButton:
text: 'Tutorial'
on_touch_down: app.root.current = 'tut'
<OptionsScreen>
name: 'option'
BoxLayout:
orientation:'vertical'
BoxLayout:
orientation:'horizontal'
size_hint_y: 1/3
Label:
text:'Text size'
font_size: textsize.value
size_hint_x:.5
Slider:
id:textsize
min: 5
max: 25
value:15
step: 1
size_hint_x:.5
BoxLayout:
#fontsize checkbox
orientation:'horizontal'
size_hint_y: 1/3
BoxLayout:
orientation:'vertical'
Label:
text: 'Nightmode'
CheckBox:
id:default
size_hint_y: None
active: True
height:'50dp'
group:'g1'
BoxLayout:
orientation:'vertical'
Label:
text: 'Daymode'
CheckBox:
id:stor
size_hint_y: None
height:'50dp'
group:'g1'
BoxLayout:
orientation:'horizontal'
size_hint_y: 1/3
canvas:
Color:
rgba: 0,0,1,1
Rectangle
size: self.size
pos: self.pos
ActionBar:
pos_hint: {'top':1}
ActionView:
use_separator: True
ActionPrevious:
title: 'Fredde & Kribbas kivy'
with_previous: False
ActionOverflow:
ActionGroup:
text: 'Group1'
ActionButton:
text: 'home'
on_touch_down: app.root.current = 'home'
ActionButton:
text: 'Options'
on_touch_down: app.root.current = 'option'
ActionButton:
text: 'Tutorial'
on_touch_down: app.root.current = 'tut'
<TutorialScreen>
name: 'tut'
ActionBar:
pos_hint: {'top':1}
ActionView:
use_separator: True
ActionPrevious:
title: 'Fredde & Kribbas kivy'
with_previous: False
ActionOverflow:
ActionGroup:
text: 'Group1'
ActionButton:
text: 'home'
on_touch_down: app.root.current = 'home'
ActionButton:
text: 'Options'
on_touch_down: app.root.current = 'option'
ActionButton:
text: 'Tutorial'
on_touch_down: app.root.current = 'tut'
Does anyone know why I might be having this issue? I'm fairly new to kivy but I've played around with the slider before and never had these issues until now.
You don't need to load your kv file inside your python code since you already named your kv file as main.kv.
You can try to remove this line:
look = Builder.load_file('main.kv')
and change this line:
return look
to:
pass
Pop up and EXE issue
Hi guys I've got problem, whenever I open my Kivy Program via Python, a popup is actually showing up
But when I convert it via Pyinstaller, it gives me an error:
How can I possibly fix this?
Python Code:
import os
os.environ["KIVY_IMAGE"] = "pil, sdl2"
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.popup import Popup
Builder.load_file("kivy.kv")
class Rusure(Popup):
pass
class Menu(Screen):
def quit(self):
Rusure().open()
class Settings(Screen):
def bright (self,*args):
self.brightness.text = "Brightness: {}".format(str(int(args[1])))
class Play(Screen):
pass
class Sm(ScreenManager):
def __init__(self):
super().__init__()
self.add_widget(Menu(name="menu"))
self.add_widget(Settings(name="settings"))
self.add_widget(Play(name="play"))
class GoodApp(App):
def build(self):
return Sm()
GoodApp().run()
Kivy Code:
#: import rit kivy.uix.screenmanager.RiseInTransition
#: import st kivy.uix.screenmanager.SlideTransition
#: import fot kivy.uix.screenmanager.FallOutTransition
#: import Factory kivy.factory.Factory
<Menu>:
BoxLayout:
padding: 100,100,100,100
orientation: "vertical"
Label:
text: "Menu"
BoxLayout:
orientation: "horizontal"
Button:
text: "Play"
background_normal: "Image.jpg"
background_down: "ImageRel.jpg"
color: 1,1,1,1
on_press:
root.manager.transition = rit()
root.manager.current = "play"
Button:
text: "Settings"
background_color: 0.9,1,1,1
on_press:
root.manager.transition = st()
root.manager.current = "settings"
root.manager.transition.direction = "up"
Button:
text: "Quit"
background_color: 1,0.7,0,1
on_press:
root.quit()
<Settings>:
brightness: brght
BoxLayout:
padding: 100,100,100,100
orientation: "vertical"
Label:
text: "Settings"
GridLayout:
cols: 3
Label:
text: "Brightness"
Slider:
min: 0
max: 10
value: 5
on_value: root.bright(*args)
Label:
id: brght
text: "Change Value"
Button:
text: "Back"
on_press:
root.manager.transition = st()
root.manager.current = "menu"
root.manager.transition.direction = "down"
<Play>:
BoxLayout:
Label:
text: "Welcome to the game!"
Button:
text: "Back"
on_press:
root.manager.transition = fot()
root.manager.current = "menu"
<Rusure>:
title: "Are you sure?"
size_hint: 0.5,0.5
auto_dismiss: False
BoxLayout:
orientation: "vertical"
Label:
text: "Your progress will be lost"
GridLayout:
cols: 2
Button:
text: "Oh shit man!"
on_press: root.dismiss()
Button:
text: "Cancel"
on_press: root.dismiss()
I tried searching solution on the internet, but after 3 hours of searching I couldn't come up whith any answer.