python - __init__ values vs instantiation value -


i new python , kivy, stuck @ under standing __init__ variable instantiation, code follows:

from kivy.uix.button import button kivy.uix.gridlayout import gridlayout kivy.uix.boxlayout import boxlayout  spots={}  class spot(button):     '''     classdocs     '''     def __init__(self, **kwargs):         '''         constructor         '''         super(spot,self).__init__(**kwargs)         self.ismine=false         self.text="x"  class game(boxlayout):              def attachtogrid(self):         self.m.clear_widgets()         spots.clear()         r in range(0,25):             c in range(0,25):                 id=str(r)+","+str(c)                 spots[id]=id                 self.m.add_widget(spot(text=id))  

my issue although passing id value text property (last line of code), still getting 'x' text default in spot class; , if remove default text (self.text="x") class id text working.

could please clarify above default values , instantiation differences. thank you.

def __init__(self, **kwargs): # kwargs dict containing text     '''     constructor     '''     super(spot,self).__init__(**kwargs)     self.ismine=false     self.text=kwargs['text'] # need assign here 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -