Archaeopteryx Software, Inc.
Take Flight!Search

Wing IDE
About Us
Open Source

 Advanced Search

[wingide-users] Another one

Stephan R.A. Deibel
Mon, 24 Sep 2001 18:24:55 -0400 (EDT)

On Mon, 24 Sep 2001, Ken Kinder wrote:
> I don't know what causes this. I have a function that looks something
> like this:
>     def browse(self, *args):
>         win = GtkFileSelection("Select File to Export")
>         win.connect("delete_event", win.hide)
>         def file_selection_ok(_button, fs=win):
> *           self.file.set_text(fs.get_filename())
>         win.ok_button.connect("clicked", file_selection_ok)
>         win.cancel_button.connect("clicked", win.hide)
> The * is a breakpoint. As you can tell, this shows a file selection
> box. The breakpoint should invoke when the user selects a file. It
> does, but when it happens, WingIDE and my whole X server freeze. I
> have to ctrl+alt+backspace out of it. As you can tell, that line would
> generate an error because self is out of scope. On the command line it
> gracefully tracebacks. In Wing, with or without the breakpoint, it
> crashes the X server.

We have been able to reproduce this in about 1 out of 15 tries... it's a
timing issue inside gtk, so I hope it's at least that intermittent for you
also.  The problem is caused by our semi-incorrect use of nested gtk
mainloop() calls, something we already knew about and plan to fix in the
next beta (but unfortunately isn't a quick fix).

Since you're using gtk also, be warned that calling gtk.mainloop() more
than once is bad.  Although seen in many gtk examples, it is really just a
great way to add some bugs to your program!

> There's probably a conflict or something. BTW, if you can offer a suggestion
> on how to get self in scope I would love that. I'm not too experienced
> with GUI programming in Python. :)

Try this for the nested def:

  def file_selection_ok(_button, fs=win, s=self):

- Stephan

Run by Mailman v 2.0.8

Copyright (c) 2000-2002, Archaeopteryx Software, Inc.
Legal Statements