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
python类Colour()的实例源码
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)
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
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
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
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})
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)
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)
def __init__(self, x0, y0, x1, y1):
self.xList = [x0, x1]
self.yList = [y0, y1]
self.P_color = wx.Colour(50,50,50)
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)
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()
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()
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)
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()
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()))
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()))
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()
ProcessingPlaceholderText.py 文件源码
项目:irida-miseq-uploader
作者: phac-nml
项目源码
文件源码
阅读 17
收藏 0
点赞 0
评论 0
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))
ProcessingPlaceholderText.py 文件源码
项目:irida-miseq-uploader
作者: phac-nml
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def SetSuccess(self, api=None):
self._timer.Stop()
super(ProcessingPlaceholderText, self).SetLabel(u"?")
self.SetForegroundColour(wx.Colour(51, 204, 51))
ProcessingPlaceholderText.py 文件源码
项目:irida-miseq-uploader
作者: phac-nml
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def Restart(self):
self.SetForegroundColour(wx.Colour(0, 0, 255))
self._update_progress_text()
self._timer.Start(500)
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)
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]
)
)
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]
)
)
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 )
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)
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)
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)
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
def SetGridColour(self, colour):
if isinstance(colour, wx.Colour):
self._gridColour = colour
else:
self._gridColour = wx.Colour(colour)
# SaveFile
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 ------------------