title: Get global position of widget in Kivy?
body: <p>I have an image located relative to the screen size with <code>RelativeLayout</code>. How can I get the global (/window) position of that image, so that I can detect if touch coordinates overlap the image?</p>
  <p>this is my current implimentation:</p>
  <pre><code>from kivy.app import App
  
  from kivy.uix.floatlayout import FloatLayout
  from kivy.uix.image import Image
  from kivy.uix.relativelayout import RelativeLayout
  
  class mainApp(App):
      def build(slef):
  
          appRoot = FloatLayout()
          relPos = RelativeLayout()
  
          button = Image()
          relPos.pos_hint = {&quot;right&quot;:1,&quot;top&quot;:1.5}
  
          relPos.add_widget(button)
  
          #attempting to print the coordinates of the Image in the window
          print(relPos.to_parent(*button.pos))
  
          return relPos
  
  if __name__ == '__main__':
      mainApp().run()
  </code></pre>
  <p>As you can see, I'm attempting to use <code>to_parent</code> to get the position relative to the parent. However, I don't think it works <code>pos_hint</code>.</p>
  <p>I've also tried using <code>AnchorLayout</code>, and have had similar issues</p>
  <p>Note: while I know I can use the <code>window_size</code>, allong with a bit of math, I would like a more robust solution that can handle more complex situations</p>