Python wx 模块,Colour() 实例源码

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

项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __set_properties(self):
        # begin wxGlade: ChatFrameGui.__set_properties
        self.SetTitle("Chat")
        self.frmMain_statusbar.SetStatusWidths([-1])
        # statusbar fields
        frmMain_statusbar_fields = ["frmMain_statusbar"]
        for i in range(len(frmMain_statusbar_fields)):
            self.frmMain_statusbar.SetStatusText(frmMain_statusbar_fields[i], i)
        self.lblIpAddress.SetSize((51, 13))
        self.edtIPAddress.SetToolTipString("The ip address or host name of a remote machine running chat")
        self.spnConnectPort.SetToolTipString("The port on which the remote chat program is listening")
        self.lblListenPort.SetSize((64, 13))
        self.spnListenPort.SetToolTipString("The port on which to listen for incoming connections")
        self.btnListen.SetToolTipString("Listen for incoming connections")
        self.edtReceived.SetBackgroundColour(wx.Colour(192, 192, 192))
        self.edtReceived.SetForegroundColour(wx.Colour(0, 0, 0))
        self.edtSent.SetBackgroundColour(wx.Colour(192, 192, 192))
        self.btnSend.SetDefault()
        # end wxGlade
项目:Crypter    作者:sithis993    | 项目源码 | 文件源码
def __set_label_colour(self, label_object_name, colour="red"):
        '''
        @summary: Sets the specified label text colour and refreshes the object
        '''

        # Set colour string
        if colour == "red":
            colour_object = "wx.Colour (255,0,0)"
        elif colour == "default":
            colour_object = "wx.SystemSettings.GetColour( wx.SYS_COLOUR_WINDOWTEXT )"

        # Change foreground colour
        exec("self.%s.SetForegroundColour( %s )" %
             (label_object_name, colour_object)
            )
        # Refresh object appearance
        exec("self.%s.Hide()" % label_object_name)
        exec("self.%s.Show()" % label_object_name)
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def draw(self, dc, printerScale, coord=None):
        colour = self.attributes['colour']
        width = self.attributes['width'] * printerScale * self._pointSize[0]
        style = self.attributes['style']
        if not isinstance(colour, wx.Colour):
            if IsNotWX4():
                colour = wx.NamedColour(colour)
            else:
                colour = wx.Colour(colour)
        pen = wx.Pen(colour, width, style)
        pen.SetCap(wx.CAP_BUTT)
        dc.SetPen(pen)
        if coord is None:
            if len(self.scaled):  # bugfix for Mac OS X
                dc.DrawLines(self.scaled)
        else:
            dc.DrawLines(coord)  # draw legend line
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def draw(self, dc, printerScale, coord=None):
        colour = self.attributes['colour']
        width = self.attributes['width'] * printerScale * self._pointSize[0]
        size = self.attributes['size'] * printerScale * self._pointSize[0]
        fillcolour = self.attributes['fillcolour']
        fillstyle = self.attributes['fillstyle']
        marker = self.attributes['marker']
        if colour and not isinstance(colour, wx.Colour):
            colour = wx.Colour(colour)
        if fillcolour and not isinstance(fillcolour, wx.Colour):
            fillcolour = wx.Colour(fillcolour)
        dc.SetPen(wx.Pen(colour, width))
        if fillcolour:
            dc.SetBrush(wx.Brush(fillcolour, fillstyle))
        else:
            dc.SetBrush(wx.Brush(colour, fillstyle))
        if coord == None:
            if len(self.scaled):  # bugfix for Mac OS X
                self._drawmarkers(dc, self.scaled, marker, size)
        else:
            self._drawmarkers(dc, coord, marker, size)  # draw legend marker
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def update_display(self, msg):
        """
        Receives data from thread and updates the display
        """
        data = msg.data

        self.label_satus.SetLabel("Status: "+str(data))
        if data=="Successfully Logged in" or data=="Aborted" :
            self.text_ctrl_report.Value="\n"+data+self.text_ctrl_report.Value

        if data.find("Fetching Data from remote server")!=-1:
            self.text_ctrl_report.Value="\n        Preparations made for download"+self.text_ctrl_report.Value
        if data.find("Processeing Data")!=-1:
            self.text_ctrl_report.Value="\n        Downloaded data for the class"+self.text_ctrl_report.Value

        if data.find("Writing to Local Database")!=-1:
            self.text_ctrl_report.Value="\n        Data Processing Completed for the class"+self.text_ctrl_report.Value

        if data.find("Updation Completed ")!=-1:
            self.text_ctrl_report.Value="\n        Database Updated for the class"  +self.text_ctrl_report.Value  
        #self.list_ctrl_1.Append(str(data))
        if msg.data=="Invalid Username Password combination":
            self.button_finished.SetLabel("Close")
            self.label_1.SetForegroundColour(wx.Colour(204, 50, 50))
            self.text_ctrl_report.Value=msg.data
项目:LalkaChat    作者:DeForce    | 项目源码 | 文件源码
def on_button_press(self, event):
        dialog = wx.ColourDialog(self.panel)
        if dialog.ShowModal() == wx.ID_OK:
            colour = dialog.GetColourData()
            hex_colour = colour.Colour.GetAsString(flags=wx.C2S_HTML_SYNTAX)
            self.panel.SetBackgroundColour(colour.Colour)
            self.panel.Refresh()
            self.text.SetLabel(hex_colour)
            self.panel.Layout()
            col = colour.Colour
            if (col.red * 0.299 + col.green * 0.587 + col.blue * 0.114) > 186:
                self.text.SetForegroundColour('black')
            else:
                self.text.SetForegroundColour('white')

            self.event({'colour': colour.Colour, 'hex': hex_colour, 'key': self.key})
