Steve, thanks for the info, I am struggling still.
When I unplug my second monitor everything works as expected, no real
surprise there.
My Laptop screen size is 1366 x 768
However when I plug the second monitor 1920 x 1080
The first screenshot, (of the smaller res monitor), I get is again an
image of the smaller screen but there is a black band at the top of that
image, presumably the height of the difference between the heights of my
screen resolution (1080-766) adn it is missing the bottom of the screen
The second screenshot is very similar to the first image but wider (1920
pixels) and but the capture is still starting at the 0,0 coordinate of
both my monitors
I am confused about the 'screen' parameter in the call to Blit.
I was thinking to shift the coordinates of the screen
using SetClippingRect() but I can't seem to figure out how to adjust the
spot the image is captured from, its always at upper left of my screens
How can i shift the screen ot maybe I'm thinking about this all wrong
(likely the case)
Sean
def onScreenShot2():
app = wx.App(False)
displays = (wx.Display(i) for i in range(wx.Display.GetCount()))
for i,d in enumerate(displays):
geom = d.GetGeometry() # inspect this in debugger
size = geom.GetSize()
print("Monitor{} size is {}".format(i,size))
width=size[0] #Width of Monitor
height=size[1] # Height of monitor
bmp = wx.EmptyBitmap(width, height) # create empty bitmap same size as screen
mem = wx.MemoryDC(bmp)
screen = wx.ScreenDC() # What is this,
#rect = (1366,0,width,height)
#screen.SetClippingRect(rect)
mem.Blit(0, 0, width, height, screen, 0, 0)
bmp.SaveFile("myImage_{}.png".format(i), wx.BITMAP_TYPE_PNG)
On Monday, 3 October 2016 21:28:05 UTC-4, Sean Tiley wrote:
Hello,
I am trying to figure out how to grab a screenshot of one of my 2
monitors.
Using wxPython 3 and python version 2.7.12 running on latest Ubuntu
I am relatively new to python so any help is certainly appreciated.
I found several code snippets and have cobbled together pieces
This is what I have so far
>
importwx
displays =(wx.Display(i)fori inrange(wx.Display.GetCount()))
sizes =[display.GetGeometry().GetSize()fordisplay indisplays]
for(i,s)inenumerate(sizes):
print("Monitor{} size is {}".format(i,s))
screen =wx.ScreenDC()
size =screen.GetSize()
size1=screen.GetSizeMMTuple()
print("Width = {}".format(size[0]))
print("Heigh = {}".format(size[1]))
width=size[0]
height=size[1]
bmp =wx.EmptyBitmap(width,height)
mem =wx.MemoryDC(bmp)
mem.Blit(0,0,width,height,screen,0,0)
delmem
bmp.SaveFile("testimg.png",wx.BITMAP_TYPE_PNG)
>
When I run I see the followinginfo printed out on the console
Monitor0 size is (1366, 768) Monitor1 size is (1920, 1080) Width =
3286 Height = 1080
When the screenshot is taken, I get is a snapshot of the entire
viewing area (both monitors).
I don't understand how to limit to one monitor or the other.
I'm certain the issue is when I say
screen = wx.ScreenDC()
but I don't know how to narrow down the size of that Object to the
size of either of my monitors
Any thoughts are appreciated
Thanks
Sean
Hope that helps.