Tkinter: Determine Widget Position relative to Root Window

The tkinter MouseWheel event can only be bound to the root window. Thus the event position is also relative to the root position. For a canvas zooming operation, I would like to get the MouseWheel-event with information about the cursor-position within the canvas. To calculate this I thought I would simply subtract the position of the canvas within the root window. Problem now is, that I can not find out the canvas position in the window.

I tried: can.grid_bbox --> (0,0,0,0) ? can.grid_info can.grid_location cget("offset") pointerx

and some others I can't remember. Somehow I keep on missing it could someone give me a hint?

---edit--- To get the position of the mouseWheel event relative to the canvas, this approach seems to work:

def on_mouse_wheel(self, event): xCan = event.x_root - self.can.winfo_rootx() yCan = event.y_root - self.can.winfo_rooty()


You want to use the winfo_x and winfo_y methods to get the x/y position relative to the parent.


  • How to implement operations from signatures
  • Nepali Date to English Date: Subtract - 56 Years - 8 Months - 16 Days
  • SQLITE - calculate remaining item quantities
  • Pixel-wise summation and subtraction in EmguCV
  • How to $push a field depending on a condition?
  • How can I change the curve of this random number generator dynamically?
  • Parse datetime with hours 1-24 instead of 0-23
  • datatype for handling big numbers in pyspark
  • Numeric to Alphabetic Lettering Function in R [duplicate]
  • Storing a TimeSpan between two DateTimes
  • Tkinter: Determine Widget Position relative to Root Window
  • GMP Bit shift doesn't work on negative numbers
  • Timer once a minute on the minute
  • Finding the number of elements less than or equal to k in a multiset
  • How to get the position of a click event relative to its layer in KineticJS?
  • How to get or calculate size of Azure File/Share or Service
  • MIT Kerberos fails to locate TGT in MSLSA cache
  • How to model a mixture of finite components from different parametric families with JAGS?
  • Query timeout expired in django-mssql when executing custom SQL directly
  • How to use the resource module to measure the running time of a function?
  • SQL Server re-calculate or not?
  • Pre-populated SQLite Database not reading properly in Android Studio
  • Receive mouse move even cursor is outside control
  • Converting query results into DataFrame in python
  • Symfony 2 error page response
  • Yii2: Finding file and getting path in a directory tree
  • How can I tell a form not to dispose a particular control when it closes?
  • Hash Code in SQL Server?
  • Possible to get mouse events fired when cursor is outside page?
  • Intel-64 and ia32 atomic operations acquire-release semantics and GCC 5+
  • Read text file that is not in the main package in a runnable jar
  • WPF ICommand CanExecute(): RaiseCanExecuteChanged() or automatic handling via DispatchTimer?
  • How solve “Qt: Untested Windows version 10.0 detected!”
  • How would I use PHP exceptions to define a redirect?
  • DirectX11 ClearRenderTargetViewback with transparent buffer?
  • Javascript Callbacks with Object constructor
  • How can I use Kendo UI with Razor?
  • Why is the timeout on a windows udp receive socket always 500ms longer than set by SO_RCVTIMEO?
  • Web-crawler for facebook in python
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent