Jozef Méry
Jozef Méry

Reputation: 357

How to get the current view position of a canvas?

How can I get (or calculate) the number from the interval [0.0, 1.0], which corresponds to the part of the canvas I'm viewing ? I need the number which is used in for example the canvas.yview_moveto(1.0)(which moves it to the bottom). In my case I only require the Y part. I need this number to be able to fix my previous problem which sadly didn't get fixed. I understand users often ask for a snippet, but in this case I hope it is not needed as I'm asking for either a built-in method or a way to do this. I simply have no idea how to even start with this. Thank you.

Past problem: Canvas leaves scrollregion if scrolled with mouswheel I fixed it using a scrollbar which has the .get() method returning the number as I need it, but I want a better solution, without the scrollbar.

Upvotes: 1

Views: 1553

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 385870

The yview method of a canvas, when called with no arguments, returns a tuple containing the two values you seek.

Upvotes: 5

Related Questions