python - Why can't I change screens on click? -


i trying make game using kivy. have created start screen , game screen. app won't run , error "typeerror: bind() takes 0 positional arguments (1 given)". sounds there problem when try bind screen action "press start" image.

from kivy.app import app kivy.uix.widget import widget kivy.uix.image import image kivy.core.window import window kivy.uix.screenmanager import screenmanager, screen kivy.uix.label import label kivy.uix.behaviors import buttonbehavior  #beginning of screen manager code  class menuscreen(screen):     pass class game(screen):     pass  sm = screenmanager() sm.add_widget(menuscreen(name = "menu")) sm.add_widget(game(name = "game"))  #end of screen manager code  class iconbutton(buttonbehavior, image):     pass  class moveableimage(image):      def __init__(self, **kwargs):         super(moveableimage, self).__init__(**kwargs)         self._keyboard = window.request_keyboard(none, self)         if not self._keyboard:             return         self._keyboard.bind(on_key_down=self.on_keyboard_down)         self._keyboard.bind(on_key_up=self.on_keyboard_up)       def on_keyboard_down(self, keyboard, keycode, text, modifiers):         if keycode[1] == 'left':             self.x -= 6             self.source = 'selectionscreen/jeezyleft.zip'         elif keycode[1] == 'right':             self.x += 6             self.source ='selectionscreen/jeezyright.zip'         elif keycode[1] == 'down':             self.y -= 6             self.source ='selectionscreen/jeezyright.zip'         elif keycode[1] == 'up':             self.y += 6             self.source = 'selectionscreen/jeezyback.zip'         else:             return false         return true      def on_keyboard_up(self, keyboard, keycode):         if keycode[1] == 'left':             self.source = 'selectionscreen/jeezyleft1.png'         elif keycode[1] == 'right':             self.source ='selectionscreen/jeezyright1.png'         elif keycode[1] == 'down':             self.source ='selectionscreen/jeezyright1.png'         elif keycode[1] == 'up':             self.source ='selectionscreen/jeezyback2.png'         else:             return false         return true   class gameapp(app):     def build(self):         #instantiate menuscreen class         p = menuscreen()         clickme = iconbutton(source='selectionscreen/presstostart.png')         #clickme = label(text='press start [ref=start]start[/ref]', markup=true)         clickme.bind(sm.switch_to(game(), direction='right'))         p.add_widget(clickme)         return p            #instantiate gamescreen class         m = game()         wimg = moveableimage(source='selectionscreen/jeezyright1.png',    anim_available=true, anim_delay=.15)         m.add_widget(wimg)       if __name__ == '__main__':     gameapp().run() 

i answered on irc when asked, guess got disconnected:

03:51 < inclement> on line 12 create game class, intend called gamescreen? code pasted crash, refer gamescreen don't declare it

03:52 < inclement> on line 70 switch game, empty screen since has no behaviour

03:53 < inclement> if want switch 1 created on line 73, set 'current' property 'game', don't use switch_to

also, syntax bind wrong, calling switch_to when should pass it. use functools.partial give arguments @ stage (returning new function automatically gets arguments).

i'm pasting because have couple of minutes, i'll write more later if isn't clear.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -