From 286a94c77658bf491fbb3e17bf77e2bb057e691c Mon Sep 17 00:00:00 2001 From: Capocchi L Date: Thu, 5 Nov 2020 15:06:06 +0100 Subject: [PATCH] Add stay on top option to detached frame --- Container.py | 33 +++++++++++++++++++-------------- DetachedFrame.py | 26 +++++++++++++++++++------- Menu.py | 20 +++++++++++++++++--- icons/16x16/pin_in.png | Bin 0 -> 207 bytes icons/16x16/pin_out.png | Bin 0 -> 2887 bytes icons/pin_in.png | Bin 0 -> 311 bytes icons/pin_out.png | Bin 0 -> 676 bytes 7 files changed, 55 insertions(+), 24 deletions(-) create mode 100644 icons/16x16/pin_in.png create mode 100644 icons/16x16/pin_out.png create mode 100644 icons/pin_in.png create mode 100644 icons/pin_out.png diff --git a/Container.py b/Container.py index 2e8e25a7..908d0eda 100644 --- a/Container.py +++ b/Container.py @@ -76,6 +76,11 @@ import WizardGUI import LabelGUI + RED = '#d91e1e' + GREEN = '#90ee90' + BLACK = '#000000' + BLUE = '#add8e6' + import Components if builtins.__dict__.get('GUI_FLAG',True): @@ -1184,7 +1189,7 @@ class Shape(ShapeEvtHandler): """ Shape class """ - FILL = ['#add8e6'] + FILL = [BLUE] def __init__(self, x=[], y=[]): """ Constructor @@ -2814,7 +2819,7 @@ def __init__(self, line): """ Shape.__init__(self) - self.fill = ['#d91e1e'] + self.fill = [RED] self.x = array.array('d', line.x) self.y = array.array('d', line.y) @@ -3847,7 +3852,7 @@ class ContainerBlock(Block, Diagram): """ ContainerBlock(label, inputs, outputs) """ - FILL = ['#90ee90'] + FILL = [GREEN] ### def __init__(self, label = 'ContainerBlock', nb_inputs = 1, nb_outputs = 1): @@ -4114,7 +4119,7 @@ def draw(self, dc): x,y = self.item.getPortXY('input', self.index) self.moveto(x, y) - self.fill = ['#00b400'] #GREEN + self.fill = [GREEN] dc.SetFont(wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL)) @@ -4185,7 +4190,7 @@ def draw(self, dc): """ x,y = self.item.getPortXY('output', self.index) self.moveto(x, y) - self.fill = ['#ff0000'] + self.fill = [RED] dc.SetFont(wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL)) #dc.SetPen(wx.Pen(wx.NamedColour('black'), 20)) @@ -4225,7 +4230,7 @@ def __init__(self, item, index, cf, t = 'rect'): """ Node.__init__(self, item, index, cf, t) - self.fill = ['#000000'] #BLACK + self.fill = [BLACK] def draw(self, dc): """ Drawing method. @@ -4325,7 +4330,7 @@ def draw(self, dc): """ CircleShape.draw(self, dc) - w,h = dc.GetTextExtent(self.label) + w,h = dc.GetTextExtent(self.label) ### label position manager if self.label_pos == 'bottom': @@ -4342,8 +4347,8 @@ def draw(self, dc): dc.DrawText(self.label, mx, my) if self.lock_flag: - img = wx.Bitmap(os.path.join(ICON_PATH_16_16, 'lock.png'),wx.BITMAP_TYPE_ANY) - dc.DrawBitmap( img, self.x[0]+w/3, self.y[0]) + img = wx.Bitmap(os.path.join(ICON_PATH_16_16, 'lock.png'),wx.BITMAP_TYPE_ANY) + dc.DrawBitmap(img, self.x[0]+w/3, self.y[0]) def leftUp(self, event): """ Left up event has been invoked. @@ -4403,15 +4408,15 @@ def __repr__(self): #------------------------------------------------------------------ class iPort(Port): - """ IPort(label) + """ IPort(label) for ContainerBlock (coupled model) """ def __init__(self, label = 'iPort'): - """ Constructor + """ Constructor. """ Port.__init__(self, 50, 60, 100, 120, label) - self.fill= ['#add8e6'] # fill color + self.fill= [GREEN] #self.AddAttribute('id') self.label_pos = 'bottom' self.input = 0 @@ -4430,7 +4435,7 @@ def __repr__(self): #---------------------------------------------------------------- class oPort(Port): - """ OPort(label) + """ OPort(label) for ContainerBlock (coupled model) """ def __init__(self, label = 'oPort'): @@ -4438,7 +4443,7 @@ def __init__(self, label = 'oPort'): """ Port.__init__(self, 50, 60, 100, 120, label) - self.fill = ['#90ee90'] + self.fill = [RED] #self.AddAttribute('id') self.label_pos = 'bottom' self.input = 1 diff --git a/DetachedFrame.py b/DetachedFrame.py index 6f39236d..e8e4d399 100644 --- a/DetachedFrame.py +++ b/DetachedFrame.py @@ -29,8 +29,12 @@ wx.ST_SIZEGRIP = wx.STB_SIZEGRIP if __name__ == '__main__': - builtins.__dict__['DEVS_DIR_PATH_DICT'] = {'PyDEVS':os.path.join(os.pardir,'DEVSKernel','PyDEVS'),'PyPDEVS':os.path.join(os.pardir,'DEVSKernel','PyPDEVS')} - builtins.__dict__['DEFAULT_DEVS_DIRNAME'] = 'PyPDEVS' + builtins.__dict__['GUI_FLAG'] = True + builtins.__dict__['HOME_PATH'] = os.path.abspath(os.path.dirname(sys.argv[0])) + builtins.__dict__['DEFAULT_DEVS_DIRNAME'] = "PyDEVS" + builtins.__dict__['DEVS_DIR_PATH_DICT'] = {\ + 'PyDEVS':os.path.join(os.pardir,'DEVSKernel','PyDEVS'),\ + 'PyPDEVS':os.path.join(os.pardir,'DEVSKernel','PyPDEVS', 'old')} import Container import Menu @@ -61,11 +65,14 @@ def __init__(self, parent=None, ID=wx.NewIdRef(), title="", diagram=None, name=" name=name, style=wx.DEFAULT_FRAME_STYLE | wx.CLIP_CHILDREN) + self.default_style = self.GetWindowStyle() + ### local Copy self.title = title self.parent = parent self.diagram = diagram + ### current abstract level #======================================================================= if hasattr(diagram, 'layers') and hasattr(diagram, 'current_level'): @@ -100,7 +107,7 @@ def __init__(self, parent=None, ID=wx.NewIdRef(), title="", diagram=None, name=" self.toggle_list = wx.GetApp().GetTopWindow().toggle_list else: sys.stdout.write(_('Alone mode for DetachedFrame: Connector buttons are not binded\n')) - self.toggle_list = [wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef()] + self.toggle_list = [wx.NewIdRef() for i in range(6)] if wx.VERSION_STRING < '2.9': self.tools = [ toolbar.AddTool(Menu.ID_SAVE, wx.Bitmap(os.path.join(ICON_PATH,'save.png')), shortHelpString=_('Save File') ,longHelpString=_('Save the current diagram'), clientData=self.canvas), @@ -155,7 +162,6 @@ def __init__(self, parent=None, ID=wx.NewIdRef(), title="", diagram=None, name=" ID_DOWNWARD = self.toggle_list[5] if wx.VERSION_STRING < '2.9': - self.tools.append(toolbar.AddTool(ID_DOWNWARD, wx.Bitmap(os.path.join(ICON_PATH,'downward.png')), shortHelpString=_('Downward rules'), longHelpString=_('Define Downward rules atomic model'))) self.tools.append(toolbar.AddTool(ID_UPWARD, wx.Bitmap(os.path.join(ICON_PATH,'upward.png')), shortHelpString=_('Upward rules'), longHelpString=_('Define Upward rules atomic model'))) else: @@ -213,10 +219,18 @@ def __binding(self): self.Bind(wx.EVT_TOOL, self.OnSaveAsFile, id=Menu.ID_SAVEAS) self.Bind(wx.EVT_CLOSE, self.OnClose) + def OnStayOnTop(self, event): + """ + """ + + if self.GetWindowStyle()==self.default_style: + self.SetWindowStyle(wx.CLIP_CHILDREN | wx.STAY_ON_TOP) + else: + self.SetWindowStyle(self.default_style) + def OnSaveFile(self, event): """ Save button has been clicked """ - ### OnSaveFile of the mainW is activated mainW = wx.GetApp().GetTopWindow() mainW.OnSaveFile(event) @@ -283,7 +297,6 @@ def OnInit(self): import gettext - #builtins.__dict__['PYDEVS_SIM_STRATEGY_DICT'] = {'original':'SimStrategy1', 'bag-based':'SimStrategy2', 'direct-coupling':'SimStrategy3'} #builtins.__dict__['PYPDEVS_SIM_STRATEGY_DICT'] = {'original':'SimStrategy4', 'distributed':'SimStrategy5', 'parallel':'SimStrategy6'} @@ -302,6 +315,5 @@ def OnQuit(self, event): self.Close() if __name__ == '__main__': - app = TestApp(0) app.MainLoop() \ No newline at end of file diff --git a/Menu.py b/Menu.py index bf9c5341..702bd3a1 100644 --- a/Menu.py +++ b/Menu.py @@ -140,6 +140,9 @@ # Experiment ID_GEN_EXPERIMENT = wx.NewIdRef() +# Stay on top +ID_STAY_ON_TOP = wx.NewIdRef() + # Library popup menu identifiers ID_NEW_LIB = wx.NewIdRef() ID_IMPORT_LIB = wx.NewIdRef() @@ -825,7 +828,7 @@ def __init__(self, parent): add_constants.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16,'properties.png'))) preview_dia.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16,'print-preview.png'))) generate_experiment.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16,'generation.png'))) - + AppendItem = self.AppendItem if wx.VERSION_STRING < '4.0' else self.Append ### append items @@ -836,7 +839,19 @@ def __init__(self, parent): AppendItem(preview_dia) AppendItem(generate_experiment) - self.Enable(ID_PASTE_SHAPE, not Container.clipboard == []) + ### Stay on top always for the detached frame (not for diagram into devsimpy as tab of notebook) + if isinstance(self.parent.parent, wx.Frame): + if self.parent.parent.GetWindowStyle() == self.parent.parent.default_style: + stay_on_top = wx.MenuItem(self, ID_STAY_ON_TOP, _('Enable stay on top'), _('Coupled model frame stay on top')) + stay_on_top.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16,'pin_out.png'))) + else: + stay_on_top = wx.MenuItem(self, ID_STAY_ON_TOP, _('Disable stay on top'), _('Coupled model frame not stay on top')) + stay_on_top.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16,'pin_in.png'))) + + AppendItem(stay_on_top) + parent.Bind(wx.EVT_MENU, parent.parent.OnStayOnTop, id=ID_STAY_ON_TOP) + + self.Enable(ID_PASTE_SHAPE, Container.clipboard != []) ### binding parent.Bind(wx.EVT_MENU, parent.OnNewModel, id=ID_NEW_SHAPE) @@ -845,7 +860,6 @@ def __init__(self, parent): parent.Bind(wx.EVT_MENU, parent.diagram.OnAddConstants, id=ID_ADD_CONSTANTS) parent.Bind(wx.EVT_MENU, parent.parent.PrintPreview, id=ID_PREVIEW_PRINT) parent.Bind(wx.EVT_MENU, ExperimentGenerator(os.path.join(HOME_PATH,'out')).OnExperiment, id=ID_GEN_EXPERIMENT) - class ShapePopupMenu(wx.Menu): """ Shape menu class """ diff --git a/icons/16x16/pin_in.png b/icons/16x16/pin_in.png new file mode 100644 index 0000000000000000000000000000000000000000..d5c4f3906ab9c5d94d5becce800cebffa45e03b9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V=}`Efo=T|JH;Kq~q?}yk>_> zn^Uq6e9%5Z|Ix$%$(yFS9>y`USglA-?Qz!XG={;R8L*w>xz}nxfWmEk2-Vp2~j%J zOJB+)N5n<=zWmRoNyT#qY@HIHCpF5HYftOG_PN++uBxdL;rpg3ex24a0EkO$X**oZdR4o>ek=Fw#c>zGWUrhvd z#W2haMNuB4q755XiXehbu!AbF$Wyqr>`{4D9Y9gl1}JGk1p%`&j}a7?~AH0si>gzv2}2<$yo;SsH!@JPkk| zhJ)y70STx|2*Cm-1_%<;@&HGKb2z{XVe5*ZII`l1pju2y74T<20WoQcGKwHCAov#a z=mi`BD&l;ol>m&73_xlAHaS&IAQTGZh(z%TC{7q$b*Zx$8AzafeV9@UU0swa(&PVa zaUCE8A|R5)p~Bz`0QfIZgE%RINKY^WU0O8wCs-6CDlE|j7!K2Md<$$-5#;0|Sl~B8 zCLAG7?1dDi;9RLF`QMEAH`oq>??A9MKoB+ovVjVlK&3^(;c&m2;F$2=@UWLS4mS(9 z3&E};@YG1(Ux{#S45LEvRRZxZBt!^4a>s_hQ2-#5P|^*s105(_3||caa3i6DX#|5G eu_*P|+5g?uU3n6n!^1(Mi0#h3wENT_V*d-d^JKjM literal 0 HcmV?d00001 diff --git a/icons/pin_in.png b/icons/pin_in.png new file mode 100644 index 0000000000000000000000000000000000000000..14cb32be9ef18756fdeae57a476f659bf478e2af GIT binary patch literal 311 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjoCO|{#S9GG!XV7ZFl!D-#Y;~Y z#}JRsw^MAn4mk+8%~wi#$e6?8*fQrpP_eLgbo6YA{Dkb6o;}m5SOoVpw`!_vJfSkF z)ZG4dr(J~Fn{(&PPfy_g#M5Xk5WOxSD`ksFqumA8vID(UJPk9i?3gtv=H-#Kk#{P> zYaLYz^A#t2(h;&?_Fllerh!>tibzSL<_5Ky2UljP8$Jj>@mV$8d-JMUy7i6n0tOEQ z?zhXtE^JH7XOVeY9ldek&Lf-!n%>{Ktc)h?yAjMEvby1WOx31W9}I)%I%r%x_Q9#t z*}U1zz^o%*Mb9K%urtz5N9r_(M)`G_`~MgJW%a6Ltmm>-pZ%+KKG4$)p00i_>zopr E07~R_CIA2c literal 0 HcmV?d00001 diff --git a/icons/pin_out.png b/icons/pin_out.png new file mode 100644 index 0000000000000000000000000000000000000000..7b0f8935c06df11e1c137ba3b6987056bcfba7c0 GIT binary patch literal 676 zcmV;V0$crwP)>aI=Gh)X~GlK#Wz}1hm>{?s2)4c(v&z)n~nz z@8`Yu%=hexMin9Zu=#eUyrK%)ISB{mYsIpP8mP~z`B6@v>!4M zU|Ckwizfx+v=E__06zCa1_C0Hhzsy{0AVnTwYpOiB2?^$3otDYm@jW5^b}m!;p;Y>tRM}z=@=hw< zl&M^n{ISu5Jwf5lJTYb%h!WrcI1J!Uvr)MS!0lbXKbbSbg3DlQJEE(GS;+gpOQn~k(r<#a{(1+k zkMEy@_%VPCQM>H_69T^guni6hkWA?tU^)ll`v4MQ`t__AVbDPUUxxv_IIe(jv-zPq z%j}*7$nGL>%T5EB1@lr6p!cEq;+3la7}$D%j{tVOr5ScRldaX769nnT7o^fGQ+mM% zqlCkKfmHl8m8iSK17Hl8p1ulR5BcHn8avGnQy0000< KMNUMnLSTYw$uoTb literal 0 HcmV?d00001