title: How to randomize the location of a button in kivy python screen manager?
body: <p>I'm a newbie when it comes to python and kivy, and I have been working on this problem for a while and getting nowhere, so any help is greatly appreciated.  I am working on a behavioral task for rats, in which they would need to press a white square button on a screen to get a treat.  I want the white square to appear in one of three locations each time the stimulus screen appears.  Here is the relevant code that I have so far:</p>
  
  <p>main.kv:</p>
  
  <pre><code>&lt;Stimulus&gt;:
      on_pre_enter: self.update_pos()
      FloatLayout:
          StimButton:
              id: stimbutton
              on_press: root.manager.current = 'screen1'
  
  &lt;StimButton&gt;
      background_normal: ''
      color: 1,1,1,1
      size_hint: 0.2, 0.3
  </code></pre>
  
  <p>and within the python main.py:</p>
  
  <pre><code>class Stimulus(Screen):
      a = ObjectProperty(None)
      def update_pos(self):
          b = randint(1,3)
          if b==1:
              a = {'x':0.1,'y':0.33}
          elif b==2:
              a = {'x':0.4,'y':0.33}
          elif b==3:
              a = {'x':0.7,'y':0.33}
          self.ids.stimbutton.pos_hint = a
  
  class StimButton(Button):
      def on_press(self):
          deliver_pellet()
  </code></pre>
  
  <p>What should happen is that a white square appears, when the rat presses it they get a treat and it switches to a dark screen.  After a delay, a white square shows up in a different one of the 3 possible locations, and they go again.  What ends up happening is that I get one white square in the lower left corner, and the next time the screen appears I have a square in one of the random 3 positions, and one in the lower left corner.  Pressing either square produces the desired outcome.  How do I get that square in the lower left to go away?</p>