示例#1
0
def app_windows_image():
    '''
    Returns a bitmap showing all the top level windows in this application.

    Other areas of the screen are blanked out.
    '''

    # get the union of all screen rectangles (this will be a big rectangle
    # covering the area of all monitors)
    rect = reduce(wx.Rect.Union, (m.Geometry for m in Monitor.All()))
    if "wxMSW" in wx.PlatformInfo:
        screen = getScreenBitmap(rect).PIL
    else:
        screen = wx.ScreenDC().GetAsBitmap().PIL

    mask = Image.new('RGBA', rect.Size, (255, 255, 255, 255))
    drawrect = lambda r: ImageDraw.Draw(mask).rectangle(
        [r.x, r.y, r.Right, r.Bottom], fill=(0, 0, 0, 0))

    # draw rectangles into a mask for each top level window (and the system tray)
    for r in [GetTrayRect()
              ] + [w.Rect for w in wx.GetTopLevelWindows() if w.IsShown()]:
        r.Offset((-rect.Position[0], -rect.Position[1]
                  ))  # some monitors may be in negative coordinate space...
        drawrect(r)

    # paste the mask into the screenshot--whiteing out areas not in our windows
    screen_full = screen.copy()
    screen.paste(mask, (0, 0), mask)

    return screen_full, screen
示例#2
0
    def on_capture(self):
        self.slider.Enable(True)
        dragger = self.dragger
        self.Freeze()

        try:
            if config.platform == 'win':
                try:
                    from cgui import getScreenBitmap
                except ImportError:
                    print_exc()
                    return

                bitmap = getScreenBitmap(wx.RectPS(dragger.ScreenRect.Position, dragger.ClientSize))
            else:
                screendc = wx.ScreenDC()
                bitmap = screendc.GetAsBitmap()

            if bitmap is not None:
                self.set_image(wx.ImageFromBitmap(bitmap))

            s = self.slider
            s.Value = (s.Max - s.Min) / 2
        finally:
            wx.CallAfter(self.ThawLater)
示例#3
0
def app_windows_image():
    '''
    Returns a bitmap showing all the top level windows in this application.

    Other areas of the screen are blanked out.
    '''

    # get the union of all screen rectangles (this will be a big rectangle
    # covering the area of all monitors)
    rect     = reduce(wx.Rect.Union, (m.Geometry for m in Monitor.All()))
    if "wxMSW" in wx.PlatformInfo:
        screen   = getScreenBitmap(rect).PIL
    else:
        screen = wx.ScreenDC().GetAsBitmap().PIL

    mask     = Image.new('RGBA', rect.Size, (255, 255, 255, 255))
    drawrect = lambda r: ImageDraw.Draw(mask).rectangle([r.x, r.y, r.Right, r.Bottom ], fill = (0, 0, 0, 0))

    # draw rectangles into a mask for each top level window (and the system tray)
    for r in [GetTrayRect()] + [w.Rect for w in wx.GetTopLevelWindows() if w.IsShown()]:
        r.Offset(-rect.Position) # some monitors may be in negative coordinate space...
        drawrect(r)

    # paste the mask into the screenshot--whiteing out areas not in our windows
    screen_full = screen.copy()
    screen.paste(mask, (0, 0), mask)

    return screen_full, screen
示例#4
0
    def on_capture(self):
        self.slider.Enable(True)
        dragger = self.dragger
        self.Freeze()

        try:
            if config.platform == 'win':
                try:
                    from cgui import getScreenBitmap
                except ImportError:
                    print_exc()
                    return

                bitmap = getScreenBitmap(
                    wx.RectPS(dragger.ScreenRect.Position, dragger.ClientSize))
            else:
                screendc = wx.ScreenDC()
                bitmap = screendc.GetAsBitmap()

            if bitmap is not None:
                self.set_image(wx.ImageFromBitmap(bitmap))

            s = self.slider
            s.Value = (s.Max - s.Min) / 2
        finally:
            wx.CallAfter(self.ThawLater)