Hi all,
I would like to create a tool for drawing on screen with mouse to annotate any application and then save the annotations as an image (something similar to Ardesia, just simpler). I was searching online and I found basically three possibilities - using wx.ScreenDC, drawing on transparent frame or ShapedWindow. I was doing some very preliminary tests and I was not able to get anything usable so far. The wx.ScreenDC looked promising but the drawing disappears immediately. The transparent frame makes transparent also the drawing which I don’t want. The ShapedWindow seems to allow to draw only on the not transparent part. So I was wondering if you have any idea what could be the right approach. I need it mostly for Windows platform.
Thanks for any advice.
Anna
Anna Petrášová wrote:
I would like to create a tool for drawing on screen with mouse to
annotate any application and then save the annotations as an image
(something similar to Ardesia, just simpler). I was searching online
and I found basically three possibilities - using wx.ScreenDC, drawing
on transparent frame or ShapedWindow. I was doing some very
preliminary tests and I was not able to get anything usable so far.
The wx.ScreenDC looked promising but the drawing disappears
immediately. The transparent frame makes transparent also the drawing
which I don't want. The ShapedWindow seems to allow to draw only on
the not transparent part. So I was wondering if you have any idea what
could be the right approach.
wx.ScreenDC will allow you to draw on any portion of the desktop, but
since you don't have a window over the top, it doesn't keep focus. When
you click the mouse to start drawing, the app you're drawing on will get
the mouse click and motion messages.
It seems to me that the only practical way to do this is to grab a
screenshot of the entire screen, then have your app come up as a normal
full-screen window without borders. Display the screenshot, and let the
user draw on it like a normal paint application. That way, you're in
complete control, and the background applications won't interfere. It
does mean you won't see any updates should the background windows change.
If you really want the drawing to be relative to another application,
has it occurred to you that you will need to track the window location
and size of application you're drawing on, so you can make all of the
drawing relative to that window?
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Hi all,
I would like to create a tool for drawing on screen with mouse to annotate any application and then save the annotations as an image
So you want to draw on top of other applications? Interesting…
That’s probably the way to go,
drawing on transparent frame
That also may work, it depends some on the UI you want. And what you can get to work…
The wx.ScreenDC looked promising but the drawing disappears immediately.
You might try:
Drawing to a MemoryDC, then drawing That to a screenDC – that way you can save the contents of the bitmap associated with the MemoryDC. And easily re-draw it to the screen DC when it needs to be refreshed.
Not that I’ve ever tried anything like that…
You could also save a vector representation if what is drawn that you can then re-render to the Screen,DC when needed, and render to a MemoryDC when you want to save it.
One trick is knowing when you need to re- draw – you probably don’t get a PaintEvent when stuff needs refreshing outside your app’s Windows.
HTH,
Chris
···
On Sep 30, 2014, at 2:23 PM, “Anna Petrášová” kratochanna@gmail.com wrote:
The transparent frame makes transparent also the drawing which I don’t want. The ShapedWindow seems to allow to draw only on the not transparent part. So I was wondering if you have any idea what could be the right approach. I need it mostly for Windows platform.
Thanks for any advice.
Anna
–
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 wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Seems like ShapedWindow might be able to be combined with wx.STAY_ON_TOP… have a button in your application that turns on and off drawing, when drawing is on and MOUSE_DOWN happens, find the window under the cursor (likely OS dependent calls needed) and create a bitmap the size of that window (on Windows I guess you’d track the HWND) and also a Frame (Shaped) if you don’t already have one stored for it.
Then as the ShapedWindow demo does, perform this on the new frame with you drawn-on bitmap:
Use the bitmap’s mask to determine the region
r = wx.RegionFromBitmap(self.bmp)
self.hasShape = self.SetShape(r)
Then you’ll need to have a thread I guess that runs and watches all the windows you drew on to see if they moved, and also if they got expanded/resized (not sure if you would want to increase/crop or scale the image), and probably also what Z-index or Z-height the Window is at (so your drawing is hidden when another window is dragged on top).
Pretty cool idea!
···
On Tuesday, September 30, 2014 2:23:19 PM UTC-7, annakrat wrote:
Hi all,
I would like to create a tool for drawing on screen with mouse to annotate any application and then save the annotations as an image (something similar to Ardesia, just simpler). I was searching online and I found basically three possibilities - using wx.ScreenDC, drawing on transparent frame or ShapedWindow.
Thanks all for your ideas, too bad nobody actually did anything like that. It seems the result would be quite unsure, I have to give it a thought,
Cheers,
Anna
···
On Wednesday, October 1, 2014 5:00:28 PM UTC-4, Nathan McCorkle wrote:
On Tuesday, September 30, 2014 2:23:19 PM UTC-7, annakrat wrote:
Hi all,
I would like to create a tool for drawing on screen with mouse to annotate any application and then save the annotations as an image (something similar to Ardesia, just simpler). I was searching online and I found basically three possibilities - using wx.ScreenDC, drawing on transparent frame or ShapedWindow.
Seems like ShapedWindow might be able to be combined with wx.STAY_ON_TOP… have a button in your application that turns on and off drawing, when drawing is on and MOUSE_DOWN happens, find the window under the cursor (likely OS dependent calls needed) and create a bitmap the size of that window (on Windows I guess you’d track the HWND) and also a Frame (Shaped) if you don’t already have one stored for it.
Then as the ShapedWindow demo does, perform this on the new frame with you drawn-on bitmap:
Use the bitmap’s mask to determine the region
r = wx.RegionFromBitmap(self.bmp)
self.hasShape = self.SetShape(r)
Then you’ll need to have a thread I guess that runs and watches all the windows you drew on to see if they moved, and also if they got expanded/resized (not sure if you would want to increase/crop or scale the image), and probably also what Z-index or Z-height the Window is at (so your drawing is hidden when another window is dragged on top).
Pretty cool idea!
P.S. I said to do it this way, so that interacting with the drawn-on window isn’t blocked by a non-shaped but transparent window/frame with your drawing bitmap.
···
On Wednesday, October 1, 2014 2:00:28 PM UTC-7, Nathan McCorkle wrote:
On Tuesday, September 30, 2014 2:23:19 PM UTC-7, annakrat wrote:
Hi all,
I would like to create a tool for drawing on screen with mouse to annotate any application and then save the annotations as an image (something similar to Ardesia, just simpler). I was searching online and I found basically three possibilities - using wx.ScreenDC, drawing on transparent frame or ShapedWindow.
Seems like ShapedWindow might be able to be combined with wx.STAY_ON_TOP… have a button in your application that turns on and off drawing, when drawing is on and MOUSE_DOWN happens, find the window under the cursor (likely OS dependent calls needed) and create a bitmap the size of that window (on Windows I guess you’d track the HWND) and also a Frame (Shaped) if you don’t already have one stored for it.
Then as the ShapedWindow demo does, perform this on the new frame with you drawn-on bitmap:
Use the bitmap’s mask to determine the region
r = wx.RegionFromBitmap(self.bmp)
self.hasShape = self.SetShape(r)
Tim Roberts wrote:
Anna Petrášová wrote:
I would like to create a tool for drawing on screen with mouse to
annotate any application and then save the annotations as an image
(something similar to Ardesia, just simpler). ...
...
It seems to me that the only practical way to do this is to grab a
screenshot of the entire screen, then have your app come up as a normal
full-screen window without borders.
For what it's worth, the scheme I described is exactly how the "snipping
tool" in Windows 7 works. It grabs a screen shot of the entire desktop,
and then you work with that static snapshot. Anything that changes
while you're working is not reflected.
I'm not sure you could do it any other way. You are liable to make
things very difficult for the user if he can SEE a window, but he can't
click on the buttons or type text because your transparent window is on
top. That's why the snipping tool changes the screen contrast -- it
makes it obvious that you're not live.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
That was my thinking for why you’d want to use a shaped window, it would fail if a user drew all over the buttons though… you could literally cross-out buttons by drawing on top of them… which might be a fun trick to play on someone 
···
On Friday, October 3, 2014 10:02:07 AM UTC-7, Tim Roberts wrote:
Tim Roberts wrote:
Anna Petrášová wrote:
I would like to create a tool for drawing on screen with mouse to
annotate any application and then save the annotations as an image
(something similar to Ardesia, just simpler). …
…
It seems to me that the only practical way to do this is to grab a
screenshot of the entire screen, then have your app come up as a normal
full-screen window without borders.
For what it’s worth, the scheme I described is exactly how the "snipping
tool" in Windows 7 works. It grabs a screen shot of the entire desktop,
and then you work with that static snapshot. Anything that changes
while you’re working is not reflected.
I’m not sure you could do it any other way. You are liable to make
things very difficult for the user if he can SEE a window, but he can’t
click on the buttons or type text because your transparent window is on
top.