我们从Python开源项目中,提取了以下25个代码示例,用于说明如何使用wx.FONTSTYLE_NORMAL。
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 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 __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 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 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, name, init, stextwidth): def OnEdit(event): text = event.GetString() point = self.value.GetInsertionPoint() if (IsNumber(self.value.GetValue()) == False): self.value.SetBackgroundColour( "Pink" ) self.value.SetForegroundColour( "Black" ) else: self.value.SetBackgroundColour(wx.NullColour) self.value.SetForegroundColour(wx.NullColour) self.value.ChangeValue(text) self.value.SetInsertionPoint(point) fontpointsize=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPointSize() self.font = wx.Font(fontpointsize, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) wx.BoxSizer.__init__(self, wx.HORIZONTAL) dc = wx.ScreenDC() dc.SetFont(self.font) textw,texth = dc.GetTextExtent(name) if textw > stextwidth: labelw = textw else: labelw = stextwidth 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.value = TextCtrlNew(parent, value=str(init), style=wx.TE_PROCESS_ENTER) self.value.SetWindowStyle(wx.TE_RIGHT) self.value.SetFont(self.font) self.value.Bind(wx.EVT_TEXT, OnEdit) self.Add( self.value, 1, wx.CENTER|wx.EXPAND )
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 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 draw_bitmap_rectangle(bitmap, faces): """Draw rectangle on bitmap.""" dc = wx.MemoryDC(bitmap.bmp) dc.SetPen(wx.BLUE_PEN) dc.SetBrush(wx.TRANSPARENT_BRUSH) dc.SetTextBackground('black') dc.SetTextForeground('white') dc.SetBackgroundMode(wx.SOLID) dc.SetFont(wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)) for face in faces: dc.DrawRectangle( face.rect.left * bitmap.scale, face.rect.top * bitmap.scale, face.rect.width * bitmap.scale, face.rect.height * bitmap.scale, ) if face.name: text_width, text_height = dc.GetTextExtent(face.name) dc.DrawText(face.name, face.rect.left * bitmap.scale, face.rect.top * bitmap.scale - text_height) dc.SelectObject(wx.NullBitmap) bitmap.bitmap.SetBitmap(bitmap.bmp)
def initMessageArea(self): """Initialize the message log area. """ # font for messages msgFont = wx.Font(pointSize=11, family=wx.FONTFAMILY_MODERN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL, underline=False) # font for CEBL introduction message helloFont = wx.Font(pointSize=24, family=wx.FONTFAMILY_ROMAN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_BOLD, underline=True) # the message log messageControlBox = widgets.ControlBox(self.scrolledPanel, label='Message Log', orient=wx.VERTICAL) self.messageArea = wx.TextCtrl(self.scrolledPanel, style=wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_RICH) self.messageArea.SetMinSize((150,150)) messageControlBox.Add(self.messageArea, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) # intro message self.messageArea.SetDefaultStyle( #wx.TextAttr(colText=wx.Colour('black'), font=helloFont)) # wxpython3 wx.TextAttr(font=helloFont)) self.messageArea.AppendText('Welcome to CEBL!\n\n') # setup message style self.messageArea.SetDefaultStyle(wx.TextAttr()) #self.messageArea.SetDefaultStyle(wx.TextAttr(colText=wx.Colour('black'), font=msgFont)) # wxpython3 self.messageArea.SetDefaultStyle(wx.TextAttr(font=msgFont)) # add the message area text ctrl widget as a log target self.mgr.logger.addTextCtrl(self.messageArea) messageControlSizer = wx.BoxSizer(orient=wx.HORIZONTAL) # button for saving the message log to a file self.saveMessagesButton = wx.Button(self.scrolledPanel, label='Save') messageControlSizer.Add(self.saveMessagesButton, proportion=0, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT, border=10) self.Bind(wx.EVT_BUTTON, self.saveMessages, self.saveMessagesButton) # button for clearing the message log self.clearMessagesButton = wx.Button(self.scrolledPanel, label='Clear') messageControlSizer.Add(self.clearMessagesButton, proportion=0, flag=wx.BOTTOM | wx.RIGHT, border=10) self.Bind(wx.EVT_BUTTON, self.clearMessages, self.clearMessagesButton) # set up verbose logging self.verboseMessagesCheckBox = wx.CheckBox(self.scrolledPanel, label='Verbose') messageControlSizer.Add(self.verboseMessagesCheckBox, proportion=0, flag=wx.BOTTOM | wx.RIGHT, border=10) messageControlBox.Add(messageControlSizer, proportion=0, flag=wx.EXPAND) # sizer for message log area self.messageSizer = wx.BoxSizer(orient=wx.VERTICAL) self.messageSizer.Add(messageControlBox, proportion=1, flag=wx.ALL | wx.EXPAND, border=10)
def __init__(self, parent, name, smax, smin, sinc, sinit, stextwidth, swidth): if abs(sinc) < 1.0: self.precision = "%."+str(str(sinc)[::-1].find('.'))+"f" else: self.precision = "%d" def OnSpin(pos): self.value.ChangeValue(self.precision%(sinc * pos + self.remainder)) def OnEdit(event): text = event.GetString() point = self.value.GetInsertionPoint() if (IsNumber(self.value.GetValue()) == False): self.value.SetBackgroundColour( "Pink" ) self.value.SetForegroundColour( "Black" ) else: self.value.SetBackgroundColour(wx.NullColour) self.value.SetForegroundColour(wx.NullColour) self.value.ChangeValue(text) self.value.SetInsertionPoint(point) if ( text == '' or text == '.'): self.spin.SetValue(smin/sinc); try: self.spin.SetValue(int(float(text)/sinc)) except: pass event.Skip() 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 > stextwidth: labelw = textw else: labelw = stextwidth 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.value = TextCtrlNew(parent, value=str(sinit),size=(swidth, -1), style=wx.TE_PROCESS_ENTER) self.value.SetWindowStyle(wx.TE_RIGHT) self.value.SetFont(self.font) self.value.Bind(wx.EVT_TEXT, OnEdit) self.Add( self.value, 0, wx.CENTER ) bw,bh = dc.GetTextExtent("0") spinw = int(1.5*bh) self.spin = SpinButtonNew(parent, size=(spinw,-1), spinfunc=OnSpin) self.spin.SetRange(int(smin/sinc), int(smax/sinc)) self.spin.SetValue(int(sinit/sinc)) self.remainder = smin%sinc self.Add( self.spin, 0, wx.CENTER ) self.IsEnabled = True self.Layout() self.Show()
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)==1 else key['cur']] for i in range(len(data)): pos = f(*(data[i][0], data[i][1])) dc.SetBrush(wx.Brush((255,255,255))) dc.DrawCircle(pos[0], pos[1], 2) dc.SetBrush(wx.Brush((0,0,0), wx.BRUSHSTYLE_TRANSPARENT)) dc.DrawCircle(pos[0], pos[1], data[i][2]*key['k']) dc.DrawText('id={}, r={}'.format(i, data[i][2]), pos[0], pos[1])