项目:wxpythoncookbookcode    作者:driscollis    | 项目源码 | 文件源码
def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)

        text = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        sizer = wx.WrapSizer()
        for letter in text:
            btn = GenButton(self, label=letter)
            r = random.randint(128, 255)
            g = random.randint(128, 255)
            b = random.randint(128, 255)
            btn.SetBackgroundColour(wx.Colour(r,g,b))
            btn.Refresh()
            sizer.Add(btn, 0, wx.ALL, 5)

        self.SetSizer(sizer)
项目:DeepQNetworkTest    作者:Chachay    | 项目源码 | 文件源码
def Draw(self, dc):
        dc.SetPen(wx.Pen(self.P_color))
        dc.SetBrush(wx.Brush(self.B_color))
        if self.Primary:
            for e in self.eyes:
                if e.obj == 1:
                    dc.SetPen(wx.Pen(wx.Colour(112,173,71)))
                elif e.obj == 2:
                    dc.SetPen(wx.Pen(wx.Colour(237,125,49)))
                else:
                    dc.SetPen(wx.Pen(self.P_color))
                dc.DrawLine(self.pos_x, self.pos_y, 
                        self.pos_x + e.SightDistance*math.sin(self.dir_Angle + e.OffSetAngle),
                        self.pos_y - e.SightDistance*math.cos(self.dir_Angle + e.OffSetAngle))

        super(Agent, self).Draw(dc)
项目:Gym_LineFollower    作者:Chachay    | 项目源码 | 文件源码
def __init__(self, x0, y0, x1, y1):
        self.xList = [x0, x1]
        self.yList = [y0, y1]
        self.P_color = wx.Colour(50,50,50)
项目:Gym_LineFollower    作者:Chachay    | 项目源码 | 文件源码
def __init__(self, x, y, color, property = 0):
        self.pos_x = x
        self.pos_y = y
        self.rad = 10 

        self.property = property

        self.B_color = color
        self.P_color = wx.Colour(50,50,50)
项目:Gym_LineFollower    作者:Chachay    | 项目源码 | 文件源码
def __init__(self, canvasSize, x, y, epsilon = 0.99, model = None):
        super(Agent, self).__init__(
            x, y, wx.Colour(112,146,190)
        )
        self.dir_Angle = 0.0#-math.pi/2.0
        self.speed     = 5.0

        self.pos_x_max, self.pos_y_max = canvasSize
        self.pos_y_max = 480

        self.EYE = Sens()
项目:irida-miseq-uploader    作者:phac-nml    | 项目源码 | 文件源码
def _settings_changed(self, api=None):
        """Reset the main display and attempt to connect to the server
           whenever the connection settings may have changed.

        Args:
            api: A placeholder for a complete api that's passed when the event is fired.
        """

        # before doing anything, clear all of the children from the sizer and
        # also delete any windows attached (Buttons and stuff extend from Window!)
        self._sizer.Clear(deleteWindows=True)
        # and clear out the list of discovered runs that we might be uploading to the server.
        self._discovered_runs = []
        # initialize the invalid sheets panel so that it can listen for events
        # before directory scanning starts, but hide it until we actually get
        # an error raised by the validation part.
        self._invalid_sheets_panel = InvalidSampleSheetsPanel(self, self._get_default_directory())
        self._invalid_sheets_panel.Hide()

        should_monitor_directory = read_config_option("monitor_default_dir", expected_type=bool, default_value=False)

        if should_monitor_directory:
            automatic_upload_status_sizer = wx.BoxSizer(wx.HORIZONTAL)
            auto_upload_enabled_text = wx.StaticText(self, label=u"? Automatic upload enabled.")
            auto_upload_enabled_text.SetFont(wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.BOLD))
            auto_upload_enabled_text.SetForegroundColour(wx.Colour(51, 102, 255))
            auto_upload_enabled_text.SetToolTipString("Monitoring {} for CompletedJobInfo.xml".format(self._get_default_directory()))

            self._sizer.Add(auto_upload_enabled_text, flag=wx.ALIGN_CENTER | wx.ALL, border=5)
            logging.info("Going to monitor default directory [{}] for new runs.".format(self._get_default_directory()))
            # topics to handle when monitoring a directory for automatic upload
            pub.subscribe(self._prepare_for_automatic_upload, DirectoryMonitorTopics.new_run_observed)
            pub.subscribe(self._start_upload, DirectoryMonitorTopics.finished_discovering_run)

            threading.Thread(target=monitor_directory, kwargs={"directory": self._get_default_directory()}).start()

       # run connecting in a different thread so we don't freeze up the GUI
        threading.Thread(target=self._connect_to_irida).start()
项目:irida-miseq-uploader    作者:phac-nml    | 项目源码 | 文件源码
def _handle_connection_error(self, error_message=None):
        """Handle connection errors that might be thrown when initially connecting to IRIDA.

        Args:
            error_message: A more detailed error message than "Can't connect"
        """

        logging.error("Handling connection error.")

        self.Freeze()

        connection_error_sizer = wx.BoxSizer(wx.HORIZONTAL)
        connection_error_header = wx.StaticText(self, label=u"? Uh-oh. I couldn't to connect to IRIDA.")
        connection_error_header.SetFont(wx.Font(18, wx.DEFAULT, wx.NORMAL, wx.BOLD))
        connection_error_header.SetForegroundColour(wx.Colour(255, 0, 0))
        connection_error_header.Wrap(350)
        connection_error_sizer.Add(connection_error_header, flag=wx.LEFT | wx.RIGHT, border=5)

        self._sizer.Add(connection_error_sizer, flag=wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, border=5)
        if error_message:
            self._sizer.Add(wx.StaticText(self, label=wordwrap(error_message, 350, wx.ClientDC(self))), flag=wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, border=5)

        open_settings_button = wx.Button(self, label="Open Settings")
        self.Bind(wx.EVT_BUTTON, self._parent._open_settings, id=open_settings_button.GetId())
        self._sizer.Add(open_settings_button, flag=wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, border=5)

        self.Layout()
        self.Thaw()
        pub.unsubscribe(self._handle_connection_error, APIConnectorTopics.connection_error_topic)
