python - StackLayout changes size automagically in kivy framework -



using win7, eclipse, python 2.7 + kivy framework developing opengl app.
trying check collision points(x, y) of widget on mouse click. create layout specific size, when entering on_touch_down(mouse click) callback layout size strangely changed(here problem). let me show code:

class playscreen(screen):      layout = none      def __init__(self):           self.layout = stacklayout(size=(types.screen_size_width, 100))           #then create widgets inside layout:           self.lblscore = label(text='score:', size_hint=(.1, .1))           self.lblscorevalue = label(text='0', size_hint=(.1, .1))           .....           self.layout.add_widget(self.lblscore)           self.layout.add_widget(self.lblscorevalue)           #here debugger shows me self.layout size be(800, 100)       #and want test if click on self.layout:     def on_touch_down(self, touch):         bcanaddtower = true         if self.layout.collide_point(touch.x, touch.y) == true:             print "colision menu"         #here self.layout has size=(800, 600)(here problem) entire window size, , of course collision time. 

does have idea why size of self.layout changes in on_touch_down method?

the initial size because instantiate widget size, code run aftewards sees value. however, parent widget screen layout class (specifically relativelayout) automatically resizes children fill unless set other options. automatic resizing takes place after __init__ (but before next frame), why on_touch_down, or other method, see new size.

in case, can add size_hint=(none, none) self.layout instantiation. tells parent screen not manually control size, remain have set it.

in longer term, may want work proportional size setting rather fixed value, totally fixed size won't appear same way on different screen sizes, pixel densities etc.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -