dialogs/IDManager.py
author Edouard Tisserant <edouard.tisserant@gmail.com>
Sat, 25 Nov 2023 00:18:05 +0100
changeset 3880 89549813a6c1
parent 3750 f62625418bff
permissions -rw-r--r--
SVGHMI: Fixes UI lifecycle problems

Was sometime showing HMI tree of previously closed project : no more module globals to store hmi tree.
C++ dead object exceptions happened when re-opening SVGHMI UI or building after close of UI.


import wx
from controls.IDBrowser import IDBrowser


class IDManager(wx.Dialog):
    def __init__(self, parent, ctr):
        self.ctr = ctr
        wx.Dialog.__init__(self,
                           name='IDManager', parent=parent,
                           title=_('URI Editor'),
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
                           size=(800, 600))
        # start IDBrowser in manager mode
        self.browser = IDBrowser(self, ctr)
        self.Bind(wx.EVT_CHAR_HOOK, self.OnEscapeKey)

    def OnEscapeKey(self, event):
        keycode = event.GetKeyCode()
        if keycode == wx.WXK_ESCAPE:
            self.EndModal(wx.ID_CANCEL)
        else:
            event.Skip()