def Attach(self): if self.detached: self.detached = False self.Frame.Hide() self.Frame.Main = None self.Frame.GetSizer().Detach(self) self[0].Hide() self.Layout() if 1 in self: self[1].Func = self.OnBegin if not self.IsShown(): self.Show() self.Reparent(self.Harbor.Inner) self.Head = AttachedHead(self.Harbor.Inner, tag=self.Widget.NAME, pic=self.R["AP_ABORT"][0], func=(self.Harbor.OnChild, self)) self.Sash = UI.Sash(self.Harbor.Inner, target=self, direction="T", vRange=(2, 600), func=((self.Harbor.SetActualSize,), self.Harbor.Inner.Layout, self.Harbor.ReDraw), res="D") self.Harbor.Inner.GetSizer().AddMany(( (self.Head, SF_HEAD), (self, SF_MAIN), (self.Sash, SF_SASH) )) self.Harbor.SetActualSize() self.Harbor.ReDraw() if not self.Harbor.IsShown(): self.Harbor.GetParent().HiderR.Click() self.Widget.Canvas.ReDraw()
def __init__(self, r, s, l, m): super().__init__(parent=None, title=l["TITLE"], pos=s["LAST_POS"], size=s["LAST_SIZE"], style=wx.DEFAULT_FRAME_STYLE | wx.FULL_REPAINT_ON_RESIZE) self.R = r self.S = s self.L = l self.M = m self.D = {} self.T = { "LAST_FILE": "", } self.SetStatus = UI.DoNothing self.SetDoubleBuffered(True) self.SetMinSize(wx.Size(800, 600)) self.SetIcon(self.R["__LabPype__"]) self.SetFont(self.R["FONT_N"]) self.Bind(wx.EVT_CLOSE, self.OnClose) if self.S["MAXIMIZED"]: self.Maximize() self.Tool = UI.Tool(self, edge=("", "B")) self.Info = UI.Info(self, edge=("T", "")) self.Gadget = Gadget(self, size=wx.Size(self.S["WIDTH_GADGET"], -1)) self.Canvas = Canvas(self) self.Harbor = Harbor(self, size=wx.Size(self.S["WIDTH_HARBOR"], -1)) self.Manage = None self.Center = UI.BaseControl(self, size=wx.Size(-1, self.S["HEIGHT_CENTER"]), edge=("LR", "")) self.Record = Record(self.Center) self.SashC = UI.Sash(self, target=self.Center, direction="B", vRange=(0, 250), edge=("LR", "T")) self.SashL = UI.Sash(self, target=self.Gadget, direction="L", vRange=(0, 384), edge=("T", "RB")) self.SashR = UI.Sash(self, target=self.Harbor, direction="R", vRange=(0, 600), edge=("T", "LB")) self.HiderC = UI.Hider(self, targets=(self.Center, self.SashC), orientation="H", edge=("LR", "B")) self.HiderL = UI.Hider(self, targets=(self.Gadget, self.SashL), edge="H") self.HiderR = UI.Hider(self, targets=(self.Harbor, self.SashR), edge="H") self.HiderC.SetTip(self.SetStatus, self.L["HIDER_CENTER"]) self.HiderL.SetTip(self.SetStatus, self.L["HIDER_GADGET"]) self.HiderR.SetTip(self.SetStatus, self.L["HIDER_HARBOR"]) self.AcceleratorEntries = [] for flags, keyCode, func in ( (wx.ACCEL_NORMAL, wx.WXK_F3, self.HiderL.Click), (wx.ACCEL_NORMAL, wx.WXK_F4, self.HiderC.Click), (wx.ACCEL_NORMAL, wx.WXK_F5, self.HiderR.Click), (wx.ACCEL_CTRL, ord("F"), lambda evt: self.Gadget.Tool["GADGET_SEARCH"].SetFocus()), (wx.ACCEL_CTRL, ord("D"), self.Gadget.Tool["GADGET_CANCEL"].Click), (wx.ACCEL_CTRL, ord("E"), self.Gadget.Tool["TOOL_T_SHOW"].Click), (wx.ACCEL_CTRL, ord("R"), self.Gadget.Tool["TOOL_T_TEXT"].Click), (wx.ACCEL_CTRL, ord("W"), self.Gadget.Tool["TOOL_MANAGE"].Click), (wx.ACCEL_CTRL, ord("A"), lambda evt: self.Canvas.SelectAll()), ): cmd = wx.NewId() self.Bind(wx.EVT_MENU, func, id=cmd) self.AcceleratorEntries.append( wx.AcceleratorEntry(flags=flags, keyCode=keyCode, cmd=cmd)) self.Tool.AddItemsWithHotKey( ("N", "TOOL_OPTION", self.OnOption, wx.ACCEL_CTRL | wx.ACCEL_ALT, ord("S")), "|", ("N", "TOOL_FILE_N", self.OnNew, wx.ACCEL_CTRL, ord("N")), ("N", "TOOL_FILE_O", (self.OnMakeDialog, "DIALOG_HEAD_LOAD", LoadDialog, { "buttons": False }), wx.ACCEL_CTRL, ord("O")), ("N", "TOOL_FILE_S", (self.OnMakeDialog, "DIALOG_HEAD_SAVE", SaveDialog, { "buttons": False }), wx.ACCEL_CTRL, ord("S")), "|", ("T", "TOOL_T_ANCR", (self.OnToggle, "TOGGLE_ANCR"), wx.ACCEL_NORMAL, wx.WXK_F6, { "toggle": self.S["TOGGLE_ANCR"] }), ("T", "TOOL_T_NAME", (self.OnToggle, "TOGGLE_NAME"), wx.ACCEL_NORMAL, wx.WXK_F7, { "toggle": self.S["TOGGLE_NAME"] }), ("T", "TOOL_T_SNAP", (self.OnToggle, "TOGGLE_SNAP"), wx.ACCEL_NORMAL, wx.WXK_F8, { "toggle": self.S["TOGGLE_SNAP"] }), ("T", "TOOL_T_CURV", self.Canvas.ToggleLinkType, wx.ACCEL_NORMAL, wx.WXK_F9, { "toggle": self.S["TOGGLE_CURV"] }), ("T", "TOOL_T_DIAG", self.OnToggleDialogSize, wx.ACCEL_NORMAL, wx.WXK_F10, { "toggle": 0 }), ("T", "TOOL_T_FSCN", self.OnToggleFullScreen, wx.ACCEL_NORMAL, wx.WXK_F11, { "toggle": 0 }), "|", ("N", "TOOL_ALGN_L", (self.Canvas.Align, Ut.AlignL), wx.ACCEL_CTRL, wx.WXK_NUMPAD4), ("N", "TOOL_ALGN_V", (self.Canvas.Align, Ut.AlignV), wx.ACCEL_CTRL, wx.WXK_NUMPAD5), ("N", "TOOL_ALGN_R", (self.Canvas.Align, Ut.AlignR), wx.ACCEL_CTRL, wx.WXK_NUMPAD6), ("N", "TOOL_ALGN_T", (self.Canvas.Align, Ut.AlignT), wx.ACCEL_CTRL, wx.WXK_NUMPAD8), ("N", "TOOL_ALGN_H", (self.Canvas.Align, Ut.AlignH), wx.ACCEL_CTRL, wx.WXK_NUMPAD0), ("N", "TOOL_ALGN_B", (self.Canvas.Align, Ut.AlignB), wx.ACCEL_CTRL, wx.WXK_NUMPAD2), "|", ("N", "TOOL_DIST_H", (self.Canvas.Distribute, Ut.DistributeH), wx.ACCEL_CTRL, ord("H")), ("N", "TOOL_DIST_V", (self.Canvas.Distribute, Ut.DistributeV), wx.ACCEL_CTRL, ord("V")), "|", ("N", "TOOL_MOVE_T", (self.Canvas.AlterLayer, "T"), wx.ACCEL_CTRL, wx.WXK_NUMPAD9), ("N", "TOOL_MOVE_U", (self.Canvas.AlterLayer, "U"), wx.ACCEL_CTRL, wx.WXK_NUMPAD7), ("N", "TOOL_MOVE_D", (self.Canvas.AlterLayer, "D"), wx.ACCEL_CTRL, wx.WXK_NUMPAD1), ("N", "TOOL_MOVE_B", (self.Canvas.AlterLayer, "B"), wx.ACCEL_CTRL, wx.WXK_NUMPAD3), "|", ("N", "TOOL_CANCEL", self.OnDismissAllDialog, wx.ACCEL_CTRL, wx.WXK_DELETE, { "res": "R" }), ("N", "TOOL_DELETE", self.Canvas.DeleteSelected, wx.ACCEL_NORMAL, wx.WXK_DELETE, { "res": "R" }), ) self.Info.AddItems((wx.StaticText(self.Info, size=(268, 16)), 0), (wx.StaticText(self.Info, size=(-1, 16)), 1), (wx.StaticText(self.Info, size=(268, 16)), 0)) self.SetAcceleratorTable(wx.AcceleratorTable(self.AcceleratorEntries)) CenterSizer = wx.BoxSizer(wx.HORIZONTAL) CenterSizer.Add(self.Record, 1, wx.EXPAND | wx.ALL, 1) self.Center.SetSizer(CenterSizer) MiddleSizer = wx.BoxSizer(wx.VERTICAL) MiddleSizer.AddMany(( (self.Canvas, 1, wx.EXPAND), (self.SashC, 0, wx.EXPAND), (self.Center, 0, wx.EXPAND), (self.HiderC, 0, wx.EXPAND), )) MainSizer = wx.BoxSizer(wx.HORIZONTAL) MainSizer.AddMany(( (self.HiderL, 0, wx.EXPAND), (self.Gadget, 0, wx.EXPAND), (self.SashL, 0, wx.EXPAND), (MiddleSizer, 1, wx.EXPAND), (self.SashR, 0, wx.EXPAND), (self.Harbor, 0, wx.EXPAND), (self.HiderR, 0, wx.EXPAND), )) FrameSizer = wx.BoxSizer(wx.VERTICAL) FrameSizer.AddMany(( (self.Tool, 0, wx.EXPAND), (MainSizer, 1, wx.EXPAND), (self.Info, 0, wx.EXPAND), )) self.SetSizer(FrameSizer) self.Layout() if not self.S["SHOW_GADGET"]: self.HiderL.OnHider() if not self.S["SHOW_HARBOR"]: self.HiderR.OnHider() if not self.S["SHOW_CENTER"]: self.HiderC.OnHider() self.M.Init(self)