我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用wx.Font()。
def _post_processing_task_started(self): """Show a 'processing' message on the UI while the post processing task is executing.""" pub.unsubscribe(self._post_processing_task_started, RunUploaderTopics.started_post_processing) pub.subscribe(self._post_processing_task_completed, RunUploaderTopics.finished_post_processing) pub.subscribe(self._post_processing_task_failed, RunUploaderTopics.failed_post_processing) logging.info("Post-processing started, updating UI.") self.Freeze() self._post_processing_sizer = wx.BoxSizer(wx.HORIZONTAL) self._post_processing_placeholder = ProcessingPlaceholderText(self) self._post_processing_placeholder.SetFont(wx.Font(pointSize=18, family=wx.FONTFAMILY_DEFAULT, style=wx.NORMAL, weight=wx.FONTWEIGHT_BOLD, face="Segoe UI Symbol")) self._post_processing_text = wx.StaticText(self, label="Executing post-processing task.") self._post_processing_text.SetFont(wx.Font(18, wx.DEFAULT, wx.NORMAL, wx.BOLD)) self._post_processing_text.Wrap(350) self._post_processing_text.SetToolTipString("Executing command `{}`.".format(read_config_option("completion_cmd"))) self._post_processing_sizer.Add(self._post_processing_text, flag=wx.RIGHT, border=5, proportion=1) self._post_processing_sizer.Add(self._post_processing_placeholder, flag=wx.LEFT, border=5, proportion=0) self._sizer.Insert(0, self._post_processing_sizer, flag=wx.EXPAND | wx.ALL, border=5) self.Layout() self.Thaw()
def initConfig(self): #self.stimColor = (179, 179, 36) self.stimColor = (255, 255, 10) self.stimFont = wx.Font(pointSize=196, family=wx.FONTFAMILY_SWISS, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL) self.protocols = ('3minutes', 'letter practice b', 'letter b', 'letter d', 'letter p', 'letter m', 'letter t', 'letter x', 'motortasks practice', 'motortasks trial1', 'motortasks trial2', 'mentaltasks practice', 'mentaltasks trial1', 'mentaltasks trial2', 'mentaltasks trial3', 'mentaltasks trial4', 'mentaltasks trial5') self.nProtocols = len(self.protocols) self.setProtocol('3minutes') self.startPause = 2.0
def initDefaultFonts(self): """Initialize default fonts. """ fontEnum = wx.FontEnumerator() fontEnum.EnumerateFacenames() faceList = fontEnum.GetFacenames() if 'Utopia' in faceList: self.defaultStimFont = wx.Font(pointSize=50, family=wx.FONTFAMILY_ROMAN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL, #underline=False, faceName='Utopia') # wxpython3 underline=False, face='Utopia') #self.defaultFeedFont = wx.Font(pointSize=36, family=wx.FONTFAMILY_ROMAN, # style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL, # underline=True, faceName='Utopia') else: self.defaultStimFont = wx.Font(pointSize=50, family=wx.FONTFAMILY_ROMAN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL, underline=False) #self.defaultFeedFont = wx.Font(pointSize=32, family=wx.FONTFAMILY_ROMAN, # style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL, underline=True) self.defaultFeedFont = wx.Font(pointSize=32, family=wx.FONTFAMILY_MODERN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL, underline=False)
def initDefaultFonts(self): """Initialize default fonts. """ fontEnum = wx.FontEnumerator() fontEnum.EnumerateFacenames() faceList = fontEnum.GetFacenames() if 'Utopia' in faceList: self.defaultStimFont = wx.Font(pointSize=196, family=wx.FONTFAMILY_ROMAN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL, #underline=False, faceName='Utopia') # wxpython3 underline=False, face='Utopia') self.defaultFeedFont = wx.Font(pointSize=32, family=wx.FONTFAMILY_ROMAN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL, #underline=True, faceName='Utopia') # wxpython3 underline=True, face='Utopia') else: self.defaultStimFont = wx.Font(pointSize=196, family=wx.FONTFAMILY_ROMAN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL, underline=False) self.defaultFeedFont = wx.Font(pointSize=32, family=wx.FONTFAMILY_ROMAN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL, underline=True)
def initGame(self): #font argument (??|??|????|????|???) self.bgFont = wx.Font(50,wx.SWISS,wx.NORMAL,wx.BOLD,face=u"Roboto")#???? self.scFont = wx.Font(36,wx.SWISS,wx.NORMAL,wx.BOLD,face=u"Roboto") self.smFont = wx.Font(12,wx.SWISS,wx.NORMAL,wx.NORMAL,face=u"Roboto") self.curScore = 0 #???? self.bstScore = 0 #???? self.loadScore() #????????????????? self.data = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]] #4x4 ??? #????????????? count = 0 while count < 2: row = random.randint(0,len(self.data)-1) col = random.randint(0,len(self.data[0])-1) if self.data[row][col] != 0: continue self.data[row][col] = 2 if random.randint(0,1) else 4 count += 1
def drawTiles(self,dc): dc.SetFont(self.scFont) for row in range(4): for col in range(4): value = self.data[row][col] color = self.colors[value] if value==2 or value==4: dc.SetTextForeground((119,110,101)) else: dc.SetTextForeground((255,255,255)) dc.SetBrush(wx.Brush(color)) dc.SetPen(wx.Pen(color)) dc.DrawRoundedRectangle(30+col*115,165+row*115,100,100,2) size = dc.GetTextExtent(str(value)) while size[0]>100-15*2: self.scFont = wx.Font(self.scFont.GetPointSize()*4/5,wx.SWISS,wx.NORMAL,wx.BOLD,face=u"Roboto") dc.SetFont(self.scFont) size = dc.GetTextExtent(str(value)) if value!=0: dc.DrawText(str(value),30+col*115+(100-size[0])/2,165+row*115+(100-size[1])/2)
def draw(self, dc, f, **key): dc.SetPen(wx.Pen((255,255,0), width=1, style=wx.SOLID)) dc.SetTextForeground((255,255,0)) font = wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False) dc.SetFont(font) data = self.data[0 if len(self.data)==0 else key['cur']] pos = [f(*(i[0][1], i[0][0])) for i in data] for i in pos:dc.DrawCircle(i[0], i[1], 2) txts = ['id={}'.format(i) for i in range(len(data))] dc.DrawTextList(txts, pos) if data[0][1]==None:return lt = [f(*(i[1][1], i[1][0])) for i in data] rb = [f(*(i[1][3], i[1][2])) for i in data] rects = [(x1,y1,x2-x1,y2-y1) for (x1,y1),(x2,y2) in zip(*(lt,rb))] dc.DrawRectangleList(rects, brushes = wx.Brush((0,0,0), wx.BRUSHSTYLE_TRANSPARENT))
def draw(self, dc, f, **key): dc.SetTextForeground((255,255,0)) font = wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False) dc.SetFont(font) dc.SetPen(wx.Pen((0,255,0), width=1, style=wx.SOLID)) dc.SetBrush(wx.Brush((0,255,0))) pos = [f(*(i[1], i[0])) for i in self.xy[self.msk]] for i in pos:dc.DrawCircle(int(i[0]), int(i[1]), 2) dc.SetPen(wx.Pen((255,0,0), width=1, style=wx.SOLID)) dc.SetBrush(wx.Brush((255,0,0))) pos = [f(*(i[1], i[0])) for i in self.xy[~self.msk]] for i in pos:dc.DrawCircle(int(i[0]), int(i[1]), 2)
def draw(self, dc, f, **key): dc.SetPen(wx.Pen(Setting['color'], width=1, style=wx.SOLID)) dc.SetTextForeground(Setting['tcolor']) linefont = wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False) dc.SetFont(linefont) dc.DrawLines([f(*i) for i in self.buf]) for i in self.buf:dc.DrawCircle(f(*i),2) for line in self.body: dc.DrawLines([f(*i) for i in line]) for i in line:dc.DrawCircle(f(*i),2) pts = np.array(line) v1 = pts[:-2]-pts[1:-1] v2 = pts[2:]-pts[1:-1] a = np.sum(v1*v2, axis=1)*1.0 a/=norm(v1,axis=1)*norm(v2,axis=1) ang = np.arccos(a)/np.pi*180 for i,j in zip(ang,line[1:-1]): dc.DrawText('%.0f'%i, f(*j))
def draw(self, dc, f, **key): dc.SetPen(wx.Pen(Setting['color'], width=1, style=wx.SOLID)) dc.SetTextForeground(Setting['tcolor']) linefont = wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False) dc.SetFont(linefont) dc.DrawLines([f(*i) for i in self.buf]) for i in self.buf:dc.DrawCircle(f(*i),2) for line in self.body: dc.DrawLines([f(*i) for i in line]) for i in line:dc.DrawCircle(f(*i),2) pts = np.array(line) mid = (pts[:-1]+pts[1:])/2 dxy = (pts[:-1]-pts[1:]) dxy[:,1][dxy[:,1]==0] = 1 l = norm(dxy, axis=1)*-np.sign(dxy[:,1]) ang = np.arccos(dxy[:,0]/l)/np.pi*180 for i,j in zip(ang, mid): dc.DrawText('%.0f'%i, f(*j))
def draw(self, dc, f, **key): dc.SetPen(wx.Pen(Setting['color'], width=1, style=wx.SOLID)) dc.SetTextForeground(Setting['tcolor']) font = wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False) dc.SetFont(font) dc.DrawLines([f(*i) for i in self.buf]) for i in self.buf:dc.DrawCircle(f(*i),2) for pg in self.body: plg = Polygon(pg) dc.DrawLines([f(*i) for i in pg]) for i in pg: dc.DrawCircle(f(*i),2) area, xy = plg.area, plg.centroid if self.unit!=None: area *= self.unit[0]**2 dc.DrawText('%.1f'%area, f(xy.x, xy.y))
def draw(self, dc, f, **key): dc.SetPen(wx.Pen(Setting['color'], width=1, style=wx.SOLID)) dc.SetTextForeground(Setting['tcolor']) linefont = wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False) dc.SetFont(linefont) if len(self.buf)>1: dc.DrawLines([f(*i) for i in self.buf]) for i in self.buf:dc.DrawCircle(f(*i),2) for line in self.body: dc.DrawLines([f(*i) for i in line]) for i in line:dc.DrawCircle(f(*i),2) pts = np.array(line) mid = (pts[:-1]+pts[1:])/2 dxy = (pts[:-1]-pts[1:]) dis = norm(dxy, axis=1) unit = 1 if self.unit is None else self.unit[0] for i,j in zip(dis, mid): dc.DrawText('%.2f'%(i*unit), f(*j))
def __set_properties(self): # begin wxGlade: Login.__set_properties self.SetTitle("Login") #_icon = wx.EmptyIcon() #_icon.CopyFromBitmap(wx.Bitmap("/media/f67bc164-f440-4c0f-9e9b-3ad70ff1adc2/home/asif/Desktop/waiter animation/2.gif", wx.BITMAP_TYPE_ANY)) #self.SetIcon(_icon) self.SetSize((462, 239)) self.SetFocus() self.label_1.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.combo_box_1.SetSelection(0) self.label_2.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.text_ctrl_1.SetMinSize((185, 30)) self.button_1.SetMinSize((85, 35)) self.button_1.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Ubuntu")) self.button_2.SetMinSize((85, 35)) self.button_2.Disable() # end wxGlade
def __set_properties(self): # begin wxGlade: chng_pass.__set_properties self.SetTitle("Change Password") self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.label_3.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.combo_box_1.SetMinSize((180, 32)) self.combo_box_1.SetSelection(0) self.label_4.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.text_ctrl_1.SetMinSize((180, 33)) self.label_5.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.text_ctrl_2.SetMinSize((180, 33)) self.label_6.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.text_ctrl_3.SetMinSize((180, 33)) self.button_1.SetMinSize((85, 33)) self.button_2.SetMinSize((85, 33)) self.button_2.Enable(False) # end wxGlade
def __set_properties(self): # begin wxGlade: consolidated_report.__set_properties self.SetTitle("Consolidated Report") self.SetSize((420, 550)) self.combo_box_1.SetSelection(0) self.combo_box_2.SetSelection(0) self.combo_box_3.SetSelection(0) self.combo_box_4.SetSelection(0) self.label_1.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.check_list_box_1.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.button_1.SetMinSize((85, 32)) self.button_2.SetMinSize((85, 32)) self.checkbox_1.SetValue(1) self.checkbox_2.SetValue(1) self.checkbox_3.SetValue(1) self.checkbox_4.SetValue(1) self.button_2.Enable(False) # end wxGlade
def __set_properties(self): # begin wxGlade: MyFrame.__set_properties self.SetTitle("Promotion List") self.SetSize((450, 350)) self.label_1.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.combo_box_1.SetSelection(0) self.label_2.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.combo_box_2.SetSelection(0) self.button_1.SetMinSize((90, 35)) self.button_2.SetMinSize((90, 35)) self.button_2.Enable(False) #self.label_4.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) #self.combo_box_4.SetSelection(0) # end wxGlade
def __set_properties(self): # begin wxGlade: Institution.__set_properties 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)) # end wxGlade
def __init__(self, parent): super(MyTitle, self).__init__(parent) self.SetBackgroundColour('#00b294') self.SetMinSize((-1, 80)) sizer = wx.BoxSizer() sizer.AddStretchSpacer() family = wx.FONTFAMILY_DEFAULT style = wx.FONTSTYLE_NORMAL weight = wx.FONTWEIGHT_NORMAL font = wx.Font(20, family, style, weight) self.text = wx.StaticText(self, label=TITLE, style=wx.ALIGN_CENTER) self.text.SetFont(font) sizer.Add(self.text, flag=wx.ALIGN_CENTER_VERTICAL) sizer.AddStretchSpacer() self.SetSizer(sizer)
def OnDrawItem(self, dc, rect, item, flags): if item == wx.NOT_FOUND: # painting the control, but there is no valid item selected yet return font = wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, 'Segoe UI') dc.SetFont(font) if flags == 3: margin = 3 else: margin = 1 r = wx.Rect(*rect) # make a copy r.Deflate(margin, margin) tam = self.OnMeasureItem(item)-2 dc.SetPen(wx.Pen("grey", style=wx.TRANSPARENT)) color_name = self.GetString(item) color = self.colors.get(color_name) if not color: color = wx.NamedColour(color_name) dc.SetBrush(wx.Brush(color)) dc.DrawRectangle(r.x, r.y, tam, tam) dc.DrawText(self.GetString(item), r.x + tam + 2, r.y)
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_terminated(self, label, colour, tooltip): """Stop the timer and hide self when the upload is has terminated.""" self._timer.Stop() self.Freeze() status_label = wx.StaticText(self, label=label) status_label.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD)) status_label.SetForegroundColour(colour) status_label.SetToolTipString(tooltip) self._sizer.Add(status_label, flag=wx.EXPAND | wx.RIGHT, border=5) if self._progress is not None: self._progress.Destroy() 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. """ 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()
def __init__(self, parent, *args, **kwargs): wx.StaticText.__init__(self, parent, *args, **kwargs) self._timer = wx.Timer(self) self._current_char = 0 # this is the only font face on windows that actually renders the clock faces correctly. self.SetFont(wx.Font(pointSize=wx.DEFAULT, family=wx.FONTFAMILY_DEFAULT, style=wx.NORMAL, weight=wx.FONTWEIGHT_NORMAL, face="Segoe UI Symbol")) self.Bind(wx.EVT_TIMER, self._update_progress_text, self._timer) self.Restart()
def __init__(self, parent): maingui.AboutDialog.__init__(self, parent) self.font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, u'Consolas') self.FillPanelAbout() self.AddDocuments() self.Fit() # Ensure the Dialog resizes to fit the added Panels self.Centre()
def initPieMenu(self): font = wx.Font(pointSize=10, family=wx.FONTFAMILY_SWISS, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_BOLD, #underline=False, face='DejaVu Serif') #underline=False, faceName='Utopia') #wxpython3 underline=False, face='Utopia') self.pieMenu = widgets.PieMenu(self, choices=self.pg.choices, #font=font, rotation=4.0*np.pi/len(self.pg.choices), colors=('turquoise', 'red', 'blue violet', 'orange', 'blue', 'crimson')) #colors=('turquoise', 'red', 'blue', 'green', # 'yellow', 'blue violet'))
def __init__(self): PongObject.__init__(self) self.score = np.array([0,0]) self.scoreFont = wx.Font(pointSize=12, family=wx.FONTFAMILY_SWISS, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL, underline=False) self.setCoords(np.array([0.07, 0.06]))
def initFont(self, font): """Initialize font for drawing text. """ # if none, use SWISS font if font is None: self.font = \ wx.Font(pointSize=12, family=wx.FONTFAMILY_SWISS, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_BOLD, #underline=False)#, faceName='Utopia') # wxpython3 underline=False)#, face='Utopia') # wxpython3 # otherwise, use given font else: self.font = font
def setStimFont(self, font=None, refresh=True): """Set the stimulus font. Args: font: A wx.Font object specifying the font for the stimulus text. If None (default) then the font will be set to a reasonable default. """ if font is None: self.stimFont = self.defaultStimFont else: self.stimFont = font if refresh: self.refresh()
def setFeedFont(self, font=None, refresh=True): """Set the feedback font. Args: font: A wx.Font object specifying the font for the feedback message. If None (default) then the font will be set to a reasonable default. """ if font is None: self.feedFont = self.defaultFeedFont else: self.feedFont = font if refresh: self.refresh()
def _getFont(self, size): """Take font size, adjusts if printing and returns wx.Font""" s = size * self.printerScale * self._fontScale of = self.GetFont() # Linux speed up to get font from cache rather than X font server key = (int(s), of.GetFamily(), of.GetStyle(), of.GetWeight()) font = self._fontCache.get(key, None) if font: return font # yeah! cache hit else: font = wx.Font( int(s), of.GetFamily(), of.GetStyle(), of.GetWeight()) self._fontCache[key] = font return font
def OnPlotDraw3(self, event): self.resetDefaults() self.client.SetFont( wx.Font(10, wx.FONTFAMILY_SCRIPT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)) self.client.SetFontSizeAxis(20) self.client.SetFontSizeLegend(12) self.client.SetXSpec('min') self.client.SetYSpec('none') self.client.Draw(_draw3Objects())
def resetDefaults(self): """Just to reset the fonts back to the PlotCanvas defaults""" self.client.SetFont( wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)) self.client.SetFontSizeAxis(10) self.client.SetFontSizeLegend(7) self.client.setLogScale((False, False)) self.client.SetXSpec('auto') self.client.SetYSpec('auto')
def __init__(self, parent, name, objectpath, textwidth, file_extension): def assign(input): self.objectpath.ChangeValue(input) def OnBrowse(self): if IsNotWX4(): dlg = wx.FileDialog(parent, 'Choose a file', os.getcwd(), '', file_extension, wx.OPEN) else: dlg = wx.FileDialog(parent, 'Choose a file', os.getcwd(), '', file_extension, wx.FD_OPEN) if dlg.ShowModal() == wx.ID_OK: assign(dlg.GetPath()) dlg.Destroy() def OnEdit(event): self.objectpath.ChangeValue(event.GetString()) fontpointsize=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPointSize() self.font = wx.Font(fontpointsize, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) dc = wx.ScreenDC() dc.SetFont(self.font) textw,texth = dc.GetTextExtent(name) if textw > textwidth: labelw = textw else: labelw = textwidth wx.BoxSizer.__init__(self, wx.HORIZONTAL) self.label = StaticTextNew(parent, -1, name, style =wx.ALIGN_RIGHT, size=(labelw,-1) ) self.label.SetFont(self.font) self.Add( self.label, 0, wx.CENTER ) self.objectpath = TextCtrlNew(parent, -1) self.objectpath.SetFont(self.font) self.objectpath.SetValue(objectpath) self.objectpath.SetToolTipNew("Browse for file or type "+os.linesep+"path and name") self.objectpath.Bind(wx.EVT_TEXT_ENTER, OnEdit) self.Add( self.objectpath, 1, wx.CENTER |wx.EXPAND ) self.button = ButtonNew(parent, -1, "Browse") self.button.SetFont(self.font) self.button.SetToolTipNew("Browse for file or type "+os.linesep+"path and name") self.button.Bind(wx.EVT_BUTTON, OnBrowse) self.Add( self.button, 0, wx.LEFT|wx.CENTER)
def __init__(self, parent, title): self.dirname=os.getcwd() wx.Frame.__init__(self, parent, title=title, size=(1000,700)) self.SetSizeHints(1000,700,-1,-1) self.CreateStatusBar() filemenu= wx.Menu() menuOpen = filemenu.Append(wx.ID_OPEN, "&Open"," Open saved state") menuSave = filemenu.Append(wx.ID_SAVE, "&Save"," Save current state") filemenu.InsertSeparator(2) menuNew = filemenu.Append(wx.ID_NEW, "&New"," Create new session") filemenu.InsertSeparator(4) menuExit = filemenu.Append(wx.ID_EXIT,"E&xit"," Terminate the program") viewmenu = wx.Menu() vismenu = wx.Menu() self.viewmenuundock = vismenu.Append(wx.ID_ANY,"&Undock","Undock the visualisation") self.viewmenuundock.Enable(0) self.viewmenudock = vismenu.Append(wx.ID_ANY,"&Dock","Dock the visualisation") self.viewmenudock.Enable(0) self.Bind(wx.EVT_MENU, self.OnUndock, self.viewmenuundock) self.Bind(wx.EVT_MENU, self.OnDock, self.viewmenudock) if IsNotWX4(): viewmenu.AppendMenu(wx.ID_ANY,"&Visualisation", vismenu) else: viewmenu.Append(wx.ID_ANY,"&Visualisation", vismenu) self.visualdialog_docked = True editmenu = wx.Menu() self.menuCWD = editmenu.Append(wx.ID_ANY, "Current Working &Directory","Current Working Directory") self.Bind(wx.EVT_MENU, self.OnCWD, self.menuCWD) helpmenu= wx.Menu() menuAbout= helpmenu.Append(wx.ID_ABOUT, "&About"," Information about Bonsu") menuDoc= helpmenu.Append(wx.ID_HELP, "&Contents","Documentation") menuBar = wx.MenuBar() menuBar.Append(filemenu,"&File") menuBar.Append(viewmenu,"&View") menuBar.Append(editmenu,"&Edit") menuBar.Append(helpmenu,"&Help") self.SetMenuBar(menuBar) self.Bind(wx.EVT_MENU, self.OnOpen, menuOpen) self.Bind(wx.EVT_MENU, self.OnSave, menuSave) self.Bind(wx.EVT_MENU, self.OnNew, menuNew) self.Bind(wx.EVT_MENU, self.OnExit, menuExit) self.Bind(wx.EVT_MENU, self.OnAbout, menuAbout) self.Bind(wx.EVT_MENU, self.OnHelp, menuDoc) self.Bind(wx.EVT_CLOSE, self.OnExit) self.fontpointsize=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPointSize() self.font = wx.Font(self.fontpointsize, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) self.SetFont(self.font) icon = wx.Icon(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'image', 'bonsu.ico'), wx.BITMAP_TYPE_ICO) wx.Frame.SetIcon(self, icon) self.nb = None self.sizer = wx.BoxSizer(wx.VERTICAL) self.Fit() self.Layout() self.Show()
def show_on_answer_panel(self, content2show): text = wx.StaticText(parent=self.answer_panel, label=content2show) text.SetFont(wx.Font(pointSize=self.answer_panel_width_ / 10, family=wx.ROMAN, style=wx.NORMAL, weight=wx.BOLD)) self.answers_box.Add(item=text, proportion=CAN_NOT_CHANGE, border=5)
def SetPreviewFont(self, font): """ Set font of Preview panel @param font: wx.Font object containing font style """ self.Preview.SetFont(font)
def RefreshView(self): width, height = self.MessagePanel.GetClientSize() bitmap = wx.EmptyBitmap(width, height) dc = wx.BufferedDC(wx.ClientDC(self.MessagePanel), bitmap) dc.Clear() dc.BeginDrawing() if self.CurrentMessage is not None: dc.SetFont(self.Font) for button in self.LeftButtons + self.RightButtons: button.Draw(dc) message_idx = self.CurrentMessage message = self.LogMessages[message_idx] draw_date = True offset = 5 while offset < height and message is not None: message.Draw(dc, offset, width, draw_date) offset += message.GetHeight(draw_date) previous_message, message_idx = self.GetPreviousMessage(message_idx) if previous_message is not None: draw_date = message.Date != previous_message.Date message = previous_message dc.EndDrawing() self.MessageScrollBar.RefreshThumbPosition()
def OnMessageToolTipTimer(self, event): if self.LastMousePos is not None: message = self.GetMessageByScreenPos(*self.LastMousePos) if message is not None: tooltip_pos = self.MessagePanel.ClientToScreen(self.LastMousePos) tooltip_pos.x += 10 tooltip_pos.y += 10 self.MessageToolTip = CustomToolTip(self.MessagePanel, message.GetFullText(), False) self.MessageToolTip.SetFont(self.Font) self.MessageToolTip.SetToolTipPosition(tooltip_pos) self.MessageToolTip.Show() event.Skip()
def __init__(self, parent, tip, restricted=True): """ Constructor @param parent: Parent window @param tip: Tip text (may be multiline) @param restricted: Tool tip must follow size restriction in line and characters number defined (default True) """ wx.PopupWindow.__init__(self, parent) self.Restricted = restricted self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.SetTip(tip) # Initialize text font style self.Font = wx.Font( faces["size"], wx.SWISS, wx.NORMAL, wx.NORMAL, faceName=faces["mono"]) self.Bind(wx.EVT_PAINT, self.OnPaint)
def OnPaint(self, event): """ Callback for Paint Event @param event: Paint event """ # Get buffered paint DC for tool tip dc = wx.AutoBufferedPaintDC(self) dc.Clear() # Set DC drawing style dc.SetPen(wx.BLACK_PEN) dc.SetBrush(wx.Brush(wx.Colour(255, 238, 170))) dc.SetFont(self.Font) # Draw Tool tip dc.BeginDrawing() tip_width, tip_height = self.GetToolTipSize() # Draw background rectangle dc.DrawRectangle(0, 0, tip_width, tip_height) # Draw tool tip text line_offset = 0 for line in self.Tip: dc.DrawText(line, 2, line_offset + 2) line_width, line_height = dc.GetTextExtent(line) line_offset += line_height dc.EndDrawing() event.Skip()
def GenerateMethodButtonSizer(self): normal_bt_font = wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"]) mouseover_bt_font = wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"], underline=True) msizer = wx.BoxSizer(wx.HORIZONTAL) for confnode_method in self.Controler.ConfNodeMethods: if "method" in confnode_method and confnode_method.get("shown", True): button = GenBitmapTextButton(self.Editor, bitmap=GetBitmap(confnode_method.get("bitmap", "Unknown")), label=confnode_method["name"], style=wx.NO_BORDER) button.SetFont(normal_bt_font) button.SetToolTipString(confnode_method["tooltip"]) if confnode_method.get("push", False): button.Bind(wx.EVT_LEFT_DOWN, self.GetButtonCallBackFunction(confnode_method["method"], True)) else: button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(confnode_method["method"]), button) # a fancy underline on mouseover def setFontStyle(b, s): def fn(event): b.SetFont(s) b.Refresh() event.Skip() return fn button.Bind(wx.EVT_ENTER_WINDOW, setFontStyle(button, mouseover_bt_font)) button.Bind(wx.EVT_LEAVE_WINDOW, setFontStyle(button, normal_bt_font)) # hack to force size to mini if not confnode_method.get("enabled", True): button.Disable() msizer.AddWindow(button, flag=wx.ALIGN_CENTER) return msizer
def draw_coord(self, dc, w, h, l, t, r, b): xs = [5, 10, 20, 40, 50, 100, 200, 400, 500, 1000, 2000, 4000, 10000] n, dx, dy = len(self.data), 0, 0 left, low, right, high = self.extent for i in xs[::-1]: if (right-left)*1.0/i<=10:dx=i for i in xs[::-1]: if (high-low)*1.0/i<=10:dy=i dc.SetPen(wx.Pen((0, 0, 0), width=1, style=wx.SOLID)) dc.DrawRectangle(l, t, w+1, h+1) dc.SetPen(wx.Pen((100, 100, 100), width=1, style=wx.SOLID)) for i in range(int(ceil(left*1.0/dx)*dx), int(right)+1, dx): x = l+(i-left)*1.0/(right-left)*w dc.DrawLine(x, t, x, t+h) dc.DrawText(str(i), x-5, t+h) for i in range(int(ceil(low*1.0/dy)*dy), int(high)+1, dy): y = h+t-(i-low)*1.0/(high-low)*h dc.DrawLine(l, y, l+w, y) dc.DrawText(str(i), 5, y-5) titlefont = wx.Font(18, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False) dc.SetFont(titlefont) dw,dh = dc.GetTextExtent(self.title) dc.DrawText(self.title, l+w/2-dw/2, 3) lablelfont = wx.Font(14, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False) dc.SetFont(lablelfont) dw,dh = dc.GetTextExtent(self.labelx) dc.DrawText(self.labelx, l+w-dw, t+h+15) dc.DrawText(self.labely, 5, 10)
def draw(self, dc, f, **key): dc.SetPen(wx.Pen((255,255,0), width=3, style=wx.SOLID)) dc.SetTextForeground((255,255,0)) font = wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False) dc.SetFont(font) ids = self.graph.nodes() pts = [self.graph.node[i]['o'] for i in ids] pts = [f(i[1], i[0]) for i in pts] dc.DrawPointList(pts) dc.DrawTextList([str(i) for i in ids], pts)
def draw(self, dc, f, **key): dc.SetPen(wx.Pen(Setting['color'], width=1, style=wx.SOLID)) dc.SetTextForeground(Setting['tcolor']) font = wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False) dc.SetFont(font) for i in self.body: x,y = f(*i) unit = 1 if self.unit is None else self.unit[0] dc.DrawCircle(x, y, 2) dc.DrawText('(%.1f,%.1f)'%(i[0]*unit, i[1]*unit), x, y)
def __init__(self): wx.Frame.__init__(self, None, wx.ID_ANY, "File and Folder Dialogs Tutorial") global panel panel = wx.Panel(self, wx.ID_ANY) self.currentDirectory = os.getcwd() # create the buttons and bindings dirDlgBtn1 = wx.Button(panel, label="Choose Source") dirDlgBtn1.Bind(wx.EVT_BUTTON, self.onDir1) dirDlgBtn2 = wx.Button(panel, label="Choose Destination") dirDlgBtn2.Bind(wx.EVT_BUTTON, self.onDir2) moveBtn=wx.Button(panel, label="Check and Move Files") moveBtn.Bind(wx.EVT_BUTTON, self.moveUFiles) #moveBtn.Bind(wx.EVT_BUTTON, panel.Update) #SQLite conn = sqlite3.connect('checkTimes.db') conn.execute('CREATE TABLE if not exists \ Checks(ID INTEGER PRIMARY KEY AUTOINCREMENT, \ checkTime DATETIME)') cursor = conn.execute("SELECT checkTime from Checks \ where oid = (SELECT max(oid) from Checks)") rows = cursor.fetchall() conn.commit() #Show Last Time Checked timestr=str(rows).replace("[(u'", '').replace("',)]", '') TextA=wx.StaticText(panel, -1, 'Last checked: '+timestr, (100, 175)) TextA.SetForegroundColour('Navy') font = wx.Font(8, wx.DECORATIVE, wx.NORMAL, wx.NORMAL) #TextA.SetFont(font) # put the buttons in a sizer sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(dirDlgBtn1, 0, wx.ALL|wx.CENTER, 5) sizer.Add(dirDlgBtn2, 0, wx.ALL|wx.CENTER, 5) sizer.Add(moveBtn, 0, wx.ALL|wx.CENTER, 5) panel.SetSizer(sizer)
def __set_properties(self): # begin wxGlade: MyFrame.__set_properties self.SetTitle("Smart School") self.SetSize((450, 350)) self.label_1.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.combo_box_1.SetSelection(0) self.label_2.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.combo_box_2.SetSelection(0) self.label_3.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.combo_box_3.SetSelection(0) self.label_4.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.combo_box_4.SetSelection(0) # end wxGlade
def __set_properties(self): # begin wxGlade: working_days.__set_properties self.SetTitle("working_days") self.SetSize((320, 350)) self.label_1.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.combo_box_1.SetMinSize((150, 29)) self.label_5.SetFont(wx.Font(11, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.text_ctrl_1.SetMinSize((75, 33)) self.text_ctrl_2.SetMinSize((75, 33)) self.text_ctrl_3.SetMinSize((75, 33)) self.button_1.SetMinSize((80, 33)) self.button_2.SetMinSize((80, 33)) # end wxGlade