Beispiel #1
0
def start_blink(*args, **kwargs):

    global frame
    global sender
    global canvas

    parent = kwargs['parent']
    master = kwargs['master']

    ### parent is simulationGUI and parent of it can be wx main app or DetachedFrame
    mainW = parent.GetParent()

    ### find canvas depending on the parent of parent
    if isinstance(mainW, DetachedFrame):
        canvas = mainW.GetCanvas()
    else:
        nb = mainW.GetDiagramNotebook()
        actuel = nb.GetSelection()
        canvas = nb.GetPage(actuel)

    ### define diagram
    diagram = canvas.GetDiagram()

    ### define frame
    frame = BlinkFrame(parent, wx.ID_ANY, _('Blink Logger'))
    frame.SetIcon(mainW.GetIcon())
    frame.SetTitle("%s Blink Logger" %
                   os.path.basename(diagram.last_name_saved))
    frame.Show()

    ### define sender
    sender = Subject()
    sender.canvas = canvas
    sender.__state = {}
    sender.GetState = MethodType(GetState, sender)

    for block in diagram.GetFlatBlockShapeList():
        #### add model d to observer list
        sender.attach(block)
        state = sender.GetState()
        state['status_label'] = ""
        sender.notify()
        sender.detach(block)

    ### disable suspend and log button
    parent._btn3.Disable()
    parent._btn4.Disable()