문제

I am trying to learn how to run a thread off the main GUI app to do my serial port sending/receiving while keeping my GUI alive. My best Googling attempts have landed me at the wxpython wiki on: http://wiki.wxpython.org/LongRunningTasks which provides several examples. I have settled on learning the first example, involving starting a worker thread when the particular button is selected.

I am having trouble understanding the custom-event-definition:

def EVT_RESULT(win, func):
    """Define Result Event."""
    win.Connect(-1, -1, EVT_RESULT_ID, func)

class ResultEvent(wx.PyEvent):
    """Simple event to carry arbitrary result data."""
    def __init__(self, data):
        """Init Result Event."""
        wx.PyEvent.__init__(self)
        self.SetEventType(EVT_RESULT_ID)
        self.data = data

Primarily the

def EVT_RESULT(win, func):
    """Define Result Event."""
    win.Connect(-1, -1, EVT_RESULT_ID, func)

I think EVT_RESULT is placed outside the classes so as to make it call-able by both classes (making it global?)

And.. the main GUI app monitors the thread's progress via:

# Set up event handler for any worker thread results
EVT_RESULT(self,self.OnResult)

I also notice that in a lot of examples, when the writer uses

from wx import *

they simply bind things by

EVT_SOME_NEW_EVENT(self, self.handler)

as opposed to

wx.Bind(EVT_SOME_NEW_EVENT, self.handler)

Which doesn't help me understand it any faster. Thanks,

도움이 되었습니까?

해결책

변경 사항을 한 후에 콘텐츠가 올바르게 다시 인덱싱 되었습니까?버전 및 환경 설정에 따라 컨텐츠가 크롤링 될 때까지 새 권한이 검색 결과에 적용되지 않을 수 있습니다.

다른 팁

That's the old style of defining custom events. See the migration guide for more information.

Taken from the migration guide:

If you create your own custom event types and EVT_* functions, and you want to be able to use them with the Bind method above then you should change your EVT_* to be an instance of wx.PyEventBinder instead of a function. For example, if you used to have something like this:

myCustomEventType = wxNewEventType()
def EVT_MY_CUSTOM_EVENT(win, id, func):
    win.Connect(id, -1, myCustomEventType, func)

Change it like so:

myCustomEventType = wx.NewEventType()
EVT_MY_CUSTOM_EVENT = wx.PyEventBinder(myCustomEventType, 1)

Here is another post that I made with a couple of example programs that do exactly what you are looking for.

One 옵션은 전자 메일을 전자 메일로 보내서 파일을 보내려는 경우이 전자 메일 주소를 사용하여 SharePoint 서버를 전자 메일로 보내고 보고서를 문서 라이브러리에 저장합니다.나는 SSRS 서버가 아닌 SSRS 서버가없는 과거 의이 기술을 SharePoint에 대한 일정에 대한 보고서를 제공했습니다.

SharePoint 팜이 들어오는 이메일이 구성된 이메일을 가정합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top