All pastes #516978 Raw Edit

Miscellany

public python v1 · immutable
#516978 ·published 2007-05-28 22:32 UTC
rendered paste body
#!/usr/bin/pythonimport wximport ConfigParserclass Mainframe(wx.Frame):    def __init__(self, parent, id, title):        self.readconfig()        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, (550, 350))        self.panel = wx.Panel(self, -1)                        self.startbutton = wx.BitmapButton(self.panel, -1, wx.Bitmap('icons/'+self.iconset+'/start.png'), style = wx.BU_EXACTFIT)        self.addbutton = wx.BitmapButton(self.panel, -1, wx.Bitmap('icons/'+self.iconset+'/add.png'), style = wx.BU_EXACTFIT)        self.pastebutton = wx.BitmapButton(self.panel, -1, wx.Bitmap('icons/'+self.iconset+'/paste.png'), style = wx.BU_EXACTFIT)        self.logbutton = wx.BitmapButton(self.panel, -1, wx.Bitmap('icons/'+self.iconset+'/log.png'), style = wx.BU_EXACTFIT)        self.settingsbutton = wx.BitmapButton(self.panel, -1, wx.Bitmap('icons/'+self.iconset+'/settings.png'), style = wx.BU_EXACTFIT)        self.infobutton = wx.BitmapButton(self.panel, -1, wx.Bitmap('icons/'+self.iconset+'/info.png'), style = wx.BU_EXACTFIT)                self.listbox = wx.ListBox(self.panel, 0, choices=self.links)        self.gauge = wx.Gauge(self.panel, size = (-1,15))        self.gauge.SetValue(10)                self.Bind(wx.EVT_CLOSE, self.quit)        self.Bind(wx.EVT_BUTTON, self.addlinks, self.addbutton)                self.layoutstuff()            def layoutstuff(self):        mainsizer = wx.BoxSizer(wx.VERTICAL)        subsizer = wx.BoxSizer(wx.VERTICAL)        buttonsizer = wx.GridSizer(rows=1,hgap=5)                buttonsizer.Add(self.startbutton)        buttonsizer.Add(self.addbutton)        buttonsizer.Add(self.pastebutton)        buttonsizer.Add(self.logbutton)        buttonsizer.Add(self.settingsbutton)        buttonsizer.Add(self.infobutton)                subsizer.Add(self.listbox,1, wx.EXPAND)        subsizer.Add(self.gauge,0, wx.EXPAND)                mainsizer.Add(buttonsizer,0,wx.TOP)        mainsizer.Add(subsizer,1, wx.EXPAND)        self.panel.SetSizer(mainsizer)            def addlinks(self,event):        dialog = LinkDialog(self, -1, 'Adding Links...')        dialog.ShowModal()        dialog.Destroy()        self.writedllist()        def writedllist(self):        dlfile = open('dllist', 'w')        dlfile.writelines(self.links)        dlfile.close()            def readconfig(self):        config = ConfigParser.ConfigParser()        config.read('tuxl33ch.cfg')        self.iconset = config.get('APPEARANCE', 'iconset')                dlfile = open('dllist', 'r')        self.links=[l.rstrip() for l in dlfile.readlines()]        print self.links                        def writeconfig(self):        config = ConfigParser.ConfigParser()        config.read('tuxl33ch.cfg')        config.set('APPEARANCE', 'iconset',self.iconset)                    def quit(self,event):        self.writeconfig        self.Destroy()                class LinkDialog(wx.Dialog):    def __init__(self, parent, id, title):        wx.Dialog.__init__(self, parent, id, title, size=(350,300))        sizer =  self.CreateTextSizer('Please enter/paste some links')        ver_sizer = wx.BoxSizer(wx.VERTICAL)        hor_sizer = wx.BoxSizer(wx.HORIZONTAL)        self.textctrl = wx.TextCtrl(self, style = wx.TE_MULTILINE)        self.okbutton = wx.Button(self, id=wx.ID_OK)        self.cancelbutton = wx.Button(self, id=wx.ID_CANCEL)        hor_sizer.Add(self.cancelbutton)        hor_sizer.Add(self.okbutton)        ver_sizer.Add(self.textctrl, 1, wx.EXPAND)        ver_sizer.Add(hor_sizer)        sizer.Add(ver_sizer, 1, wx.EXPAND)        self.SetSizer(sizer)                self.Bind(wx.EVT_BUTTON, self.on_ok, self.okbutton)            def on_ok(self,event):        Mainframe.links += self.textctrl.Getstring.split('\n')        self.quit()        class TuxL33ch(wx.App):    def OnInit(self):        frame = Mainframe(None, -1, 'TuxL33ch')        frame.Centre()        frame.Show(True)        return Trueapp = TuxL33ch(0)app.MainLoop()