项目:irida-miseq-uploader    作者:phac-nml    | 项目源码 | 文件源码
def _finished_loading(self):
        """Update the display when the run scan is finished.

        When the `DirectoryScannerTopics.finished_run_scan` topic is received, add
        the upload button to the page so that the user can start the upload.
        """
        if not self._invalid_sheets_panel.IsShown():
            self.Freeze()
            if self._discovered_runs:
                upload_button = wx.Button(self, label="Upload")
                self._upload_sizer.Add(upload_button, flag=wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, border=5)
                self.Bind(wx.EVT_BUTTON, self._start_upload, id=upload_button.GetId())
            else:
                all_uploaded_sizer = wx.BoxSizer(wx.HORIZONTAL)
                all_uploaded_header = wx.StaticText(self, label=u"? All sample sheets uploaded.")
                all_uploaded_header.SetFont(wx.Font(18, wx.DEFAULT, wx.NORMAL, wx.BOLD))
                all_uploaded_header.SetForegroundColour(wx.Colour(51, 204, 51))
                all_uploaded_header.Wrap(350)
                all_uploaded_sizer.Add(all_uploaded_header, flag=wx.LEFT | wx.RIGHT, border=5)

                self._sizer.Add(all_uploaded_sizer, flag=wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, border=5)

                all_uploaded_details = wx.StaticText(self, label="I scanned {}, but I didn't find any sample sheets that weren't already uploaded. Click 'Scan again' to try finding new runs.".format(self._get_default_directory()))
                all_uploaded_details.Wrap(350)

                self._sizer.Add(all_uploaded_details, flag=wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, border=5)

                scan_again = wx.Button(self, label="Scan again")
                self._sizer.Add(scan_again, flag=wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, border=5)
                self.Bind(wx.EVT_BUTTON, self._settings_changed, id=scan_again.GetId())

            self.Layout()
            self.Thaw()
项目:irida-miseq-uploader    作者:phac-nml    | 项目源码 | 文件源码
def _upload_failed(self, exception=None):
        """Update the display when the upload has failed.

        Args:
            exception: the exception that caused the failure.
        """
        logging.info("Upload failed for sample {}".format(self._sample.get_id()))
        pub.unsubscribe(self._upload_failed, self._sample.upload_failed_topic)
        self._upload_terminated(label=u"?", colour=wx.Colour(255, 0, 0),
                                tooltip="{} failed to upload.".format(self._sample.get_id()))
项目:irida-miseq-uploader    作者:phac-nml    | 项目源码 | 文件源码
def _upload_completed(self, sample=None):
        """Stop the timer and hide self when the upload is complete."""

        logging.info("Upload complete for sample {}".format(self._sample.get_id()))

        pub.unsubscribe(self._upload_completed, self._sample.upload_completed_topic)
        pub.unsubscribe(self._upload_progress, self._sample.upload_progress_topic)
        self._upload_terminated(label=u"?", colour=wx.Colour(51, 204, 51),
                                tooltip="{} is completed uploading.".format(self._sample.get_id()))
项目:irida-miseq-uploader    作者:phac-nml    | 项目源码 | 文件源码
def _upload_failed(self, exception=None):
        """Update the display when the upload has failed.

        Args:
            exception: the exception that caused the failure.
        """

        pub.unsubscribe(self._upload_failed, self._run.upload_failed_topic)
        pub.unsubscribe(self._handle_progress, self._run.upload_progress_topic)
        pub.unsubscribe(self._upload_complete, self._run.upload_completed_topic)

        self.Freeze()
        self._timer.Stop()
        self._progress_text.Destroy()
        self._progress.Destroy()
        error_label = wx.StaticText(self, label=u"? Yikes!")
        error_label.SetForegroundColour(wx.Colour(255, 0, 0))
        error_label.SetFont(wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.BOLD))
        detailed_error_label = wx.StaticText(self, label="The IRIDA server failed to accept the upload. You can try again by clicking the 'Try again' button below. If the problem persists, please contact an IRIDA administrator.".format(str(exception)))
        detailed_error_label.Wrap(350)

        self._sizer.Insert(0, detailed_error_label, flag=wx.EXPAND | wx.ALL, border=5)
        self._sizer.Insert(0, error_label, flag=wx.EXPAND | wx.ALL, border=5)

        self.Layout()
        self.Thaw()
项目:irida-miseq-uploader    作者:phac-nml    | 项目源码 | 文件源码
def SetError(self, error_message=None):
        self._timer.Stop()
        super(ProcessingPlaceholderText, self).SetLabel(u"?")
        self.SetToolTipString(error_message)
        self.SetForegroundColour(wx.Colour(255, 0, 0))
项目:irida-miseq-uploader    作者:phac-nml    | 项目源码 | 文件源码
def SetSuccess(self, api=None):
        self._timer.Stop()
        super(ProcessingPlaceholderText, self).SetLabel(u"?")
        self.SetForegroundColour(wx.Colour(51, 204, 51))
项目:irida-miseq-uploader    作者:phac-nml    | 项目源码 | 文件源码
def Restart(self):
        self.SetForegroundColour(wx.Colour(0, 0, 255))
        self._update_progress_text()
        self._timer.Start(500)
