Exemplo n.º 1
0
def SendReplaceEvent(td, w=None, a1=None, a2=None, 
                         hl=False, a1all=None, a2all=None):
    # events sent when figobj replaces its artist
    # this event is processed immediately using
    # process event in order to keep data consisntency

    if td.get_root_parent().app is None: return

    app = td.get_root_parent().app
    book = td.get_root_figobj()
    viewer = app.find_bookviewer(book)
    if viewer is None: return

    evt=TreeDictEvent(ArtistReplace, 
                      wx.ID_ANY)
    evt.a1 = a1
    evt.a2 = a2
    evt.hl = hl
    evt.a1all = a1all
    evt.a2all = a2all
    evt.SetTreeDict(td)
    if w is not None:
        evt.SetEventObject(deref_proxy(w))    
    else:
        evt.SetEventObject(viewer)
    handler=viewer.GetEventHandler()
    post_process_event(evt, handler, True)
Exemplo n.º 2
0
def SendChangedEvent(td, w=None, useProcessEvent=False):
    #print 'sending changed event', td
    #traceback.print_stack()

    # I wanted to avoid issuing this event too many.
    # so it records if this event is already in event
    # queue.
    # However, if the event is not processed properly, 
    # this approach could make a dead-lock.
    # Not running mainloop is one such case. 
    # there may be a better way to do this...
    if not wx.GetApp().IsMainLoopRunning(): return

    global changed_in_queue
    try:
       if td.get_root_parent().app is None: return
    except:
       return
#    if changed_in_queue: return
#    traceback.print_stack()
    evt=TreeDictEvent(Changed, wx.ID_ANY)
    evt.SetTreeDict(td)
    evt.SetEventObject(deref_proxy(w))

    handler=td.get_root_parent().app.GetEventHandler()
    post_process_event(evt, handler, useProcessEvent)
    changed_in_queue = changed_in_queue + 1
Exemplo n.º 3
0
def SendThreadStartEvent(td, w=None, thread=None, useProcessEvent=False):
    if td.get_root_parent().app is None: return

    handler=td.get_root_parent().app.GetEventHandler()
    evt = TreeDictEvent(ThreadStart, wx.ID_ANY)
    evt.thread = thread
    evt.SetTreeDict(td)
    evt.SetEventObject(deref_proxy(w))
    post_process_event(evt, handler, useProcessEvent)
Exemplo n.º 4
0
def SendCloseFileEvent(td, w=None, file=file):
    if td.get_root_parent().app is None: return

    handler=td.get_root_parent().app.GetEventHandler()
    evt = TreeDictEvent(CloseFile, wx.ID_ANY)
    evt.SetTreeDict(td)
    evt.SetEventObject(deref_proxy(w))
    evt.file = file
    post_process_event(evt, handler, True)
Exemplo n.º 5
0
def SendSimpleTDEvent2(evt, td=None, w=None, useProcessEvent=False):
#    if td.get_root_parent().app is None: return

    evt = TreeDictEvent(EditFile, wx.ID_ANY)
    evt.SetTreeDict(td)
    evt.SetEventObject(deref_proxy(w))
    handler = wx.GetApp().TopWindow.GetEventHandler()
#    handler=td.get_root_parent().app.GetEventHandler()
    post_process_event(evt, handler, useProcessEvent)
Exemplo n.º 6
0
def SendEditFileEvent(td, w=None, file=file, readonly=False):
#    if td.get_root_parent().app is None: return

    handler=td.get_root_parent().app.GetEventHandler()
    evt = TreeDictEvent(EditFile, wx.ID_ANY)
    evt.SetTreeDict(td)
    evt.SetEventObject(deref_proxy(w))
    evt.file = file
    evt.readonly = readonly
    post_process_event(evt, handler, True)
Exemplo n.º 7
0
def SendSimpleTDEvent(evt, td=None, w=None, useProcessEvent=False, code='', handler=None):
#    if td.get_root_parent().app is None: return

    if evt is None:
       evt = TreeDictEvent(EvtTDDict, wx.ID_ANY)
    evt.SetTreeDict(td)
    evt.SetEventObject(deref_proxy(w))
    evt.code = code
    if handler is None:
       handler = wx.GetApp().TopWindow.GetEventHandler()
    post_process_event(evt, handler, useProcessEvent)
Exemplo n.º 8
0
def SendVar0ChangedEvent(td, w=None):
#    if td.get_root_parent().app is None: return
    if not hasattr(td.get_root_parent(), 'app'): return
    if td.get_root_parent().app is None: return

    evt=TreeDictEvent(Var0Changed, wx.ID_ANY)
    evt.SetTreeDict(td)
    evt.SetEventObject(deref_proxy(w))    

    handler=td.get_root_parent().app.GetEventHandler()
#    handler.ProcessEvent(evt)
    post_process_event(evt, handler, False)
Exemplo n.º 9
0
def SendSelectionEvent(td, w=None, selections=[], mode='replace', useProcessEvent=True):
    # events sent when figobj is selected 
    # selections can be self.selection or self.axes_selection
    if td is None: return
    if td.get_root_parent().app is None: return

    evt=TreeDictEvent(ArtistSelection, 
                      wx.ID_ANY)
    evt.selections = selections
    evt.SetTreeDict(td)
    evt.SetEventObject(deref_proxy(w))    
    evt.event_name = 'selection'
    evt.mode=mode
    handler=td.get_root_parent().app.GetEventHandler()
    post_process_event(evt, handler, useProcessEvent)
Exemplo n.º 10
0
def SendFileChangedEvent(td, w=None, operation=None, param=None):
    '''
    opeartion 
    1) rename  : param = { "oldname": xxx , "newname": 
    2) delete  : param = { "oldname": xxx }
    '''

    if td.get_root_parent().app is None: return

    handler=td.get_root_parent().app.GetEventHandler()
    evt = TreeDictEvent(FileChanged, wx.ID_ANY)
    evt.op = operation
    evt.param = param
    evt.SetTreeDict(td)
    evt.SetEventObject(deref_proxy(w))
    post_process_event(evt, handler, False)
Exemplo n.º 11
0
def SendShowPageEvent(td, w=None, inc='0'):
    try:
        app =  td.get_root_parent().app
    except:
        return
    if app is None: return

    #inc = 1, -1, 'last', 'first'
    evt=TreeDictEvent(ShowPage, wx.ID_ANY)
    evt.SetTreeDict(td)
    if w is None:
        book = td.get_figbook()
        w = app.find_bookviewer(book).canvas
    evt.SetEventObject(deref_proxy(w))    
    evt.inc = inc
 
    if w is None:
       handler = td.get_root_parent().app.GetEventHandler()
    else:
       handler = w
    evt.BookViewerFrame_Processed = False
    post_process_event(evt, handler, True)