def OnPaint(self, evt): dc = wx.PaintDC(self) bk = wx.Image(r"image/mainbk.jpg", wx.BITMAP_TYPE_ANY, -1) size = self.GetSize() bk = bk.Scale(size[0], size[1]) bk = bk.ConvertToBitmap() dc.DrawBitmap(bk, 0, 0, True) size = self.ApiPage.GetSize() lbdc = wx.PaintDC(self.ApiPage) memDC = wx.MemoryDCFromDC(lbdc) memDC.SelectObject(bk) lbdc.Blit(0, 0, size[0], size[1], memDC, 80, 200) memDC.SelectObject(wx.NullBitmap) weidc = wx.PaintDC(self.WeiboPage) memDC1 = wx.MemoryDCFromDC(weidc) memDC1.SelectObject(bk) weidc.Blit(0, 0, size[0], size[1], memDC1, 80, 200) memDC1.SelectObject(wx.NullBitmap) dc.SetBackgroundMode(wx.TRANSPARENT) brush = wx.Brush("#000000", wx.TRANSPARENT) dc.SetBackground(brush) evt.Skip()
def take_screen(i): lock.acquire() # sleep(.2) global screenshot_num timestamp = get_timestamp() picFolder = os.path.normpath(os.path.expanduser("~\Pictures\SeLCont")) s = wx.ScreenDC() w, h = s.Size.Get() b = wx.EmptyBitmap(w, h) m = wx.MemoryDCFromDC(s) m.SelectObject(b) m.Blit(0, 0, w, h, s, 0, 0) m.SelectObject(wx.NullBitmap) if not (os.path.exists(picFolder)): os.makedirs(picFolder) sd = get_date() filepath = os.path.join(picFolder, sd) if not (os.path.exists(filepath)): os.makedirs(filepath) fullpath = os.path.join(filepath, timestamp + ".png") b.SaveFile(fullpath, wx.BITMAP_TYPE_PNG) print "ScreenShot " + str(screenshot_num) + " - " + get_formal_timestamp() try: screenshot_num += 1 except: pass lock.release()
def saveImage(canvas, filename): s = wx.ScreenDC() w, h = canvas.size.Get() b = wx.EmptyBitmap(w, h) m = wx.MemoryDCFromDC(s) m.SelectObject(b) m.Blit(0, 0, w, h, s, 70, 0) m.SelectObject(wx.NullBitmap) b.SaveFile(filename, wx.BITMAP_TYPE_PNG)
def take(self): """takes a screenshot and stores bitmap data""" bitmap = wx.EmptyBitmap(self.screen_size[0], self.screen_size[1]) memory = wx.MemoryDCFromDC(self.screen_dc) memory.SelectObject(bitmap) memory.Blit(0, 0, self.screen_size[0], self.screen_size[1], self.screen_dc, 0, 0) memory.SelectObject(wx.NullBitmap) return bitmap
def OnLeftUp(self, event): if self.flag: s = wx.ScreenDC() w, h = s.Size.Get() b = wx.EmptyBitmap(1, 1) m = wx.MemoryDCFromDC(s) m.SelectObject(b) m.BlitPointSize((0, 0), (1, 1), s, wx.GetMousePosition()) self.colour = m.GetPixel(0, 0).Get() m.SelectObject(wx.NullBitmap) dc = wx.PaintDC(self.bit) dc.SetBrush(wx.Brush(self.colour)) dc.SetPen(wx.Pen(self.colour)) dc.DrawRectangle(0, 0, 140, 40) self.ReleaseMouse() else: pass
path = data.split(' ', 1) os.remove(path[1]) con.send('Removed: ' + path[1]) data = '' elif data[:5] == 'rexit': print 'Closed Connection with {}, waiting...'.format(cli) con.close() elif data[:5] == 'close': con.close() print 'Closing with: ', cli elif data[:5] == 'print': app = wx.App(False) SD = wx.ScreenDC() wid, hei = SD.Size.Get() b = wx.EmptyBitmap(wid, hei) m = wx.MemoryDCFromDC(SD) m.SelectObject(b) m.Blit(0, 0, wid, hei, SD, 0, 0) m.SelectObject(wx.NullBitmap) b.SaveFile(os.getcwd() + '/screenshot.png', wx.BITMAP_TYPE_PNG) con.send('imgok') if con.recv(1024)[:4] == 'send': f = open(os.getcwd() + '/screenshot.png', 'rb') l = f.read() while (l): con.send(l) l = f.read() f.close() print 'Sended print' con.close()
# # taking a screenshot # import wx app = wx.App(False) screen = wx.ScreenDC() size = screen.GetSize() bmp = wx.EmptyBitmap(size[0], size[1]) mem = wx.MemoryDCFromDC(screen) mem.SelectObject(bmp) mem.Blit(0, 0, size[0], size[1], screen, 0, 0) mem.SelectObject(wx.NullBitmap) bmp.SaveFile("screenshot.png", wx.BITMAP_TYPE_PNG)
""" #!/usr/bin/python import wx import platform import ftplib import os w = wx.App() screen = wx.ScreenDC() size = screen.GetSize() bmap = wx.EmptyBitmap(size[0], size[1]) mem = wx.MemoryDCFromDC(bmap) mem.Blit(0, 0, size[0], size[1], screen, 0, 0) del mem bmap.SaveFile("screenshot.png", wx.BITMAP_TYPE_PNG) """ if platform.system() == "Windows": sess = ftplib.FTP('192.168.0.101','ftpuser','ftppass') file = open("screenshot.png", 'rb') sess.storbinary("STOR /tmp/screenshot.png", file) file.close() sess.quit() if platform.system() == "Linux": os.system("scp screenshot.png [email protected]:/tmp/")