Most people don’t really think about the widgets they use every day. Instead, they just take them for granted. The button is one of the most commonly used widgets that we use. From the keys on our keyboards to the buttons on door locks, we find them everywhere. They are even more prevalent in software where buttons can be practically any shape or size. Some buttons don’t even look like buttons! In this article, we’ll look at several buttons that wxPython provides for you and how to use them. (more…)
Wed 9 Jun 2010
wxPython: A Tour of Buttons (Part 1 of 2)
Posted by Mike under Cross-Platform, Python, wxPython
View Comments
Sat 5 Jun 2010
Python: Running Ping, Traceroute and More
Posted by Mike under Python, System Administration, wxPython
View Comments
Last year I needed to figure out a way to get the following information with Python: get the route table, capture the data from pinging a series of IPs, run tracert and get information about the NIC(s) installed. This all needed to be done on a Windows machine as it was part of a diagnostics script to try to figure out why the machine (usually a laptop) wouldn’t connect to our VPN. I ended up creating a wxPython GUI to make it easy for the user to run, but these scripts will work just fine without wx. Let’s see what they look like! (more…)
Fri 4 Jun 2010
June Pyowa 2010 Wrap-up
Posted by Mike under Pyowa
View Comments
We had our June Pyowa meeting last night in Ames, IA. There were NINE people in attendance, which is pretty big for our group. I think we’ve only managed that number of people on only one other occasion. Thanks goes out to everyone who spread the word and invited their friends.
At the meeting, I demoed a wxPython music player that I’ve been working on for around a month. It uses the cross-platform mplayer as its backend and wxPython for the front. Right now it allows the user to load a folder of mp3s into a custom list control (technically an ObjectListView widget instance) and play them one-by-one by either pressing the play button after selecting a track or by double-clicking a track. The player also displays cover art (if available), has a volume control and a playback slider.
Before I even started that demo though, I was asked about creating executables using py2exe, so I did an impromptu presentation on that subject using GUI2Exe. I rediscovered py2exe’s dislike of egg files when I tried to build the exe, so I had to unzip those so it could find the modules it needed for the project. Once that was done, the program compiled nicely.
Next time, we’ll be meeting in West Des Moines at the IMT Group building. Pizza and pop will be provided, so come hungry! The talks will be about Django, TurboGears and (maybe) SWIG. That will be happening on the 1st of July. I hope you can make it!
Sat 22 May 2010
A Quick EasyGui Tutorial
Posted by Mike under Cross-Platform, Python
View Comments
Earlier this week, I was reading my copy of “Hello World” by Warren D. Sande and Carter Sande and in its chapter on graphical user interfaces, it mentioned a library called EasyGui. It’s the first and only Python GUI project I’ve seen that’s not event-driven. Instead, EasyGui is basically a set of dialogs that can be opened on demand. This package would be handy for command line programs that need to get information from the user using a dialog or for teaching new programmers about simple GUIs. Let’s take a quick look at what EasyGui can do. We’ll use some of the examples from the book. (more…)
Sat 22 May 2010
wxPython and Threads
Posted by Mike under Cross-Platform, Python, wxPython
View Comments
If you use GUIs in Python much, then you know that sometimes you need to execute some long running process every now and then. Of course, if you do that as you would with a command line program, then you’ll be in for a surprise. In most cases, you’ll end up blocking your GUI’s event loop and the user will see your program freeze. What can you do to get around just mishaps? Start the task in another thread or process of course! In this article, we’ll look at how to do this with wxPython and Python’s threading module. (more…)
Thu 20 May 2010
Book Preview: Python 3 Object Oriented Programming
Posted by Mike under Python
View Comments
In late December, I was approached by Packt Publishing to write a book on wxPython. I turned them down because the editor’s vision for the book and mine did not mesh. Anyway, I did end up accepting the job of being a technical editor for one of their upcoming books: Python 3 Object Oriented Programming by Dusty Phillips. I started doing that in January 2010. The “pay” is a copy of the book plus one other book of my choice from Packt’s catalog. That’s it. I won’t get either book until this one is published, which is supposed to happen in August of this year. This article is a preview of the book. (more…)
Sat 15 May 2010
Manipulating PDFs with Python and pyPdf
Posted by Mike under Cross-Platform, Python, wxPython
View Comments
There’s a handy 3rd party module called pyPdf out there that you can use to merge PDFs documents together, rotate pages, split and crop pages, and decrypt/encrypt PDF documents. In this article, we’ll take a look at a few of these functions and then create a simple GUI with wxPython that will allow us to merge a couple of PDFs. (more…)
Fri 14 May 2010
How to Send Email with Python
Posted by Mike under Cross-Platform, Python, System Administration
View Comments
Where I work, we run a number of login scripts written in Python. When an error occurs in one of those scripts, we want to know. So we wrote a simple Python script to email the error to us. Since then, I’ve needed to figure out a way to send attachments with some of my more advanced scripts. If you’re a long-time reader of this blog, then you may remember wxPyMail, which was a simple wxPython program that could send email. In this article, you’ll discover how to send email with just Python’s standard library. We will focus on smtplib and the email modules. (more…)
Tue 11 May 2010
wxPython: An Introduction to XRC
Posted by Mike under Cross-Platform, Python, wxPython
View Comments
Have you ever wondered if you could create a wxPython program using XML? Well, I never did either, but there is a way and its name is XRC. In fact, wxPython comes with an editor called XRCed that you can use to layout your GUI and generate the XML code with. In this article, we’ll give you a quick walk-through of XRC and how to use it to create a couple GUI skeletons. We will look at two examples that use only XRC controls and then a third that mixes in some additional non-XRC widgets. (more…)
Fri 7 May 2010
May 2010 Pyowa Wrap-up
Posted by Mike under Pyowa
View Comments
Last night, we had our May 2010 Pyowa meeting. It is the only Python Users Group in Iowa and we welcome anyone who is programming in Python (or interested in learning Python) to come and be a part of our group. At this meeting, we had three good presentations. The first was given by Jim and his topic was web scraping. He uses a combination of Mechanize and lxml to scrape the Ames City website for archival purposes on one of his own websites.
Mechanize allows Jim to impersonate a browser and navigate a website. It can fill in forms, login with your supplied credentials, etc. He then uses lxml to parse the pages he wants and if he needs to download something, he just uses os.system in conjunction with wget. The beautiful soup library was also mentioned, but Jim didn’t use it. One of our other members said that their organization did use beautiful soup for a while and was pleased with the results.
Our next two presentations were given by a fellow named Kevin. He spoke on the Mercurial distributed version control system and Trac, a web-based issue tracker. Kevin walked us through how to set up a Mercurial repository, add files, branch, update, merge and more. He did all this using virtualenv, a handy way to isolate projects. After completing the Mercurial talk, Kevin showed us how to set up Trac with his Mercurial repository, add tickets, commit fixes to the tickets from within Mercurial, and various administration tools that are included with Trac. Kevin also highlighted some of the Trac and Mercurial plugins that he liked.
If you would like to come to our next meeting, it will be held at the same location, the Ames Public Library in Ames, IA on June 3rd, which is a Thursday. If you would like to share your experiences with Python or one of its many projects, that would be great! Please email me at mike at pythonlibrary dot org so we can get you scheduled. Watch our website for the most up-to-date information.