Python wx 模块,RED 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用wx.RED

项目:SameKeyProxy    作者:xzhou    | 项目源码 | 文件源码
def _log(self, line, status='info'):
      """Writing given line to the log-textCtrl.

      :Parameters:
         - `line`: text to log
         - `status`: status should be 'info' or 'error'. If 'info' the
                     text will be colored blue, if 'error' the text will
                     be red.
      """
      start = self.txtCtrlLog.GetLastPosition()
      self.txtCtrlLog.AppendText('%s\n' % line)
      color = wx.BLACK
      if status == 'info':
         color = wx.BLUE
      elif status == 'error':
         color = wx.RED
      self.txtCtrlLog.SetStyle(start, self.txtCtrlLog.GetLastPosition(),
                               wx.TextAttr(color))
项目:paho.mqtt.testing    作者:eclipse    | 项目源码 | 文件源码
def log(self, timestamp, direction, clientid, packet):
    self.list.InsertStringItem(self.listitem, str(self.listitem))

    if direction.startswith("C"):
      self.list.SetItemTextColour(self.listitem, wx.RED)
    else:
      self.list.SetItemTextColour(self.listitem, wx.BLUE)

    self.list.SetStringItem(self.listitem, 1, timestamp)
    self.list.SetStringItem(self.listitem, 2, direction)
    self.list.SetStringItem(self.listitem, 3, clientid)
    self.list.SetStringItem(self.listitem, 4, packet)

    self.list.SetItemData(self.listitem, self.listitem)
    self.itemDataMap[self.listitem] = (self.listitem, timestamp, direction, clientid, packet)

    self.list.EnsureVisible(self.listitem)
    self.listitem += 1
项目:pypilot    作者:pypilot    | 项目源码 | 文件源码
def set_mode_color(self):
        modecolors = {'compass': wx.GREEN, 'gps': wx.YELLOW,
                      'wind': wx.BLUE, 'true wind': wx.CYAN}
        if self.enabled and self.mode in modecolors:
            color = modecolors[self.mode]
        else:
            color = wx.RED
        self.tbAP.SetForegroundColour(color)
