#!/usr/bin/kivy
import mechanizeimport sys
from kivy.app import App
from kivy.uix.floatlayout import FloatLayoutfrom kivy.uix.button import Button from kivy.uix.textinput import TextInputfrom kivy.uix.label import Label
from kivy.uix.screenmanager import ScreenManager, Screen
class MainMenu(Screen): pass
class HackingScreen(Screen): pass
class AboutScreen(Screen): pass
class HelpScreen(Screen): pass
class HackingLayout(FloatLayout): pass
class RootLayout(FloatLayout): def __init__(self): super(FloatLayout, self).__init__()
sm.current = "MainMenu"
def start(self): sm.current = "HackingScreen"
return HackingLayout()
def about(self): pass
def help(self): pass
def quit(self): sys.exit(0)
def get_screen_manager(self): return sm
sm = ScreenManager()
sm.add_widget( MainMenu( name = "MainMenu" ) )sm.add_widget( HackingScreen( name = "HackingScreen" ) )sm.add_widget( AboutScreen( name = "AboutScreen" ) )sm.add_widget( HelpScreen( name = "HelpScreen" ) )
class MainApp(App):
def build(self): return RootLayout()
if __name__ == '__main__': MainApp().run()
<RootLayout>: Label: id: title_label
pos: root.width / 2 - self.width / 2, root.height / 2 - self.height / 2 + 150
font_size: 50
text: "Interletter Hacking Program"
Button: id: start_button
pos: root.width / 2 - self.width / 2, root.height / 2 - self.height / 2
text: "Start Hacking"
size: 150, 30
size_hint_x: None size_hint_y: None
on_release: root.start()
font_size: 19
Button: id: about_button
pos: root.width / 2 - self.width / 2, root.height / 2 - self.height / 2 - 50
text: "About"
size: 150, 30
size_hint_x: None size_hint_y: None
on_release: root.about()
font_size: 19
Button: id: help_button
pos: root.width / 2 - self.width / 2, root.height / 2 - self.height / 2 - 100
text: "How to use"
size: 150, 30
size_hint_x: None size_hint_y: None
on_release: root.help()
font_size: 19
Button: id: quit_button
pos: root.width / 2 - self.width / 2, root.height / 2 - self.height / 2 - 150
text: "Quit"
size: 150, 30
size_hint_x: None size_hint_y: None
on_release: root.quit()
font_size: 19
<HackingLayout>: Button: id: test_button
pos: 100, 100
size: 150, 30
text: "Hello World"
size_hint_x: None size_hint_y: None
font_size: 19
Here is an example of transitioning between 3 screens.
from kivy.app import App
from kivy.lang import Builder
kv = """
#:import FadeTransition kivy.uix.screenmanager.FadeTransition
ScreenManager:
transition: FadeTransition()
MainScreen:
name: 'main'
AnotherScreen:
name: 'other'
text: 'This is the other screen,\\nPress to go to yet another screen'
next_screen: 'yet another'
AnotherScreen:
name: 'yet another'
text: 'This is yet another screen,\\n press to go to main'
next_screen: 'main'
<MainScreen@Screen>:
Button:
on_release: app.root.current = 'other'
text: 'This is main,\\nPress to go to the other Screen'
font_size: 40
<AnotherScreen@Screen>:
text: 'init'
next_screen: 'init'
Button:
on_release: app.root.current = root.next_screen
text: root.text
font_size: 40
"""
class Main1App(App):
def build(self):
return Builder.load_string(kv)
Main1App().run()
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/124e398f-4440-483a-948c-95e73f2aa688o%40googlegroups.com.