Fabio Zadrozny, the primary developer behind PyDev has started a campaign on Indiegogo to fund continuing development of PyDev. In case you’re new to Python development, PyDev is a plugin for Eclipse that provides a nice Integrated Development Environment (IDE) for Python, Jython and IronPython in the Eclipse environment.

You can read about why Fabio decided to go the Indiegogo route for funding on his blog. While I personally don’t use PyDev, several of my co-workers really like it. I think supporting our fellow Python developers is a good thing, so if you have some extra cash to spare for a pretty great open source project, then you might want to support this campaign.

The Python.org website is finally getting a much needed update and at PyCon 2013, they announced that you can now check out a preview of what it’s going to look like here: http://preview.python.org/

There’s a call for beta testers at the bottom of the website, so if you want to help Python, here’s a really simple way for you to do so. They’re still putting content on the site, so it’s going to be kind of rough for a while with placeholders and what-not, but I like the look and feel already. Go check it out for yourself and see what you think!

This week, I needed to figure out how to attach an event handler that would fire when I double-clicked an item (i.e. row) in an ObjectListView widget that was in LC_REPORT mode. For some reason, there isn’t an obvious mouse event for that. There is an EVT_LIST_ITEM_RIGHT_CLICK and an EVT_LIST_ITEM_MIDDLE_CLICK, but nothing for LEFT clicks of any sort. After a bit of searching on Google, I found that I can get it to work by using EVT_LIST_ITEM_ACTIVATED. This will fire when an item is double-clicked and when an item is selected and the user presses ENTER. Here’s a code example:

import wx
from ObjectListView import ObjectListView, ColumnDefn
 
########################################################################
class Results(object):
    """"""
 
    #----------------------------------------------------------------------
    def __init__(self, tin, zip_code, plus4, name, address):
        """Constructor"""
        self.tin = tin
        self.zip_code = zip_code
        self.plus4 = plus4
        self.name = name
        self.address = address
 
 
########################################################################
class DCPanel(wx.Panel):
    """"""
 
    #----------------------------------------------------------------------
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent=parent)
 
        mainSizer = wx.BoxSizer(wx.VERTICAL)
 
        self.test_data = [Results("123456789", "50158", "0065", "Patti Jones",
                                  "111 Centennial Drive"),
                          Results("978561236", "90056", "7890", "Brian Wilson",
                                  "555 Torque Maui"),
                          Results("456897852", "70014", "6545", "Mike Love", 
                                  "304 Cali Bvld")
                          ]
        self.resultsOlv = ObjectListView(self, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
        self.resultsOlv.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onDoubleClick)
 
        self.setResults()
 
        mainSizer.Add(self.resultsOlv, 1, wx.EXPAND|wx.ALL, 5)
        self.SetSizer(mainSizer)
 
    #----------------------------------------------------------------------
    def onDoubleClick(self, event):
        """
        When the item is double-clicked or "activated", do something
        """
        print "in onDoubleClick method"
 
    #----------------------------------------------------------------------
    def setResults(self):
        """"""
        self.resultsOlv.SetColumns([
            ColumnDefn("TIN", "left", 100, "tin"),
            ColumnDefn("Zip", "left", 75, "zip_code"),
            ColumnDefn("+4", "left", 50, "plus4"),
            ColumnDefn("Name", "left", 150, "name"),
            ColumnDefn("Address", "left", 200, "address")
            ])
        self.resultsOlv.CreateCheckStateColumn()
        self.resultsOlv.SetObjects(self.test_data)
 
 
########################################################################
class DCFrame(wx.Frame):
    """"""
 
    #----------------------------------------------------------------------
    def __init__(self):
        """Constructor"""
        wx.Frame.__init__(self, parent=None, title="Double-click Tutorial")
        panel = DCPanel(self)
 
#----------------------------------------------------------------------
if __name__ == "__main__":
    app = wx.App(False)
    frame = DCFrame()
    frame.Show()
    app.MainLoop()

Pretty straight-forward, right? I hope it’ll help you if you ever need to know how to do this. This method should work with a ListCtrl as well.

