Re: a graphics issue I can not figure out
"'Chris Barker' via wxPython-users" <[email protected]>
| Newsgroups | gmane.comp.python.wxpython |
|---|---|
| Message-ID | <CALGmxE+vBzceRKc=D5dtZoPzxm8YNoAb25NP1Rpt+5NWtz20GQ@mail.gmail.com> |
It's been a while, but note that wx.lib.FloatCanvas was designed specifically to solve these kinds of problems :-) https://wxpython.org/Phoenix/docs/html/wx.lib.floatcanvas.html -CHB On Thu, Mar 5, 2020 at 6:05 AM Nathan smith <[email protected]> wrote: > Hello! > > I actually did not know that and have thus, slapped myself (virtually) in > the face. > > That would actually explain quite a bit. > > I was thinking 0 0 was in the bottom left hand corner of the screen. > > thank you, Rufus for your pointing out what I'm sure was an obvious logic > error to everyone else, you've made this little project make a lot more > sense :) > > Tim, as always, your advice is extremely valuable and often times I find > myself coming back to your emails on other projects and going "Now hang on > a second here... Aha, yes Tim mentioned that when answering that question." > > Thank you so much again. > > Nathan > On 05/03/2020 05:33, Tim Roberts wrote: > > 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 > <https://groups.google.com/d/msgid/wxpython-users/DF46E483-BA2E-4E9A-A264-4A9E50870126%40probo.com?utm_medium=email&utm_source=footer> > . > > -- > 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/0c3cb2d8-9c75-3a97-a91d-f27001e4bf51%40gmail.com > <https://groups.google.com/d/msgid/wxpython-users/0c3cb2d8-9c75-3a97-a91d-f27001e4bf51%40gmail.com?utm_medium=email&utm_source=footer> > . > -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [email protected] -- 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/CALGmxE%2BvBzceRKc%3DD5dtZoPzxm8YNoAb25NP1Rpt%2B5NWtz20GQ%40mail.gmail.com.