Python wx.EmptyBitmap() Examples
The following are 30
code examples of wx.EmptyBitmap().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
wx
, or try the search function
.
Example #1
Source File: pyslip.py From dials with BSD 3-Clause "New" or "Revised" License | 6 votes |
def OnSize(self, event=None): """Create a new off-screen buffer to hold drawn data.""" (width, height) = self.GetClientSizeTuple() if WX3 else self.GetClientSize() if width == 0: width = 1 if height == 0: height = 1 self.buffer = wx.EmptyBitmap(width, height) self.view_width = width self.view_height = height # call onSize callback, if registered if self.onSizeCallback: self.onSizeCallback() # Now update the screen self.Update() ###### # Base class for a tile object - handles access to tiles. ######
Example #2
Source File: ListCtrl.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
def draw_sort_arrow(self, direction): b = wx.EmptyBitmap(self.icon_size, self.icon_size) w, h = b.GetSize() ho = (h - 5) / 2 dc = wx.MemoryDC() dc.SelectObject(b) colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_GRAYTEXT) dc.SetBackgroundMode(wx.TRANSPARENT) dc.Clear() dc.SetPen(wx.Pen(colour)) for i in xrange(5): if direction == 'down': j = 4 - i else: j = i dc.DrawLine(i,j+ho,9-i,j+ho) dc.SelectObject(wx.NullBitmap) b.SetMask(wx.Mask(b, (255, 255, 255))) return b
Example #3
Source File: ListCtrl.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
def add_image(self, image): b = wx.BitmapFromImage(image) if not b.Ok(): raise Exception("The image (%s) is not valid." % image) if (sys.platform == "darwin" and (b.GetWidth(), b.GetHeight()) == (self.icon_size, self.icon_size)): return self.il.Add(b) b2 = wx.EmptyBitmap(self.icon_size, self.icon_size) dc = wx.MemoryDC() dc.SelectObject(b2) dc.SetBackgroundMode(wx.TRANSPARENT) dc.Clear() x = (b2.GetWidth() - b.GetWidth()) / 2 y = (b2.GetHeight() - b.GetHeight()) / 2 dc.DrawBitmap(b, x, y, True) dc.SelectObject(wx.NullBitmap) b2.SetMask(wx.Mask(b2, (255, 255, 255))) return self.il.Add(b2) # Arrow drawing
Example #4
Source File: gui_mixins.py From wxGlade with MIT License | 6 votes |
def get_preview_obj_bitmap(self, bitmap=None): """Create a wx.Bitmap or wx.EmptyBitmap from the given statement. If no statement is given, the instance variable named "bitmap" is used. bitmap: Bitmap definition (str or None) see: get_preview_obj_artprovider(), get_preview_obj_emptybitmap()""" if bitmap is None: bitmap = getattr(self, 'bitmap', None) if not bitmap: return compat.wx_EmptyBitmap(1, 1) if bitmap.startswith('var:') or bitmap.startswith('code:'): return compat.wx_EmptyBitmap(16, 16) elif bitmap.startswith('empty:'): return self.get_preview_obj_emptybitmap(bitmap) elif bitmap.startswith('art:'): return self.get_preview_obj_artprovider(bitmap) else: bitmap = misc.get_absolute_path(bitmap) return wx.Bitmap(bitmap, wx.BITMAP_TYPE_ANY)
Example #5
Source File: ShowOSD.py From EventGhost with GNU General Public License v2.0 | 6 votes |
def __init__(self, parent): wx.Frame.__init__( self, parent, -1, "OSD Window", size=(0, 0), style=( wx.FRAME_SHAPED | wx.NO_BORDER | wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP ) ) self.hwnd = self.GetHandle() self.bitmap = wx.EmptyBitmap(0, 0) # we need a timer to possibly cancel it self.timer = threading.Timer(0.0, eg.DummyFunc) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_CLOSE, self.OnClose)
Example #6
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 6 votes |
def Draw(self, dc, scale=128): dc.Clear() width, height = dc.GetSizeTuple() sineTab = [ int(127.5 * sin(math.pi * (i - 127.5) / 127.5) + 127.5) for i in range(256) ] cx = width / 2 cy = height / 2 bmp = wx.EmptyBitmap(width, height, 24) pixelData = wx.NativePixelData(bmp) pixels = pixelData.GetPixels() y = -cy for i in range(height): x = -cx for j in range(width): d = ((x * x + y * y) * scale) >> 8 val = sineTab[d & 0xFF] pixels.Set(val, val, val) pixels.nextPixel() x += 1 y += 1 pixels.MoveTo(pixelData, 0, y + cy) dc.DrawBitmap(bmp, 0, 0, False)
Example #7
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 6 votes |
def __init__(self, size=(-1, -1), pic_path=None, display=0): wx.Frame.__init__( self, None, -1, "ShowPictureFrame", style=wx.NO_BORDER | wx.FRAME_NO_TASKBAR #| wx.STAY_ON_TOP ) self.SetBackgroundColour(wx.Colour(0, 0, 0)) self.Bind(wx.EVT_LEFT_DCLICK, self.LeftDblClick) self.Bind(wx.EVT_CLOSE, self.OnClose) bitmap = wx.EmptyBitmap(1, 1) self.staticBitmap = wx.StaticBitmap(self, -1, bitmap) self.staticBitmap.Bind(wx.EVT_LEFT_DCLICK, self.LeftDblClick) self.staticBitmap.Bind(wx.EVT_MOTION, self.ShowCursor) self.timer = Timer(2.0, self.HideCursor)
Example #8
Source File: wm_legend.py From wafer_map with GNU General Public License v3.0 | 6 votes |
def on_color_change(self, event): """ Change the plot colors. This is done by updating self.gradient and calling self.draw_scale() """ if event['low'] is not None: self.low_color = event['low'] if event['high'] is not None: self.high_color = event['high'] self.gradient = wm_utils.LinearGradient(self.low_color, self.high_color) # self._clear_scale() self.hbox.Remove(0) self.hbox.Add((self.dc_w, self.dc_h)) # self.mdc.SelectObject(wx.EmptyBitmap(self.dc_w, self.dc_h)) self.mdc.SelectObject(wx.Bitmap(self.dc_w, self.dc_h)) self.draw_scale()
Example #9
Source File: ObjectListView.py From bookhub with MIT License | 6 votes |
def AddNamedImages(self, name, smallImage=None, normalImage=None): """ Add the given images to the list of available images. Return the index of the image. If a name is given, that name can later be used to refer to the images rather than having to use the returned index. """ if isinstance(smallImage, basestring): smallImage = wx.Bitmap(smallImage) if isinstance(normalImage, basestring): normalImage = wx.Bitmap(normalImage) # We must have image lists for images to be added to them if self.smallImageList is None or self.normalImageList is None: self.SetImageLists() # There must always be the same number of small and normal bitmaps, # so if we aren't given one, we have to make an empty one of the right size smallImage = smallImage or wx.EmptyBitmap(*self.smallImageList.GetSize(0)) normalImage = normalImage or wx.EmptyBitmap(*self.normalImageList.GetSize(0)) self.smallImageList.AddNamedImage(name, smallImage) return self.normalImageList.AddNamedImage(name, normalImage)
Example #10
Source File: wm_legend.py From wafer_map with GNU General Public License v3.0 | 6 votes |
def draw_background(self): """ Draw the background box. If I don't do this, then the background is black. Could I change wx.EmptyBitmap() so that it defaults to white rather than black? """ # TODO: change the bitmap background to be transparent c = wx.Colour(200, 230, 230, 0) c = wx.Colour(255, 255, 255, 0) pen = wx.Pen(c) brush = wx.Brush(c) self.mdc.SetPen(pen) self.mdc.SetBrush(brush) self.mdc.DrawRectangle(0, 0, self.dc_w, self.dc_h)
Example #11
Source File: WordWrapRenderer.py From bookhub with MIT License | 6 votes |
def OnPaint(self, evt): dc = wx.PaintDC(self) inset = (20, 20, 20, 20) rect = [inset[0], inset[1], self.GetSize().width-(inset[0]+inset[2]), self.GetSize().height-(inset[1]+inset[3])] # Calculate exactly how high the wrapped is going to be and put a frame around it. dc.SetFont(self.font) dc.SetPen(wx.RED_PEN) rect[3] = WordWrapRenderer.CalculateHeight(dc, self.text, rect[2]) dc.DrawRectangle(*rect) WordWrapRenderer.DrawString(dc, self.text, rect, wx.ALIGN_LEFT) #WordWrapRenderer.DrawTruncatedString(dc, self.text, rect, wx.ALIGN_CENTER_HORIZONTAL,s ellipse=wx.CENTER) #bmp = wx.EmptyBitmap(rect[0]+rect[2], rect[1]+rect[3]) #mdc = wx.MemoryDC(bmp) #mdc.SetBackground(wx.Brush("white")) #mdc.Clear() #mdc.SetFont(self.font) #mdc.SetPen(wx.RED_PEN) #rect[3] = WordWrapRenderer.CalculateHeight(mdc, self.text, rect[2]) #mdc.DrawRectangle(*rect) #WordWrapRenderer.DrawString(mdc, self.text, rect, wx.ALIGN_LEFT) #del mdc #dc = wx.ScreenDC() #dc.DrawBitmap(bmp, 20, 20)
Example #12
Source File: ObjectListView.py From bookhub with MIT License | 5 votes |
def _InitializeCheckBoxImages(self): """ Initialize some checkbox images for use by this control. """ def _makeBitmap(state, size): bitmap = wx.EmptyBitmap(size, size) dc = wx.MemoryDC(bitmap) dc.Clear() # On Linux, the Renderer draws the checkbox too low if wx.Platform == "__WXGTK__": yOrigin = -1 else: yOrigin = 0 wx.RendererNative.Get().DrawCheckBox(self, dc, (0, yOrigin, size, size), state) dc.SelectObject(wx.NullBitmap) return bitmap def _makeBitmaps(name, state): self.AddNamedImages(name, _makeBitmap(state, 16), _makeBitmap(state, 32)) # If there isn't a small image list, make one if self.smallImageList is None: self.SetImageLists() _makeBitmaps(ObjectListView.NAME_CHECKED_IMAGE, wx.CONTROL_CHECKED) _makeBitmaps(ObjectListView.NAME_UNCHECKED_IMAGE, wx.CONTROL_CURRENT) _makeBitmaps(ObjectListView.NAME_UNDETERMINED_IMAGE, wx.CONTROL_UNDETERMINED)
Example #13
Source File: ListCtrl.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def draw_blank(self): b = wx.EmptyBitmap(self.icon_size, self.icon_size) dc = wx.MemoryDC() dc.SelectObject(b) dc.SetBackgroundMode(wx.TRANSPARENT) dc.Clear() dc.SelectObject(wx.NullBitmap) b.SetMask(wx.Mask(b, (255, 255, 255))) return b # this builds an identical arrow to the windows listctrl arrows, in themed # and non-themed mode.
Example #14
Source File: ObjectListView.py From bookhub with MIT License | 5 votes |
def _InitializeImages(self): """ Initialize the images used to indicate expanded/collapsed state of groups. """ def _makeBitmap(state, size): bitmap = wx.EmptyBitmap(size, size) dc = wx.MemoryDC(bitmap) dc.SetBackground(wx.Brush(self.groupBackgroundColour)) dc.Clear() (x, y) = (0, 0) # The image under Linux is smaller and needs to be offset somewhat to look reasonable if wx.Platform == "__WXGTK__": (x, y) = (4, 4) wx.RendererNative.Get().DrawTreeItemButton(self, dc, (x, y, size, size), state) dc.SelectObject(wx.NullBitmap) return bitmap # If there isn't a small image list, make one if self.smallImageList is None: self.SetImageLists() size = self.smallImageList.GetSize()[0] self.AddNamedImages(ObjectListView.NAME_EXPANDED_IMAGE, _makeBitmap(wx.CONTROL_EXPANDED, size)) self.AddNamedImages(ObjectListView.NAME_COLLAPSED_IMAGE, _makeBitmap(0, size)) #---------------------------------------------------------------------------- # Accessing
Example #15
Source File: adm.py From admin4 with Apache License 2.0 | 5 votes |
def GetJoinedId(self, ids): if len(ids) < 2: return ids[0] name="joined:%s" % "+".join(map(str, ids)) id=self.list.get(name) if id: return id dc=wx.MemoryDC() w,h=self.GetSize(0) bmp=wx.EmptyBitmap(w,h) dc.SelectObject(bmp) # TODO should rewrite using wx.GraphicsContext if wx.Platform not in ("__WXMAC__"): b=self.GetBitmap(1) dc.DrawBitmap(b, 0, 0, True) for id in ids: if id > 0: b=self.GetBitmap(id) dc.DrawBitmap(b, 0, 0, True) #self.Draw(id, dc, 0,0) dc.DrawBitmap(b, 0, 0, True) dc.SelectObject(wx.NullBitmap) id=self.Add(bmp) self.list[name]=id return id
Example #16
Source File: adm.py From admin4 with Apache License 2.0 | 5 votes |
def GetId(self, name): if name == None: return -1 id=self.list.get(name) if id: return id id=-1 bmp=wh.GetBitmap(name) if bmp: if bmp.GetSize() != self.GetSize(0): dcs=wx.MemoryDC() w1,h1=bmp.GetSize() dcs.SelectObject(bmp) dc=wx.MemoryDC() w,h=self.GetSize(0) bmpneu=wx.EmptyBitmap(w,h) dc.SelectObject(bmpneu) if wx.Platform not in ("__WXMAC__"): b=self.GetBitmap(1) dc.DrawBitmap(b, 0, 0, True) dc.StretchBlit(0, 0, w, h, dcs, 0,0,w1,h1) dc.SelectObject(wx.NullBitmap) dcs.SelectObject(wx.NullBitmap) id=self.Add(bmpneu) logger.debug("Bitmap %s has wrong format. Need %s, is %s", name, self.GetSize(0), bmp.GetSize()) else: id=self.Add(bmp) else: fn="%s.ico" % name if os.path.exists(fn): id=self.AddIcon(wx.Icon(fn)) self.list[name]=id return id
Example #17
Source File: gui_mixins.py From wxGlade with MIT License | 5 votes |
def get_preview_obj_artprovider(self, bitmap): """Create a wxBitmap or wx.EmptyBitmap from the given statement using wxArtProvider. (note: Preview shows only wxART_* resources.) bitmap: Bitmap definition (str or None) see: Lwcodegen.BaseWidgetWriter.get_inline_stmt_artprovider()""" # keep in sync with BitmapMixin.get_inline_stmt_artprovider() art_id = 'wxART_ERROR' art_client = 'wxART_OTHER' size = wx.DefaultSize # art:ArtID,ArtClient # art:ArtID,ArtClient,width,height try: content = bitmap[4:] elements = [item.strip() for item in content.split(',')] if len(elements) == 2: art_id, art_client = elements elif len(elements) == 4: art_id, art_client, width, height = elements size = wx.Size(int(width), int(height)) else: raise ValueError except (ValueError, TypeError): logging.warn( 'Malformed statement to create a bitmap via wxArtProvider(): %s', bitmap ) # show wx art resources only if not art_id.startswith('wx'): art_id = 'wxART_HELP' if not art_client.startswith('wx'): art_client = 'wxART_OTHER' return wx.ArtProvider.GetBitmap( self.wxname2attr(self.codegen.cn(art_id)), self.wxname2attr(self.codegen.cn(art_client)), size )
Example #18
Source File: gui_mixins.py From wxGlade with MIT License | 5 votes |
def get_preview_obj_emptybitmap(self, bitmap): """Create an empty wx.EmptyBitmap instance from the given statement. bitmap: Bitmap definition as str or None see: wcodegen.BaseWidgetWriter.get_inline_stmt_emptybitmap()""" # keep in sync with BaseWidgetWriter.get_inline_stmt_emptybitmap() width = 16 height = 16 try: size = bitmap[6:] width, height = [int(item.strip()) for item in size.split(',', 1)] except ValueError: logging.warn( 'Malformed statement to create an empty bitmap: %s', bitmap ) return compat.wx_EmptyBitmap( max(1,width), max(1,height) )
Example #19
Source File: Main_Dialog.py From topoflow with MIT License | 5 votes |
def Plotting_Test(self): #-------------------------------------------------------- # Note: We may need to save the window's bitmap in a # buffer and refresh it on certain events. # As it stands now, moving the cursor to another # window causes window contents to be lost, # even if we use the Freeze() method. #-------------------------------------------------------- window = self.plot_window nx = self.window_nx ny = self.window_ny # win_buffer = self.plot_buffer win_buffer = wx.EmptyBitmap(nx,ny) #--------------------------------------------- # Create a device context (don't store them) #--------------------------------------------- dc = wx.BufferedDC(wx.ClientDC(window)) ## dc = wx.BufferedDC(wx.ClientDC(window), win_buffer) ## dc = wx.ClientDC(window) # (also works) ## dc = wx.WindowDC(window) # (also works) pen = wx.Pen("black", 2, wx.SOLID) brush = wx.Brush("white", wx.SOLID) # (for filling in areas) dc.SetPen(pen) dc.SetBrush(brush) dc.SetBackground(brush) dc.Clear() #------------------------------------------ dc.DrawRectangle(0,0,nx,ny) dc.DrawLine(0,0,nx,ny) dc.DrawCircle(nx/2,ny/2, nx/3) # print 'dc.GetSize() =', dc.GetSize() ## window.Freeze() # (see also window.Thaw() ) ## window.Disable() # Plotting_Test() #----------------------------------------------------------------
Example #20
Source File: AnimatedWindow.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def MakeBackground(self): self.backbuffer = wx.EmptyBitmap(self.width, self.height) deviceContext = wx.MemoryDC() deviceContext.SelectObject(self.backbuffer) deviceContext.BeginDrawing() deviceContext.SetBackground(wx.Brush(self.GetBackgroundColour())) deviceContext.Clear() # make sure you clear the bitmap! deviceContext.SetFont(self.font) deviceContext.SetTextForeground((128, 128, 128)) width1 = self.logo1.GetWidth() width2 = self.logo2.GetWidth() height1 = self.logo1.GetHeight() height2 = self.logo2.GetHeight() height = max(height1, height2) deviceContext.DrawBitmap( self.logo1, self.width - width1 - width2, self.height - height + (height - height1) // 2, True ) deviceContext.DrawBitmap( self.logo2, self.width - width2, self.height - height + (height - height2) // 2, True ) deviceContext.DrawBitmap( self.logo3, (self.width - self.logo3.GetWidth()) // 2, (self.height - self.logo3.GetHeight()) // 3, True ) deviceContext.EndDrawing()
Example #21
Source File: AnimatedWindow.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def OnSize(self, dummyEvent): self.width, self.height = self.GetClientSizeTuple() self.dcBuffer = wx.EmptyBitmap(self.width, self.height) self.y3 = (self.height - self.bmpHeight) / 4.0 self.x3 = (self.width - self.bmpWidth) / 4.0 self.MakeBackground() self.UpdateDrawing()
Example #22
Source File: make_timelapse.py From Pigrow with GNU General Public License v3.0 | 5 votes |
def updatefirstpic(self, fframe): capsdir = self.capsfolder_box.GetValue() first_pic = str(capsdir + cap_files[fframe]) if os.path.exists(first_pic): first_pic = wx.Image(first_pic, wx.BITMAP_TYPE_ANY) first_pic = self.scale_pic(first_pic, 500) fpicdate = self.date_from_fn(cap_files[fframe]) self.fpic_text.SetLabel('Frame ' + str(fframe) + ' - ' + str(fpicdate)) self.first_pic.SetBitmap(wx.BitmapFromImage(first_pic)) else: self.first_pic.SetBitmap(wx.EmptyBitmap(10,10)) self.fpic_text.SetLabel('start')
Example #23
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def SetDrawing(self, drawFunc, args): self.drawing = drawFunc d = GetMonitorDimensions()[self.displayNum] self.SetDimensions(d.x, d.y, d.width, d.height) self._buffer = wx.EmptyBitmap(d.width, d.height) dc = wx.BufferedDC(wx.ClientDC(self), self._buffer) self.drawing(dc, *args) #self.Refresh(eraseBackground=False) wx.Frame.Show(self, True) BringHwndToFront(self.GetHandle(), False) self.SetCursor(wx.StockCursor(wx.CURSOR_BLANK))
Example #24
Source File: Viewer.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def GetLogicalDC(self, buffered=False): if buffered: bitmap = wx.EmptyBitmap(*self.Editor.GetClientSize()) dc = wx.MemoryDC(bitmap) else: dc = wx.ClientDC(self.Editor) dc.SetFont(self.GetFont()) self.Editor.DoPrepareDC(dc) dc.SetUserScale(self.ViewScale[0], self.ViewScale[1]) return dc
Example #25
Source File: Viewer.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def RefreshScaling(self, refresh=True): properties = self.Controler.GetProjectProperties(self.Debug) scaling = properties["scaling"][self.CurrentLanguage] if scaling[0] != 0 and scaling[1] != 0: self.Scaling = scaling if self.DrawGrid: width = max(2, int(scaling[0] * self.ViewScale[0])) height = max(2, int(scaling[1] * self.ViewScale[1])) bitmap = wx.EmptyBitmap(width, height) dc = wx.MemoryDC(bitmap) dc.SetBackground(wx.Brush(self.Editor.GetBackgroundColour())) dc.Clear() dc.SetPen(MiterPen(wx.Colour(180, 180, 180))) dc.DrawPoint(0, 0) self.GridBrush = wx.BrushFromBitmap(bitmap) else: self.GridBrush = wx.TRANSPARENT_BRUSH else: self.Scaling = None self.GridBrush = wx.TRANSPARENT_BRUSH page_size = properties["pageSize"] if page_size != (0, 0): self.PageSize = map(int, page_size) self.PagePen = MiterPen(wx.Colour(180, 180, 180)) else: self.PageSize = None self.PagePen = wx.TRANSPARENT_PEN if refresh: self.RefreshVisibleElements() self.Editor.Refresh(False) # ------------------------------------------------------------------------------- # Refresh functions # -------------------------------------------------------------------------------
Example #26
Source File: ConfTreeNodeEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent, ID, bitmapname, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, name="genstatbmp"): bitmap = GetBitmap(bitmapname) if bitmap is None: bitmap = wx.EmptyBitmap(0, 0) wx.StaticBitmap.__init__(self, parent, ID, bitmap, pos, size, style, name)
Example #27
Source File: BitmapLibrary.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def GetBitmap(bmp_name1, bmp_name2=None, size=None): bmp = BitmapLibrary.get((bmp_name1, bmp_name2, size)) if bmp is not None: return bmp if bmp_name2 is None: bmp = SearchBitmap(bmp_name1) else: # Bitmap with two icon bmp1 = SearchBitmap(bmp_name1) bmp2 = SearchBitmap(bmp_name2) if bmp1 is not None and bmp2 is not None: # Calculate bitmap size width = bmp1.GetWidth() + bmp2.GetWidth() - 1 height = max(bmp1.GetHeight(), bmp2.GetHeight()) # Create bitmap with both icons bmp = wx.EmptyBitmap(width, height) dc = wx.MemoryDC() dc.SelectObject(bmp) dc.Clear() dc.DrawBitmap(bmp1, 0, 0) dc.DrawBitmap(bmp2, bmp1.GetWidth() - 1, 0) dc.Destroy() elif bmp1 is not None: bmp = bmp1 elif bmp2 is not None: bmp = bmp2 if bmp is not None: BitmapLibrary[(bmp_name1, bmp_name2, size)] = bmp return bmp
Example #28
Source File: LogViewer.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def RefreshView(self): width, height = self.MessagePanel.GetClientSize() bitmap = wx.EmptyBitmap(width, height) dc = wx.BufferedDC(wx.ClientDC(self.MessagePanel), bitmap) dc.Clear() dc.BeginDrawing() if self.CurrentMessage is not None: dc.SetFont(self.Font) for button in self.LeftButtons + self.RightButtons: button.Draw(dc) message_idx = self.CurrentMessage message = self.LogMessages[message_idx] draw_date = True offset = 5 while offset < height and message is not None: message.Draw(dc, offset, width, draw_date) offset += message.GetHeight(draw_date) previous_message, message_idx = self.GetPreviousMessage(message_idx) if previous_message is not None: draw_date = message.Date != previous_message.Date message = previous_message dc.EndDrawing() self.MessageScrollBar.RefreshThumbPosition()
Example #29
Source File: make_timelapse.py From Pigrow with GNU General Public License v3.0 | 5 votes |
def updatelastpic(self, lframe): capsdir = self.capsfolder_box.GetValue() last_pic = str(capsdir + cap_files[lframe]) if os.path.exists(last_pic): last_pic = wx.Image(last_pic, wx.BITMAP_TYPE_ANY) last_pic = self.scale_pic(last_pic, 500) self.last_pic.SetBitmap(wx.BitmapFromImage(last_pic)) lpicdate = self.date_from_fn(cap_files[lframe]) self.lpic_text.SetLabel('Frame ' + str(lframe) + ' - ' + str(lpicdate)) else: self.last_pic.SetBitmap(wx.EmptyBitmap(10,10)) self.fpic_text.SetLabel('end')
Example #30
Source File: backend_wxagg.py From neural-network-animation with MIT License | 5 votes |
def _WX28_clipped_agg_as_bitmap(agg, bbox): """ Convert the region of a the agg buffer bounded by bbox to a wx.Bitmap. Note: agg must be a backend_agg.RendererAgg instance. """ l, b, width, height = bbox.bounds r = l + width t = b + height srcBmp = wx.BitmapFromBufferRGBA(int(agg.width), int(agg.height), agg.buffer_rgba()) srcDC = wx.MemoryDC() srcDC.SelectObject(srcBmp) destBmp = wx.EmptyBitmap(int(width), int(height)) destDC = wx.MemoryDC() destDC.SelectObject(destBmp) destDC.BeginDrawing() x = int(l) y = int(int(agg.height) - t) destDC.Blit(0, 0, int(width), int(height), srcDC, x, y) destDC.EndDrawing() srcDC.SelectObject(wx.NullBitmap) destDC.SelectObject(wx.NullBitmap) return destBmp