PyWin32


There are a couple of ways to create Microsoft Excel spreadsheets with Python. You can use PyWin32’s win32com.client method, which was discussed in an old article a number of years ago or you could use the xlwt package. We’ll be looking at the latter in this article. You will learn how to create an Excel spreadsheet with multiple worksheets and how to create styled cells. Let’s get started! (more…)

Last week, there was an interesting thread on the PyWin32 mailing list about how to read Microsoft Access databases with Python without having Access actually installed. Vernon Cole had the solution, but I noticed that Google doesn’t seem to index the PyWin32 list very well, so I decided to write about it here. (more…)

A lot of websites are doing year-end retrospectives this week, so I thought you might find it interesting to know which articles on this blog were the most popular this year. Below you will find links to each article along with the page view count I got from Google Analytics:

  1. A Simple Step-by-Step Reportlab Tutorial, 9,709 page views, posted 03/08/2010
  2. Another Step-by-Step SqlAlchemy Tutorial Part 1, 7,746 page views, posted 02/03/2010
  3. Another Step-by-Step SqlAlchemy Tutorial Part 2, 4,858 page views, posted 02/03/2010
  4. Manipulating PDFs with Python and pyPdf, 4,511 page views, posted 05/15/2010
  5. Python 101: Introspection, 4,473 page views, posted 10/14/2010
  6. wxPython: Grid Tips and Tricks, 3,476 page views, posted 04/04/2010
  7. wxPython: Creating a Simple MP3 Player, 3,401 page views, posted 04/20/2010
  8. Python and Microsoft Office – Using PyWin32, 3,323 page views, posted 07/16/2010
  9. wxPython and Threads, 3,183 page views, posted 05/22/2010

It would seem that SqlAlchemy and Reportlab are pretty popular topics. Are there any articles about either of these cool packages that you think I should write? As you can see, wxPython makes it into the top ten 3 times! What should I write about next regarding wxPython?

This upcoming year, I plan to write about some of the other GUI toolkits. Which one do you think I should do first? Tkinter, PySide, PyGUI or something else? What packages or standard libraries do you think I should cover? Feel free to let me know via the comments below or via my contact form (link at top). I’m looking forward to another year of Python tinkering and writing and I hope you are too! Thanks for your readership and encouragement this year!

Most typical users have used Microsoft Office. While Office may be the bane of tech support, we still have to deal with it. Python can be used to script (AKA automate) Office and make it easier for us or our users to use. It may not be as easy as recording a macro, but it’s close. For this article, you will learn how to use the PyWin32 module to access some of the Office programs and manipulate them with Python. Some forums say that you need to run PythonWin’s makepy utility on Microsoft Word (and Excel) before you can access Office applications. I don’t think I needed to do that to make it work though (at least, not with the 2007 version). However, PythonWin comes with the PyWin32, so if you do run into trouble, you can try it. (more…)

Back when I first wrote about creating shortcuts with Python last month, I kept thinking to myself that I had a 3rd way of doing it. Today, I had to maintain some of my shortcut code and I stumbled upon it once more. I also noticed that my post had received a comment from Tim Golden on yet another way to create shortcuts, so I’ll include that in this post as well. (more…)

The past couple of days, I’ve needed a way to create a shortcut on a user’s desktop during the login process. I had a way that worked for most shortcuts, but I just could not figure out how to do this one.

(more…)

One of the first scripts I had to help translate from Kixtart to Python was our map drives script. In it, we would map drives based on either which group the user was in and/or what a custom registry entry said. Here is a partial example of each of these categories in Kixtart:

IF READVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\MyOrg", "Office")= "officeName"
$Drive="g:" $Path="\\serverName\" + @userid Call "@lserver\\folderName"
ENDIF
 
IF InGroup("Dept XYZ")
$Drive="g:" $Path="\\serverName\" + @userid Call "@lserver\\folderName"
ELSE
ENDIF

(more…)

We’ve been discussing how to use OpenVPN with Python in the last two articles. In this final post, I’ll show how to bring it all together into a GUI with some wxPython code. I’m also going to discuss some important snippets.

(more…)

This is the 2nd part of a 3-part series on using wxPython + PyWin32 to grab the output from an OpenVPN session on Windows. In this article, I will show how how to start OpenVPN with Python and how to watch a file that OpenVPN writes its data logs to.

(more…)

I’m doing a 3 part series on using wxPython and PyWin32 to capture output from a running OpenVPN session.

I use OpenVPN to connect to PCs at work. I noticed that our current method of launching OpenVPN was in a console window so that one could monitor the program’s output. If the user happened to close said window, it would end the VPN session. I thought this was dumb, so I decided that I would try wrapping the interface using wxPython in such a way that I can minimize it to the system tray and bring it back up on demand to check the output if I was having an issue. (more…)