项目:Crypter    作者:sithis993    | 项目源码 | 文件源码
def blink(self, event):
        '''
        @summary: Blinks the subheader text
        '''

        # Update the time remaining
        time_remaining = self.get_time_remaining()

        # Set message to blank
        if self.set_message_to_null and time_remaining:
            self.FlashingMessageText.SetLabelText("")
            self.HeaderPanel.Layout() # Recenters the child widgets after text update (this works!)
            self.set_message_to_null = False
        # Set message to text
        elif time_remaining:
            self.FlashingMessageText.SetLabelText(self.GUI_LABEL_TEXT_FLASHING_ENCRYPTED[self.LANG])
            self.HeaderPanel.Layout() # Recenters the child widgets after text update (this works!)
            self.set_message_to_null = True

        # If the key has been destroyed, update the menu text
        if not time_remaining:
            # Cleanup decrypter and change dialog message
            self.decrypter.cleanup()
            # Update main window
            self.key_destruction_timer.Stop()
            self.TimeRemainingTime.SetLabelText(self.GUI_LABEL_TEXT_TIME_BLANK[self.LANG])
            self.FlashingMessageText.SetLabelText(self.GUI_LABEL_TEXT_FLASHING_DESTROYED[self.LANG])
            self.FlashingMessageText.SetForegroundColour( wx.Colour(0, 0, 0) )
            # Disable decryption button
            self.EnterDecryptionKeyButton.Disable()
            self.ViewEncryptedFilesButton.Disable()
            self.HeaderPanel.Layout() # Recenters the child widgets after text update (this works!)
        else:
            self.TimeRemainingTime.SetLabelText(time_remaining)
项目:Crypter    作者:sithis993    | 项目源码 | 文件源码
def __set_as_secondary_colour(self, obj):
        '''
        @summary: Sets the objects foreground colour to the secondary colour specified by the config
        '''

        obj.SetForegroundColour(wx.Colour(
            self.__config["secondary_font_colour"][0],
            self.__config["secondary_font_colour"][1],
            self.__config["secondary_font_colour"][2]
            )
        )
项目:Crypter    作者:sithis993    | 项目源码 | 文件源码
def __set_as_primary_colour(self, obj):
        '''
        @summary: Sets the objects foreground colour to the primary colour specified by the config
        '''

        obj.SetForegroundColour(wx.Colour(
            self.__config["primary_font_colour"][0],
            self.__config["primary_font_colour"][1],
            self.__config["primary_font_colour"][2]
            )
        )
项目:squaremap3    作者:kawaiicthulhu    | 项目源码 | 文件源码
def BrushForNode( self, node, depth=0 ):
        """Create brush to use to display the given node"""
        if node == self.selectedNode:
            colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT)
        elif node == self.highlightedNode:
            colour = wx.Colour( red=0, green=255, blue=0 )
        else:
            colour = self.adapter.background_color(node, depth)
            if not colour:
                red = (depth * 10)%255
                green = 255-((depth * 5)%255)
                blue = (depth * 25)%255
                colour = wx.Colour( red, green, blue )
        return wx.Brush( colour  )
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.ancestor = parent
        self.fontpointsize=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPointSize()
        self.colour = wx.Colour(30,70,115, alpha=wx.ALPHA_OPAQUE)
        self.canvas = PlotCanvas(self)
        if IsNotWX4():
            self.canvas.SetInitialSize(size=self.GetClientSize())
            self.canvas.SetShowScrollbars(True)
            self.canvas.SetEnableZoom(False)
            self.canvas.SetFontSizeAxis(point=12)
            self.canvas.SetFontSizeTitle(point=12)
            self.canvas.SetGridColour(wx.Colour(0, 0, 0))
            self.canvas.SetForegroundColour(wx.Colour(0, 0, 0))
            self.canvas.SetBackgroundColour(wx.Colour(255, 255, 255))
        else:
            self.canvas.axesPen = wx.Pen(self.colour, width=1, style=wx.PENSTYLE_SOLID)
            self.canvas.SetForegroundColour(wx.Colour(0, 0, 0))
            self.canvas.SetBackgroundColour(wx.Colour(255, 255, 255))
            self.canvas.enableGrid = (True,True)
            self.canvas.fontSizeAxis = self.fontpointsize
            self.canvas.fontSizeTitle = self.fontpointsize
        self.vbox = wx.BoxSizer(wx.VERTICAL)
        self.vbox.Add(self.canvas, 1, flag=wx.LEFT | wx.TOP | wx.GROW)
        self.paused = False
        self.hbox_btn = wx.BoxSizer(wx.HORIZONTAL)
        self.hbox_btn.AddSpacer(20)
        self.button_pause =wx.Button(self, label="Pause Graph")
        self.Bind(wx.EVT_BUTTON, self.OnClickPauseButton, self.button_pause)
        self.hbox_btn.Add(self.button_pause)
        self.button_save =wx.Button(self, label="Save Data")
        self.Bind(wx.EVT_BUTTON, self.OnClickSaveButton, self.button_save)
        self.hbox_btn.Add(self.button_save)
        self.vbox.Add(self.hbox_btn, 0, wx.EXPAND)
        self.SetSizer(self.vbox)
        self.Fit()
        self.Show()
        self.data_poll_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.UpdateGraph, self.data_poll_timer)
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def __init__(self, points, **attr):
        """
        Creates PolyLine object
        :param `points`: sequence (array, tuple or list) of (x,y) points making up line
        :keyword `attr`: keyword attributes, default to:
         ==========================  ================================
         'colour'= 'black'           wx.Pen Colour any wx.Colour
         'width'= 1                  Pen width
         'style'= wx.PENSTYLE_SOLID  wx.Pen style
         'legend'= ''                Line Legend to display
         ==========================  ================================
        """
        PolyPoints.__init__(self, points, attr)
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def __init__(self, points, **attr):
        """
        Creates PolyLine object
        :param `points`: sequence (array, tuple or list) of (x,y) points making up spline
        :keyword `attr`: keyword attributes, default to:
         ==========================  ================================
         'colour'= 'black'           wx.Pen Colour any wx.Colour
         'width'= 1                  Pen width
         'style'= wx.PENSTYLE_SOLID  wx.Pen style
         'legend'= ''                Line Legend to display
         ==========================  ================================
        """
        PolyLine.__init__(self, points, **attr)
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def draw(self, dc, printerScale, coord=None):
        colour = self.attributes['colour']
        width = self.attributes['width'] * printerScale * self._pointSize[0]
        style = self.attributes['style']
        if not isinstance(colour, wx.Colour):
            colour = wx.Colour(colour)
        pen = wx.Pen(colour, width, style)
        pen.SetCap(wx.CAP_ROUND)
        dc.SetPen(pen)
        if coord == None:
            if len(self.scaled):  # bugfix for Mac OS X
                dc.DrawSpline(self.scaled)
        else:
            dc.DrawLines(coord)  # draw legend line
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def SetGridColour(self, colour):
        if isinstance(colour, wx.Colour):
            self._gridColour = colour
        else:
            self._gridColour = wx.Colour(colour)
    # SaveFile
