Python wx 模块,FONTWEIGHT_NORMAL 实例源码

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

项目:cebl    作者:idfah    | 项目源码 | 文件源码
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
项目:cebl    作者:idfah    | 项目源码 | 文件源码
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)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
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))
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
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)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
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))
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
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))
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
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))
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
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))
项目:Cognitive-Face-Python    作者:Microsoft    | 项目源码 | 文件源码
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)
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
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)
项目:irida-miseq-uploader    作者:phac-nml    | 项目源码 | 文件源码
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()
项目:cebl    作者:idfah    | 项目源码 | 文件源码
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]))
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
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())
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
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')
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
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)
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
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 )
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
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)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
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)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
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)
项目:mobileinsight-core    作者:mobile-insight    | 项目源码 | 文件源码
def __init__(self, parent, start_time, end_time):
        wx.Dialog.__init__(self, parent, -1)
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetTitle("Time Window")
        self.start_label = wx.StaticText(self, -1, label="...", style=wx.BOLD)
        self.end_label = wx.StaticText(self, -1, label="...", style=wx.BOLD)
        self.window_label = wx.StaticText(self, -1, "\t to \t")
        # self.start_label.SetFont(wx.Font(11, wx.DEFAULT, wx.BOLD, wx.NORMAL))
        # self.window_label.SetFont(wx.Font(11, wx.DEFAULT, wx.ITALIC, wx.NORMAL))
        # self.end_label.SetFont(wx.Font(11, wx.DEFAULT, wx.BOLD, wx.NORMAL))

        self.start_label.SetFont(wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_SLANT, wx.FONTWEIGHT_NORMAL))
        self.window_label.SetFont(wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_ITALIC, wx.FONTWEIGHT_NORMAL))
        self.end_label.SetFont(wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_SLANT, wx.FONTWEIGHT_NORMAL))

        labelSizer = wx.BoxSizer(wx.HORIZONTAL)
        labelSizer.Add(self.start_label, 0, wx.ALL | wx.EXPAND, 3)
        labelSizer.Add(self.window_label, wx.ALL, 1)
        labelSizer.Add(self.end_label, 0, wx.ALL | wx.EXPAND, 3)

        self.btns = self.CreateSeparatedButtonSizer(wx.OK | wx.CANCEL)
        start_sizer = wx.BoxSizer(wx.HORIZONTAL)
        start_sizer.Add(wx.StaticText(self, -1, "Start: "), 0, wx.ALL, 1)
        self.start_slider = wx.Slider(
            self, -1, 0, 0, 100, wx.DefaultPosition, (250, -1), wx.SL_HORIZONTAL)
        start_sizer.Add(self.start_slider, 0, wx.ALL | wx.EXPAND, 5)
        self.Bind(wx.EVT_SLIDER, self.start_slider_update, self.start_slider)

        end_sizer = wx.BoxSizer(wx.HORIZONTAL)
        end_sizer.Add(wx.StaticText(self, -1, "End: "), 0, wx.ALL, 1)
        self.end_slider = wx.Slider(
            self, -1, 100, 0, 100, wx.DefaultPosition, (250, -1), wx.SL_HORIZONTAL)
        end_sizer.Add(self.end_slider, 0, wx.ALL | wx.EXPAND, 5)
        self.Bind(wx.EVT_SLIDER, self.end_slider_udpate, self.end_slider)

        self.start_time = start_time
        self.cur_end = end_time
        self.cur_start = self.start_time
        self.unit_seconds = (end_time - start_time).total_seconds() / 100.0

        self.updateUI()
        sizer.Add(labelSizer, 0, wx.ALL | wx.EXPAND, 5)
        sizer.Add(start_sizer, 0, wx.ALL | wx.EXPAND, 5)
        sizer.Add(end_sizer, 0, wx.ALL | wx.EXPAND, 5)
        sizer.Add(self.btns, 0, wx.ALL | wx.EXPAND, 5)
        self.SetSizer(sizer)
        self.Fit()
项目:cebl    作者:idfah    | 项目源码 | 文件源码
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)
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def drawGrid(self, dc):
        """Draw the grid characters and highlights.

        Args:
            dc:     wx.DC drawing context.  Calling the methods of dc will
                    modify the drawing accordingly.
        """
        ##dc.SetFont(self.gridFont) # setting the font for the text

        # figuring out what is the y-offset for the grid of symbols
        yOffset = self.winHeight*32/340.0
        if len(self.copyText) == 0:
            yOffset = self.winHeight * 14/340.0

        # figuring out the distances between each symbol horizontaly and vertically
        dx = (self.winWidth+0.0)/(self.nCols+1)
        dy = (self.winHeight-yOffset)/(self.nRows+1)

        for i in xrange(self.nRows):
            for j in xrange(self.nCols):
                # select the color and font for the next symbol
                mark = self.marked[i,j]

                if mark == grid.normal:
                    dc.SetTextForeground(self.gridColor)

                elif mark == grid.highlighted:
                    dc.SetTextForeground(self.highlightColor)
                    self.gridFont.SetWeight(wx.FONTWEIGHT_BOLD)

                elif mark == grid.unhighlighted:
                    dc.SetTextForeground(self.unhighlightColor)

                elif mark == grid.selected:
                    dc.SetTextForeground(self.selectColor)
                    self.gridFont.SetWeight(wx.FONTWEIGHT_BOLD)

                else:
                    raise Exception('Invalid mark value %d.' % mark)

                dc.SetFont(self.gridFont)

                # get extents of symbol
                text = self.grid[i,j]
                textWidth, textHeight = dc.GetTextExtent(text)

                # draw next symbol
                #dc.DrawText(self.grid[i,j], (j+0.7)*dx, (i+0.7)*dy+yOffset)
                dc.DrawText(self.grid[i,j],
                        (j+1.0)*dx-textWidth/2.0,
                        (i+1.0)*dy+yOffset-textHeight/2.0)
                self.gridFont.SetWeight(wx.FONTWEIGHT_NORMAL)
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
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()
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
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])