Reputation: 35
I have tried to write code using Kivy/KivyMD libraries after a break and I noted that I cannot make buttons to work. There is no reaction even when I use the old code I know was working fine.
There is no reaction after I click a button and I have this issue with both Kivy and KivyMD buttons.
Here is a sample code:
from kivy.app import App
from kivy.uix.button import Button
class ButtonApp(App):
def build(self):
btn = Button(text="Push Me !",
font_size="20sp",
background_color=(1, 1, 1, 1),
color=(1, 1, 1, 1),
size=(32, 32),
size_hint=(.2, .2),
pos=(300, 250))
btn.bind(on_press=self.callback)
return btn
def callback(self, event):
print("button pressed")
root = ButtonApp()
root.run()
I took the above sample code from this webpage: https://www.geeksforgeeks.org/python-working-with-buttons-in-kivy/. As I wrote this is true for both Kivy and KivyMD and there is simply no reaction once I press the button.
I'm using Pycharm version 203.7148.72, Kivy version 2.0.0, KivyMD version 0.104.1.
Thank you in advance for any assistance.
Upvotes: 0
Views: 315
Reputation: 5947
Posting as an answer for more visibility since the issue was solved in comments.
Make sure that kivy input sources are correctly configured for your device, in the config.ini file (<HOME_DIRECTORY>/.kivy/config.ini
see https://kivy.org/doc/stable/guide/config.html?highlight=config), is an [input]
section.
On desktop, you usually want at least a mouse to be configured in this section, the most simple way to achieve that being a mouse=mouse
line, with optionaly the multitouch_on_demand
option (i.e mouse=mouse,multitouch_on_demand
).
Upvotes: 1