项目:nimo    作者:wolfram2012    | 项目源码 | 文件源码
def DisplayImage(self):
        if self.current_image:
            tw = self.static_bitmap.GetSize().GetWidth()
            th = self.static_bitmap.GetSize().GetHeight()
            sw = self.current_image.GetSize().GetWidth()
            sh = self.current_image.GetSize().GetHeight()

            #self.scale = min(tw/float(sw),th/float(sh))


            tw = int(sw*self.scale)
            th = int(sh*self.scale)

            im = self.current_image.Copy()
            im.Rescale(tw,th)
            bm = im.ConvertToBitmap()  
            bmdc = wx.MemoryDC(bm)
            bmdc.SetBrush(wx.TRANSPARENT_BRUSH)
            bmdc.SetPen(wx.RED_PEN)
            bmdc.SetTextForeground(wx.RED)

            i = 1
            for point in self.coords[self.image_name]:
                bmdc.DrawCircle(self.scale*point[0], self.scale*point[1], 5)
                w,h = bmdc.GetTextExtent(str(i))
                bmdc.DrawText(str(i),self.scale*point[0]-w/2, self.scale*point[1]+5)
                i += 1

            del bmdc

            self.static_bitmap.SetBitmap(bm)


    # ------------- Event Handlers ---------------
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def DrawHighlightment(self, dc):
        scalex, scaley = dc.GetUserScale()
        dc.SetUserScale(1, 1)
        # If user trying to connect wire with wrong input, highlight will become red.
        if self.ErrHighlight and not (self.EndConnected):
            highlightcolor = wx.RED
        else:
            highlightcolor = HIGHLIGHTCOLOR
        dc.SetPen(MiterPen(highlightcolor, (2 * scalex + 5)))
        dc.SetBrush(wx.Brush(highlightcolor))
        dc.SetLogicalFunction(wx.AND)
        # Draw the start and end points if they are not connected or the mouse is over them
        if len(self.Points) > 0 and (not self.StartConnected or self.OverStart):
            dc.DrawCircle(round(self.Points[0].x * scalex),
                          round(self.Points[0].y * scaley),
                          (POINT_RADIUS + 1) * scalex + 2)
        if len(self.Points) > 1 and (not self.EndConnected or self.OverEnd):
            dc.DrawCircle(self.Points[-1].x * scalex, self.Points[-1].y * scaley, (POINT_RADIUS + 1) * scalex + 2)
        # Draw the wire lines and the last point (it seems that DrawLines stop before the last point)
        if len(self.Points) > 1:
            points = [wx.Point(round((self.Points[0].x - self.Segments[0][0]) * scalex),
                               round((self.Points[0].y - self.Segments[0][1]) * scaley))]
            points.extend([wx.Point(round(point.x * scalex), round(point.y * scaley)) for point in self.Points[1:-1]])
            points.append(wx.Point(round((self.Points[-1].x + self.Segments[-1][0]) * scalex),
                                   round((self.Points[-1].y + self.Segments[-1][1]) * scaley)))
        else:
            points = []
        dc.DrawLines(points)
        dc.SetLogicalFunction(wx.COPY)
        dc.SetUserScale(scalex, scaley)

        if self.StartConnected is not None:
            self.StartConnected.DrawHighlightment(dc)
            self.StartConnected.Draw(dc)
        if self.EndConnected is not None:
            self.EndConnected.DrawHighlightment(dc)
            self.EndConnected.Draw(dc)

    # Draws the wire lines and points
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def Set_ReadOnly(self):


        #print "cols n rows",self.grid_1.GetNumberCols(),self.grid_1.GetNumberRows()
        for i in range(1,self.grid_1.GetNumberCols(),1):

            if self.grid_1.GetNumberCols()>8:# =="Basic Science":

                for j in range(0,self.grid_1.GetNumberRows(),1):

                    if i==9:

                        self.grid_1.SetCellBackgroundColour(j, i, wx.RED)
                        self.grid_1.SetCellTextColour(j,i, wx.BLACK)
                        self.grid_1.SetReadOnly(j,i, True)

                    elif i==10:

                        self.grid_1.SetCellBackgroundColour(j, i, wx.GREEN)
                        self.grid_1.SetCellTextColour(j,i, wx.BLACK)
                        self.grid_1.SetReadOnly(j,i, True)
                    elif i==11:


                        self.grid_1.SetCellBackgroundColour(j, i,  wx.BLUE)
                        self.grid_1.SetCellTextColour(j,i, wx.WHITE)
                        self.grid_1.SetReadOnly(j,i, True)
                    elif i==12:


                        self.grid_1.SetCellBackgroundColour(j, i, wx.BLACK)
                        self.grid_1.SetCellTextColour(j,i, wx.WHITE)
                        self.grid_1.SetReadOnly(j,i, True)

                    else:
                        self.grid_1.SetCellBackgroundColour(j, i, wx.WHITE)
                        self.grid_1.SetCellTextColour(j,i, wx.BLACK)
                        self.grid_1.SetReadOnly(j,i, False)
            else:

                for j in range(0,self.grid_1.GetNumberRows(),1):
                    if i==5:

                        self.grid_1.SetCellBackgroundColour(j, i,  wx.BLUE)
                        self.grid_1.SetCellTextColour(j,i, wx.WHITE)
                        self.grid_1.SetReadOnly(j,i, True)
                    elif i==6:


                        self.grid_1.SetCellBackgroundColour(j, i, wx.BLACK)
                        self.grid_1.SetCellTextColour(j,i, wx.WHITE)
                        self.grid_1.SetReadOnly(j,i, True)

                    else:
                        self.grid_1.SetCellBackgroundColour(j, i, wx.WHITE)
                        self.grid_1.SetCellTextColour(j,i, wx.BLACK)
                        self.grid_1.SetReadOnly(j,i, False)