Memory Leak with Tkinter Canvas (Python 2.5 Win32)
Hey everyone. I have been working with python for a couple years now, but just recently built my first program with a GUI. I decided to start with Tkinter since it is included with the base package, although wxWindows will likely be my next choice. Tkinter seems to be pretty slow for my needs. Anyway - I am building a genetic algorithm simulator. I have a grid where an Ant moves around. It is infeasible for me to update the grid every simulation step - so I just do it at the end. But what I've realized is that my program performs worse and worse when I update the grid. Turns out there is a memory leak somewhere and I don't think it is in my code. The memory leak occurs only when I write (via create_rectangle) to the canvas widget. I wrote the following small script to demonstrate this problem (see below). Every time the button is pressed, _1040KB_ is added to the RAM of wpython.exe. This adds up FAST. I have not verified this on my OS X box. As you can see- I am doing nothing other than drawing a lot of rectangles on the canvas. I have two questions. 1. Is this a bug in my usage of Tkinter? Am I somehow leaving objects laying around that aren't being deleted? Is create_rectangle not the appropriate function to use?) 2. Is there a better, quicker way to update a "grid"-like object? Thanks, Blaine Current System: Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32 Windows XP SP2 - all recent patches and updates Script: from Tkinter import * canv = None HEIGHT=600 WIDTH=600 def clear_grid(): for i in range(0,HEIGHT/10): for j in range(0, HEIGHT/10): canv.create_rectangle(i*10,j*10, \ i*10+10, j*10+10, \ fill = "white") def draw_window(master): global canv frame = Frame(master) btn_grid = Button(frame, text="draw grid", command=clear_grid) btn_grid.pack(side=TOP) canv = Canvas(frame, height=HEIGHT, width=WIDTH, bg='white') canv.pack() frame.pack() root = Tk() draw_window(root) mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: Memory Leak with Tkinter Canvas (Python 2.5 Win32)
On Aug 3, 2:26 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > "frikk" wrote: > > 1. ... Am I somehow leaving > > objects laying around that aren't being deleted? Is create_rectangle > > not the appropriate function to use?) > > Try calling the canvas's delete method with the old rectangle before > making a new one. > > - Hendrik Hey guys- Both of your suggestions were perfect - I was just unaware I was actually creating new *object* instead of drawing on the canvas. noob mistake. Thanks again! -Blaine -- http://mail.python.org/mailman/listinfo/python-list
wxWindows - incorrect path on installation?
This should be a very simple one, sorry! I installed wxWindows on my OS X box but I am unable to get my python install to recognize the module. Unfortunately I don't know a whole lot about where modules install to or how to configure python to see them. IE: 'import wx' does not work - it says unknown module wx. Do I need to tweak a path variable or something? I have MacPython installed and the binary of wxWindows (wxPython) from wxpython.com Thanks guys, Blaine -- http://mail.python.org/mailman/listinfo/python-list
Python, Sharepoint, .NET, NTLM
Hey everyone, I need to authenticate with a Sharepoint server. It looks to be using 'NTLM' authentication. I've looked on the newsgroup and it looks like there has been talk of using python and NTLM but no definite solutions are apparent. Can anyone provide me with any kind of help on this issue? URLLIB2 keeps getting a 401 error when I try any kind of authentication. I am trying to use python here in my company (for obvious reasons - python is awesome!) and this is the first major project that would use it. Unfortunately if I cannot talk to Sharepoint (I am just trying to get a list of .xml files and data from a form library) I cannot use python. The other solution would be: Does anyone know how to get xml files from a sharepoint library in python? The worst case would be using another language to compile just the xml file downloader. This is not the optimal solution. Thank you, Blaine -- http://mail.python.org/mailman/listinfo/python-list
Accessing Windows Network Share?
I previously posted about accessing SharePoint over the web. Well I
have since given up any easy means of doing this, since something else
has perked my interest. Instead of going to http://sharepoint/site,
why not just access \\sharepoint\site\ directly?
So my question is this - How do I access that network share?
If I go to start -> run, and type in "\\SharPointServer\Site\Folder",
windows explorer will pop up with it. I suppose I could have a little
batch script that python runs to map the drive to a local letter, like
J:, but this does not seem necessary.
Suggestions?
This does not work, for obvious reasons:
>>> import glob.glob
>>> glob.glob("server\\folder\\*")
[]
Thanks guys!
Blaine
--
http://mail.python.org/mailman/listinfo/python-list
Re: Accessing Windows Network Share?
On Aug 16, 2:43 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> On 8/16/07, frikk <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > I previously posted about accessing SharePoint over the web. Well I
> > have since given up any easy means of doing this, since something else
> > has perked my interest. Instead of going tohttp://sharepoint/site,
> > why not just access \\sharepoint\site\ directly?
>
> > So my question is this - How do I access that network share?
>
> > If I go to start -> run, and type in "\\SharPointServer\Site\Folder",
> > windows explorer will pop up with it. I suppose I could have a little
> > batch script that python runs to map the drive to a local letter, like
> > J:, but this does not seem necessary.
>
> > Suggestions?
>
> > This does not work, for obvious reasons:
> > >>> import glob.glob
> > >>> glob.glob("server\\folder\\*")
> > []
>
> I don't see whats "obvious" about this. Access to windows shares is
> handled by Windows in a VFS layer, and glob and all other Python file
> access works fine over them for me.- Hide quoted text -
>
> - Show quoted text -
Haha ok, you're right its not obvious. Sorry for that.
But that code does not work - should it?
Do you have an example of glob working over a file share, not a
network mapped drive?
--
http://mail.python.org/mailman/listinfo/python-list
Re: Accessing Windows Network Share?
On Aug 16, 3:03 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> On 8/16/07, frikk <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On Aug 16, 2:43 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> > > On 8/16/07, frikk <[EMAIL PROTECTED]> wrote:
>
> > > > I previously posted about accessing SharePoint over the web. Well I
> > > > have since given up any easy means of doing this, since something else
> > > > has perked my interest. Instead of going tohttp://sharepoint/site,
> > > > why not just access \\sharepoint\site\ directly?
>
> > > > So my question is this - How do I access that network share?
>
> > > > If I go to start -> run, and type in "\\SharPointServer\Site\Folder",
> > > > windows explorer will pop up with it. I suppose I could have a little
> > > > batch script that python runs to map the drive to a local letter, like
> > > > J:, but this does not seem necessary.
>
> > > > Suggestions?
>
> > > > This does not work, for obvious reasons:
> > > > >>> import glob.glob
> > > > >>> glob.glob("server\\folder\\*")
> > > > []
>
> > > I don't see whats "obvious" about this. Access to windows shares is
> > > handled by Windows in a VFS layer, and glob and all other Python file
> > > access works fine over them for me.- Hide quoted text -
>
> > > - Show quoted text -
>
> > Haha ok, you're right its not obvious. Sorry for that.
>
> > But that code does not work - should it?
>
> > Do you have an example of glob working over a file share, not a
> > network mapped drive?
>
> import glob
> glob.glob(r"\\localhost\c$\python25\libs\*")
> ['localhost\\c$\\python25\\libs\\bz2.lib',
> 'localhost\\c$\\python25\\libs\\libpython25.a',
> 'localhost\\c$\\python25\\libs\\pyexpat.lib',
> 'localhost\\c$\\python25\\libs\\python25.lib',
> 'localhost\\c$\\python25\\libs\\select.lib',
> 'localhost\\c$\\python25\\libs\\unicodedata.lib',
> 'localhost\\c$\\python25\\libs\\winsound.lib',
> 'localhost\\c$\\python25\\libs\\_bsddb.lib',
> 'localhost\\c$\\python25\\libs\\_ctypes.lib',
> 'localhost\\c$\\python25\\libs\\_ctypes_test.lib',
> 'localhost\\c$\\python25\\libs\\_elementtree.lib',
> 'localhost\\c$\\python25\\libs\\_hashlib.lib',
> 'localhost\\c$\\python25\\libs\\_msi.lib',
> 'localhost\\c$\\python25\\libs\\_socket.lib',
> 'localhost\\c$\\python25\\libs\\_sqlite3.lib',
> 'localhost\\c$\\python25\\libs\\_ssl.lib',
> 'localhost\\c$\\python25\\libs\\_testcapi.lib',
> 'localhost\\c$\\python25\\libs\\_tkinter.lib']
>
> I do it all the time. I'd double check your slash escaping (consider
> using r'') and pathnames.- Hide quoted text -
>
> - Show quoted text -
I must have been doing it wrong. Thanks! That works great!
--
http://mail.python.org/mailman/listinfo/python-list
Real Time Embedded Systems Monitor in Python?
Hey Everyone! I've got a question regarding the capabilities of python in a real time environment. I'll start by saying I'm a little bit flaky when it comes to terminology, so please correct me or ask where it seems I'm not beings specific or using the wrong wording. I am looking into a project for the company I work for. Essentially it involves setting up a real time monitor / signal injector in between a CPU board and a system controller. The system controller sends signals (message packets) to the CPU board. We would like to create an environment where we can modify signals, inject new messages, drop signals, etc. This would simulate communication failures and message dropouts to see how the CPU board responds. The application monitor would use a COM port to send and receive messages. The most important part about this monitor is that absolutely no messages get delayed or dropped due to inturrupts or lag on the PC that the monitor is running on. What would be the expected sampling time range that I could expect to handle? I have seen similar applications written for other projects that we have which were done in Visual Basic. I assume that if VB is up to the task, Python should be as well. What kind of libraries am I looking at? I will probably use wxWindows, but what about for the serial ports and packet timing? Like I said - I'm not sure what kind of "real time" this is - all I know is that I need messages to not get dropped when they're received. Thanks! Blaine Booher -- http://mail.python.org/mailman/listinfo/python-list
