Exemplo n.º 1
0
def wxEnableEvents():
    """This will import wxPython and simplify the process of sending thread events.

    Probably it's better to use the Stunt class from this module with a timer event.
    """
    from wxPython import wx
    global wxEVT_THREAD_TYPE,connect,event,postEvent
    wxEVT_THREAD_TYPE=wx.wxNewEventType()

    def connect(win):
        """Connects the thread event of win with the onThread method.

        Make sure the onThread method is defined for this dialog win.
        """
        win.Connect(-1, -1, wxEVT_THREAD_TYPE, win.onThread)

    class Event(wx.wxPyEvent):
        """Makes an event of the wxEVT_THREAD_TYPE."""
        def __init__(self, **keywords):
            self.__dict__=keywords
            wx.wxPyEvent.__init__(self)
            self.SetEventType(wxEVT_THREAD_TYPE)

    def postEvent(win,**keywords):
        """Post an event from within a thread to the dialog win."""
        wx.wxPostEvent(win,Event(**keywords))
Exemplo n.º 2
0
def wxEnableEvents():
    """This will import wxPython and simplify the process of sending thread events.

    Probably it's better to use the Stunt class from this module with a timer event.
    """
    from wxPython import wx
    global wxEVT_THREAD_TYPE, connect, event, postEvent
    wxEVT_THREAD_TYPE = wx.wxNewEventType()

    def connect(win):
        """Connects the thread event of win with the onThread method.

        Make sure the onThread method is defined for this dialog win.
        """
        win.Connect(-1, -1, wxEVT_THREAD_TYPE, win.onThread)

    class Event(wx.wxPyEvent):
        """Makes an event of the wxEVT_THREAD_TYPE."""
        def __init__(self, **keywords):
            self.__dict__ = keywords
            wx.wxPyEvent.__init__(self)
            self.SetEventType(wxEVT_THREAD_TYPE)

    def postEvent(win, **keywords):
        """Post an event from within a thread to the dialog win."""
        wx.wxPostEvent(win, Event(**keywords))
Exemplo n.º 3
0
# Written by Bram Cohen
# modified for multitracker by John Hoffman
# see LICENSE.txt for license information

import sys
import os
import threading
from BitTornado.BT1.makemetafile import make_meta_file, completedir
from BitTornado.Info import MetaInfo
try:
    from wxPython import wx
except:
    print 'wxPython is not installed or has not been installed properly.'
    sys.exit(1)

wxEVT_INVOKE = wx.wxNewEventType()


def EVT_INVOKE(win, func):
    win.Connect(-1, -1, wxEVT_INVOKE, func)


class InvokeEvent(wx.wxPyEvent):
    def __init__(self, func, args, kwargs):
        super(InvokeEvent, self).__init__()
        self.SetEventType(wxEVT_INVOKE)
        self.func = func
        self.args = args
        self.kwargs = kwargs