first commit
This commit is contained in:
commit
417e54da96
5696 changed files with 900003 additions and 0 deletions
Binary file not shown.
34
kivy_venv/share/kivy-examples/kv/ids/kv_and_py/kv_and_py.py
Normal file
34
kivy_venv/share/kivy-examples/kv/ids/kv_and_py/kv_and_py.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
'''
|
||||
Referring on ids from Python
|
||||
=============================
|
||||
|
||||
This example shows how to refer to an id from a Python file.
|
||||
'''
|
||||
|
||||
import kivy
|
||||
kivy.require('1.8.0')
|
||||
|
||||
from kivy.app import App
|
||||
from kivy.uix.boxlayout import BoxLayout
|
||||
|
||||
|
||||
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()
|
11
kivy_venv/share/kivy-examples/kv/ids/kv_and_py/test.kv
Normal file
11
kivy_venv/share/kivy-examples/kv/ids/kv_and_py/test.kv
Normal file
|
@ -0,0 +1,11 @@
|
|||
#:kivy 1.8.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'
|
Loading…
Add table
Add a link
Reference in a new issue