def OnPaint(self, event): rect = self.GetClientRect() dc = wx.AutoBufferedPaintDC(self) windowColor = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW) dc.SetBackground(wx.Brush(windowColor)) dc.Clear() barColor = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT) shadeColor = colorUtils.GetSuitable(barColor, 0.75) barWidth = rect.width / self.bars barHeight = rect.height - self.padding * 2 x = self.padding for bar in range(self.bars): if bar != self.animCount: dc.SetPen(wx.Pen(shadeColor)) dc.SetBrush(wx.Brush(shadeColor)) bh = barHeight y = self.padding else: barColor = colorUtils.GetSuitable( barColor, float(self.animCount / 2) / 10) dc.SetPen(wx.Pen(barColor)) dc.SetBrush(wx.Brush(barColor)) bh = rect.height y = 0 dc.DrawRectangle(x, y, barWidth, bh) x += barWidth textColor = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT) dc.SetTextForeground(textColor) dc.DrawLabel(self.label, rect, wx.ALIGN_CENTER)
def paint(e): dc = wx.AutoBufferedPaintDC(f) dc.SetPen(wx.TRANSPARENT_PEN) dc.SetBrush(wx.BLACK_BRUSH) dc.DrawRectangleRect(f.ClientRect) font = wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD) font.SetPixelSize(wx.Size(0, -f.fontsize)) font.SetFaceName('Times New Roman') dc.TextForeground = wx.WHITE dc.Font = font str = 'test hello world xyz' x, y = 40, 10 dc.DrawText(str, x, y) w, h, desc, externalLeading = dc.GetFullTextExtent(str) print w, h, desc, externalLeading r = wx.Rect(x, y + desc, w, h - desc * 2) realHeight = (h - desc * 2) f.SetTitle('%s / %s = %s' % (f.fontsize, realHeight, f.fontsize / realHeight))
def OnPaint(self, event): width, height = self.GetClientSize() dc = wx.AutoBufferedPaintDC(self) dc.SetBackground(wx.WHITE_BRUSH) dc.Clear() font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) font.MakeSmaller() dc.SetFont(font) w, labelHeight = dc.GetTextExtent('Wy') name = self.pen_name if "STIPPLE" in name: bmp = images.Smiles.GetBitmap() penWidth = 8 #bmp.GetHeight() pen = wx.Pen(wx.BLUE, penWidth, eval(name)) pen.SetStipple(bmp) else: penWidth = 3 if 'HATCH' in name: penWidth = 8 pen = wx.Pen(wx.BLUE, penWidth, eval(name)) if "USER" in name: # dash values represent units on, off, on. off... pen.SetDashes([2, 5, 2, 2]) name += " ([2, 5, 2, 2])" dc.SetTextForeground(wx.BLACK) dc.DrawText(name, 1, 1) dc.SetPen(pen) y = labelHeight + (height - labelHeight) / 2 dc.DrawLine(5, int(y), width - 5, int(y))
def repaint(self): w, h = self.GetClientSize() dc = wx.AutoBufferedPaintDC(self) if self.weight > 0: c = 255 - int(min(self.weight, 1) * 255.0) colour = wx.Colour(c, 255, c) else: c = 255 - int(min(-self.weight, 1) * 255.0) colour = wx.Colour(255, c, c) pen = wx.Pen(colour, 2) dc.SetPen(pen) dc.DrawRectangle(0, 0, w, h) yscale = -min(w, h) * self.yscale yshift = h / 2 dc.SetPen(wx.Pen(wx.RED)) if self.secondary_history is not None: for i in xrange(len(self.history) - 1): x1 = w * i / float(self.history_length) y1 = self.secondary_history[i] * yscale + yshift x2 = w * (i + 1) / float(self.history_length) y2 = self.secondary_history[i + 1] * yscale + yshift dc.DrawLine(x1, y1, x2, y2) dc.SetPen(wx.Pen(wx.BLACK)) for i in xrange(len(self.history) - 1): x1 = w * i / float(self.history_length) y1 = self.history[i] * yscale + yshift x2 = w * (i + 1) / float(self.history_length) y2 = self.history[i + 1] * yscale + yshift dc.DrawLine(x1, y1, x2, y2)
def OnPaint(self, event): """ Handles the ``wx.EVT_PAINT`` event for :class:`RibbonButtonBar`. :param `event`: a :class:`PaintEvent` event to be processed. """ dc = wx.AutoBufferedPaintDC(self) self._art.DrawButtonBarBackground(dc, self, wx.Rect(0, 0, *self.GetSize())) layout = self._layouts[self._current_layout] for button in layout.buttons: base = button.base bitmap = base.bitmap_large bitmap_small = base.bitmap_small if base.state & RIBBON_BUTTONBAR_BUTTON_DISABLED: bitmap = base.bitmap_large_disabled bitmap_small = base.bitmap_small_disabled rect = wx.Rect(button.position + self._layout_offset, base.sizes[button.size].size) self._art.DrawButtonBarButton(dc, self, rect, base.kind, base.state | button.size, base.label, bitmap, bitmap_small)
def OnPaint(self, event): dc = wx.AutoBufferedPaintDC(self) if self._art == None: return cur_size = self.GetSize() min_size = self.GetMinSize() self._art.DrawGalleryBackground(dc, self, wx.Rect(0, 0, *cur_size)) padding_top = self._art.GetMetric(RIBBON_ART_GALLERY_BITMAP_PADDING_TOP_SIZE) padding_left = self._art.GetMetric(RIBBON_ART_GALLERY_BITMAP_PADDING_LEFT_SIZE) dc.SetClippingRect(self._client_rect) offset_vertical = True if self._art.GetFlags() & RIBBON_BAR_FLOW_VERTICAL: offset_vertical = False for item in self._items: if not item.IsVisible(): continue pos = item.GetPosition() offset_pos = wx.Rect(*pos) if offset_vertical: offset_pos.SetTop(offset_pos.GetTop() - self._scroll_amount) else: offset_pos.SetLeft(offset_pos.GetLeft() - self._scroll_amount) self._art.DrawGalleryItemBackground(dc, self, offset_pos, item) dc.DrawBitmap(item.GetBitmap(), offset_pos.GetLeft() + padding_left, offset_pos.GetTop() + padding_top)
def OnPaint(self, event): mdc = wx.AutoBufferedPaintDC(self) # if 'wxMac' in wx.PlatformInfo: # color = wx.Colour(0, 0, 0) # brush = wx.Brush(color) # # @todo: what needs to be changed with wxPheonix? # from Carbon.Appearance import kThemeBrushDialogBackgroundActive # brush.MacSetTheme(kThemeBrushDialogBackgroundActive) # else: color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE) brush = wx.Brush(color) if "wxGTK" not in wx.PlatformInfo: mdc.SetBackground(brush) mdc.Clear() selected = None if self.show_add_button: ax, ay = self.add_button.GetPosition() mdc.DrawBitmap(self.add_button.Render(), ax, ay, True) for i in range(len(self.tabs) - 1, -1, -1): tab = self.tabs[i] posx, posy = tab.GetPosition() if not tab.IsSelected(): # drop shadow first mdc.DrawBitmap(self.fx_bmp, posx, posy, True) bmp = tab.Render() img = bmp.ConvertToImage() img = img.AdjustChannels(1, 1, 1, 0.85) bmp = wx.Bitmap(img) mdc.DrawBitmap(bmp, posx, posy, True) mdc.SetDeviceOrigin(posx, posy) tab.DrawText(mdc) mdc.SetDeviceOrigin(0, 0) else: selected = tab # we draw selected tab separately (instead of in else) so as to not hide # the front bit behind the preceding tab if selected: posx, posy = selected.GetPosition() # drop shadow first mdc.DrawBitmap(self.fx_bmp, posx, posy, True) bmp = selected.Render() if self.dragging: img = bmp.ConvertToImage() img = img.AdjustChannels(1.2, 1.2, 1.2, 0.7) bmp = wx.Bitmap(img) mdc.DrawBitmap(bmp, posx, posy, True) mdc.SetDeviceOrigin(posx, posy) selected.DrawText(mdc) mdc.SetDeviceOrigin(0, 0)
def on_paint(self, event): dc = wx.AutoBufferedPaintDC(self) self.setup_dc(dc) dc.Clear() self.draw_lines(dc)
def on_paint(self, event): pen_alpha = 150 colors = { model.RED: wx.Colour(178, 34, 34), model.GREEN: wx.Colour(50, 205, 50), model.BLUE: wx.Colour(65, 105, 225), model.YELLOW: wx.Colour(255, 215, 0), } pen_colors = { model.RED: wx.Colour(178, 34, 34, pen_alpha), model.GREEN: wx.Colour(50, 205, 50, pen_alpha), model.BLUE: wx.Colour(65, 105, 225, pen_alpha), model.YELLOW: wx.Colour(255, 215, 0, pen_alpha), } if len(self.game.robots) == 5: colors[model.SILVER] = wx.Colour(100, 100, 100) pen_colors[model.SILVER] = wx.Colour(100, 100, 100, pen_alpha) dc = wx.AutoBufferedPaintDC(self) dc.SetBackground(wx.LIGHT_GREY_BRUSH) dc.Clear() w, h = self.GetClientSize() p = 40 size = min((w - p) // 16, (h - p) // 16) wall = size // 8 ox = (w - size * 16) // 2 oy = (h - size * 16) // 2 dc.SetDeviceOrigin(ox, oy) dc.SetClippingRegion(0, 0, size * 16 + 1, size * 16 + 1) dc.SetBrush(wx.WHITE_BRUSH) dc.DrawRectangle(0, 0, size * 16 + 1, size * 16 + 1) for color, start, end, direction in self.lines: dc.SetPen(wx.Pen(pen_colors[color], 3, wx.PENSTYLE_SHORT_DASH)) x1, y1 = model.xy(start) x1, y1 = x1 * size + size // 2, y1 * size + size // 2 x2, y2 = model.xy(end) x2, y2 = x2 * size + size // 2, y2 * size + size // 2 if x1 > x2 and direction == 'E': dc.DrawLine(x1, y1, 800, y2) dc.DrawLine(0, y1, x2, y2) elif x1 < x2 and direction == 'W': dc.DrawLine(800, y1, x2, y2) dc.DrawLine(x1, y1, 0, y2) elif y1 > y2 and direction == 'S': dc.DrawLine(x1, y1, x2, 800) dc.DrawLine(x1, 0, x2, y2) elif y1 < y2 and direction == 'N': dc.DrawLine(x1, 800, x2, y2) dc.DrawLine(x1, y1, x2, 0) else: dc.DrawLine(x1, y1, x2, y2) for j in range(16): for i in range(16): x = i * size y = j * size index = model.idx(i, j) cell = self.game.grid[index] robot = self.game.get_robot(index) # border dc.SetPen(wx.BLACK_PEN) dc.SetBrush(wx.TRANSPARENT_BRUSH) dc.DrawRectangle(x, y, size + 1, size + 1) # token if self.game.token in cell: dc.SetBrush(wx.Brush(colors[self.game.token[0]])) dc.DrawRectangle(x, y, size + 1, size + 1) if i in (7, 8) and j in (7, 8): dc.SetBrush(wx.LIGHT_GREY_BRUSH) dc.DrawRectangle(x, y, size + 1, size + 1) # robot if robot: dc.SetBrush(wx.Brush(colors[robot])) dc.DrawCircle(x + size // 2, y + size // 2, size // 3) # walls dc.SetBrush(wx.BLACK_BRUSH) if model.NORTH in cell: dc.DrawRectangle(x, y, size + 1, wall) dc.DrawCircle(x, y, wall - 1) dc.DrawCircle(x + size, y, wall - 1) if model.EAST in cell: dc.DrawRectangle(x + size + 1, y, -wall, size + 1) dc.DrawCircle(x + size, y, wall - 1) dc.DrawCircle(x + size, y + size, wall - 1) if model.SOUTH in cell: dc.DrawRectangle(x, y + size + 1, size + 1, -wall) dc.DrawCircle(x, y + size, wall - 1) dc.DrawCircle(x + size, y + size, wall - 1) if model.WEST in cell: dc.DrawCircle(x, y, wall - 1) dc.DrawCircle(x, y + size, wall - 1) dc.DrawRectangle(x, y, wall, size + 1) # bumpers if model.LEFT in cell: bumper_color = [c for c in colors.keys() if c in cell][0] dc.SetPen(wx.Pen(colors[bumper_color], 9)) dc.DrawLine(x, y, x + size, y + size) if model.RIGHT in cell: bumper_color = [c for c in colors.keys() if c in cell][0] dc.SetPen(wx.Pen(colors[bumper_color], 9)) dc.DrawLine(x + size, y, x, y + size) dc.DrawText(str(self.game.moves), wall + 1, wall + 1)
def on_paint(self,event): # w,h = self.GetClientSize() dc = wx.AutoBufferedPaintDC(self) dc.Clear() dc.DrawBitmap(self.bitmap1,0,0) dc.DrawBitmap(self.bitmap2,224,0)
def OnPaint(self, event): if "wxGTK" in wx.PlatformInfo: mdc = wx.AutoBufferedPaintDC(self) else: rect = self.GetRect() mdc = wx.BufferedPaintDC(self) selected = 0 if 'wxMac' in wx.PlatformInfo and wx.VERSION < (3, 0): color = wx.Colour(0, 0, 0) brush = wx.Brush(color) from Carbon.Appearance import kThemeBrushDialogBackgroundActive brush.MacSetTheme(kThemeBrushDialogBackgroundActive) else: color = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE) brush = wx.Brush(color) if "wxGTK" not in wx.PlatformInfo: mdc.SetBackground(brush) mdc.Clear() selected = None tabsWidth = 0 for tab in self.tabs: tabsWidth += tab.tabWidth - self.inclination * 2 pos = tabsWidth if self.showAddButton: ax, ay = self.addButton.GetPosition() mdc.DrawBitmap(self.addButton.Render(), ax, ay, True) for i in xrange(len(self.tabs) - 1, -1, -1): tab = self.tabs[i] width = tab.tabWidth - 6 posx, posy = tab.GetPosition() if not tab.IsSelected(): mdc.DrawBitmap(self.efxBmp, posx, posy, True) bmp = tab.Render() img = bmp.ConvertToImage() img = img.AdjustChannels(1, 1, 1, 0.85) bmp = wx.BitmapFromImage(img) mdc.DrawBitmap(bmp, posx, posy, True) else: selected = tab if selected: posx, posy = selected.GetPosition() mdc.DrawBitmap(self.efxBmp, posx, posy, True) bmp = selected.Render() if self.dragging: img = bmp.ConvertToImage() img = img.AdjustChannels(1.2, 1.2, 1.2, 0.7) bmp = wx.BitmapFromImage(img) mdc.DrawBitmap(bmp, posx, posy, True)
def _on_paint(self, event): dc = wx.AutoBufferedPaintDC(self) if self._surface_bitmap: dc.DrawBitmap(self._surface_bitmap, 0, 0, True) else: pass # TODO: Fill with white?
def OnPaint(self, event): dc = wx.AutoBufferedPaintDC(self) self.DoDrawing(dc)
def OnPaint(self, event=None): width, height = self.GetSize() self.draw(wx.AutoBufferedPaintDC(self), width, height)
def on_paint(e): dc = wx.AutoBufferedPaintDC(ctrl) return paint(dc)
def OnPaint(self, event): dc = wx.AutoBufferedPaintDC(self) rect = wx.RectS(self.Size) dc.SetBrush(wx.WHITE_BRUSH) dc.SetPen(wx.Pen(wx.Color(200, 200, 200))) dc.DrawRectangleRect(rect)
def OnPaint(self, event): """ Handles the ``wx.EVT_PAINT`` event for :class:`RibbonBar`. :param `event`: a :class:`PaintEvent` event to be processed. """ dc = wx.AutoBufferedPaintDC(self) if not self.GetUpdateRegion().Contains(wx.Rect(0, 0, self.GetClientSize().GetWidth(), self._tab_height)): # Nothing to do in the tab area, and the page area is handled by the active page return self.DoEraseBackground(dc) numtabs = len(self._pages) sep_visibility = 0.0 draw_sep = False tabs_rect = wx.Rect(self._tab_margin_left, 0, self.GetClientSize().GetWidth() - self._tab_margin_left - self._tab_margin_right, self._tab_height) if self._tab_scroll_buttons_shown: tabs_rect.x += self._tab_scroll_left_button_rect.GetWidth() tabs_rect.width -= self._tab_scroll_left_button_rect.GetWidth() + self._tab_scroll_right_button_rect.GetWidth() for info in self._pages: dc.DestroyClippingRegion() if self._tab_scroll_buttons_shown: if not tabs_rect.Intersects(info.rect): continue dc.SetClippingRegion(tabs_rect) dc.SetClippingRegion(info.rect) self._art.DrawTab(dc, self, info) if info.rect.width < info.small_begin_need_separator_width: draw_sep = True if info.rect.width < info.small_must_have_separator_width: sep_visibility += 1.0 else: sep_visibility += float(info.small_begin_need_separator_width - info.rect.width)/ \ float(info.small_begin_need_separator_width - info.small_must_have_separator_width) if draw_sep: rect = wx.Rect(*self._pages[0].rect) rect.width = self._art.GetMetric(RIBBON_ART_TAB_SEPARATION_SIZE) sep_visibility /= float(numtabs) for i in range(0, numtabs-1): info = self._pages[i] rect.x = info.rect.x + info.rect.width if self._tab_scroll_buttons_shown and not tabs_rect.Intersects(rect): continue dc.DestroyClippingRegion() dc.SetClippingRegion(rect) self._art.DrawTabSeparator(dc, self, rect, sep_visibility) if self._tab_scroll_buttons_shown: dc.DestroyClippingRegion() if self._tab_scroll_left_button_rect.GetWidth() != 0: self._art.DrawScrollButton(dc, self, self._tab_scroll_left_button_rect, RIBBON_SCROLL_BTN_LEFT | self._tab_scroll_left_button_state | RIBBON_SCROLL_BTN_FOR_TABS) if self._tab_scroll_right_button_rect.GetWidth() != 0: self._art.DrawScrollButton(dc, self, self._tab_scroll_right_button_rect, RIBBON_SCROLL_BTN_RIGHT | self._tab_scroll_right_button_state | RIBBON_SCROLL_BTN_FOR_TABS)
def on_paint(self, event): '''repaint the image''' dc = wx.AutoBufferedPaintDC(self) dc.DrawBitmap(self._bmp, 0, 0)
def OnPaint(self, event): self.framebg.Draw(wx.AutoBufferedPaintDC(self), wx.RectS(self.ClientSize))
def OnPaint(self, event): dc = wx.AutoBufferedPaintDC(self) rect = wx.RectS(self.Size) self.skinTB['background'].Draw(dc, rect) self.OnPaintMore(dc)
def onpaint(self, event): """ The main Drawing function All visuals are done here Rect states of drawing: unnamed, named, and currently being added via mouse Preferences.py stores the color preferences for the program """ # TODO: future feature of zooming in on the image (use of a zoom variable? enhanced bitdrawing?) event.Skip() w, h = self.GetClientSize() # these two aren't used much right now dc = wx.AutoBufferedPaintDC(self) dc.Clear() # Cause the render to draw unfilled rectangles with borders (may be root of problems) dc.SetBrush(wx.Brush("000000", style=wx.TRANSPARENT)) if self.image is not None: # draw the new bitmap dc.DrawBitmap(self.image, self.offsetx, self.offsety) # draw rectangles here etc # draw the left-click preview rectangle if self.displayrect: # draw the being-made rectangle dc.SetPen( wx.Pen(Preferences.displayRectangleBorder, 2, style=wx.DOT_DASH)) dc.DrawRectangle(*self.createrect(self.leftclick_topleft, self.leftclick_botright)) for r in self.rects: if r.idtag.strip( ) != "": # condition for a tag being completely empty dc.SetPen( wx.Pen(Preferences.inactiveRectangleBorder, 1, style=wx.SOLID)) dc.DrawRectangle(r.x + self.offsetx, r.y + self.offsety, r.w, r.h) else: dc.SetPen( wx.Pen(Preferences.errorRectangleBorder, 1, style=wx.SOLID)) dc.DrawRectangle(r.x + self.offsetx, r.y + self.offsety, r.w, r.h) if self.selrect is not None: dc.SetPen( wx.Pen(Preferences.highlightedRectangleBorder, 1, style=wx.SOLID)) dc.DrawRectangle(self.selrect.x + self.offsetx, self.selrect.y + self.offsety, self.selrect.w, self.selrect.h) if len(self.selectedrects): dc.SetPen( wx.Pen(Preferences.highlightedRectangleBorder, 2, style=wx.DOT_DASH)) for r in self.selectedrects: dc.DrawRectangle(r.x + self.offsetx, r.y + self.offsety, r.w, r.h) else: dc.SetPen(wx.Pen(wx.BLACK, 5)) n = len(Preferences.noImgText) * 5 dc.DrawText(Preferences.noImgText, (w / 2) - n, (h / 2)) # end
def OnPaint(self, event): dc = wx.AutoBufferedPaintDC(event.GetEventObject()) dc.DrawBitmap(self._bmp, 0, 0)
def onPaint(self,evt): dc=wx.AutoBufferedPaintDC(self) #dc=self.__getClientDC() self.doPaint(dc) evt.Skip()
def on_paint(self, event): bitmap = self.get_bitmap() dc = wx.AutoBufferedPaintDC(self) dc.DrawBitmap(bitmap, 0, 0)
def on_paint(self, event): colors = { model.RED: wx.Colour(178, 34, 34), model.GREEN: wx.Colour(50, 205, 50), model.BLUE: wx.Colour(65, 105, 225), model.YELLOW: wx.Colour(255, 215, 0), } dc = wx.AutoBufferedPaintDC(self) dc.SetBackground(wx.LIGHT_GREY_BRUSH) dc.Clear() w, h = self.GetClientSize() p = 40 size = min((w - p) // 16, (h - p) // 16) wall = size // 8 ox = (w - size * 16) // 2 oy = (h - size * 16) // 2 dc.SetDeviceOrigin(ox, oy) dc.SetClippingRegion(0, 0, size * 16 + 1, size * 16 + 1) dc.SetBrush(wx.WHITE_BRUSH) dc.DrawRectangle(0, 0, size * 16 + 1, size * 16 + 1) for color, start, end in self.lines: dc.SetPen(wx.Pen(colors[color], 3, wx.DOT)) x1, y1 = model.xy(start) x1, y1 = x1 * size + size // 2, y1 * size + size // 2 x2, y2 = model.xy(end) x2, y2 = x2 * size + size // 2, y2 * size + size // 2 dc.DrawLine(x1, y1, x2, y2) for j in range(16): for i in range(16): x = i * size y = j * size index = model.idx(i, j) cell = self.game.grid[index] robot = self.game.get_robot(index) # border dc.SetPen(wx.BLACK_PEN) dc.SetBrush(wx.TRANSPARENT_BRUSH) dc.DrawRectangle(x, y, size + 1, size + 1) # token if self.game.token in cell: dc.SetBrush(wx.Brush(colors[self.game.token[0]])) dc.DrawRectangle(x, y, size + 1, size + 1) if i in (7, 8) and j in (7, 8): dc.SetBrush(wx.LIGHT_GREY_BRUSH) dc.DrawRectangle(x, y, size + 1, size + 1) # robot if robot: dc.SetBrush(wx.Brush(colors[robot])) dc.DrawCircle(x + size // 2, y + size // 2, size // 3) # walls dc.SetBrush(wx.BLACK_BRUSH) if model.NORTH in cell: dc.DrawRectangle(x, y, size + 1, wall) dc.DrawCircle(x, y, wall - 1) dc.DrawCircle(x + size, y, wall - 1) if model.EAST in cell: dc.DrawRectangle(x + size + 1, y, -wall, size + 1) dc.DrawCircle(x + size, y, wall - 1) dc.DrawCircle(x + size, y + size, wall - 1) if model.SOUTH in cell: dc.DrawRectangle(x, y + size + 1, size + 1, -wall) dc.DrawCircle(x, y + size, wall - 1) dc.DrawCircle(x + size, y + size, wall - 1) if model.WEST in cell: dc.DrawCircle(x, y, wall - 1) dc.DrawCircle(x, y + size, wall - 1) dc.DrawRectangle(x, y, wall, size + 1) dc.DrawText(str(self.game.moves), wall + 1, wall + 1)
def OnPaint(self, event): dc = wx.AutoBufferedPaintDC(self) rect = self.GetClientRect() dc.SetBackground(wx.Brush(self.GetBackgroundColour())) dc.Clear() colour = self.GetBackgroundColour() dc.SetBrush(wx.Brush(colour)) dc.SetPen(wx.Pen(colour)) dc.DrawRectangle(rect) value = self._percentage if self._timer: if self._timer.IsRunning(): value = self._anim_value if self._border_colour: dc.SetPen(wx.Pen(self.GetBorderColour())) dc.DrawRectangle(rect) pad = 1 + self.GetBorderPadding() rect.Deflate(pad, pad) if True: # if we have a bar color set, then we will use this colour = self.goodColor if value >= 0 else self.badColor is_even = rect.width % 2 == 0 # the size of half our available drawing area (since we're only working in halves) half = (rect.width / 2) # calculate width of bar as a percentage of half the space w = abs(half * (value / 100)) w = min(w, half) # Ensure that we don't overshoot our drawing area w = math.ceil( w ) # round up to nearest pixel, this ensures that we don't lose representation for sub pixels # print("Percentage: {}\t\t\t\t\tValue: {}\t\t\t\t\tWidth: {}\t\t\t\t\tHalf: {}\t\t\t\t\tRect Width: {}".format(round(self._percentage, 3), round(value,3), w, half, rect.width)) # set guide_lines every 10 pixels of the main gauge (not including borders) if self.guide_lines: for x in range(1, 20): dc.SetBrush(wx.Brush(wx.LIGHT_GREY)) dc.SetPen(wx.Pen(wx.LIGHT_GREY)) dc.DrawRectangle(x * 10, 1, 1, rect.height) dc.SetBrush(wx.Brush(colour)) dc.SetPen(wx.Pen(colour)) # If we have an even width, we can simply dedicate the middle-most pixels to both sides # However, if there is an odd width, the middle pixel is shared between the left and right gauge if value >= 0: padding = (half if is_even else math.ceil(half - 1)) + 1 dc.DrawRectangle(padding, 1, w, rect.height) else: padding = half - w + 1 if is_even else math.ceil(half) - (w - 1) dc.DrawRectangle(padding, 1, w, rect.height) if self.leading_edge and (self.edge_on_neutral or value != 0): dc.SetPen(wx.Pen(wx.WHITE)) dc.SetBrush(wx.Brush(wx.WHITE)) if value > 0: dc.DrawRectangle(min(padding + w, rect.width), 1, 1, rect.height) else: dc.DrawRectangle(max(padding - 1, 1), 1, 1, rect.height)
def on_paint(self, event): dc = wx.AutoBufferedPaintDC(self) #@UndefinedVariable dc.SetBackground(wx.Brush(self.GetParent().GetBackgroundColour())) #@UndefinedVariable dc.Clear() dc.DrawBitmap(self._activeBitmap, 0, 0)
def OnPaint(self, event): dc = wx.AutoBufferedPaintDC(self) if self._art: self._art.DrawScrollButton(dc, self, wx.Rect(0, 0, *self.GetSize()), self._flags)
def paint(self): self.dc = wx.AutoBufferedPaintDC(self) self.dsp.showPlayground(self.dc, self.clearDC, self.pg_stat, self.pg_dof, self.pg_dynp, self.playerpos, \ self.size, self.isDeadList, self.markDeadBoxes, self.showSolutionMode) self.clearDC = False
def __on_paint(self, _event): dc = wx.AutoBufferedPaintDC(self) self.__draw_graticule(dc) self.__draw_channels(dc)