This week I spent some time learning how to add check boxes to the ObjectListView widget in wxPython. If you don’t know, ObjectListView is a 3rd party wrapper for the wx.ListCtrl widget that makes using the ListCtrl much easier. You can read all about it in this older article from the archives. I had a requirement where I needed to have a check box next to each item in the report view of the widget. After some digging on the ObjectListView website, I found an article that sort of explained how to do it. According to the documentation, I could use the CreateCheckStateColumn method or register a column and use InstallCheckStateColumn. In this article, we’ll be focusing on the CreateCheckStateColumn method. (more…)

Last week I was contacted about a cool sounding book project on Kickstarter: Real Python for Web Development, featuring web2py by Michael Herman. I have to admit that I’m not familiar with Mr. Herman or the person who originally contacted me about the book, but since I enjoy reading Python books and this one sounded interesting, I thought I’d let my readers know about it too. You can support the project yourself if you want. He’s recently added some tutorials for Flask to the book, so you can learn a little about two Python web frameworks!

I first heard about Blaze from NumPy’s original developer’s blog back in December 2012. A few days ago, InformationWeek announced that DARPA was funding the project to the tune of $3 million dollars to get some big data libraries written for Python. There will be two new projects, Blaze and Bokeh. Blaze will be an extension of NumPy and SciPy and make those libraries big data friendly. The Bokeh project will be for big data visualization.

Blaze will be open source. You can read more about it here. I was unable to find a specific link to the Bokeh project.

I was approached by a representative from No Starch Press, the publisher of Python For Kids, to review their book. They provided me with a free dead tree copy and an eBook (PDF) version. This book appears to be in direct competition with Manning’s Hello World! Computer Programming for Kids and Other Beginners by Sande. I’ll do a quick review and then you can read the more detailed review after the jump if you’re still interested.

Quick Review

  • Why I picked it up: Primarily because I asked by the publisher to read it. However, I find these extreme beginner books interesting in their own right. I just didn’t want to spend my own money on it. It’s also a Python 3 book!
  • Why I finished it: Actually, I didn’t finish it. The book is quite good, but it’s a beginner book and I ended up skimming it after I read about halfway through. But this is a well written book with an engaging writing style.
  • I’d give it to: I would give this book to someone with kids in high school who are interested in programming in general or Python specifically.

(more…)

The other day, I was trying to figure out if there was an easy way to grab a class’s defined attributes (AKA “instance variables”). The reason was that we were using the attributes we created to match up with the fields in a file we parse. So basically we read a file line-by-line and each line can be split into 150+ pieces that need to be mapped to the fields we create in the class. The catch is that we recently added more fields to the class and there’s a check in the code that is hard-coded with the number of fields that should be in the file. Thus, when I added more fields, it broke the check. I hope that all made sense. Now you know the background, so we can move on. I found three different ways to accomplish this, so we’ll go from the most complex to the simplest. (more…)

I forgot to get this article done for the first of the year as I have in the past. I hope you find some interesting reading material from this tardy post. I also hope my readers have had wonderful holidays and are looking forward to the upcoming year!

Note: I use Google Analytics to help me figure out which articles are doing well and get lots of other interesting information. That is where this information comes from.

  1. Python 101: How to Open a File or Program (32,631 page views)
  2. How to Send Email with Python (25,573 page views)
  3. Python: Parsing XML with minidom (23,813 page views)
  4. A Simple Step-by-Step Reportlab Tutorial (22,260 page views)
  5. Python 101: An Intro to logging (16,171 page views)
  6. Python and Microsoft Office – Using PyWin32 (14,084 page views)
  7. A cx_Freeze Tutorial – Build a Binary Series! (12,724 page views)
  8. Python: A Simple Step-by-Step SQLite Tutorial (11,834 page views)
  9. Another Step-by-Step SqlAlchemy Tutorial (part 1 of 2) (10,207 page views)
  10. wxPython: wx.ListCtrl Tips and Tricks (10,142 page views)

I always find it interesting how the articles from the past still get so many hits. Seven of these articles are from 2010, one is from 2011 and only two are from 2012. Hopefully the articles I write this year will prove as enduring as the ones from years past. As always, I welcome suggestions on what to write about or Python books to review. I look forward to hearing from you this year!

Top Ten Lists of Yore

If you do much system administration, then you know that sometimes you have to write scripts that can move files between servers. I’m not really a system administrator by trade, but I did have to do this sort of thing in some of my programs anyway. Python has several 3rd party packages that provide this ability. We’ll be looking at how to do it with paramiko which depends on PyCrypto (or download PyCrypto from PyPI). (more…)

« Previous PageNext Page »