Python wx 模块,FONTFAMILY_SWISS 实例源码

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

项目: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 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'))
项目: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]))
项目:cebl    作者:idfah    | 项目源码 | 文件源码
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
项目: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 )
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
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()
项目: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()