3

I have a very weird problem at the moment and I hope you'll be able to reproduce it. Please try the following Python code:

import gtk print '=== 1 ===' def _createFileDialog(): dialog = gtk.FileChooserDialog() print dialog.get_current_folder(), '***' dialog.set_current_folder('/home/') print dialog.get_current_folder(), '###' dialog = _createFileDialog() print '=== 2 ===' dialog = gtk.FileChooserDialog() print dialog.get_current_folder(), '***' dialog.set_current_folder('/home/') print dialog.get_current_folder(), '###' 

As you can see, the code sections are basically the same, so you might expect the same results. However, during the first section, the line ending with '###' prints 'None ###', while the second section correctly prints '/home ###'. I re-tried this on two different computers of my colleagues, and on one computer this was reproducable. Does anybody know what the problem might be?

Nice greetings and thanks in advance Chris

1 Answer 1

2

It can also print "None ###" in both cases.

The call to set_current_folder seems to be asynchronous, it works as expected if you let GTK handle pending events before calling get_current_folder:

dialog = gtk.FileChooserDialog() print dialog.get_current_folder(), '***' dialog.set_current_folder('/home/') while gtk.events_pending(): gtk.main_iteration() print dialog.get_current_folder(), '###' 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.