Python wx 模块,SWISS 实例源码

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

项目:python_2048    作者:OATOMO    | 项目源码 | 文件源码
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
项目:python_2048    作者:OATOMO    | 项目源码 | 文件源码
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)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
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)
项目:wxpythoncookbookcode    作者:driscollis    | 项目源码 | 文件源码
def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent=parent)
        font = wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False)

        # create and setup first set of widgets
        lbl = wx.StaticText(self, 
                            label="Drag some URLS from your browser here:")
        lbl.SetFont(font)
        self.dropText = wx.TextCtrl(
            self, size=(200,200), 
            style=wx.TE_MULTILINE|wx.HSCROLL|wx.TE_READONLY)
        dt = MyURLDropTarget(self.dropText)
        self.dropText.SetDropTarget(dt)
        firstSizer = self.addWidgetsToSizer([lbl, self.dropText])

        # create and setup second set of widgets
        lbl = wx.StaticText(self, label="Drag this URL to your browser:")
        lbl.SetFont(font)
        self.draggableURLText = wx.TextCtrl(self, 
                                            value="http://www.mousevspython.com")
        self.draggableURLText.Bind(wx.EVT_MOTION, self.OnStartDrag)
        secondSizer = self.addWidgetsToSizer([lbl, self.draggableURLText])

        # Add sizers to main sizer
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(firstSizer, 0, wx.EXPAND)
        mainSizer.Add(secondSizer, 0, wx.EXPAND)
        self.SetSizer(mainSizer)
项目:wxpythoncookbookcode    作者:driscollis    | 项目源码 | 文件源码
def __init__(self, parent, label="Close"):
        """Constructor"""
        font = wx.Font(16, wx.SWISS, wx.NORMAL, wx.BOLD)
        img = wx.Bitmap(r"%s/images/cancel.png" % appPath)
        GenBitmapTextButton.__init__(self, parent, wx.ID_CLOSE, img,
                                     label=label, size=(110, 50))
        self.SetFont(font)
项目:specto    作者:mrknow    | 项目源码 | 文件源码
def __init__(self, parent, title):
            wx.Frame.__init__(self, parent, -1, title,
                              pos=(150, 150), size=(350, 200))

            # Create the menubar
            menuBar = wx.MenuBar()

            # and a menu
            menu = wx.Menu()

            # add an item to the menu, using \tKeyName automatically
            # creates an accelerator, the third param is some help text
            # that will show up in the statusbar
            menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit this simple sample")

            # bind the menu event to an event handler
            self.Bind(wx.EVT_MENU, self.on_time_to_close, id=wx.ID_EXIT)

            # and put the menu on the menubar
            menuBar.Append(menu, "&File")
            self.SetMenuBar(menuBar)

            self.CreateStatusBar()

            # Now create the Panel to put the other controls on.
            panel = wx.Panel(self)

            # and a few controls
            text = wx.StaticText(panel, -1, "Hello World!")
            text.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD))
            text.SetSize(text.GetBestSize())
            btn = wx.Button(panel, -1, "Close")
            funbtn = wx.Button(panel, -1, "Just for fun...")

            # bind the button events to handlers
            self.Bind(wx.EVT_BUTTON, self.on_time_to_close, btn)
            self.Bind(wx.EVT_BUTTON, self.on_fun_button, funbtn)

            # Use a sizer to layout the controls, stacked vertically and with
            # a 10 pixel border around each
            sizer = wx.BoxSizer(wx.VERTICAL)
            sizer.Add(text, 0, wx.ALL, 10)
            sizer.Add(btn, 0, wx.ALL, 10)
            sizer.Add(funbtn, 0, wx.ALL, 10)
            panel.SetSizer(sizer)
            panel.Layout()
