shortening_py2.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:wxpythoncookbookcode 作者: driscollis 项目源码 文件源码
def createLayout(self):
        """
        Create widgets and lay them out
        """
        choices = ["is.gd"]
        if bitlyFlag:
            choices.append("bit.ly")
        if tinyURLFlag:
            choices.append("tinyURL")
        choices.sort()

        # create the widgets
        self.URLCbo = wx.ComboBox(self, wx.ID_ANY, "is.gd",
                                  choices=choices,
                                  size=wx.DefaultSize,
                                  style=wx.CB_DROPDOWN)
        self.inputURLTxt = wx.TextCtrl(self, value="Paste long URL here")
        self.inputURLTxt.Bind(wx.EVT_SET_FOCUS, self.onFocus)
        self.outputURLTxt = wx.TextCtrl(self, style=wx.TE_READONLY)

        shortenBtn = wx.Button(self, label="Shorten URL")
        shortenBtn.Bind(wx.EVT_BUTTON, self.onShorten)
        copyBtn = wx.Button(self, label="Copy to Clipboard")
        copyBtn.Bind(wx.EVT_BUTTON, self.onCopy)

        # create the sizers
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)

        # layout the widgets
        mainSizer.Add(self.URLCbo, 0, wx.ALL, 5)
        mainSizer.Add(self.inputURLTxt, 0,
                      wx.ALL|wx.EXPAND, 5)
        mainSizer.Add(self.outputURLTxt, 0,
                      wx.ALL|wx.EXPAND, 5)
        btnSizer.Add(shortenBtn, 0, wx.ALL|wx.CENTER, 5)
        btnSizer.Add(copyBtn, 0, wx.ALL|wx.CENTER, 5)
        mainSizer.Add(btnSizer, 0, wx.ALL|wx.CENTER, 5)
        self.SetSizer(mainSizer)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号