Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Brady James Garvin
separate_screens
Commits
f88be241
Commit
f88be241
authored
Mar 22, 2019
by
Brady James Garvin
Browse files
Added explanatory comments.
parent
566967e5
Changes
6
Hide whitespace changes
Inline
Side-by-side
first_screen.kv
View file @
f88be241
...
...
@@ -5,7 +5,7 @@
text: 'This is the first screen.'
Button:
text: 'This button prints a number.'
on_press: root.print_number()
on_press: root.print_number()
# In a custom widget's Kv, `root` refers to the custom widget.
Button:
text: 'Change…'
on_press: app.open_second_screen()
on_press: app.open_second_screen()
# But `app` still refers to the application object.
first_screen.py
View file @
f88be241
...
...
@@ -3,7 +3,7 @@ from kivy.uix.screenmanager import Screen
from
kivy.properties
import
NumericProperty
Builder
.
load_file
(
'first_screen.kv'
)
Builder
.
load_file
(
'first_screen.kv'
)
# Because this is not the main app Kv, we must load it explicitly.
class
FirstScreen
(
Screen
):
...
...
main.py
View file @
f88be241
from
kivy.app
import
App
# The following lines ensure that FirstScreen and SecondScreen are available for when the Kv code is loaded.
# Because neither PyCharm nor PyLint are aware of the associated Kv, we must disable their warnings about these widgets
# not being used.
# noinspection PyUnresolvedReferences
from
first_screen
import
FirstScreen
# pylint: disable=unused-import
# noinspection PyUnresolvedReferences
...
...
second_screen.kv
View file @
f88be241
...
...
@@ -4,7 +4,7 @@
Label:
text: 'This is the second screen.'
Label:
text: root.message
text: root.message
# In a custom widget's Kv, `root` refers to the custom widget.
Button:
text: 'Change…'
on_press: app.open_first_screen()
on_press: app.open_first_screen()
# But `app` still refers to the application object.
second_screen.py
View file @
f88be241
...
...
@@ -3,8 +3,8 @@ from kivy.uix.screenmanager import Screen
from
kivy.properties
import
StringProperty
Builder
.
load_file
(
'second_screen.kv'
)
Builder
.
load_file
(
'second_screen.kv'
)
# Because this is not the main app Kv, we must load it explicitly.
class
SecondScreen
(
Screen
):
message
=
StringProperty
(
'Hello, World!'
)
message
=
StringProperty
(
'Hello, World!'
)
# This property is changed by twoscreen.kv.
twoscreen.kv
View file @
f88be241
...
...
@@ -5,4 +5,4 @@ ScreenManager:
SecondScreen:
id: second
name: 'second'
message: 'This is a message!'
message: 'This is a message!'
# The app sends information to the custom widgets by setting their properties.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment