Re: a graphics issue I can not figure out

Tim Roberts <[email protected]>
Newsgroups gmane.comp.python.wxpython
Message-ID <[email protected]>
On Mar 4, 2020, at 3:58 PM, Nathan smith <[email protected]> wrote:
> 
> My goal was to create a grid and then plot some lines upon it.
> 
> I have got the grid working, but I can not seem to position a triangle correctly.

I have a bad habit of making stylistic comments about submitted code.

You should not be storing “dc” and “pen” in a member.  That is, you should use “dc” and “pen”, not “self.dc” and “self.pen”.  You need those objects to evaporate when the function returns, otherwise things don’t get cleaned up.

You can draw the horizontal and vertical grid lines in a single loop:

x0 = g.center_point[0]-6*38
y0 = g.center_point[1]-6*38
x1 = g.center_point[0]+5*38
y1 = g.center_point[1]+5*38
for x in range(11):
    dc.DrawLine( x0, y0+x*38, x1, y0+x*38 )
    dc.DrawLine( x0+x*38, y0, x0+x*38, y1 )

Rufus nailed your other issue.  (0,0) in Windows, X, and MacOS is the upper left and Y increases going down.  In Postscript and OS/2, (0,0) is the lower left and Y increases going up.

I hope you realize that 38 pixels per centimeter is only a rough approximation.  Windows lies about the actual pixel size, because in reality it has no idea how large your monitor is physically.  38 per centimeter maps to 96 pixels per inch.  A 22” monitor running full HD would be 96 dpi, but most people have pixels bigger than that.
— 
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.

-- 
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/DF46E483-BA2E-4E9A-A264-4A9E50870126%40probo.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.