[gedit-list] Question On Using Threads From A Plugin's Menu Item Handler



   Hello,

In some plugin, I'd like to launch a thread to do some work when the user clicks some menu item. The problem is that the thread doesn't seem to ever launch.

   Following is the simplest version of the problem.

   First is the worker thread; its run method just prints that its running.

<code>
class worker_thread(threading.Thread):
   def run(self):
       print 'worker thread running'
</code>

Now here's the plugin-instance's menu-item handler; it just prints that it's been activated, then launches a worker thread.

<code>
   def on_foo_menu_item_activate(self):
       print 'activated'
t = worker_thread() t.start()
</code>

   So when the user clicks the item, I'd expect to see:
<output>
activated
worker thread running
</output>

   Unfortunately, the 2nd line never appears.

Could someone please tell me what I'm doing wrong? I'd sure appreciate it...

   Thanks & Bye,

   Ami




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