项目:Cosplay2-Automation    作者:Himura2la    | 项目源码 | 文件源码
def grid_column_readonly(self, col):
        grid_disabled_color = wx.Colour(240, 240, 240)

        def disable_cell(cell):
            self.grid.SetReadOnly(*cell)
            self.grid.SetCellBackgroundColour(*(cell + (grid_disabled_color,)))
        map(disable_cell, [(row, col) for row in range(self.grid.GetNumberRows())])

    # ------------------ Cosplay2 ------------------
项目:pinder    作者:dhharris    | 项目源码 | 文件源码
def __init__(self, parent, session):
        wx.Frame.__init__(self, parent, wx.ID_ANY, 'Messages', size=(240,500))
        self.panel = scrolledpanel.ScrolledPanel(parent = self, id = -1)
        self.panel.SetupScrolling()
        self.SetBackgroundColour(wx.Colour(100,100,100))

        self.session = session
        self.display_matches()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def GenerateProjectTreeBranch(self, root, infos, item_alone=False):
        to_delete = []
        item_name = infos["name"]
        if infos["type"] in ITEMS_UNEDITABLE:
            if len(infos["values"]) == 1:
                return self.GenerateProjectTreeBranch(root, infos["values"][0], True)
            item_name = _(item_name)
        self.ProjectTree.SetItemText(root, item_name)
        self.ProjectTree.SetPyData(root, infos)
        highlight_colours = self.Highlights.get(infos.get("tagname", None), (wx.Colour(255, 255, 255, 0), wx.BLACK))
        self.ProjectTree.SetItemTextColour(root, highlight_colours[1])
        self.ProjectTree.SetItemExtraImage(root, None)
        if infos["type"] == ITEM_POU:
            self.ProjectTree.SetItemImage(
                root, self.TreeImageDict[self.Controler.GetPouBodyType(infos["name"])])
            if item_alone:
                self.ProjectTree.SetItemExtraImage(root, self.Controler.GetPouType(infos["name"]))
        elif "icon" in infos and infos["icon"] is not None:
            icon_name = infos["icon"]
            if icon_name not in self.TreeImageDict:
                self.TreeImageDict[icon_name] = self.TreeImageList.Add(GetBitmap(icon_name))
            self.ProjectTree.SetItemImage(root, self.TreeImageDict[icon_name])
        elif infos["type"] in self.TreeImageDict:
            self.ProjectTree.SetItemImage(root, self.TreeImageDict[infos["type"]])

        item, root_cookie = self.ProjectTree.GetFirstChild(root)
        for values in infos["values"]:
            if values["type"] not in ITEMS_UNEDITABLE or len(values["values"]) > 0:
                if item is None or not item.IsOk():
                    item = self.ProjectTree.AppendItem(root, "")
                    item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
                self.GenerateProjectTreeBranch(item, values)
                item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
        while item is not None and item.IsOk():
            to_delete.append(item)
            item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
        for item in to_delete:
            self.ProjectTree.Delete(item)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
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
    # -------------------------------------------------------------------------------
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, 
                            pos = wx.DefaultPosition, size = wx.Size(256,80), 
                            style = wx.SIMPLE_BORDER|wx.TAB_TRAVERSAL )
        self.init_buf()
        self.data, self.extent = [], [0,0,1,1]
        self.set_title_label('Graph', 'X-unit', 'Y-unit')
        self.update = False

        self.SetBackgroundColour( wx.Colour( 255, 255, 255 ) )
        self.Bind(wx.EVT_SIZE, self.on_size)
        self.Bind(wx.EVT_PAINT, self.on_paint)
        self.Bind(wx.EVT_IDLE, self.on_idle)
        self.Bind(wx.EVT_MOTION, self.on_move )
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def __set_properties(self):
        # begin wxGlade: Institution.__set_properties
        self.SetBackgroundColour(wx.Colour(47, 47, 47))
        self.SetTitle("Institution")
        self.SetSize((550, 303))
        self.SetFocus()
        self.label_1.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.label_2.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.text_ctrl_5.SetFont(wx.Font(7, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.text_ctrl_5.SetMinSize((250, 27))
        self.label_4.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.text_ctrl_6.SetFont(wx.Font(7, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))

        self.label_6.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.text_ctrl_1.SetMinSize((250, 27))
        self.label_7.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.text_ctrl_2.SetMinSize((250, 27))
        self.label_8.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.text_ctrl_3.SetMinSize((250, 27))
        self.button_1.SetMinSize((80, 33))
        self.button_2.SetMinSize((80, 33))


        self.button_1.SetBackgroundColour(wx.Colour(33, 137, 33))
        self.button_1.SetForegroundColour(wx.Colour(255, 255, 255))
        self.button_2.SetBackgroundColour(wx.Colour(33, 137, 33))
        self.button_2.SetForegroundColour(wx.Colour(255, 255, 255))

        self.label_1.SetForegroundColour(wx.Colour(255, 255, 255))
        self.label_2.SetForegroundColour(wx.Colour(255, 255, 255))
        self.label_4.SetForegroundColour(wx.Colour(255, 255, 255))
        self.label_6.SetForegroundColour(wx.Colour(255, 255, 255))
        self.label_7.SetForegroundColour(wx.Colour(255, 255, 255))
        self.label_8.SetForegroundColour(wx.Colour(255, 255, 255))
        # end wxGlade
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def __set_properties(self):
        # begin wxGlade: sampoorna_win.__set_properties
        self.SetTitle(_("frame_1"))
        self.panel_warning.SetForegroundColour(wx.Colour(201, 0, 0))
        self.panel_warning.Hide()
        self.panel_1.SetScrollRate(10, 10)
        # end wxGlade
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def __set_properties(self):
        # begin wxGlade: sampoorna_win.__set_properties
        self.SetTitle(_("Import from Sampoorna"))
        self.SetSize((894, 640))
        self.label_1.SetForegroundColour(wx.Colour(204, 50, 50))
        self.label_1.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
        self.label_2.SetForegroundColour(wx.Colour(95, 159, 159))
        self.label_2.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
        self.label_3.SetForegroundColour(wx.Colour(185, 115, 45))
        self.label_3.SetFont(wx.Font(11, wx.DEFAULT, wx.ITALIC, wx.BOLD, 0, ""))
        self.text_ctrl_user.SetMinSize((250, 35))
        self.label_4.SetForegroundColour(wx.Colour(185, 115, 45))
        self.label_4.SetFont(wx.Font(11, wx.DEFAULT, wx.ITALIC, wx.BOLD, 0, ""))
        self.text_ctrl_passw.SetMinSize((250,35))
        self.panel_1.SetBackgroundColour(wx.Colour(193, 193, 255))
        self.button_next.SetMinSize((100, 35))
        self.login_pane.SetBackgroundColour(wx.Colour(249, 249, 248))
        self.login_pane.SetFocus()
        self.checkbox_8.SetMinSize((100, 30))
        self.checkbox_9.SetMinSize((100, 30))
        self.checkbox_10.SetMinSize((120, 30))
        self.panel_3.SetBackgroundColour(wx.Colour(193, 193, 255))
        self.button_next_copy_copy.SetMinSize((100, 35))
        self.button_next_copy.SetMinSize((100, 35))
        self.standard_pane.SetBackgroundColour(wx.Colour(249, 249, 248))
        self.standard_pane.Hide()
        self.progresss_total.SetMinSize((400, 30))
        self.progress_each.SetMinSize((400, 30))
        self.text_ctrl_1.SetMinSize((450, 400))
        self.text_ctrl_1.SetBackgroundColour(wx.Colour(204, 204, 204))
        self.text_ctrl_1.SetForegroundColour(wx.Colour(17, 17, 71))
        self.text_ctrl_1.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
        self.button_finished.SetMinSize((100, 35))
        self.panel_2.SetBackgroundColour(wx.Colour(193, 193, 255))
        self.report_pane.SetBackgroundColour(wx.Colour(249, 249, 248))
        # end wxGlade
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def __set_properties(self):
        # begin wxGlade: sampoorna_win.__set_properties
        self.SetTitle(_("Import from Sampoorna"))
        self.SetSize((894, 640))
        self.label_1.SetForegroundColour(wx.Colour(204, 50, 50))
        self.label_1.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
        self.label_2.SetForegroundColour(wx.Colour(95, 159, 159))
        self.label_2.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
        self.label_3.SetForegroundColour(wx.Colour(185, 115, 45))
        self.label_3.SetFont(wx.Font(11, wx.DEFAULT, wx.ITALIC, wx.BOLD, 0, ""))
        self.text_ctrl_user.SetMinSize((250, 35))
        self.label_4.SetForegroundColour(wx.Colour(185, 115, 45))
        self.label_4.SetFont(wx.Font(11, wx.DEFAULT, wx.ITALIC, wx.BOLD, 0, ""))
        self.text_ctrl_passw.SetMinSize((250,35))
        self.panel_1.SetBackgroundColour(wx.Colour(193, 193, 255))
        self.button_next.SetMinSize((100, 35))
        self.login_pane.SetBackgroundColour(wx.Colour(249, 249, 248))
        self.login_pane.SetFocus()
        self.checkbox_8.SetMinSize((100, 30))
        self.checkbox_9.SetMinSize((100, 30))
        self.checkbox_10.SetMinSize((120, 30))
        self.panel_3.SetBackgroundColour(wx.Colour(193, 193, 255))
        self.button_previous.SetMinSize((100, 35))
        self.button_proceed.SetMinSize((100, 35))
        self.standard_pane.SetBackgroundColour(wx.Colour(249, 249, 248))
        self.standard_pane.Hide()
        self.progresss_total.SetMinSize((400, 30))
        self.progress_each.SetMinSize((400, 30))
        self.button_finished.SetMinSize((100, 35))
        self.panel_2.SetBackgroundColour(wx.Colour(193, 193, 255))
        self.report_pane.SetBackgroundColour(wx.Colour(249, 249, 248))
        '''self.report_pane.Hide()
        self.button_finished.Hide()
        self.button_next.Disable()
        self.button_proceed.Disable()
        '''
        # end wxGlade
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def error_report(self,msg):
        data = msg.data

        self.label_status.SetForegroundColour(wx.Colour(204, 50, 50))
        self.label_status.SetLabel(str(data))
        self.stop_animation('')
        self.label_status.Wrap(300)
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def update_display(self, msg):
        """
        Receives data from thread and updates the display
        """
        data = msg.data

        self.label_satus.SetLabel("Status: "+str(data))
        if data=="Successfully Logged in" or data=="Aborted" :
            self.text_ctrl_report.Value="\n"+data+self.text_ctrl_report.Value

        if data.find("Fetching Data from remote server")!=-1:
            self.text_ctrl_report.Value="\n        Preparations made for download"+self.text_ctrl_report.Value
        if data.find("Processeing Data")!=-1:
            self.text_ctrl_report.Value="\n        Downloaded data for the class"+self.text_ctrl_report.Value

        if data.find("Writing to Local Database")!=-1:
            self.text_ctrl_report.Value="\n        Data Processing Completed for the class"+self.text_ctrl_report.Value

        if data.find("Updation Completed ")!=-1:
            self.text_ctrl_report.Value="\n        Database Updated for the class"  +self.text_ctrl_report.Value  
        #self.list_ctrl_1.Append(str(data))
        if msg.data=="Invalid Username Password combination":
            self.button_finished.SetLabel("Close")
            self.text_ctrl_report.SetForegroundColour(wx.Colour(204, 50, 50))
            self.text_ctrl_report.Value=msg.data
        else: #some error
            self.text_ctrl_report.SetForegroundColour(wx.Colour(204, 50, 50))
            self.text_ctrl_report.Value=msg.data
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def __set_properties(self):
        # begin wxGlade: add_div.__set_properties
        self.SetTitle("Year & Division")
        self.SetSize((600, 500))
        #self.Enable(False)
        self.SetFocus()
        self.label_1.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.combo_box_1.SetSelection(0)
        self.label_2.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.combo_box_2.SetSelection(0)
        self.list_box_1.SetMinSize((150, 257))
        self.list_box_1.SetBackgroundColour(wx.Colour(255, 255, 255))
        self.list_box_1.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.button_1.SetMinSize((120, 40))
        self.text_ctrl_1.SetMinSize((90, 33))
        self.text_ctrl_1.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.text_ctrl_1.Value='Eg: A-K'
        self.text_ctrl_1.SetForegroundColour('#9CA998')
        self.button_2.SetMinSize((120, 40))
        self.button_1.Enable(False)
        self.button_2.Enable(False)
        self.button_3.SetMinSize((85, 35))
        self.panel_1.SetScrollRate(10, 10)


        # end wxGlade
项目:bp5000    作者:isaiahr    | 项目源码 | 文件源码
def setup(self):
        menubar = wx.MenuBar()
        filem = wx.Menu()
        helpm = wx.Menu()
        setm = wx.Menu()
        new = filem.Append(wx.ID_NEW, '&New Tournament')
        open_ = filem.Append(wx.ID_OPEN, '&Open Tournament')
        filem.AppendSeparator()
        self.Bind(wx.EVT_MENU, self.new_event, new)
        qmi = wx.MenuItem(filem, wx.ID_EXIT, '&Quit\tCtrl+W')
        filem.AppendItem(qmi)
        about = helpm.Append(wx.ID_ANY, '&About BP5000')
        options = setm.Append(wx.ID_ANY, '&Options')
        self.Bind(wx.EVT_MENU, self.quit_event, qmi)
        self.Bind(wx.EVT_MENU, self.load_event, open_)
        self.Bind(wx.EVT_MENU, self.about_event, about)
        self.Bind(wx.EVT_MENU, self.options_event, options)
        self.options = Options()
        menubar.Append(filem, '&File')
        menubar.Append(setm, '&Settings')
        menubar.Append(helpm, '&Help')
        self.SetMenuBar(menubar)
        p = wx.Panel(self)
        self.nb = fnb.FlatNotebook(p, agwStyle=fnb.FNB_X_ON_TAB)

        def pagechanged(event):
            col = wx.Colour(hash(self.nb.GetPage(event.GetSelection()).sname))
            self.nb.SetActiveTabColour(col)
            if isinstance(self.nb.GetPage(event.GetSelection()), BracketPage):
                self.nb.GetPage(event.GetSelection()).updatebracketimg()

        self.nb.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, pagechanged)
        sz = wx.BoxSizer()
        sz.Add(self.nb, 1, wx.EXPAND)
        p.SetSizer(sz)
        self.Bind(wx.EVT_CLOSE, self.quit_event)
        self.SetSize((950, 650))
        self.SetTitle('BP5000')
        self.Centre()
        self.Show(True)
项目:baroness    作者:ulrichknecht    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=(0, 0), size=(480, 320))
        self.parent = parent
        self.bitmap_1 = wx.StaticBitmap(self, wx.ID_ANY, wx.Bitmap("./gui/users.png", wx.BITMAP_TYPE_ANY), pos=(0, 0))

        users = get_users()
        self.names = list()
        for user in users:
            if user.isshown and not user.onlyrfid:
                self.names.append(user.longname)

        self.but_names = list()
    self.position = 0
    self.lines = 4
    self.items = len(self.names) 

    for i in range(self.lines):
            #480x320
            self.but = wx.lib.platebtn.PlateButton(self, label=self.names[self.position+i] if self.position+i < len(self.names) else "", pos=(3, 3+i*80),
                                                   style=wx.BU_EXACTFIT | wx.lib.platebtn.PB_STYLE_SQUARE)
            self.but.SetSize((365, 74))

            self.but.SetBackgroundColour((255-(i*20 % 40), (160+(i*50 % 100)), 0))
            #self.but.SetForegroundColour("#006699")
            self.but.SetPressColor(wx.Colour(255,255,255,0))
            self.but.SetFont(wx.Font(25, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Humor Sans"))
            self.but.Bind(wx.EVT_LEFT_DOWN, parent.onUser, id=self.but.Id)
            self.but_names.append(self.but)

        self.b_up = wx.Button(self, id=wx.ID_ANY, label=u"\u25B2", pos=(374, 0), size=(106, 106))
        self.b_up.SetFont(wx.Font(20, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Humor Sans"))
        self.b_up.Bind(wx.EVT_LEFT_DOWN, self.on_up, id=self.b_up.Id)

        self.b_down = wx.Button(self, id=wx.ID_ANY, label=u"\u25BC", pos=(374, 214), size=(106, 106))
        self.b_down.SetFont(wx.Font(20, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Humor Sans"))
        self.b_down.Bind(wx.EVT_LEFT_DOWN, self.on_down, id=self.b_down.Id)

        self.b_exit = wx.Button(self, id=wx.ID_ANY, label="X", pos=(374, 107), size=(106, 106))
        self.b_exit.SetFont(wx.Font(20, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Humor Sans"))
        self.b_exit.Bind(wx.EVT_LEFT_DOWN, parent.onExit, id=self.b_exit.Id)
        self.Layout()
项目:cx_Freeze    作者:anthony-tuininga    | 项目源码 | 文件源码
def __init__(self):
        wx.Frame.__init__(self, None, -1, 'CanvasFrame', size=(550, 350))
        color = wx.Colour("WHITE")
        self.SetBackgroundColour(color)
        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)
        t = arange(0.0, 3.0, 0.01)
        s = sin(2 * pi * t)
        self.axes.plot(t, s)
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        self.SetSizerAndFit(self.sizer)
        self.add_toolbar()
项目:LalkaChat    作者:DeForce    | 项目源码 | 文件源码
def set_online(self, module_name, channel):
        if module_name in self.chats:
            if channel.lower() in self.chats[module_name]:
                self.chats[module_name][channel.lower()]['status'].SetBackgroundColour(wx.Colour(0, 128, 0))
        self.Layout()
        self.Refresh()
项目:DeepQNetworkTest    作者:Chachay    | 项目源码 | 文件源码
def __init__(self, x0, y0, x1, y1):
        self.xList = [x0, x1]
        self.yList = [y0, y1]
        self.P_color = wx.Colour(50,50,50)
项目:DeepQNetworkTest    作者:Chachay    | 项目源码 | 文件源码
def __init__(self, x, y, color, property = 0):
        self.pos_x = x
        self.pos_y = y
        self.rad = 10 

        self.property = property

        self.B_color = color
        self.P_color = wx.Colour(50,50,50)
项目:DeepQNetworkTest    作者:Chachay    | 项目源码 | 文件源码
def __init__(self, panel, x, y, epsilon = 0.99):
        super(Agent, self).__init__(
            x, y, wx.Colour(112,146,190)
        )
        self.dir_Angle = math.pi/4
        self.speed     = 5

        self.pos_x_max, self.pos_y_max = panel.GetSize()

        self.eyes = [ EYE(i) for i in range(0, NUM_EYES)]

        self.actions = [-math.pi/16, -math.pi/8, 0.0, math.pi/8, math.pi/16]
        self.prevActions = np.zeros_like(self.actions)

        # DQN Model
        self.model = Q()
        self.optimizer = optimizers.Adam()
        self.optimizer.setup(self.model)

        self.epsilon = epsilon

        self.eMem = np.array([],dtype = np.float32)
        self.memPos = 0 
        self.memSize = 30000

        self.batch_num = 30
        self.gamma = 0.7
        self.loss = 0.0

        self.State = SState()
        self.prevState = np.ones((1,STATE_DIM))
项目:DeepQNetworkTest    作者:Chachay    | 项目源码 | 文件源码
def Draw(self, dc):
        dc.SetPen(wx.Pen(self.P_color))
        dc.SetBrush(wx.Brush(self.B_color))
        for e in self.eyes:
            if e.obj == 1:
                dc.SetPen(wx.Pen(wx.Colour(112,173,71)))
            elif e.obj == 2:
                dc.SetPen(wx.Pen(wx.Colour(237,125,49)))
            else:
                dc.SetPen(wx.Pen(self.P_color))
            dc.DrawLine(self.pos_x, self.pos_y, 
                    self.pos_x + e.SightDistance*math.sin(self.dir_Angle + e.OffSetAngle),
                    self.pos_y - e.SightDistance*math.cos(self.dir_Angle + e.OffSetAngle))

        super(Agent, self).Draw(dc)
项目:DeepQNetworkTest    作者:Chachay    | 项目源码 | 文件源码
def __init__(self, parent=None, id=-1, title=None):
        wx.Frame.__init__(self, parent, id, title)
        self.panel = wx.Panel(self, size=(640, 480))
        self.panel.SetBackgroundColour('WHITE')
        self.Fit()

        self.A = Agent(self.panel, 150, 100 )

        self.greenB = [Ball(rnd.randint(40, 600),rnd.randint(40, 440), 
                        wx.Colour(112,173,71), property =  1) for i in range(0, 15)]
        self.redB  = [Ball(rnd.randint(40, 600),rnd.randint(40, 440), 
                        wx.Colour(237,125,49), property = 2) for i in range(0, 10)]

        # OutrBox
        self.Box = Walls(640, 480, 0, 480)
        self.Box.addPoint(0,0)
        self.Box.addPoint(640,0)
        self.Box.addPoint(640,480)

        # Wall in the world
        self.WallA = Walls(96, 90, 256, 90)
        self.WallA.addPoint(256, 390)
        self.WallA.addPoint(96,390)

        self.Bind(wx.EVT_CLOSE, self.CloseWindow)

        self.cdc = wx.ClientDC(self.panel)
        w, h = self.panel.GetSize()
        self.bmp = wx.EmptyBitmap(w,h)

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnTimer)
        self.timer.Start(20)