PyQt: viewport vs window - how do you translate co-ordinates?

Michael Torrie torriem at gmail.com
Sat Sep 23 11:05:10 EDT 2017


On 09/23/2017 05:38 AM, Veek M wrote:
> I didn't understand any of that - could someone expand on that para?
> Is there a reading resource that explains the Viewport and translations? I am not a CS student so I did not study computer graphics.

I'm sure there are lots of things that might help. This is primarily
about OpenGL but the principles may apply:
https://www.cs.mtsu.edu/~jhankins/files/4250/notes/WinToView/WinToViewMap.html

Alternatively, you can think it through.  Imagine you're laying out a
fence around your house. You could use global coordinates for
everything, or you could just call the exact center of your yard 0,0 and
measure everything from there, in whatever units you wish. That's the
idea here. Rather than referring to pixels by their screen coordinates
(which can change if it moves around the screen), you refer to them by
an arbitrary coordinate system with it's own scaling relative to the
screen region.  You could have a screen region that is 100 px by 100 px,
and the you designate that the upper left corner of that region is
-500,500 and the lower right corner is 500,-500. Or it could be
something like -500,200 to 500,-200, which would make things stretched
out in the x axis compared to the y axis.

> (sorry for using google groups but my knode is broken and pan is horrible on olvwm - my plan is to write myself a News client in PyQt :))

I don't think you need to know that much about graphics coordinate
systems to get started with Qt. Most GUI layout stuff does not depend on
pixels or coordinates.




More information about the Python-list mailing list