These are open source projects that I’m involved in.

Developer

  • MediaLocker - a wxPython Application for managing your personal media

Documentation

  • wxPython via their wiki and my blog
  • MplayerCtrl - embed the cross-platform Mplayer in wxPython
Print Friendly
  • http://www.web-designs-company.com/ web design company

    Good article My Projects it cools great here.

  • meyyao
  • Chapter 3

    Hi, this is really an awesome python blog that I have came across surfing the net!

    Examples are clear, neat, concise, easy to understand and read.

    Keep up the good work!

  • shadow86

    Hi, this was a great help as im starting out learning python. 5 stars.

  • Coleman

    A man by the name of Nick Driscoll sent me your way. I am a Software Engineer at Iowa State University, and this blog has taken my python abilities to their height. Thank you!

  • pytho

    I am a beginner to the python scripting and i have learned some basics of wxpython and developed code of my own. I have the setup where svn checkout from the server and builds it on the local system through tortoise svn.I need to automate the checking out of svn,building it on the system on a single click.Here’s my code which i tried to build a gui for it.

    import wx
    import os
    import smtplib
    import time

    ID_OPENPYTHON= 107
    ID_OPEN = 104
    ID_SAVE = 119
    ID_RUN = 109
    ID_EXIT = 102
    ID_LOCATEONDISK = 111
    #ID_SUB = 118
    ID_SENDTO = 110
    ID_CHECKOUT =122
    ID_REPOSITORY = 112
    ID_SERVER = 113
    ID_SYSTEMLOGS = 114
    ID_SCHEDULER = 115

    ID_ABOUT = 101
    ID_CANCEL = 116
    ID_LOAD = 117
    ID_CLOSE=105
    ID_OK= 106
    #ID_RECORD = 108
    ID_SEND = 120
    ID_LIST = 121
    #ID_EMAIL = 122

    class MyFrame(wx.Frame):
    #def __init__(self, *args, **kw):
    #super(MyFrame, self).__init__(*args, **kw)

    #sself.InitUI()
    def __init__(self, parent, ID, title):
    wx.Frame.__init__(self, parent, ID, title, wx.DefaultPosition, wx.Size(500, 250))
    self.CreateStatusBar()
    self.SetStatusText(“This is the statusbar”)
    self.control = wx.TextCtrl(self, 1, style=wx.TE_MULTILINE)
    self.dirname = ”

    menuBar = wx.MenuBar()

    file = wx.Menu()
    file.Append(ID_OPENPYTHON,”&Open python project”, “Open python project”)
    file.AppendSeparator()
    file.Append(ID_OPEN, “&Open Ctrl+Q”, “Open a file”)
    file.AppendSeparator()
    file.Append(ID_SAVE, “&Save”, “Save the file”)
    file.AppendSeparator()
    file.Append(ID_RUN, “&Run”, “Run the file”)
    file.AppendSeparator()
    file.Append(ID_EXIT,”&Exit”,”Exit”)

    edit = wx.Menu()
    edit.Append(ID_LOCATEONDISK, “&Locate on disk”, “Locate on the disk”)
    edit.AppendSeparator()
    #submenu = wx.Menu()
    #submenu.Append(ID_SUB, ‘Via email’, kind=wx.ITEM_RADIO)
    edit.Append(ID_SENDTO, “&sendto”, “Send via email”)

    checkout = wx.Menu()
    checkout.Append(ID_CHECKOUT,”&svn checkout”,”checkout svn”)

    tools = wx.Menu()
    tools.Append(ID_REPOSITORY,”&Repository”,”Repository to connect”)
    tools.AppendSeparator()
    tools.Append(ID_SERVER,”&Server communication”,”connect to server”)
    tools.AppendSeparator()
    tools.Append(ID_SYSTEMLOGS,”&System logs”,”Logs”)
    tools.AppendSeparator()
    tools.Append(ID_SCHEDULER,”&Schedule manager”,”Schedule manager”)

    help = wx.Menu()
    help.Append(ID_ABOUT, “&About”, “Information about testing tool”)

    menuBar.Append(file, “&File”);
    menuBar.Append(edit, “&Edit”);
    menuBar.Append(checkout,”&Checkout”);
    menuBar.Append(tools, “&Tools”);
    menuBar.Append(help, “&Help”);
    self.SetMenuBar(menuBar)

    wx.EVT_MENU(self, ID_ABOUT, self.OnAbout)
    wx.EVT_MENU(self, ID_EXIT, self.TimeToQuit)
    wx.EVT_MENU(self, ID_OPEN, self.ClickOnOpen)
    wx.EVT_MENU(self, ID_SAVE, self.ClickOnSave)
    wx.EVT_MENU(self, ID_SENDTO, self.OnSendto)
    #wx.EVT_MENU(self, ID_CHECKOUT, self.OnCheckout)
    wx.EVT_MENU(self, ID_OPENPYTHON,self.OnOpenPython)
    #EVT_BUTTON(self, ID_LOAD, self.loadEvent)
    #EVT_MENU(self, ID_CANCEL, self.OnCancel)

    def OnAbout(self, event):
    self.aboutme = wx.MessageDialog( self, ” A GUI forn”
    ” SMART TESTER”,”About me”, wx.OK)
    self.aboutme.ShowModal()

    def TimeToQuit(self, event):
    self.doiexit = wx.MessageDialog( self, ” Are U Sure want to Exit? n”,
    “GOING away …”, wx.YES_NO)
    igot = self.doiexit.ShowModal()
    if igot == wx.ID_YES:
    self.Close(True)

    def ClickOnOpen(self, event):
    dlg = wx.FileDialog(self, “Choose a file”, self.dirname, “”, “*.*”, wx.OPEN)
    if dlg.ShowModal() == wx.ID_OK:
    self.filename=dlg.GetFilename()
    self.dirname=dlg.GetDirectory()

    # Open the file, read the contents and set them into
    # the text edit window
    filehandle=open(os.path.join(self.dirname, self.filename),’r')
    self.control.SetValue(filehandle.read())
    filehandle.close()

    # Report on name of latest file read
    self.SetTitle(“Editing”+self.filename)
    #dlg.Destroy()

    #EVT_MENU(self,ID_SEND,self.OnSend)

    def OnSendto(self,event):
    class Example(wx.Dialog):

    def __init__(self, *args, **kw):
    super(Example, self).__init__(*args, **kw)

    self.InitUI()

    def InitUI(self):

    pnl = wx.Panel(self)

    vbox = wx.BoxSizer(wx.VERTICAL)
    hbox1 = wx.BoxSizer(wx.HORIZONTAL)
    hbox2 = wx.BoxSizer(wx.HORIZONTAL)
    hbox3 = wx.BoxSizer(wx.HORIZONTAL)

    st1 = wx.StaticText(pnl, label=’From’)
    st2 = wx.StaticText(pnl, label=’To ‘)
    st3 = wx.StaticText(pnl, label=’Subject’)

    self.tc1 = wx.TextCtrl(pnl, size=(180, -1))
    self.tc2 = wx.TextCtrl(pnl, size=(180, -1))
    self.tc3 = wx.TextCtrl(pnl, size=(180, -1))

    self.tc = wx.TextCtrl(pnl, style=wx.TE_MULTILINE)
    button_send = wx.Button(pnl, label=’Send’)

    hbox1.Add(st1, flag=wx.LEFT, border=10)
    hbox1.Add(self.tc1, flag=wx.LEFT, border=35)
    hbox2.Add(st2, flag=wx.LEFT, border=10)
    hbox2.Add(self.tc2, flag=wx.LEFT, border=50)
    hbox3.Add(st3, flag=wx.LEFT, border=10)
    hbox3.Add(self.tc3, flag=wx.LEFT, border=20)
    vbox.Add(hbox1, flag=wx.TOP, border=10)
    vbox.Add(hbox2, flag=wx.TOP, border=10)
    vbox.Add(hbox3, flag=wx.TOP, border=10)
    vbox.Add(self.tc, proportion=1, flag=wx.EXPAND | wx.TOP |
    wx.RIGHT | wx.LEFT, border=15)
    vbox.Add(button_send, flag=wx.ALIGN_CENTER | wx.TOP |
    wx.BOTTOM, border=20)

    self.Bind(wx.EVT_BUTTON, self.OnSend, button_send)
    pnl.SetSizer(vbox)

    self.SetSize((400, 420))
    self.SetTitle(‘Tom’)
    self.Centre()
    self.ShowModal()
    self.Destroy()

    def OnSend(self, e):

    sender = self.tc1.GetValue()
    recipient = self.tc2.GetValue()
    subject = self.tc3.GetValue()
    text = self.tc.GetValue()
    header = ‘From: %srnTo: %srnSubject: %srnrn’ % (sender, recipient, subject)
    message = header + text

    try:

    server = smtplib.SMTP(‘smtp.manipal.net’)
    server.sendmail(sender, recipient, message)
    server.quit()
    dlg = wx.MessageDialog(self, ‘Email was successfully sent’, ‘Success’,
    wx.OK | wx.ICON_INFORMATION)
    dlg.ShowModal()
    dlg.Destroy()

    except smtplib.SMTPException, error:

    dlg = wx.MessageDialog(self, ‘Failed to send email’,
    ‘Error’, wx.OK | wx.ICON_ERROR)
    dlg.ShowModal()
    dlg.Destroy()
    def main():

    ex = wx.App()
    Example(None)
    ex.MainLoop()

    if __name__ == ‘__main__’:
    main()

    def ClickOnSave(self,event):
    dlg = wx.FileDialog(self, “Choose a file”, self.dirname, “”, “*.*”,
    wx.SAVE | wx.OVERWRITE_PROMPT)
    if dlg.ShowModal() == wx.ID_OK:
    itcontains = self.control.GetValue()

    # Open the file for write, write, close
    self.filename=dlg.GetFilename()
    self.dirname=dlg.GetDirectory()
    filehandle=open(os.path.join(self.dirname, self.filename),’w')
    filehandle.write(itcontains)
    filehandle.close()
    # Get rid of the dialog to keep things tidy
    dlg.Destroy()

    #ef OnCheckout(self,event):
    #window = wx.Window()
    #def __init__(parent, id=-1, title=”", pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE, name=wx.DialogNameStr):

    #dlg = wx.Dialog(window, id=-1,title=”svn Box”, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE)
    #if dlg.ShowModal() == wx.ID_OK:
    #svn checkout svn://localhost/dev/main/QvisViewer “C:UsersqvisDocumentsqvpath”
    #dlg.Destroy()

    def OnOpenPython(self, event):
    class MyListCtrl(wx.ListCtrl):
    def __init__(self, parent, id):
    wx.ListCtrl.__init__(self, parent, id, style=wx.LC_REPORT)

    files = os.listdir(‘.’)

    self.InsertColumn(0, ‘Name’)
    self.InsertColumn(1, ‘Ext’)
    self.InsertColumn(2, ‘Size’, wx.LIST_FORMAT_RIGHT)
    self.InsertColumn(3, ‘Modified’)

    self.SetColumnWidth(0, 220)
    self.SetColumnWidth(1, 70)
    self.SetColumnWidth(2, 100)
    self.SetColumnWidth(3, 420)

    j = 0
    for i in files:
    (name, ext) = os.path.splitext(i)
    ex = ext[1:]
    size = os.path.getsize(i)
    sec = os.path.getmtime(i)
    self.InsertStringItem(j, “%s%s” % (name, ext))
    self.SetStringItem(j, 1, ex)
    self.SetStringItem(j, 2, str(size) + ‘ B’)
    self.SetStringItem(j, 3, time.strftime(‘%Y-%m-%d %H:%M’,
    time.localtime(sec)))

    if os.path.isdir(i):
    self.SetItemImage(j, 1)
    elif ex == ‘py’:
    self.SetItemImage(j, 2)
    elif ex == ‘jpg’:
    self.SetItemImage(j, 3)
    elif ex == ‘pdf’:
    self.SetItemImage(j, 4)
    else:
    self.SetItemImage(j, 0)

    if (j % 2) == 0:
    self.SetItemBackgroundColour(j, ‘#e6f1f5′)
    j = j + 1

    ########################################################################
    class FileHunter(wx.Frame):
    def __init__(self, parent, id, title):
    wx.Frame.__init__(self, parent, -1, title,size=(550,600))
    panel = wx.Panel(self)

    p1 = MyListCtrl(panel, -1)
    p1.Bind(wx.EVT_LIST_BEGIN_DRAG, self.onDrag)
    sizer = wx.BoxSizer()
    sizer.Add(p1, 1, wx.EXPAND)
    panel.SetSizer(sizer)

    self.Center()
    self.Show(True)

    #———————————————————————-
    def onDrag(self, event):

    data = wx.FileDataObject()
    obj = event.GetEventObject()
    id = event.GetIndex()
    filename = obj.GetItem(id).GetText()
    dirname = os.path.dirname(os.path.abspath(os.listdir(“.”)[0]))
    fullpath = str(os.path.join(dirname, filename))

    data.AddFile(fullpath)

    dropSource = wx.DropSource(obj)
    dropSource.SetData(data)
    result = dropSource.DoDragDrop()
    print fullpath

    #———————————————————————-
    app = wx.App(False)
    FileHunter(None, -1, ‘File Hunter’)
    #file.Show(trues)
    app.MainLoop()

    class MyApp(wx.App):
    def OnInit(self):
    frame = MyFrame(None, -1, “Smart Tester”)
    frame.Show()
    self.SetTopWindow(frame)
    #file=FileHunter(None, -1, ‘File Hunter’)
    #file.Show(true)
    return True

    app = MyApp(0)
    app.MainLoop()

  • driscollis

    The easiest way to make sure you’re doing things right is to write the code without the GUI first. Then when you have a script that works, put that in the button handler.

  • pytho

    yeah ok.I will try doing that.Thank you for the suggestion.

  • pytho

    I need to checkout svn using python script.I use python 2.7 and i wrote
    svn checkout svn://localhost/dev/main “C:UsersDocuments. It is showing syntax error. I could checkout creating batch file and running it on command line. Please help me out.

  • pytho

    How to write the script to connect to visual studio and build a project?

  • pytho

    how to install msi using python script?

  • priyanka

    How to set image next to radio button in wxpython?