def __init__(self, *args, **kwargs): #--call the super-class constructor-- wx.Panel.__init__(self, *args, **kwargs) #--globals-- global boldFont12 #--setup parent-- self.parent = args[0] #--set the background color-- self.SetBackgroundColour(wx.Color(0, 0, 128)) #--attributes-- self.playQueue = [] #--add static text label-- label = wx.StaticText(self, id=wx.ID_ANY, label="Playlist:") label.SetForegroundColour(wx.Color(255, 255, 255)) label.SetFont(boldFont12) #--play queue-- self.playQueueDisplay = wx.ListBox(parent=self, id=wx.ID_ANY) self.playQueueDisplay.SetBackgroundColour(wx.Color(102, 102, 255)) self.playQueueDisplay.Bind(wx.EVT_LISTBOX, self.onSelect_song) #self.playQueueDisplay.Disable() #disable since it is read-only sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(label, 0, wx.ALL, 10) sizer.Add(self.playQueueDisplay, 1, wx.ALL | wx.EXPAND, 10) self.SetSizer(sizer) self.Fit() return
def Paint(self): #log.debug("OnPaint event") dc = wx.MemoryDC() dc.SelectObject(self.bitmap) dc.Clear() dc.BeginDrawing() dc.SetBrush(wx.Brush(wx.Color(*self.falling_block.color), wx.SOLID)) for (i, j) in self.falling_block.absolute_positions(): dc.DrawRectangle(j * Tetris.BLOCK_SIZE, i * Tetris.BLOCK_SIZE, Tetris.BLOCK_SIZE, Tetris.BLOCK_SIZE) for i in xrange(len(self.used_positions)): for j in xrange(len(self.used_positions[i])): if self.used_positions[i][j]: dc.SetBrush(wx.Brush(wx.Color(*self.used_positions[i][j]), wx.SOLID)) dc.DrawRectangle(j * Tetris.BLOCK_SIZE, i * Tetris.BLOCK_SIZE, Tetris.BLOCK_SIZE, Tetris.BLOCK_SIZE) dc.EndDrawing() dest_dc = wx.PaintDC(self.panel) dest_dc.Blit(0, 0, Tetris.BOARD_SIZE[0], Tetris.BOARD_SIZE[1], dc, 0, 0)
def drawParticules(self, bool, col=wx.Color(255, 0, 0), valeur=None): obj = self.getObjFromType('particules') txt = [] if obj == None: return lignes = obj.getObject() data = obj.getData() if type(valeur) == type((3, 4)): if len(valeur) >= 1: valeur = valeur[0] if col == None: col = wx.Color(255, 0, 0) a = col.Get() col = (a[0] / 255, a[1] / 255, a[2] / 255) for i in range(len(lignes)): lignes[i].set_visible(bool) lignes[i].set_color(col) obj = self.getObjFromType('partTime') if obj == None: return if (valeur == None) or (bool == False): obj.setVisible(bool) elif (valeur > 0) and bool: obj.setVisible(False) for p in data: X, Y, T = p tx, ty, tt = self.ptsPartic(X, Y, T, valeur) for i in range(len(tx)): a = str(tt[i]) b = a.split('.') ln = max(4, len(b[0])) txt.append(pl.text(tx[i], ty[i], a[:ln], fontsize='8')) obj = GraphicObject('partTime', txt, False, None) self.addGraphicObject(obj) self.gui_repaint() self.draw()
def create_container(self, parent): color = self.item.feed.color or settings.POPUP_BORDER_COLOR panel1 = wx.Panel(parent, -1, style=wx.WANTS_CHARS) panel1.SetBackgroundColour(wx.Color(*color)) panel1.SetForegroundColour(wx.Color(*color)) panel2 = wx.Panel(panel1, -1) panel2.SetBackgroundColour(wx.BLACK) panel2.SetForegroundColour(wx.BLACK) panel3 = wx.Panel(panel2, -1) panel3.SetBackgroundColour(wx.WHITE) panel3.SetForegroundColour(wx.BLACK) contents = self.create_contents(panel3) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(panel2, 1, wx.EXPAND|wx.ALL, settings.POPUP_BORDER_SIZE) panel1.SetSizer(sizer) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(panel3, 1, wx.EXPAND|wx.ALL, 1) panel2.SetSizer(sizer) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(contents, 1, wx.EXPAND|wx.ALL) panel3.SetSizer(sizer) panel1.Fit() self.bind_widgets([panel1, panel2, panel3]) return panel1
def __init__(self, parent, bitmap, drawDropArrow=False, hoverBitmap=None, drawHoverBox=True, style=wx.NO_BORDER): self.bitmap = bitmap self.disabledBitmap = None self.hoverBitmap = hoverBitmap self.drawHoverBox = drawHoverBox self.drawDropArrow = drawDropArrow self.borderColor = getDefaultControlBorderColor() self.hoverBackgroundColor = wx.Color(254, 225, 119) self.clickBackgroundColor = wx.Color(251, 209, 61) wx.PyControl.__init__(self, parent, wx.ID_ANY, style=style) ZClickableControlMixin.__init__(self) ZHoverableControlMixin.__init__(self) self.Bind(wx.EVT_PAINT, self.onPaint, self) self.Bind(wx.EVT_ERASE_BACKGROUND, self.onEraseBackground, self) sizeW = self.bitmap.GetWidth() sizeH = self.bitmap.GetHeight() if self.drawHoverBox or self.drawDropArrow: sizeW += 4 sizeH += 4 self.SetSizeHints(sizeW, sizeH)
def __init__(self): super(LcdTest, self).__init__(None, size=(200, 200)) self._p = wx.Panel(self) colors = [ wx.Color(128, 128, 128), wx.Color(192, 0, 0), wx.Color(0, 192, 0), wx.Color(0, 0, 192), ] l1 = LED(self._p, colors=colors) l2 = LED(self._p, colors=colors) l3 = LED(self._p, colors=colors) self._led_lst = (l1, l2, l3) sz = wx.BoxSizer(wx.VERTICAL) flg = wx.ALL | wx.ALIGN_CENTER sz.Add(l1, 0, flg, 5) sz.Add(l2, 0, flg, 5) sz.Add(l3, 0, flg, 5) self._p.SetSizerAndFit(sz) self.SetClientSize(sz.GetSize()) self.Show() wx.FutureCall(125, self._time_passed)
def TreeColourItem(self, tree, item, mode): if mode == "normal": tree.SetItemTextColour(item, wx.Color(0, 0, 0)) elif mode == "updating": tree.SetItemTextColour(item, wx.Color(0, 0, 255)) elif mode == "removing": tree.SetItemTextColour(item, wx.Color(255, 0, 0))
def draw(self, dc): """ Draws this DrawingObject into our window. 'dc' is the device context to use for drawing. """ psize = self.parent.GetSizeTuple() # Setup the dimensions of the main bar # The main bar spans the width of the parent x1, y1 = 0, 0 w1, h1, c1 = psize[0], psize[1], 0 # c1 is the intended curve rect = (x1, y1, h1, c1) # Define Gradient colours clr1 = wx.Color(59, 59, 59) clr2 = wx.Color(190, 190, 190) # Setup drawing tools dc.SetPen(wx.Pen('white', 10, wx.TRANSPARENT)) dc.SetBrush(wx.Brush('gray', wx.SOLID)) #br1 = gc.CreateLinearGradientBrush(x1,y1,x1,(y1+h1),clr1,clr2) # +5 ensures that gradient repetition does not show # Setup and draw the main horizontal bar #gc.SetBrush(br1) dc.DrawRoundedRectangle(x1, y1, w1, h1, c1) x2 = (0.698 * psize[0]) y2 = (0.29 * psize[1]) w2 = (0.259 * psize[0]) h2 = (0.47 * psize[1]) dc.SetPen(wx.Pen('white', 1, wx.SOLID)) dc.SetBrush(wx.Brush('white', wx.SOLID)) dc.DrawRoundedRectangle(x2, y2, w2, h2, 3)
def OnPaint(self, event): pdc = wx.PaintDC(self) mdc = wx.MemoryDC() bitmap = wx.EmptyBitmap(*self.GetSize()) mdc.SelectObject(bitmap) rect = wx.RectS(self.GetSize()) mdc.SetBrush(wx.WHITE_BRUSH) mdc.SetPen(wx.TRANSPARENT_PEN) mdc.DrawRectangleRect(rect) mdc.SetBrush(wx.Brush(wx.Color(*self.color))) mdc.SetPen( wx.Pen( wx.Color(self.color[0] / 2, self.color[1] / 2, self.color[2] / 2), 1, wx.SOLID)) mdc.DrawRoundedRectangleRect(rect, 5) mdc.SelectObject(wx.NullBitmap) # image=Image.new('RGB',(bitmap.GetWidth(),bitmap.GetHeight())) # image.fromstring(bitmap.ConvertToImage().GetData()) # # enhancer = ImageEnhance.Sharpness(image) # image=enhancer.enhance(0) # # wximage=wx.EmptyImage(*image.size) # wximage.SetData(image.convert('RGB').tostring()) #wx.BitmapFromBuffer(Image.string) pdc.DrawBitmap(bitmap, 0, 0) #wximage.ConvertToBitmap(),0,0)
def LoadState(self): # Показывать ли номера строк? self.lineNumbers = configelements.BooleanElement( self.__config.lineNumbers, self.lineNumbersCheckBox) # Шрифт для редактора fontOption = FontOption(self.__config.fontName, self.__config.fontSize, self.__config.fontIsBold, self.__config.fontIsItalic) self.fontEditor = configelements.FontElement(fontOption, self.fontPicker) # Размер табуляции self.tabWidth = configelements.IntegerElement(self.__config.tabWidth, self.tabWidthSpin, self.MIN_TAB_WIDTH, self.MAX_TAB_WIDTH) if self.__config.homeEndKeys.value == 0: self.homeEndCombo.SetSelection(0) else: self.homeEndCombo.SetSelection(1) if StcStyle.checkColorString(self.__config.fontColor.value): self.fontColorPicker.SetColour(self.__config.fontColor.value) else: self.fontColorPicker.SetColour(wx.Color(0, 0, 0)) if StcStyle.checkColorString(self.__config.backColor.value): self.backColorPicker.SetColour(self.__config.backColor.value) else: self.backColorPicker.SetColour(wx.Color(255, 255, 255))
def PopulateList(self): x = 0 for data in self.datamap: attr, val = data if attr == "Instance ID": self.list.InsertImageStringItem(x, attr, self.comp_bmp) elif attr == "InPort Attr.": self.list.InsertImageStringItem(x, attr, self.inp_bmp) elif attr == "OutPort Attr.": self.list.InsertImageStringItem(x, attr, self.outp_bmp) else: self.list.InsertImageStringItem(x, attr, self.blank_bmp) self.list.SetStringItem(x, 1, val) if attr == "InPort Attr.": print "InPort Attr." self.list.SetItemBackgroundColour(x, wx.Color(0xdd, 0xdd, 0xdd)) elif attr == "OutPort Attr.": print "OutPort Attr." self.list.SetItemBackgroundColour(x, wx.Color(0xdd, 0xdd, 0xdd)) x += 1 # show how to select an item self.list.SetItemState(5, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED) self.currentItem = 0
def OnPaint(self, event): dc = wx.AutoBufferedPaintDC(self) rect = wx.RectS(self.Size) dc.Brush = wx.WHITE_BRUSH dc.Pen = wx.TRANSPARENT_PEN dc.DrawRectangleRect(rect) if rect.Contains(self.ScreenToClient(wx.GetMousePosition())): dc.Brush = wx.Brush(wx.Color(238, 239, 255)) dc.Pen = wx.Pen(wx.Color(128, 128, 255)) dc.DrawRoundedRectangleRect(rect, 4) if wx.GetMouseState().LeftDown(): rect2 = rect.Deflate(5, 5) dc.Pen = wx.TRANSPARENT_PEN dc.Brush = wx.Brush(wx.Color(200, 200, 255)) dc.DrawRectangleRect(rect2) if self.selected: rect2 = rect.Deflate(4, 4) dc.Pen = wx.TRANSPARENT_PEN dc.Brush = wx.Brush(wx.Color(128, 128, 255)) dc.DrawRectangleRect(rect2) dc.DrawBitmap(self.bitmap, 8, 8, True)
def _init_text_controls(self, parent, sizer): self._text_static = wx.StaticText(parent=parent, id=wx.ID_ANY, label="Text") self._text_text = wx.TextCtrl(parent=parent, id=wx.ID_ANY, size=(self._default_width, -1), style=wx.TE_READONLY | wx.TE_MULTILINE) color_white = wx.Color(255, 255, 255) color_blue = wx.Color(0, 0, 128) self._image_static_bitmap.SetBackgroundColour(color_white) font = wx.Font(pointSize=14, family=wx.FONTFAMILY_SWISS, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL, underline=False, face="Verdana", encoding=wx.FONTENCODING_SYSTEM) self._text_text.SetFont(font) self._text_text.SetForegroundColour(color_blue) self._text_text.SetBackgroundColour(color_white) sizer.Add(item=self._text_static) sizer.Add(item=self._text_text, flag=wx.EXPAND) self._set_current_row_growable(sizer)
def Draw(self, DC): print "In Draw" DC.SetBackground(wx.Brush("White")) DC.Clear() GC = wx.GraphicsContext.Create(DC) Pen = GC.CreatePen(wx.Pen("Black", 4)) GC.SetPen(Pen) GC.DrawLines([(0, 0), (100, 100), (300, 100)]) GC.SetPen(wx.TRANSPARENT_PEN) c1 = wx.Color(255, 0, 0, 255) c2 = wx.Color(255, 0, 0, 0) Brush = GC.CreateLinearGradientBrush(20, 150, 300, 150, c1, c2) GC.SetBrush(Brush) GC.DrawRectangle(20, 150, 200, 1) Path = GC.CreatePath() Path.MoveToPoint(0, 0) Path.AddLineToPoint(500, 300) Path.AddLineToPoint(500, 298) Path.AddLineToPoint(0, -2) GC.SetPen(wx.Pen("Blue", 3)) #GC.SetBrush(wx.Brush("Red")) #GC.DrawPath(Path) Brush = GC.CreateLinearGradientBrush(-2, -2, 500, 300, c1, c2) GC.SetBrush(Brush) GC.FillPath(Path)
def draw_popup(self, dc, region=None): if self.popupTrendGraph != None: self.popupTrendGraph.Close(True) self.popupTrendGraph = None if len(self.selected_shape_ids) == 0: return selected_ids = [] if self.layer.name in self.selected_shape_ids: selected_ids = self.selected_shape_ids[self.layer.name] self.popupTrendGraph = SubTrendGraph( self.parent, self.layer, [self.trendgraph_data, selected_ids, self.interval_labels, self.tick, self.time_gstar,self.time_gstar_z, self.t_neighbors] ) self.popupTrendGraph.Hide() # start draw a popup within window if region: x,y = region[2],region[3] else: x,y = self.layer.centroids[selected_ids[0]][0] x,y = self.view.view_to_pixel(x,y) x,y = int(x),int(y) w = int(math.ceil(self.bufferWidth * 0.5)) if w < 300: w = 300 if w > 450: w = 450 h = w * 0.7 if x + w > self.bufferWidth: if x - w > 0: x = x - w else: x = self.bufferWidth - w if y + h > self.bufferHeight: if y - h > 0: y = y - h else: y = self.bufferHeight - h dc.SetPen(wx.TRANSPARENT_PEN) dc.SetBrush(wx.Brush(wx.Color(120,120,120,160))) dc.DrawRectangle(x+5,y+h, w, 5) dc.DrawRectangle(x+w,y+5, 5, h) dc.SetPen(wx.Pen(wx.Color(100,100,100,100))) dc.SetBrush(wx.TRANSPARENT_BRUSH) dc.DrawRectangle(x,y,w,h) self.popupTrendGraph.bufferWidth = w self.popupTrendGraph.bufferHeight = h self.popupTrendGraph.buffer = wx.EmptyBitmapRGBA(w,h,255,255,255,222) tmp_dc = wx.BufferedDC(None, self.popupTrendGraph.buffer) if not 'Linux' in stars.APP_PLATFORM \ and 'Darwin' != stars.APP_PLATFORM: tmp_dc = wx.GCDC(tmp_dc) self.popupTrendGraph.DoDraw(tmp_dc) dc.DrawBitmap(self.popupTrendGraph.buffer,x,y)
def SetFormat(self, font, fgc, bgc): tc = self.tc tc.Font = font tc.SetFont(font) tc.ForegroundColour = wx.BLACK tc.ForegroundColour = wx.Color(*fgc) tc.BackgroundColour = wx.Color(*bgc) self.UpdateDisplay()
def __init__(self, parent, client, server, mapdir): wx.Notebook.__init__(self, parent, -1, style=wx.BOTTOM|wx.RIGHT) self.SetBackgroundColour(wx.Color(0,0,128)) self.SetForegroundColour(wx.Color(255,255,255)) self.AddPage(BasicServerOptionsPanel(self, client, server, mapdir), "Basic") self.AddPage(AdvancedServerOptionsPanel(self, client, server), "Advanced")
def __init__(self, *args, **kwargs): ct.CustomTreeCtrl.__init__(self, *args, **kwargs) self.SetBorderPen(wx.Pen((0, 0, 0), 0, wx.TRANSPARENT)) self.EnableSelectionGradient(True) self.SetGradientStyle(True) self.SetFirstGradientColour(wx.Color(46, 46, 46)) self.SetSecondGradientColour(wx.Color(123, 123, 123))
def SetValue(self, signal): #v3print ( '************** PyPLOT') self.line = [] SLEN = 0 pp = 0 # walk through all the input signals for i, Input in enumerate(self.Brick.In[1:]): if (Input != None) and (i < self.NCurve): #Signals, Signal_Attribs = Split_TIO_ARRAY ( Input )#, True ) #v3print ( 'PyPlot', type(Input),len(Input) ) Signals, Signal_Attribs = Analyze_TIO_Array(Input) #v3print ( 'PyPlot', type(Input),len(Input),type(Signals),len(Signals) ) for s, Signal in enumerate(Signals): #v3print ( 'PyPlot', type(Signal) ) SLEN = len(Signal) if SLEN: P = self.pointer[pp] for x in range(SLEN): self.curve[pp][P] = [P, Signal[x]] P = (P + 1) % self.Nx self.pointer[pp] = P pp += 1 while len(self.Legends) <= pp: self.Legends.append('Signal-' + str(pp)) self.Colors.append(wx.Color(0, 0, 0)) self.LineWidths.append(1) if len(Signal_Attribs) > s: """ Legend = Signal_Attribs[s].Get ( 'Name', 'Signal-' + str(pp)) Color = Signal_Attribs[s].Get ( 'Color', (0,0,0) ) Width = Signal_Attribs[s].Get ( 'LineWidth', 1 ) Color = wx.Color ( *Color) """ self.Legends [pp] =\ Signal_Attribs[s].Get ( 'Name', 'Signal-' + str(pp)) self.Colors [pp] =\ wx.Color ( *Signal_Attribs[s].Get ( 'Color', (0,0,0) ) ) self.LineWidths [pp] =\ Signal_Attribs[s].Get ( 'LineWidth', 1 ) #v3print ('TTTT',pp,len ( Signal_Attribs ),Color ) #self.line.append ( plot.PolyLine ( # self.curve [i], legend = Legend, colour = Color, width = Width )) else: #self.line.append ( plot.PolyLine ( self.curve [i] )) pass self.line.append( plot.PolyLine(self.curve[i], legend=self.Legends[pp], colour=self.Colors[pp], width=self.LineWidths[pp])) self.Canvas.Draw(plot.PlotGraphics(self.line), (0, self.Nx), (-10, 10)) self.Canvas.SetShowScrollbars(False)
def on_paint(self, e): dc = wx.AutoBufferedPaintDC(self) # gc = wx.GraphicsContext.Create(dc) o = wx.Color(254,214,76) # skin! y = wx.Color(255,251,184) dc.SetPen(wx.Pen(o)) dc.SetBrush(wx.Brush(y)) dc.DrawPolygon(self.poly) self.draw_content(dc)
def drawNote(self, gcdc, node, level = 1): # nakresli poznamku ? if not node.getNote() or not self.control.isNodeCommented(node): return # ohraniceni (x, y, w, h) = self.control.getNodeBoundary(node) note, (note_w, note_h, note_dw, note_dh) = self.control.getNoteView(node) # nastaveni color = wx.Color(200, 200, 200) textcolor = wx.Color(150, 150, 150) lib.setFont(gcdc, -1) if level == 0 or level == 1 : # kresleni trojuhelniku pt1 = (x + w/2, y + h + 5) pt2 = (x + w/2 - 7, y + h + 10) pt3 = (x + w/2 + 7, y + h + 10) # kresleni obdelniku gcdc.SetBrush(wx.Brush(color)) gcdc.DrawPolygon((pt1, pt2, pt3)) gcdc.DrawRoundedRectangle(x, y + h + 10, note_w, note_h + note_dh, 10) gcdc.SetBrush(wx.Brush('WHITE')) d = 2 gcdc.DrawRoundedRectangle(x + d, y + h + 10 + d, note_w -2*d, note_h + note_dh -2*d, 10) # kresleni textu gcdc.SetTextForeground(textcolor) gcdc.DrawLabel(note, wx.Rect(x + note_dw/2, y + h + 10 + note_dh/2, 0, 0)) else: # kresleni trojuhelniku pt1 = (x + 40, y + h - 5) pt2 = (x + 40 - 7, y + h) pt3 = (x + 40 + 7, y + h) # kresleni obdelniku gcdc.SetBrush(wx.Brush(color)) gcdc.DrawPolygon((pt1, pt2, pt3)) gcdc.DrawRoundedRectangle(x + 20, y + h, note_w + note_dw, note_h + note_dh/2, 10) gcdc.SetBrush(wx.Brush('WHITE')) d = 2 gcdc.DrawRoundedRectangle(x + 20 + d, y + h + d, note_w + note_dw -2*d, note_h + note_dh/2 -2*d, 10) # kresleni textu gcdc.SetTextForeground(textcolor) gcdc.DrawLabel(note, wx.Rect(x + 20 + note_dw/2, y + h + note_dh/4, 0, 0))
def draw_space_in_buffer(self, space_shp, width=6000,height=6000): """ Function for fast space-time query: how many points sit in each polygon """ from stars.visualization.maps.BaseMap import PolygonLayer from stars.visualization.utils import View2ScreenTransform,DrawPurePoints # specify different color for each polygon poly_color_dict = {} n = len(space_shp) if n > 10000: width = 9000 height = 9000 id_group = [] color_group = [] color_range = 254*254*254 - 1 used_color = {} for i in range(n): color_idx = random.randint(1,color_range) while color_idx in used_color: color_idx = random.randint(1,color_range) used_color[color_idx] = True r = color_idx & 255 g = (color_idx>>8) & 255 b = (color_idx>>16) & 255 id_group.append([i]) color_group.append(wx.Color(r,g,b)) poly_color_dict[(r,g,b)] = i # draw polygon to an empty_buffer polygon_layer = PolygonLayer(self, space_shp) polygon_layer.set_edge_color(wx.Color(0,0,0,0)) polygon_layer.set_data_group(id_group) polygon_layer.set_fill_color_group(color_group) #polygon_layer.set_edge_color_group(color_group) view = View2ScreenTransform(space_shp.extent, width, height) buffer = wx.EmptyBitmap(width, height) dc = wx.BufferedDC(None, buffer) dc.Clear() polygon_layer.draw(dc, view, drawRaw=True) """ _points = [] for p in points: x,y = view.view_to_pixel(p[0],p[1]) x,y = int(round(x)), int(round(y)) _points.append((x,y)) DrawPurePoints(dc, _points) """ bmp = wx.ImageFromBitmap(buffer) #buffer.SaveFile('test.bmp',wx.BITMAP_TYPE_BMP) return bmp,view,poly_color_dict
def OnSetViewMode(self, mode): self.viewMode = mode if mode == 'static': self.SetBackgroundColour(wx.Color(*Config.backgroundColorStatic)) elif mode == 'dynamic': self.SetBackgroundColour(wx.Color(*Config.backgroundColorDynamic)) for id, shape in self.nodeShapes.items(): shape.SetViewMode(mode) self.Refresh()
def stroke_highlights(self, gc, rect): hw = max(2, self.pen.Width) seq = [] if self.highlight: c1, c2 = wx.Color(255, 255, 255, 100), wx.Color(255, 255, 255, 150) seq.extend([((rect.x, rect.y), [(rect.x, rect.Bottom), (rect.x + hw, rect.Bottom - hw), (rect.x + hw, rect.y + hw), (rect.x, rect.y)], gc.CreateLinearGradientBrush(rect.x, rect.y, rect.x + hw, rect.y, c1, c2)), ((rect.x, rect.y), [(rect.Right + 1, rect.y), (rect.Right - hw, rect.y + hw), (rect.x + hw, rect.y + hw), (rect.x, rect.y)], gc.CreateLinearGradientBrush(rect.x, rect.y, rect.x, rect.y + hw, c1, c2))]) if self.shadow: sc1, sc2 = wx.Color(0, 0, 0, 50), wx.Color(0, 0, 0, 100) seq.extend([ ((rect.Right + 1, rect.Bottom + 1), [ (rect.x, rect.Bottom + 1), (rect.x + hw, rect.Bottom - hw + 1), (rect.Right - hw + 1, rect.Bottom - hw + 1), (rect.Right + 1, rect.Bottom + 1) ], gc.CreateLinearGradientBrush(rect.x, rect.Bottom - hw + 1, rect.x, rect.Bottom + 1, sc1, sc2)), ((rect.Right + 1, rect.Bottom + 1), [(rect.Right + 1, rect.y), (rect.Right - hw + 1, rect.y + hw), (rect.Right - hw + 1, rect.Bottom - hw + 1), (rect.Right + 1, rect.Bottom + 1)], gc.CreateLinearGradientBrush(rect.Right - hw + 1, rect.Bottom, rect.Right + 1, rect.Bottom, sc1, sc2)) ]) if seq: for origin, pts, brush in seq: p = gc.CreatePath() p.MoveToPoint(*origin) for pt in pts: p.AddLineToPoint(*pt) gc.SetBrush(brush) gc.FillPath(p)
def GetRoundBitmap(w, h, r): maskColor = wx.Color(0, 0, 0) shownColor = wx.Color(5, 5, 5) b = wx.EmptyBitmap(w, h) dc = wx.MemoryDC(b) dc.SetBrush(wx.Brush(maskColor)) dc.DrawRectangle(0, 0, w, h) dc.SetBrush(wx.Brush(shownColor)) dc.SetPen(wx.Pen(shownColor)) dc.DrawRoundedRectangle(0, 0, w, h, r) dc.SelectObject(wx.NullBitmap) b.SetMaskColour(maskColor) return b
def getColorConfig(self, section, option, default=[0, 0, 0, 0]): try: value = self.configIDE.get(section,option) value = value[1:-1].split(",") value = map(lambda x:int(x), value) color = wx.Color() color.Set(*value) return color except: color = wx.Color() color.Set(*default) self.setConfig(section, option, default) return color
def __init__(self, *args, **kwargs): #--call the super-class constructor-- wx.Panel.__init__(self, *args, **kwargs) #--setup parent-- self.parent = args[0] #--globals-- global btn_playFilename global btn_stopFilename #--set background color-- self.SetBackgroundColour("BLACK") #--buttons-- #play button self.btn_play = wx.BitmapButton(self, id=wx.ID_ANY, bitmap=wx.Bitmap(btn_playFilename), size=(80, 80)) self.btn_play.SetBackgroundColour(wx.Color(0, 0, 128)) self.btn_play.Bind(wx.EVT_BUTTON, self.onClick_play) self.btn_play.SetToolTip(wx.ToolTip("Play")) #stop button self.btn_stop = wx.BitmapButton(self, id=wx.ID_ANY, bitmap=wx.Bitmap(btn_stopFilename), size=(80, 80)) self.btn_stop.SetBackgroundColour(wx.Color(0, 0, 128)) self.btn_stop.Bind(wx.EVT_BUTTON, self.onClick_stop) self.btn_stop.SetToolTip(wx.ToolTip("Stop")) self.btn_stop.Disable() #disable to start with #--now playing label-- self.nowPlayingDisplay = wx.StaticText(self, id=wx.ID_ANY, style=wx.SIMPLE_BORDER | wx.EXPAND, label="") self.nowPlayingDisplay.SetForegroundColour(wx.Color(0, 0, 255)) #--add sizer-- sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.btn_play, 0, wx.ALL, 10) sizer.Add(self.btn_stop, 0, wx.ALL, 10) sizer.Add(self.nowPlayingDisplay, 1, wx.ALL, 10) self.SetSizer(sizer) self.Fit() return
def BrushForNode(self, node, depth=0): """Create brush to use to display the given node""" if node == self.selectedNode: color = wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT) elif node == self.highlightedNode: color = wx.Color(red=0, green=255, blue=0) else: color = self.adapter.background_color(node, depth) if not color: red = (depth * 10) % 255 green = 255 - ((depth * 10) % 255) blue = 200 color = wx.Color(red, green, blue) return wx.Brush(color)
def OnPaint(self, evt): dc = wx.AutoBufferedPaintDC(self) o = wx.Color(254, 214, 76) y = wx.Color(255, 251, 184) dc.SetPen(wx.Pen(o)) dc.SetBrush(wx.Brush(y)) dc.DrawPolygon(self.GetPolyPoints()) self.DrawContent(dc) dc.SetFont(self.GetFont()) textSize = wx.Size(dc.GetTextExtent(self._labelText)) dc.DrawText(self._labelText, 10, (self.GetSize().y - textSize.y) / 2 - 5)
def get_social_css(): import wx minor_color = get('infobox.fontcolors.minor', lambda: wx.Color(128, 128, 128)).GetAsString(wx.C2S_HTML_SYNTAX) postrow_hover_color = get('infobox.backgrounds.socialhovercolor', lambda: wx.Color(128, 128, 128)).GetAsString(wx.C2S_HTML_SYNTAX) return ''' .minor_border {{ border-color: {minor_color}; }} .social_background_hover:hover {{ background-color: {postrow_hover_color}; }} .social_background_hover_on {{ background-color: {postrow_hover_color}; }} '''.format(**locals())