项目:wxpythoncookbookcode    作者:driscollis    | 项目源码 | 文件源码
def createWidgets(self):
        """
        Create and layout the widgets in the dialog
        """
        lblSizer = wx.BoxSizer(wx.VERTICAL)
        valueSizer = wx.BoxSizer(wx.VERTICAL)
        btnSizer = wx.StdDialogButtonSizer()
        colSizer = wx.BoxSizer(wx.HORIZONTAL)
        mainSizer = wx.BoxSizer(wx.VERTICAL)

        iniFile = "config.ini"
        self.config = configobj.ConfigObj(iniFile)

        labels = self.config["Labels"]
        values = self.config["Values"]
        self.widgetNames = values
        font = wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD)

        for key in labels:
            value = labels[key]
            lbl = wx.StaticText(self, label=value)
            lbl.SetFont(font)
            lblSizer.Add(lbl, 0, wx.ALL, 5)

        for key in values:
            print(key)
            value = values[key]
            if isinstance(value, list):
                default = value[0]
                choices = value[1:]
                cbo = wx.ComboBox(self, value=value[0],
                                  size=wx.DefaultSize, choices=choices, 
                                  style=wx.CB_DROPDOWN|wx.CB_READONLY, 
                                  name=key)
                valueSizer.Add(cbo, 0, wx.ALL, 5)
            else:
                txt = wx.TextCtrl(self, value=value, name=key)
                valueSizer.Add(txt, 0, wx.ALL|wx.EXPAND, 5)

        saveBtn = wx.Button(self, wx.ID_OK, label="Save")
        saveBtn.Bind(wx.EVT_BUTTON, self.onSave)
        btnSizer.AddButton(saveBtn)

        cancelBtn = wx.Button(self, wx.ID_CANCEL)
        btnSizer.AddButton(cancelBtn)
        btnSizer.Realize()

        colSizer.Add(lblSizer)
        colSizer.Add(valueSizer, 1, wx.EXPAND)
        mainSizer.Add(colSizer, 0, wx.EXPAND)
        mainSizer.Add(btnSizer, 0, wx.ALL | wx.ALIGN_RIGHT, 5)
        self.SetSizer(mainSizer)
项目:PAWS    作者:Moonbase59    | 项目源码 | 文件源码
def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=wxID_TFRAME, name='TFrame', parent=prnt,
              pos=wx.Point(254, 241), size=wx.Size(829, 786),
              style=wx.DEFAULT_FRAME_STYLE, title=u'PAWS Terminal')
        self._init_utils()
        self.SetClientSize(wx.Size(821, 748))
        self.SetMenuBar(self.TMenuBar)
        self.SetAutoLayout(True)
        self.SetToolTipString('TFrame')
        self.SetMinSize(wx.Size(-1, 21))

        self.TStatusBar = wx.StatusBar(id=wxID_TFRAMETSTATUSBAR,
              name='TStatusBar', parent=self, style=0)
        self.TStatusBar.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False,
              u'Courier New'))
        self._init_coll_TStatusBar_Fields(self.TStatusBar)
        self.SetStatusBar(self.TStatusBar)

        self.TInput = wx.TextCtrl(id=wxID_TFRAMETINPUT, name='TInput',
              parent=self, pos=wx.Point(1, 728), size=wx.Size(819, 20),
              style=wx.SIMPLE_BORDER | wx.TE_PROCESS_ENTER, value="''")
        self.TInput.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False,
              u'Courier'))
        self.TInput.SetToolTipString(u'Type command here.')
        self.TInput.SetAutoLayout(False)
        self.TInput.SetEditable(True)
        self.TInput.Enable(False)
        self.TInput.Bind(wx.EVT_TEXT_ENTER, self.OnTInputTextEnter,
              id=wxID_TFRAMETINPUT)

        self.TDisplay = wx.TextCtrl(id=wxID_TFRAMETDISPLAY, name='TDisplay',
              parent=self, pos=wx.Point(0, 0), size=wx.Size(821, 728),
              style=wx.TE_RICH2 | wx.TE_MULTILINE | wx.TE_READONLY,
              value=u'To run a game, choose File ? Pick Game … then choose a game from the list.')
        self.TDisplay.SetMinSize(wx.Size(517, 440))
        self.TDisplay.SetEditable(False)
        self.TDisplay.SetToolTipString(u"Game's output displays here.")
        self.TDisplay.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, False,
              u'Arial'))
        self.TDisplay.Enable(True)

        self._init_sizers()