![]() ![]() Print "Error getting pid #%s information" % pid Gets all the process information we need as psutil isn't very fast Note that we also need to use wx.CallAfter to call pubsub as pubsub is not thread-safe. In this second version, we add threading and pubsub to make passing information from the thread to the GUI easier. Adding Threading to the Application for Alpha 2 That's annoying! So let's add threading to fix that issue. Can you tell what it is? Well the process for getting the process information is kind of slow so the GUI pauses every 5 seconds. There's a fairly obvious issue with this implementation. Wx.Frame._init_(self, None, title="PyProcMon") #ColumnDefn("description", "left", 200, "desc") Self.Bind(wx.EVT_TIMER, self.update, self.timer)ĬolumnDefn("exe location", "left", 100, "exe"),ĬolumnDefn("username", "left", 75, "user"), MainSizer.Add(self.procmonOlv, 1, wx.EXPAND|wx.ALL, 5) ![]() Self.procmonOlv = ObjectListView(self, style=wx.LC_REPORT|wx.SUNKEN_BORDER) I used the ObjectListView widget to display the data, which isn't actually included in wxPython, so you'll need to go grab that if you want to run the code.įrom ObjectListView import ObjectListView, ColumnDefnĭef _init_(self, name, pid, exe, user, cpu, mem, desc=None): My first version just shows what's currently running at the time the application itself is run and uses a wx.Timer to update every 5 seconds. If you have a moment, you can come along for the journey as I take you through 4 iterations of my code. So I thought it would be fun to put a GUI on top of it and create my own Task Manager / Process Monitor application with wxPython. What it does is grab all the running processes and gives you information on them and also gives you the ability to terminate them. It says it works on Linux, Windows, OSX and FreeBSD. This week, I came across a fun Python project named psutil on Google Code. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |