-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kivy#3154 from picibucor/picibucor
examples added
- Loading branch information
Showing
4 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
''' | ||
The use of id in .kv | ||
================================== | ||
This small example shows how to refer from one widget | ||
on an other widget within .kv | ||
''' | ||
from kivy.app import App | ||
|
||
import kivy | ||
kivy.require('1.8.0') | ||
|
||
|
||
class TestApp(App): | ||
pass | ||
|
||
if __name__ == '__main__': | ||
TestApp().run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#:kivy 1.8.0 | ||
|
||
BoxLayout: | ||
orientation: 'vertical' | ||
TextInput: | ||
# setting the id of the widget | ||
id: my_id | ||
text: 'The text of the label is set within kivy' | ||
Label: | ||
# showing the text of the textinput by referring on the id | ||
text: my_id.text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
''' | ||
Referring on ids from .py | ||
================================== | ||
This example shows how to refer to an id from a .py file. | ||
''' | ||
from kivy.app import App | ||
from kivy.uix.boxlayout import BoxLayout | ||
|
||
import kivy | ||
kivy.require('1.8.0') | ||
|
||
|
||
class RootWidget(BoxLayout): | ||
|
||
def first_function(self, status): | ||
# print out the given parameter | ||
print(status) | ||
# check the status of the switch by referring on the id | ||
if self.ids.my_switch.active is True: | ||
# set the text of the label by referring on the id | ||
self.ids.my_label.text = 'Switch is ON' | ||
else: | ||
# set the text of the label by referring on the id | ||
self.ids.my_label.text = 'Switch is OFF' | ||
|
||
|
||
class TestApp(App): | ||
pass | ||
|
||
|
||
if __name__ == '__main__': | ||
TestApp().run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#:kivy 1.0 | ||
|
||
RootWidget: | ||
BoxLayout: | ||
orientation: 'vertical' | ||
Switch: | ||
id: my_switch | ||
on_active: root.first_function(self.active) | ||
|
||
Label: | ||
id: my_label | ||
text: 'This text will be changed by the python file' |