Im using
Button:
on_press: app.test()
But whenever I run the program instead of showing a button the function I've binded it to just runs automatically. Any ideas on what I could be doing wrong
you should probably do
root.test()
not
app.test()
Related
Title might be misleading, but I am creating a login system with kivy, and I was wondering how to clear what is typed in the TextInput boxes once the user leaves the screen. I found one way, with the built in on_pre_enter function with kivy, but noticed even though it's empty, when the user returns and clicks the box everything comes back up. A way to fix this?
<LoginScreen>:
name: 'login'
on_pre_enter:
userid.canvas.clear()
userpw.canvas.clear()
I am trying to write a function that launches a popup in a kivy gui based on a conditional. The method is outside of the main app because I am using multithreading to have both run at the same time. Every time I try to initialize a new popup in the method which is outside of the main app, it crashes. If I don't initialize it, it runs fine. Any ideas?
You must perform GUI related operations (like opening or dismissing a Popup) on the kivy thread.
In your code, where you would call sm.open_unrecognized() do Clock.schedule_once(sm.open_unrecognized, 0). This will schedule the call to open_unrecognized on the kivy thread after the next frame is displayed.
Dismissing the Popup can be done automatically (any click outside the Popup) or explicitly using something like a Button in the Popup. Note that any code called by a Button event is performed on the kivy thread.
See the Clock documentation for more information
I want to be able to open the bubble with a button click.
I am kind of new to kivy.
Here's the code in the kivy file:
Button:
bubble:bubble.__self__
text:"Home"
on_release:self.show_bubble
Bubble:
id:bubble
size_hint: (None, None)
size: (150, 50)
pos_hint: {'x': 1, 'y': 1.7}
arrow_pos: 'bottom_mid'
orientation: 'horizontal'
BubbleButton:
text: "This is"
BubbleButton:
text: "a"
BubbleButton:
text: "Bubble"
Could anyone help?
Thanks.
You should follow the example shown here:
https://kivy.org/docs/api-kivy.uix.bubble.html
i.e. put the Bubble in a separate FloatLayout (for example) instead of inside the triggering Button
I have worked in KIVY for mobile-based application development. But let me tell you its quite a pain. If you just want to make interactive python programs that are not mobile based I think you should start with the Tkinter module.
KIVY is really ugly. I suggest porting to JAVA for mobile application development simply because it was born to do that.
We have a long way till everyone starts using python for mobile apps.
I'm just learning Python and the Kivy framework. I can't seem to find any specific complete examples of being able to gracefully exit a Kivy app using code linked to a button.
I have found Kivy code snippets like this
Button:
id:btnExit
text:"Exit"
on_press: app.Exit()
But not any matching code that implements the app.Exit() call. Everything I've tried stops code execution but doesn't clean up the program window.
I've read that Android and iOS style guides state that a program is not to programmatically exit and let the OS handle it but I am developing fullscreen borderless Desktop app and need a way to exit the program with a button press.
Use App.stop(*largs):
Button:
id: btnExit
text: "Exit"
on_press: app.stop()
Try using App.get_running_app().stop().
For more details, read the Kivy documentation article for the function.
Try using self.root_window.close().
There is bug in new android toolchain.
I used
on_press : app.stop()
in Button's property in Kivy Layout File and it worked well for me.
Hej
I like to customize the On/Off Switch in kivy. For a Button I know how to do it. The kv code looks like this:
Button:
background_normal: 'gfx/offButton.png'
background_down: 'gfx/onButton.png'
Now I whant to know it for the Switch widget. Any Ideas?
The switch does not have properties to control this. Maybe it should, but it also has more behaviour than just on/off since you can drag the slider.
If you just want an active/inactive choice, you could use a CheckBox (which does have background image properties).