And I had one other try that I can not find anymore.
Nevertheless:
Hello group,
I (as a entry level programmer) tried hard to do a drawing canvas using natural orientation. It should work by using “SetAxisOrientation(True, True)” on a device context.
I want to have anti-aliased drawing so I tried it with GraphicsContext and now Cairo, I would like to stay with Cairo, it has many features and good quality. I couldn’t get it working by no means.
The words in the book wxPython in Action “To every Jane and Joe Programmer, chained to their computer, burning the midnight oil, striving to make a dream come true” now get some real meaning for me
Finally I thought I mirror what I have drawn and the blit it to the device context. I have to say I consulted lots of documentation, digged up many examples from the web (actually my script consists 80% of code I glued together) and I couldn’t make it.
So even my try for using a dirty workaround failed.
Current functionality for testing is that it just draws a circle which can be dragged by holding CTRL-key and left mouse button down. It can be zoomed (incl. reset), etc.
I don’t like to go for the floatcanvas, looks complicated for me. Should I?
Take a look at the examples in the Demo’s package, a lot of the
functionality that you are asking for is in the examples there.
···
On 21/01/13 14:21, chiefenne wrote:
This is my 3rd re-post,
because I had some troubles with my computer.
The post is still
visible at:
And I had one other try that I can not find
anymore.
Nevertheless:
Hello group,
I (as a entry level programmer)
tried hard to do a drawing canvas using natural orientation. It
should work by using “SetAxisOrientation(True, True)” on a
device context.
I want to have anti-aliased
drawing so I tried it with GraphicsContext and now Cairo, I
would like to stay with Cairo, it has many features and good
quality. I couldn’t get it working by no means.
The words in the book wxPython in
Action “To every Jane and Joe Programmer, chained to their
computer, burning the midnight oil, striving to make a dream
come true” now get some real meaning for me
Finally I thought I mirror what I
have drawn and the blit it to the device context. I have to say
I consulted lots of documentation, digged up many examples from
the web (actually my script consists 80% of code I glued
together) and I couldn’t make it.
So even my try for using a dirty
workaround failed.
Current functionality for testing
is that it just draws a circle which can be dragged by holding
CTRL-key and left mouse button down. It can be zoomed (incl.
reset), etc.
Thanks for the hint, but this is what I did comprehensively before my
post
Finally I got by chance what I wanted to achieve. It somehow depends on
the call sequence of SetAxisOrientation and SetDeviceOrigin.
I thought I also could call those before memDC.Clear(). I still don't
understand it, but it works fine now. The full working script is attached.
Thanks
def OnPaint(self, event):
self.draw()
dc = wx.BufferedPaintDC(self, self._buffer)
cr = wx.lib.wxcairo.ContextFromDC(memDC)
*# These two must be called after the cairo-*
*# surface is created from the MemoryDC*
*memDC.SetDeviceOrigin(0, self.height)*
*memDC.SetAxisOrientation(True, True)*
self.draw_origin(cr)
self.draw_circle(cr)
memDC.SelectObject(wx.NullBitmap)
I expect that Cairo is also setting some origin and/or orientation settings on the DC. However I would also suggest that if you're going to be using Cairo for drawing anyway that you'll probably be better off using it for the transformations too instead of relying on the DC being already set up that way.