commiting in case the kivy trial fails
This commit is contained in:
Binary file not shown.
@@ -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
freechat-client/share/kivy-examples/kv/ids/kv_and_py/test.kv
Normal file
11
freechat-client/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'
|
||||
Reference in New Issue
Block a user