Re: Gtk, Python, and Threading.



Alright, so threading is an absolute nightmare and I've tried every
different example I could find in every different way I could think
of. I peppered thread_enter/thread_leave everywhere I could possibly
imagine, and the thread just plain blocks. Even if the entirety of the
thread code is just a single print statement, it blocks until the
interface gets clicked.

I. Give. Up.

I'm looking at using Gio.File().read_async() instead, but thankfully
there's not a lick of documentation that makes any sense whatsoever.

class GeoNamesDownloader(object):
    def get(self, data, url):
        self.stream = Gio.File(url)
        self.stream.read_async(self.read)

    def read(self, gdaemonfile, result):
        print self.stream.read_finish(result).read()[:100]

GeoNamesDownloader().get(None, 'http://www.google.ca')

This is almost word for word from the pygobject documentation, and
this is the result:

Traceback (most recent call last):
  File "./gottengeography.py", line 1306, in <module>
    GeoNamesDownloader().get(None, 'http://www.google.ca')
  File "./gottengeography.py", line 1300, in get
    self.stream = Gio.File(url)
TypeError: GInterface.__init__() takes exactly 0 arguments (1 given)

RAAAAAAAAAAAAAAAAAAAAAAAAAAGE!!!!!!!!!!

(and if I take out the argument, I get this)

Traceback (most recent call last):
  File "./gottengeography.py", line 1306, in <module>
    GeoNamesDownloader().get(None, 'http://www.google.ca')
  File "./gottengeography.py", line 1300, in get
    self.stream = Gio.File()
NotImplementedError: File can not be constructed

Fun.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]