def OnPaint(self, _): width, height = self._handler.size if width <= 0 or height <= 0: bmp = wx.EmptyBitmapRGBA(1, 1) pdc = wx.PaintDC(self) gcdc = wx.GCDC(pdc) gcdc.DrawBitmap(bmp, 0, 0) gcdc.Destroy() del gcdc self._startup = None return bmp = wx.EmptyBitmapRGBA(width, height) dc = wx.MemoryDC() dc.SelectObject(bmp) gc = wx.GraphicsContext.Create(dc) gcdc = wx.GCDC(gc) gcdc.SetBrush(wx.Brush(self.GetBackgroundColour())) gcdc.SetPen(wx.TRANSPARENT_PEN) gcdc.DrawRectangle(0, 0, width, height) def draw_circle(x, y, r, _gcdc): _gcdc.DrawEllipse(int(round(float(x) - r)), int(round(float(y) - r)), int(round(r * 2.0)), int(round(r * 2.0))) gcdc.SetBrush(wx.TRANSPARENT_BRUSH) x_center, y_center = self._handler.center gcdc.SetPen(wx.TRANSPARENT_PEN) radius = self._handler.radius if self._handler.shadow: # shadow stops = wx.GraphicsGradientStops() stops.Add(wx.GraphicsGradientStop(wx.TransparentColour, 0.45)) stops.Add(wx.GraphicsGradientStop(wx.Colour(0, 0, 0, 255), 0.25)) stops.SetStartColour(wx.Colour(0, 0, 0, 255)) stops.SetEndColour(wx.TransparentColour) gc.SetBrush( gc.CreateRadialGradientBrush(x_center + (radius * 0.10), y_center + (radius * 0.10), x_center + (radius * 0.30), y_center + (radius * 0.30), radius * 2.3, stops)) draw_circle(x_center + (radius * 0.10), y_center + (radius * 0.10), radius * 2, gcdc) # eliminate any shadow under the knob just in case there is a color # used in the gradient of the knob that does not have an alpha level of 255 gc.SetBrush(wx.Brush(self.GetBackgroundColour())) draw_circle(x_center, y_center, radius - 2, gcdc) if self._handler.glow: _ = self._handler.tick_list neon_colour = self._handler.neon_colour stops = wx.GraphicsGradientStops() stops.Add(wx.GraphicsGradientStop(wx.TransparentColour, 0.265)) stops.Add( wx.GraphicsGradientStop(wx.Colour(*neon_colour + (255, )), 0.25)) stops.Add(wx.GraphicsGradientStop(wx.TransparentColour, 0.248)) stops.SetStartColour(wx.TransparentColour) stops.SetEndColour(wx.TransparentColour) gc.SetBrush( gc.CreateRadialGradientBrush(x_center, y_center, x_center, y_center, radius * 4, stops)) draw_circle(x_center, y_center, radius * 2, gcdc) # outside ring of volume knob gc.SetBrush( gc.CreateRadialGradientBrush(x_center - radius, y_center - radius, x_center, y_center - radius, radius * 2, self._handler.secondary_colour, self._handler.primary_colour)) draw_circle(x_center, y_center, radius, gcdc) thumb_x, thumb_y = self._handler.thumb_position thumb_radius = self._handler.thumb_radius # inside of volume knob if self._handler.depression: center_radius = self._handler.center_radius gc.SetBrush( gc.CreateRadialGradientBrush( x_center + center_radius, y_center + center_radius, x_center, y_center + center_radius, center_radius * 2, self._handler.secondary_colour, self._handler.primary_colour)) draw_circle(x_center, y_center, center_radius, gcdc) if self._last_degrees is None: self._last_degrees = _remap(self._handler.value, self._handler.min_value, self._handler.max_value, 135.0, 405.0) # handle of the volume knob gc.SetBrush( gc.CreateRadialGradientBrush(thumb_x + thumb_radius, thumb_y + thumb_radius, thumb_x, thumb_y + thumb_radius, thumb_radius * 2, self._handler.secondary_colour, self._handler.primary_colour)) draw_circle(thumb_x, thumb_y, thumb_radius, gcdc) if self._handler.thumb_glow: _ = self._handler.tick_list neon_colour = self._handler.neon_colour stops = wx.GraphicsGradientStops() stops.Add(wx.GraphicsGradientStop(wx.TransparentColour, 0.355)) stops.Add( wx.GraphicsGradientStop(wx.Colour(*neon_colour + (255, )), 0.28)) stops.Add(wx.GraphicsGradientStop(wx.TransparentColour, 0.258)) stops.SetStartColour(wx.TransparentColour) stops.SetEndColour(wx.TransparentColour) gc.SetBrush( gc.CreateRadialGradientBrush(thumb_x, thumb_y, thumb_x, thumb_y, thumb_radius * 4, stops)) draw_circle(thumb_x, thumb_y, thumb_radius * 2, gcdc) gcdc.SetBrush(wx.TRANSPARENT_BRUSH) # draw the tick marks if self._handler.ticks: ticks = [] pens = [] for _, pen, coords in self._handler.tick_list: ticks += [coords] pens += [pen] gcdc.DrawLineList(ticks, pens) dc.SelectObject(wx.EmptyBitmap(1, 1)) gcdc.Destroy() del gcdc dc.Destroy() del dc # create a buffered paint dc to draw the bmp to the client area pdc = wx.PaintDC(self) gcdc = wx.GCDC(pdc) gcdc.DrawBitmap(bmp, 0, 0) gcdc.Destroy() del gcdc if self._startup is True: self._startup = None t = threading.Thread(target=self._run_startup) t.daemon = True t.start() else: self._startup = None
def voidCall(self, e): newCard = wx.PaintDC(self)
def onPaint(self, event): event.Skip() self.draw(wx.PaintDC(self))
def OnPaint(self, event): self.Paint(wx.PaintDC(self))
def OnPaint(self, event=None): deviceContext = wx.PaintDC(self) deviceContext.DrawBitmap(self.bitmap, 0, 0, True)
def OnPaint(self, evt): dc = wx.PaintDC(self) self.PrepareDC(dc) self.DrawShapes(dc)
def on_paint(self, event): "Handle paint request and draw hatched lines onto the window" #if not self.sizer: return # in deletion dc = wx.PaintDC(self.widget) self._draw_background(dc)
def OnImgPaint(self, event): self.dc = wx.PaintDC(self.img_holder) # mypath = 'C:\Users\Michael\Projects\Andrew_Project\main\image\jpg0.jpg' # mybmp=pil_to_wx(mypath) # if self.active_image.wx_image<>None: self.dc.DrawBitmap(self.active_image.wx_image.ConvertToBitmap(), 0, 0)
def OnPaint(self, event): dc = wx.PaintDC(self) self.DoPrepareDC(dc) self._drawKeys(dc)
def Paint(self, evt): dc = wx.PaintDC(self) self.RefreshZone() self.zone.Draw(dc)
def _OnPaint(self, evt): dc = wx.PaintDC(self) self._DrawSash(dc)
def OnPaint(self, event): dc = wx.PaintDC(self) if self.bitmap: dc.Blit(0, 0, self.bitmap.GetWidth(), self.bitmap.GetHeight(), wx.MemoryDC(self.bitmap), 0, 0)
def OnPaint(self, event): """The on paint event handler.""" DC = wx.PaintDC(self) self.DoDrawing(DC)
def OnPaint(self, evt): sz = self.GetSize() dc = wx.PaintDC(self) w, h = dc.GetTextExtent(self.text) dc.Clear() dc.DrawText(self.text, (sz.width - w) / 2, (sz.height - h) / 2)
def OnPaint(self, _): if self.updater is not None: self.bmp=self.updater() self.updater=None dc=wx.PaintDC(self) dc.DrawBitmap(self.bmp, 0, 0, False)
def OnPaint(self, event): dc = wx.PaintDC(self)
def OnPaint(self, event): dc = wx.PaintDC(self.m_impl.m_container) dc.SetBackground( wx.Brush(self.m_impl.m_container.GetBackgroundColour())) dc.Clear() highlight = wx.Pen( wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNHIGHLIGHT), 1) shadow = wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW), 1) black = wx.Pen(wx.BLACK, 1) size = self.m_impl.m_container.GetSize() w = size.GetWidth() h = size.GetHeight() size = self.m_hscroll.GetSize() sh = size.GetHeight() size = self.m_vscroll.GetSize() sw = size.GetWidth() dc.SetPen(shadow) dc.DrawLine(1, 1, 1, h - 2) dc.DrawLine(1, 1, w - 2, 1) dc.SetPen(black) dc.DrawLine(2, 2, 2, h - 3) dc.DrawLine(2, 2, w - 3, 2) dc.SetPen(highlight) dc.DrawLine(w - 2, 2, w - 2, h - sh - 2) dc.DrawLine(w - 2, h - sh - 2, w - sw - 2, h - sh - 2) dc.DrawLine(w - sw - 2, h - sh - 2, w - sw - 2, h - 2) dc.DrawLine(w - sw - 2, h - 2, 2, h - 2) dc.SetPen(highlight) dc.DrawLine(w - sw - 2, 8, w - sw - 2, 4) dc.DrawLine(w - sw - 2, 4, w - 5, 4) dc.SetPen(shadow) dc.DrawLine(w - 5, 4, w - 5, 8) dc.DrawLine(w - 5, 8, w - sw - 2, 8) dc.SetPen(black) dc.DrawLine(w - 4, 3, w - 4, 9) dc.DrawLine(w - 4, 9, w - sw - 3, 9) dc.SetPen(highlight) dc.DrawLine(4, h - 5, 4, h - sh - 2) dc.DrawLine(4, h - sh - 2, 8, h - sh - 2) dc.SetPen(shadow) dc.DrawLine(8, h - sh - 2, 8, h - 5) dc.DrawLine(8, h - 5, 4, h - 5) dc.SetPen(black) dc.DrawLine(9, h - sh - 3, 9, h - 4) dc.DrawLine(9, h - 4, 3, h - 4) cy = (h - sh + h - 6) / 2.0 + 1 cx = (w - sw + w - 6) / 2.0 + 1 sy = cy while sy > h - sh: sy -= 4 sx = cx while sx > w - sw: sx -= 4 for y in range(int(sy), h - 2, 4): #(y = sy; y < h - 2; y += 4) for x in range(int(sx), w - 2, 4): #(x = sx; x < w - 2; x += 4) if x - cx >= -(y - cy): dc.SetPen(highlight) dc.DrawPoint(x, y) dc.SetPen(shadow) dc.DrawPoint(x + 1, y + 1)
def OnPaint(self, evt): width, height = self.GetSizeTuple() width -= 10 height -= 10 bar_height = (height / 3) - 10 back_colour = self.GetBackgroundColour() gc = wx.PaintDC(self) gc.SetBrush(wx.Brush(back_colour)) gc.SetPen(wx.Pen(back_colour, 1)) gc.Clear() gc.SetTextForeground(self.GetForegroundColour()) gc.SetTextBackground(back_colour) font = self.GetFont() font.SetPixelSize(wx.Size(0, bar_height - (bar_height / 12))) gc.SetFont(font) text_w, text_h = gc.GetTextExtent('G') bar_width = width - 10 - text_w cursor_width = 13 cursor_height = bar_height - 2 cursor_half = cursor_width / 2 red_cursor = remap(self.red, 0, 255, width - bar_width - 5, width - 8) green_cursor = remap(self.green, 0, 255, width - bar_width - 5, width - 8) blue_cursor = remap(self.blue, 0, 255, width - bar_width - 5, width - 8) red = wx.Rect(width - bar_width - 5, 10, bar_width, bar_height) green = wx.Rect(width - bar_width - 5, 20 + bar_height, bar_width, bar_height) blue = wx.Rect(width - bar_width - 5, 30 + (bar_height * 2), bar_width, bar_height) cursor_line_height = int(bar_height * 0.6) cursor_line_start = ((bar_height - cursor_line_height) / 2) + 1 red_cursor_line = (red_cursor, red.GetY() + cursor_line_start, red_cursor, red.GetY() + cursor_line_start + cursor_line_height) green_cursor_line = (green_cursor, green.GetY() + cursor_line_start, green_cursor, green.GetY() + cursor_line_start + cursor_line_height) blue_cursor_line = (blue_cursor, blue.GetY() + cursor_line_start, blue_cursor, blue.GetY() + cursor_line_start + cursor_line_height) red_fill = wx.Rect(red.GetX() + 1, red.GetY() + 2, red.GetWidth() - 2, red.GetHeight() - 2) green_fill = wx.Rect(green.GetX() + 1, green.GetY() + 2, green.GetWidth() - 2, green.GetHeight() - 2) blue_fill = wx.Rect(blue.GetX() + 1, blue.GetY() + 2, blue.GetWidth() - 2, blue.GetHeight() - 2) self.red_cursor = (red_cursor - cursor_half, red.GetY() + 2, cursor_width, cursor_height, 2) self.green_cursor = (green_cursor - cursor_half, green.GetY() + 2, cursor_width, cursor_height, 2) self.blue_cursor = (blue_cursor - cursor_half, blue.GetY() + 2, cursor_width, cursor_height, 2) gc.SetBrush(wx.Brush(wx.Colour(0, 0, 0, 0), wx.BRUSHSTYLE_TRANSPARENT)) gc.SetPen(wx.Pen(wx.Colour(0, 0, 0), 1)) gc.DrawRectangle(red.GetX(), red.GetY() + 1, red.GetWidth(), red.GetHeight()) gc.DrawRectangle(green.GetX(), green.GetY() + 1, green.GetWidth(), green.GetHeight()) gc.DrawRectangle(blue.GetX(), blue.GetY() + 1, blue.GetWidth(), blue.GetHeight()) gc.GradientFillLinear(red_fill, wx.Colour(0, self.green, self.blue), wx.Colour(255, self.green, self.blue)) gc.GradientFillLinear(green_fill, wx.Colour(self.red, 0, self.blue), wx.Colour(self.red, 255, self.blue)) gc.GradientFillLinear(blue_fill, wx.Colour(self.red, self.green, 0), wx.Colour(self.red, self.green, 255)) gc.SetPen(wx.Pen(back_colour, 1)) gc.DrawRoundedRectangle(*self.red_cursor) gc.DrawRoundedRectangle(*self.green_cursor) gc.DrawRoundedRectangle(*self.blue_cursor) gc.DrawLine(*red_cursor_line) gc.DrawLine(*green_cursor_line) gc.DrawLine(*blue_cursor_line) gc.DrawText('R', 4, red.GetY() - 1) gc.DrawText('G', 3, green.GetY() - 1) gc.DrawText('B', 4, blue.GetY() - 1)
def OnPaint(self, evt): """Update the panel when it needs to be refreshed.""" # Bind motion event when the panel has been painted to avoid a blank # image on Windows if a file is loaded too quickly before the plugin # is initialized self.Bind(wx.EVT_MOTION, self.OnMouseMotion) # Special case for Windows to account for flickering # if and only if images are loaded if (guiutil.IsMSWindows() and len(self.images)): dc = wx.BufferedPaintDC(self) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) else: dc = wx.PaintDC(self) width, height = self.GetClientSize() try: gc = wx.GraphicsContext.Create(dc) except NotImplementedError: dc.DrawText( "This build of wxPython does not support the " "wx.GraphicsContext family of classes.", 25, 25) return # If we have images loaded, process and show the image if len(self.images): # Save the original drawing state gc.PushState() # Scale the image by the zoom factor gc.Scale(self.zoom, self.zoom) # Redraw the background on Windows if guiutil.IsMSWindows(): gc.SetBrush(wx.Brush(wx.Colour(0, 0, 0))) gc.SetPen(wx.Pen(wx.Colour(0, 0, 0))) gc.DrawRectangle(0, 0, width, height) image = guiutil.convert_pil_to_wx( self.images[self.imagenum - 1].GetImage( self.window, self.level)) bmp = wx.BitmapFromImage(image) self.bwidth, self.bheight = image.GetSize() # Center the image transx = self.pan[0] + (width - self.bwidth * self.zoom) / (2 * self.zoom) transy = self.pan[1] + (height - self.bheight * self.zoom) / (2 * self.zoom) gc.Translate(transx, transy) gc.DrawBitmap(bmp, 0, 0, self.bwidth, self.bheight) gc.SetBrush(wx.Brush(wx.Colour(0, 0, 255, 30))) gc.SetPen(wx.Pen(wx.Colour(0, 0, 255, 30))) # Draw the structures if present imdata = self.images[self.imagenum - 1].GetImageData() self.z = '%.2f' % imdata['position'][2] # Determine whether the patient is prone or supine if 'p' in imdata['patientposition'].lower(): prone = True else: prone = False # Determine whether the patient is feet first or head first if 'ff' in imdata['patientposition'].lower(): feetfirst = True else: feetfirst = False for id, structure in self.structures.iteritems(): self.DrawStructure(structure, gc, self.z, prone, feetfirst) # Draw the isodoses if present if len(self.isodoses): grid = self.dose.GetDoseGrid(float(self.z)) if not (grid == []): x, y = np.meshgrid(np.arange(grid.shape[1]), np.arange(grid.shape[0])) # Instantiate the isodose generator for this slice isodosegen = cntr.Cntr(x, y, grid) for id, isodose in iter(sorted(self.isodoses.iteritems())): self.DrawIsodose(isodose, gc, isodosegen) # Restore the translation and scaling gc.PopState() # Prepare the font for drawing the information text font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) if guiutil.IsMac(): font.SetPointSize(10) gc.SetFont(font, wx.WHITE) # Draw the information text imtext = "Image: " + str(self.imagenum) + "/" + str( len(self.images)) te = gc.GetFullTextExtent(imtext) gc.DrawText(imtext, 10, 7) impos = "Position: " + str(self.z) + " mm" gc.DrawText(impos, 10, 7 + te[1] * 1.1) if ("%.3f" % self.zoom == "1.000"): zoom = "1" else: zoom = "%.3f" % self.zoom imzoom = "Zoom: " + zoom + ":1" gc.DrawText(imzoom, 10, height - 17) imsize = "Image Size: " + str(self.bheight) + "x" + str( self.bwidth) + " px" gc.DrawText(imsize, 10, height - 17 - te[1] * 1.1) imwinlevel = "W/L: " + str(self.window) + ' / ' + str(self.level) te = gc.GetFullTextExtent(imwinlevel) gc.DrawText(imwinlevel, width - te[0] - 7, 7) impatpos = "Patient Position: " + imdata['patientposition'] te = gc.GetFullTextExtent(impatpos) gc.DrawText(impatpos, width - te[0] - 7, height - 17) # Send message with the current image number and various properties pub.sendMessage( '2dview.updated.image', { 'number': self.imagenum, # slice number 'z': self.z, # slice location 'window': self.window, # current window value 'level': self.level, # curent level value 'gc': gc, # wx.GraphicsContext 'scale': self.zoom, # current zoom level 'transx': transx, # current x translation 'transy': transy, # current y translation 'imdata': imdata, # image data dictionary 'patientpixlut': self.structurepixlut })
def OnPaint(self, event): dc = wx.PaintDC(self.panel) brush = wx.Brush(wx.Colour(1, 200, 0, 10)) dc.SetBackground(brush) dc.Clear()
def on_paint(self, event): dc = wx.PaintDC(self) x0, y0 = self.CalcUnscrolledPosition(0, 0) dc.SetLogicalOrigin(x0, y0) dc.SetPen(self.pen) for line in self.restart_lines: x1 = self.frame_to_x(line.start_frame) x2 = self.frame_to_x(line.end_frame) y = self.level_to_y(line.level) if self.highlight_over_line and line == self.over_line: dc.SetPen(self.hover_pen) dc.DrawLine(x1, y, x2, y) else: dc.SetPen(self.pen) dc.DrawLine(x1, y, x2, y) dc.SetPen(self.marker_pen) dc.SetBrush(self.marker_brush) for interesting_frame in line.interesting_frames.keys(): xi = self.frame_to_x(interesting_frame) dc.DrawCircle(xi, y, self.marker_size) if line.restart_number == 0: continue # draw vertical line connecting to parent restart parent_line = self.restart_lines[line.parent] parent_y = self.level_to_y(parent_line.level) dc.SetPen(self.pen) dc.DrawLine(x1, y, x1, parent_y) # highlighting of selected lines if self.current_mouse_state is not None: dc.SetPen(self.hover_pen) start, end = self.initial_mouse_state, self.current_mouse_state if start.frame_number > end.frame_number: start, end = end, start current_frame = end.frame_number leftmost_frame = start.frame_number line = end.nearest_line while current_frame > leftmost_frame: if line.is_frame_in_line(leftmost_frame): left_frame = leftmost_frame else: left_frame = line.start_frame x1 = self.frame_to_x(left_frame) x2 = self.frame_to_x(current_frame) y = self.level_to_y(line.level) dc.DrawLine(x1, y, x2, y) current_frame = left_frame if current_frame > leftmost_frame: line = self.restart_lines.find_parent(line) # current frame & restart number i = self.source.current_frame_number if i is not None: xc = self.frame_to_x(i) restart = self.source.get_restart_of_frame(i) line = self.restart_lines[restart.restart_number] yc = self.level_to_y(line.level) dc.SetPen(self.marker_pen) dc.SetBrush(self.cursor_brush) dc.DrawCircle(xc, yc, self.marker_size)
def onPaint(self, evt): dc = wx.PaintDC(self) self.render(wx.BufferedDC(dc))
def OnPaint(self, evt): if self.image: dc = wx.PaintDC(self) dc.Clear() dc.DrawBitmap(self.bmp, 0, 0)
def __DrawButton(self): """Draw the button""" # TODO using a buffered paintdc on windows with the nobg style # causes lots of weird drawing. So currently the use of a # buffered dc is dissabled for this style. if PB_STYLE_NOBG & self._style: dc = wx.PaintDC(self) else: dc = wx.AutoBufferedPaintDCFactory(self) gc = wx.GCDC(dc) # Setup dc.SetBrush(wx.TRANSPARENT_BRUSH) gc.SetBrush(wx.TRANSPARENT_BRUSH) gc.SetFont(self.Font) dc.SetFont(self.Font) gc.SetBackgroundMode(wx.TRANSPARENT) # The background needs some help to look transparent on # on Gtk and Windows if wx.Platform in ['__WXGTK__', '__WXMSW__']: gc.SetBackground(self.GetBackgroundBrush(gc)) gc.Clear() # Calc Object Positions width, height = self.GetSize() if wx.Platform == '__WXGTK__': tw, th = dc.GetTextExtent(self.Label) else: tw, th = gc.GetTextExtent(self.Label) txt_y = max((height - th) // 2, 1) if self._state['cur'] == PLATE_HIGHLIGHT: gc.SetTextForeground(self._color['htxt']) gc.SetPen(wx.TRANSPARENT_PEN) self.__DrawHighlight(gc, width, height) elif self._state['cur'] == PLATE_PRESSED: gc.SetTextForeground(self._color['htxt']) if wx.Platform == '__WXMAC__': pen = wx.Pen(GetHighlightColour(), 1, wx.SOLID) else: pen = wx.Pen(AdjustColour(self._color['press'], -80, 220), 1) gc.SetPen(pen) self.__DrawHighlight(gc, width, height) txt_x = self.__DrawBitmap(gc) t_x = max((width - tw - (txt_x + 2)) // 2, txt_x + 2) if wx.Platform == '__WXGTK__': dc.DrawText(self.Label, t_x, txt_y) else: gc.DrawText(self.Label, t_x, txt_y) self.__DrawDropArrow(gc, width - 10, (height // 2) - 2) else: if self.IsEnabled(): gc.SetTextForeground(self.GetForegroundColour()) else: txt_c = wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT) gc.SetTextForeground(txt_c) # Draw bitmap and text if self._state['cur'] != PLATE_PRESSED: txt_x = self.__DrawBitmap(gc) t_x = max((width - tw - (txt_x + 2)) // 2, txt_x + 2) if wx.Platform == '__WXGTK__': dc.DrawText(self.Label, t_x, txt_y) else: gc.DrawText(self.Label, t_x, txt_y) self.__DrawDropArrow(gc, width - 10, (height // 2) - 2)
def renderHands(self, e): ''' Renders the player and dealer hand.''' width = self.CARDWIDTH height = self.CARDHEIGHT x = self.CARDX y = self.CARDY # Render the cards at the bottom of the screen (current player's card). for card in self.playerList[self.currentPlayer].hand: newCard = wx.PaintDC(self) newCard.BeginDrawing() newCard.SetPen(wx.Pen('black', style=wx.SOLID)) newCard.SetBrush(wx.Brush('white', wx.SOLID)) newCard.DrawRectangle(x, y, width, height) newCard.EndDrawing() newCard.SetFont( wx.Font(18, wx.FONTFAMILY_SWISS, wx.NORMAL, wx.NORMAL)) temp = card.split() if temp[2] == 'Diamonds': suite = 'suites/diamond.png' newCard.SetTextForeground('red') elif temp[2] == 'Hearts': suite = 'suites/heart.png' newCard.SetTextForeground('red') elif temp[2] == 'Clubs': suite = 'suites/club.png' elif temp[2] == 'Spades': suite = 'suites/spade.png' letter = '' letterWidth = 1 if temp[0].isdigit(): letter = temp[0] if temp[0] == '10': letterWidth = 2 elif temp[0] == 'Ace': letter = 'A' elif temp[0] == 'Jack': letter = 'J' elif temp[0] == 'Queen': letter = 'Q' elif temp[0] == 'King': letter = 'K' else: letter = ' ' newCard.DrawText(letter, x + 14, y + 8) if letterWidth == 1: newCard.DrawText(letter, x + width - 28, y + height - 36) elif letterWidth == 2: newCard.DrawText(letter, x + width - 35, y + height - 35) suiteRender = wx.Bitmap(suite) newCard.DrawBitmap(suiteRender, x, y) x += self.CARDSPACING x = self.DEALERCARDX y = self.DEALERCARDY blankCard = True # Render the cards at the top of the screen if self.playerList[self.currentPlayer].name is not 'Dealer': for card in self.dealer.hand: newCard = wx.PaintDC(self) newCard.BeginDrawing() newCard.SetPen(wx.Pen('black', style=wx.SOLID)) newCard.SetBrush(wx.Brush('white', wx.SOLID)) newCard.DrawRectangle(x, y, width, height) newCard.EndDrawing() newCard.SetFont( wx.Font(18, wx.FONTFAMILY_SWISS, wx.NORMAL, wx.NORMAL)) if blankCard is False: temp = card.split() if temp[2] == 'Diamonds': suite = 'suites/diamond.png' newCard.SetTextForeground('red') elif temp[2] == 'Hearts': suite = 'suites/heart.png' newCard.SetTextForeground('red') elif temp[2] == 'Clubs': suite = 'suites/club.png' elif temp[2] == 'Spades': suite = 'suites/spade.png' letter = '' letterWidth = 1 if temp[0].isdigit(): letter = temp[0] if temp[0] == '10': letterWidth = 2 elif temp[0] == 'Ace': letter = 'A' elif temp[0] == 'Jack': letter = 'J' elif temp[0] == 'Queen': letter = 'Q' elif temp[0] == 'King': letter = 'K' else: letter = ' ' newCard.DrawText(letter, x + 14, y + 8) if letterWidth == 1: newCard.DrawText(letter, x + width - 28, y + height - 36) elif letterWidth == 2: newCard.DrawText(letter, x + width - 35, y + height - 35) newCard.SetTextForeground('black') else: suite = 'suites/blank.png' # Draws the suite (blank for cards that are flipped) suiteRender = wx.Bitmap(suite) newCard.DrawBitmap(suiteRender, x, y) x += self.CARDSPACING blankCard = False
def onPaintGL(self, canvas, plot, context): wx.PaintDC(canvas) canvas.SetCurrent(context) plot.display() canvas.SwapBuffers()
def on_paint(self, event): # This is your EVT_PAINT handler, which draws the state on the widget. event.Skip() dc = wx.PaintDC(self)
def OnPaint(self, event): dc = wx.PaintDC(self) dc.SetBrush(wx.RED_BRUSH) dc.DrawRectangle(*self.Rect)
def onPaint(self, event): event.Skip() dc = wx.PaintDC(self) self.draw(dc)
def OnPaint(self, evt): dc = wx.PaintDC(self) dc.DrawBitmap(self.bmp, 0, 0, True)