+ 4
kivy question (snake)
Can someone tht know kivy help me with this code? https://code.sololearn.com/cjr5xgekEE1k i dont know how to do the tail and use keyboards events in it
6 Antworten
+ 3
For adding keyboard events you can just bind a function for on_key_down on the widget.
You an do like this inside your widget class:
#make sure you import Window from kivy.core.window and request a keyboard.
# suppose your keyboard is in self.keyboard then do
self.keyboard.bind(on_key_down= self.keydownFunc)
#keydownFunc here
def keydownFunc(self, keyboard, keycode, text, modifiers):
#you can assign action using text but here I'm showing by using keycode
#assign job for each keydown
if keycode[1] == 'a':
#do something
elif keycode[1] == 'b':
#do something
elif keycode[1]== 'up':
#something else
+ 2
PyDan Shashi Ranjan Do u guys know how to do the tail? I will have to create more labels for this , right?
+ 2
Queen Arthur I'm working with kivy these days but I think, it'll take some time for me to understand the working of your code in order to help you with some specific part.
+ 1
Some widgets size are small, you can change them
+ 1
I think you maybe follow this video. It simple and easy to learn
Snake game
https://www.youtube.com/watch?v=onfix2QrES8&feature=youtu.be