kivy

Kivy - Removing widget by id

此生再无相见时 提交于 2021-02-07 09:14:06
问题 I have the following code: from kivy.app import App from kivy.uix.floatlayout import FloatLayout class GUI(FloatLayout): def remove(self): self.remove_widget(self.ids.test) class GUIApp(App): def build(self): return GUI() if __name__ == '__main__': GUIApp().run() And the corresponding kv file: #:kivy 1.9.1 <GUI>: BoxLayout: Button: id: test text: 'Test' on_press: root.remove() The button should be removed when clicked. However, this does not happen. If I remove the BoxLayout in the kv file,

Kivy - Removing widget by id

点点圈 提交于 2021-02-07 09:12:36
问题 I have the following code: from kivy.app import App from kivy.uix.floatlayout import FloatLayout class GUI(FloatLayout): def remove(self): self.remove_widget(self.ids.test) class GUIApp(App): def build(self): return GUI() if __name__ == '__main__': GUIApp().run() And the corresponding kv file: #:kivy 1.9.1 <GUI>: BoxLayout: Button: id: test text: 'Test' on_press: root.remove() The button should be removed when clicked. However, this does not happen. If I remove the BoxLayout in the kv file,

kivy, how to trigger event by text change

大兔子大兔子 提交于 2021-02-07 08:15:39
问题 Several GUI toolboxes include events such as on_change which are triggered every time the text in a textbox changes. According to this: https://kivy.org/docs/api-kivy.uix.textinput.html the on_text event should be equal. So, I created a single TextInput box expecting everytime a change a single letter, the content of the box to be displayed in the terminal. This is the code: from kivy.app import App from kivy.uix.textinput import TextInput from kivy.uix.boxlayout import BoxLayout class

kivy, how to trigger event by text change

有些话、适合烂在心里 提交于 2021-02-07 08:15:21
问题 Several GUI toolboxes include events such as on_change which are triggered every time the text in a textbox changes. According to this: https://kivy.org/docs/api-kivy.uix.textinput.html the on_text event should be equal. So, I created a single TextInput box expecting everytime a change a single letter, the content of the box to be displayed in the terminal. This is the code: from kivy.app import App from kivy.uix.textinput import TextInput from kivy.uix.boxlayout import BoxLayout class

kivy: make widget react different for single- and double-tap

我们两清 提交于 2021-02-07 04:19:43
问题 I detect a double-tap on a widget like described in the kivy doc. How can i realize different reaction for single- and double-tap in a good way? def on_touch_down(self, touch): if self.collide_point(*touch.pos): if touch.is_double_tap: print('here start function B (but not function A in advance!)') else: print('here start function A') return super(MyLabel, self).on_touch_down(touch) 回答1: I would check this out: https://groups.google.com/forum/#!topic/kivy-users/slYzx9uZ39M it looks like you

kivy: make widget react different for single- and double-tap

亡梦爱人 提交于 2021-02-07 04:19:29
问题 I detect a double-tap on a widget like described in the kivy doc. How can i realize different reaction for single- and double-tap in a good way? def on_touch_down(self, touch): if self.collide_point(*touch.pos): if touch.is_double_tap: print('here start function B (but not function A in advance!)') else: print('here start function A') return super(MyLabel, self).on_touch_down(touch) 回答1: I would check this out: https://groups.google.com/forum/#!topic/kivy-users/slYzx9uZ39M it looks like you

How to keep kivy service running in background in Android (service still run when switch to other App or lock the screen)?

为君一笑 提交于 2021-02-04 21:08:41
问题 I'm trying to build an android APP with kivy,my requirement is quit simple: When open the android APP,it will start counting from 0, and a prompt will pop up in the status bar every 5 seconds. The prompt content is the current count value. If the APP is switched to the background or the screen is locked, a prompt will still pop up in the status bar every 5 seconds. here is the code I modified from Internet: from os.path import join, dirname, realpath import kivy from kivy.app import App from

How to keep kivy service running in background in Android (service still run when switch to other App or lock the screen)?

江枫思渺然 提交于 2021-02-04 21:07:12
问题 I'm trying to build an android APP with kivy,my requirement is quit simple: When open the android APP,it will start counting from 0, and a prompt will pop up in the status bar every 5 seconds. The prompt content is the current count value. If the APP is switched to the background or the screen is locked, a prompt will still pop up in the status bar every 5 seconds. here is the code I modified from Internet: from os.path import join, dirname, realpath import kivy from kivy.app import App from

How to ref a TextInput from one screen in another screen in Kivy/Python?

狂风中的少年 提交于 2021-01-29 18:41:03
问题 I'm trying to make an app that can calculate the volume of a cone(so far). I have a screen named ConeVolumeScreen that has two TextInput widgets. <ConeVolumeScreen>: BoxLayout: orientation: ... padding: ... spacing: ... Label: text: 'Radius:' TextInput: id: cone_vol_radius multiline: False input_type: 'number' Label: text: 'Height:' TextInput: id: cone_vol_height multiline: False input_type: 'number' Button: text: 'Solve' on_release: app.root.changeScreen('solve cone volume') A person is

is there a way to write Persian in python kivy

余生长醉 提交于 2021-01-29 17:08:23
问题 i try to write Persian in python kivy but it is not working. from kivy.app import App from kivy.uix.screenmanager import ScreenManager,Screen from kivy.lang import Builder from kivy import Config from kivy.uix.label import Label from kivy.uix.widget import Widget class MainApp(App): def build(self): return Label(text= "فارسی") if __name__ == "__main__": MainApp().run() 回答1: You need to use some Persian font. I have done it with Arabic text You can download the font from here Then use arabic