From 37cfc896455c024c306cf4f5aad465d335d9c754 Mon Sep 17 00:00:00 2001 From: lcapocchi Date: Tue, 10 Mar 2020 06:05:34 -0400 Subject: [PATCH 1/3] bug fix for toolbar --- devsimpy.py | 119 ++++++++++++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 60 deletions(-) diff --git a/devsimpy.py b/devsimpy.py index 9774fa07..b2236d3a 100644 --- a/devsimpy.py +++ b/devsimpy.py @@ -537,8 +537,8 @@ def MakeToolBar(self): # for spash screen pub.sendMessage('object.added', message=_('Making tools bar ...\n')) - - self.tb = self.CreateToolBar(style = wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT | wx.TB_TEXT, name = 'tb') + + tb = wx.ToolBar(self, wx.NewIdRef(), name='tb', style=wx.TB_HORIZONTAL | wx.NO_BORDER) self.toggle_list = [wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef()] @@ -546,86 +546,84 @@ def MakeToolBar(self): ### Tools List - IDs come from Menu.py file if wx.VERSION_STRING < '4.0': - self.tb.SetToolBitmapSize((25,25)) # juste for windows - - self.tools = [ self.tb.AddTool(wx.ID_NEW, wx.Bitmap(os.path.join(ICON_PATH,'new.png')), shortHelpString=_('New diagram (Ctrl+N)'),longHelpString=_('Create a new diagram in tab')), - self.tb.AddTool(wx.ID_OPEN, wx.Bitmap(os.path.join(ICON_PATH,'open.png')), shortHelpString=_('Open File (Ctrl+O)'), longHelpString=_('Open an existing diagram')), - self.tb.AddTool(wx.ID_PREVIEW_PRINT, wx.Bitmap(os.path.join(ICON_PATH,'print-preview.png')), shortHelpString=_('Print Preview (Ctrl+P)'), longHelpString=_('Print preview of current diagram')), - self.tb.AddTool(wx.ID_SAVE, wx.Bitmap(os.path.join(ICON_PATH,'save.png')), shortHelpString=_('Save File (Ctrl+S)'), longHelpString=_('Save the current diagram'), clientData=currentPage), - self.tb.AddTool(wx.ID_SAVEAS, wx.Bitmap(os.path.join(ICON_PATH,'save_as.png')), shortHelpString=_('Save file as'), longHelpString=_('Save the diagram with an another name'), clientData=currentPage), - self.tb.AddTool(wx.ID_UNDO, wx.Bitmap(os.path.join(ICON_PATH,'undo.png')),shortHelpString= _('Undo'), longHelpString=_('Click to go upward, hold to see history'), clientData=currentPage), - self.tb.AddTool(wx.ID_REDO, wx.Bitmap(os.path.join(ICON_PATH,'redo.png')), shortHelpString=_('Redo'), longHelpString=_('Click to go forward, hold to see history'), clientData=currentPage), - self.tb.AddTool(Menu.ID_ZOOMIN_DIAGRAM, wx.Bitmap(os.path.join(ICON_PATH,'zoom+.png')), shortHelpString=_('Zoom'), longHelpString=_('Zoom +'), clientData=currentPage), - self.tb.AddTool(Menu.ID_ZOOMOUT_DIAGRAM, wx.Bitmap(os.path.join(ICON_PATH,'zoom-.png')), shortHelpString=_('UnZoom'), longHelpString=_('Zoom -'), clientData=currentPage), - self.tb.AddTool(Menu.ID_UNZOOM_DIAGRAM, wx.Bitmap(os.path.join(ICON_PATH,'no_zoom.png')), shortHelpString=_('AnnuleZoom'), longHelpString=_('Normal size'), clientData=currentPage), - self.tb.AddTool(Menu.ID_PRIORITY_DIAGRAM, wx.Bitmap(os.path.join(ICON_PATH,'priority.png')), shortHelpString=_('Priority (F3)'),longHelpString= _('Define model activation priority')), - self.tb.AddTool(Menu.ID_CHECK_DIAGRAM, wx.Bitmap(os.path.join(ICON_PATH,'check_master.png')), shortHelpString=_('Debugger (F4)'),longHelpString= _('Check devs models')), - self.tb.AddTool(Menu.ID_PLUGINS_SHAPE, wx.Bitmap(os.path.join(ICON_PATH,'plugins.png')), shortHelpString=_('Plugins'), longHelpString=_('Plugins Manager')), - self.tb.AddTool(Menu.ID_SIM_DIAGRAM, wx.Bitmap(os.path.join(ICON_PATH,'simulation.png')), shortHelpString=_('Simulation (F5)'), longHelpString=_('Simulate the diagram')), - self.tb.AddTool(self.toggle_list[0], wx.Bitmap(os.path.join(ICON_PATH,'direct_connector.png')),shortHelpString= _('Direct'),longHelpString=_('Direct connector'), isToggle=True), - self.tb.AddTool(self.toggle_list[1], wx.Bitmap(os.path.join(ICON_PATH,'square_connector.png')), shortHelpString=_('Square'), longHelpString=_('Square connector'), isToggle=True), - self.tb.AddTool(self.toggle_list[2], wx.Bitmap(os.path.join(ICON_PATH,'linear_connector.png')), shortHelpString=_('Linear'), longHelpString=_('Linear connector'), isToggle=True) + tb.SetToolBitmapSize((25,25)) # juste for windows + + self.tools = [ tb.AddTool(wx.ID_NEW, wx.Bitmap(os.path.join(ICON_PATH,'new.png')), shortHelpString=_('New diagram (Ctrl+N)'),longHelpString=_('Create a new diagram in tab')), + tb.AddTool(wx.ID_OPEN, wx.Bitmap(os.path.join(ICON_PATH,'open.png')), shortHelpString=_('Open File (Ctrl+O)'), longHelpString=_('Open an existing diagram')), + tb.AddTool(wx.ID_PREVIEW_PRINT, wx.Bitmap(os.path.join(ICON_PATH,'print-preview.png')), shortHelpString=_('Print Preview (Ctrl+P)'), longHelpString=_('Print preview of current diagram')), + tb.AddTool(wx.ID_SAVE, wx.Bitmap(os.path.join(ICON_PATH,'save.png')), shortHelpString=_('Save File (Ctrl+S)'), longHelpString=_('Save the current diagram'), clientData=currentPage), + tb.AddTool(wx.ID_SAVEAS, wx.Bitmap(os.path.join(ICON_PATH,'save_as.png')), shortHelpString=_('Save file as'), longHelpString=_('Save the diagram with an another name'), clientData=currentPage), + tb.AddTool(wx.ID_UNDO, wx.Bitmap(os.path.join(ICON_PATH,'undo.png')),shortHelpString= _('Undo'), longHelpString=_('Click to go upward, hold to see history'), clientData=currentPage), + tb.AddTool(wx.ID_REDO, wx.Bitmap(os.path.join(ICON_PATH,'redo.png')), shortHelpString=_('Redo'), longHelpString=_('Click to go forward, hold to see history'), clientData=currentPage), + tb.AddTool(Menu.ID_ZOOMIN_DIAGRAM, wx.Bitmap(os.path.join(ICON_PATH,'zoom+.png')), shortHelpString=_('Zoom'), longHelpString=_('Zoom +'), clientData=currentPage), + tb.AddTool(Menu.ID_ZOOMOUT_DIAGRAM, wx.Bitmap(os.path.join(ICON_PATH,'zoom-.png')), shortHelpString=_('UnZoom'), longHelpString=_('Zoom -'), clientData=currentPage), + tb.AddTool(Menu.ID_UNZOOM_DIAGRAM, wx.Bitmap(os.path.join(ICON_PATH,'no_zoom.png')), shortHelpString=_('AnnuleZoom'), longHelpString=_('Normal size'), clientData=currentPage), + tb.AddTool(Menu.ID_PRIORITY_DIAGRAM, wx.Bitmap(os.path.join(ICON_PATH,'priority.png')), shortHelpString=_('Priority (F3)'),longHelpString= _('Define model activation priority')), + tb.AddTool(Menu.ID_CHECK_DIAGRAM, wx.Bitmap(os.path.join(ICON_PATH,'check_master.png')), shortHelpString=_('Debugger (F4)'),longHelpString= _('Check devs models')), + tb.AddTool(Menu.ID_PLUGINS_SHAPE, wx.Bitmap(os.path.join(ICON_PATH,'plugins.png')), shortHelpString=_('Plugins'), longHelpString=_('Plugins Manager')), + tb.AddTool(Menu.ID_SIM_DIAGRAM, wx.Bitmap(os.path.join(ICON_PATH,'simulation.png')), shortHelpString=_('Simulation (F5)'), longHelpString=_('Simulate the diagram')), + tb.AddTool(self.toggle_list[0], wx.Bitmap(os.path.join(ICON_PATH,'direct_connector.png')),shortHelpString= _('Direct'),longHelpString=_('Direct connector'), isToggle=True), + tb.AddTool(self.toggle_list[1], wx.Bitmap(os.path.join(ICON_PATH,'square_connector.png')), shortHelpString=_('Square'), longHelpString=_('Square connector'), isToggle=True), + tb.AddTool(self.toggle_list[2], wx.Bitmap(os.path.join(ICON_PATH,'linear_connector.png')), shortHelpString=_('Linear'), longHelpString=_('Linear connector'), isToggle=True) ] else: - self.tools = [ self.tb.AddTool(wx.ID_NEW, "",wx.Bitmap(os.path.join(ICON_PATH,'new.png')), shortHelp=_('New diagram (Ctrl+N)')), - self.tb.AddTool(wx.ID_OPEN, "",wx.Bitmap(os.path.join(ICON_PATH,'open.png')), shortHelp=_('Open File (Ctrl+O)')), - self.tb.AddTool(wx.ID_PREVIEW_PRINT, "",wx.Bitmap(os.path.join(ICON_PATH,'print-preview.png')), shortHelp=_('Print Preview (Ctrl+P)')), - self.tb.AddTool(wx.ID_SAVE, "",wx.Bitmap(os.path.join(ICON_PATH,'save.png')), wx.NullBitmap, shortHelp=_('Save File (Ctrl+S)'), longHelp=_('Save the current diagram'), clientData=currentPage), - self.tb.AddTool(wx.ID_SAVEAS, "",wx.Bitmap(os.path.join(ICON_PATH,'save_as.png')), wx.NullBitmap, shortHelp=_('Save file as'), longHelp=_('Save the diagram with an another name'), clientData=currentPage), - self.tb.AddTool(wx.ID_UNDO, "",wx.Bitmap(os.path.join(ICON_PATH,'undo.png')), wx.NullBitmap, shortHelp= _('Undo'), longHelp=_('Click to glongHelpString=o back, hold to see history'), clientData=currentPage), - self.tb.AddTool(wx.ID_REDO, "",wx.Bitmap(os.path.join(ICON_PATH,'redo.png')), wx.NullBitmap, shortHelp=_('Redo'), longHelp=_('Click to go forward, hold to see history'), clientData=currentPage), - self.tb.AddTool(Menu.ID_ZOOMIN_DIAGRAM, "",wx.Bitmap(os.path.join(ICON_PATH,'zoom+.png')), wx.NullBitmap, shortHelp=_('Zoom'), longHelp=_('Zoom +'), clientData=currentPage), - self.tb.AddTool(Menu.ID_ZOOMOUT_DIAGRAM, "",wx.Bitmap(os.path.join(ICON_PATH,'zoom-.png')), wx.NullBitmap, shortHelp=_('UnZoom'), longHelp=_('Zoom -'), clientData=currentPage), - self.tb.AddTool(Menu.ID_UNZOOM_DIAGRAM, "",wx.Bitmap(os.path.join(ICON_PATH,'no_zoom.png')), wx.NullBitmap, shortHelp=_('AnnuleZoom'), longHelp=_('Normal size'), clientData=currentPage), - self.tb.AddTool(Menu.ID_PRIORITY_DIAGRAM, "",wx.Bitmap(os.path.join(ICON_PATH,'priority.png')), shortHelp=_('Priority (F3)')), - self.tb.AddTool(Menu.ID_CHECK_DIAGRAM, "",wx.Bitmap(os.path.join(ICON_PATH,'check_master.png')), shortHelp=_('Debugger (F4)')), - self.tb.AddTool(Menu.ID_PLUGINS_SHAPE, "", wx.Bitmap(os.path.join(ICON_PATH,'plugins.png')), shortHelp=_('Plugins Manager')), - self.tb.AddTool(Menu.ID_SIM_DIAGRAM, "",wx.Bitmap(os.path.join(ICON_PATH,'simulation.png')), shortHelp=_('Simulation (F5)')), - self.tb.AddTool(self.toggle_list[0], "",wx.Bitmap(os.path.join(ICON_PATH,'direct_connector.png')),shortHelp= _('Direct'), kind=wx.ITEM_CHECK), - self.tb.AddTool(self.toggle_list[1], "",wx.Bitmap(os.path.join(ICON_PATH,'square_connector.png')), shortHelp=_('Square'), kind = wx.ITEM_CHECK), - self.tb.AddTool(self.toggle_list[2], "",wx.Bitmap(os.path.join(ICON_PATH,'linear_connector.png')), shortHelp=_('Linear'), kind = wx.ITEM_CHECK) + tb.SetToolBitmapSize((25,25)) + self.tools = [ tb.AddTool(wx.ID_NEW, "",wx.Bitmap(os.path.join(ICON_PATH,'new.png')), shortHelp=_('New diagram (Ctrl+N)')), + tb.AddTool(wx.ID_OPEN, "",wx.Bitmap(os.path.join(ICON_PATH,'open.png')), shortHelp=_('Open File (Ctrl+O)')), + tb.AddTool(wx.ID_PREVIEW_PRINT, "",wx.Bitmap(os.path.join(ICON_PATH,'print-preview.png')), shortHelp=_('Print Preview (Ctrl+P)')), + tb.AddTool(wx.ID_SAVE, "",wx.Bitmap(os.path.join(ICON_PATH,'save.png')), wx.NullBitmap, shortHelp=_('Save File (Ctrl+S)'), longHelp=_('Save the current diagram'), clientData=currentPage), + tb.AddTool(wx.ID_SAVEAS, "",wx.Bitmap(os.path.join(ICON_PATH,'save_as.png')), wx.NullBitmap, shortHelp=_('Save file as'), longHelp=_('Save the diagram with an another name'), clientData=currentPage), + tb.AddTool(wx.ID_UNDO, "",wx.Bitmap(os.path.join(ICON_PATH,'undo.png')), wx.NullBitmap, shortHelp= _('Undo'), longHelp=_('Click to glongHelpString=o back, hold to see history'), clientData=currentPage), + tb.AddTool(wx.ID_REDO, "",wx.Bitmap(os.path.join(ICON_PATH,'redo.png')), wx.NullBitmap, shortHelp=_('Redo'), longHelp=_('Click to go forward, hold to see history'), clientData=currentPage), + tb.AddTool(Menu.ID_ZOOMIN_DIAGRAM, "",wx.Bitmap(os.path.join(ICON_PATH,'zoom+.png')), wx.NullBitmap, shortHelp=_('Zoom'), longHelp=_('Zoom +'), clientData=currentPage), + tb.AddTool(Menu.ID_ZOOMOUT_DIAGRAM, "",wx.Bitmap(os.path.join(ICON_PATH,'zoom-.png')), wx.NullBitmap, shortHelp=_('UnZoom'), longHelp=_('Zoom -'), clientData=currentPage), + tb.AddTool(Menu.ID_UNZOOM_DIAGRAM, "",wx.Bitmap(os.path.join(ICON_PATH,'no_zoom.png')), wx.NullBitmap, shortHelp=_('AnnuleZoom'), longHelp=_('Normal size'), clientData=currentPage), + tb.AddTool(Menu.ID_PRIORITY_DIAGRAM, "",wx.Bitmap(os.path.join(ICON_PATH,'priority.png')), shortHelp=_('Priority (F3)')), + tb.AddTool(Menu.ID_CHECK_DIAGRAM, "",wx.Bitmap(os.path.join(ICON_PATH,'check_master.png')), shortHelp=_('Debugger (F4)')), + tb.AddTool(Menu.ID_PLUGINS_SHAPE, "", wx.Bitmap(os.path.join(ICON_PATH,'plugins.png')), shortHelp=_('Plugins Manager')), + tb.AddTool(Menu.ID_SIM_DIAGRAM, "",wx.Bitmap(os.path.join(ICON_PATH,'simulation.png')), shortHelp=_('Simulation (F5)')), + tb.AddTool(self.toggle_list[0], "",wx.Bitmap(os.path.join(ICON_PATH,'direct_connector.png')),shortHelp= _('Direct'), kind=wx.ITEM_CHECK), + tb.AddTool(self.toggle_list[1], "",wx.Bitmap(os.path.join(ICON_PATH,'square_connector.png')), shortHelp=_('Square'), kind = wx.ITEM_CHECK), + tb.AddTool(self.toggle_list[2], "",wx.Bitmap(os.path.join(ICON_PATH,'linear_connector.png')), shortHelp=_('Linear'), kind = wx.ITEM_CHECK) ] ##################################################################### Abstraction hierarchy diagram = currentPage.GetDiagram() level = currentPage.GetCurrentLevel() - level_label = wx.StaticText(self.tb, -1, _("Level ")) - self.spin = wx.SpinCtrl(self.tb, self.toggle_list[3], str(level), pos=(55, 90), size=(50, -1), min=0, max=20) + level_label = wx.StaticText(tb, -1, _("Level ")) + self.spin = wx.SpinCtrl(tb, self.toggle_list[3], str(level), pos=(55, 90), size=(50, -1), min=0, max=20) - self.tb.AddControl(level_label) - self.tb.AddControl(self.spin) + tb.AddControl(level_label) + tb.AddControl(self.spin) ### add button to define downward and upward rules ID_UPWARD = self.toggle_list[4] ID_DOWNWARD = self.toggle_list[5] if wx.VERSION_STRING < '4.0': - self.tools.append(self.tb.AddTool(ID_DOWNWARD, wx.Bitmap(os.path.join(ICON_PATH,'downward.png')), shortHelpString=_('Downward rules'), longHelpString=_('Define Downward atomic model'))) - self.tools.append(self.tb.AddTool(ID_UPWARD, wx.Bitmap(os.path.join(ICON_PATH,'upward.png')), shortHelpString=_('Upward rules'), longHelpString=_('Define Upward atomic model'))) + self.tools.append(tb.AddTool(ID_DOWNWARD, wx.Bitmap(os.path.join(ICON_PATH,'downward.png')), shortHelpString=_('Downward rules'), longHelpString=_('Define Downward atomic model'))) + self.tools.append(tb.AddTool(ID_UPWARD, wx.Bitmap(os.path.join(ICON_PATH,'upward.png')), shortHelpString=_('Upward rules'), longHelpString=_('Define Upward atomic model'))) else: - self.tools.append(self.tb.AddTool(ID_DOWNWARD, "", wx.Bitmap(os.path.join(ICON_PATH,'downward.png')), shortHelp=_('Downward rules'))) - self.tools.append(self.tb.AddTool(ID_UPWARD, "", wx.Bitmap(os.path.join(ICON_PATH,'upward.png')), shortHelp=_('Upward rules'))) + self.tools.append(tb.AddTool(ID_DOWNWARD, "", wx.Bitmap(os.path.join(ICON_PATH,'downward.png')), shortHelp=_('Downward rules'))) + self.tools.append(tb.AddTool(ID_UPWARD, "", wx.Bitmap(os.path.join(ICON_PATH,'upward.png')), shortHelp=_('Upward rules'))) - self.tb.EnableTool(ID_DOWNWARD, False) - self.tb.EnableTool(ID_UPWARD, False) + tb.EnableTool(ID_DOWNWARD, False) + tb.EnableTool(ID_UPWARD, False) ############################################################################################## - self.tb.InsertSeparator(3) - self.tb.InsertSeparator(8) - self.tb.InsertSeparator(12) - self.tb.InsertSeparator(17) - self.tb.InsertSeparator(21) + for i in (3,8,12,17,21): + tb.InsertSeparator(i) ### undo and redo button desabled - self.tb.EnableTool(wx.ID_UNDO, False) - self.tb.EnableTool(wx.ID_REDO, False) + tb.EnableTool(wx.ID_UNDO, False) + tb.EnableTool(wx.ID_REDO, False) - self.tb.EnableTool(Menu.ID_PRIORITY_DIAGRAM, not 'PyPDEVS' in builtins.__dict__['DEFAULT_DEVS_DIRNAME']) + tb.EnableTool(Menu.ID_PRIORITY_DIAGRAM, not 'PyPDEVS' in builtins.__dict__['DEFAULT_DEVS_DIRNAME']) ### default direct connector toogled - self.tb.ToggleTool(self.toggle_list[0], 1) + tb.ToggleTool(self.toggle_list[0], 1) ### Binding self.Bind(wx.EVT_TOOL, self.OnNew, self.tools[0]) @@ -654,9 +652,9 @@ def MakeToolBar(self): self.Bind(wx.EVT_TOOL, self.OnUpWard, id=ID_UPWARD) self.Bind(wx.EVT_TOOL, self.OnDownWard, id=ID_DOWNWARD) - self.tb.Realize() + #tb.Realize() - self.SetToolBar(self.tb) + self.SetToolBar(tb) def GetExportPathsList(self): """ @@ -1836,7 +1834,8 @@ def OnShowLibraries(self, evt): ### def OnShowToolBar(self, evt): - self.tb.Show(not self.tb.IsShown()) + tb=self.GetToolBar() + tb.Show(not tb.IsShown()) def OnShowEditor(self, evt): """ Editor view has been pressed. From 4d93e7178d0981ed03a5cb331ef601e8b112847e Mon Sep 17 00:00:00 2001 From: lcapocchi Date: Tue, 10 Mar 2020 06:08:56 -0400 Subject: [PATCH 2/3] bug fix for tool bar (compatibility with windows) --- devsimpy.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/devsimpy.py b/devsimpy.py index b2236d3a..8dc87303 100644 --- a/devsimpy.py +++ b/devsimpy.py @@ -567,7 +567,6 @@ def MakeToolBar(self): tb.AddTool(self.toggle_list[2], wx.Bitmap(os.path.join(ICON_PATH,'linear_connector.png')), shortHelpString=_('Linear'), longHelpString=_('Linear connector'), isToggle=True) ] else: - tb.SetToolBitmapSize((25,25)) self.tools = [ tb.AddTool(wx.ID_NEW, "",wx.Bitmap(os.path.join(ICON_PATH,'new.png')), shortHelp=_('New diagram (Ctrl+N)')), tb.AddTool(wx.ID_OPEN, "",wx.Bitmap(os.path.join(ICON_PATH,'open.png')), shortHelp=_('Open File (Ctrl+O)')), tb.AddTool(wx.ID_PREVIEW_PRINT, "",wx.Bitmap(os.path.join(ICON_PATH,'print-preview.png')), shortHelp=_('Print Preview (Ctrl+P)')), @@ -652,7 +651,7 @@ def MakeToolBar(self): self.Bind(wx.EVT_TOOL, self.OnUpWard, id=ID_UPWARD) self.Bind(wx.EVT_TOOL, self.OnDownWard, id=ID_DOWNWARD) - #tb.Realize() + tb.Realize() self.SetToolBar(tb) From cfd2c392a23669562e851db308a4c230fbc3ac52 Mon Sep 17 00:00:00 2001 From: lcapocchi Date: Tue, 10 Mar 2020 10:16:07 -0400 Subject: [PATCH 3/3] Bug Fix for ToolBar and new dialog for LibTreeCtrl --- Components.py | 19 ++++++++------ DetachedFrame.py | 6 ++--- Editor.py | 13 ++++++---- ImportLibrary.py | 65 ++++++++++++++++++++++++++++++++++------------- LibPanel.py | 5 ++-- LibraryTree.py | 4 +-- Menu.py | 3 +++ PreferencesGUI.py | 3 ++- SpreadSheet.py | 6 ++--- devsimpy.py | 3 +-- wxPyMail.py | 9 +++---- 11 files changed, 88 insertions(+), 48 deletions(-) diff --git a/Components.py b/Components.py index f4d97cfa..c6f78bf1 100644 --- a/Components.py +++ b/Components.py @@ -24,6 +24,7 @@ import string import types import importlib +import subprocess import gettext _ = gettext.gettext @@ -50,9 +51,10 @@ #from DomainInterface.DomainBehavior import DomainBehavior #from DomainInterface.DomainStructure import DomainStructure from ReloadModule import recompile -from Utilities import GetActiveWindow, path_to_module +from Utilities import GetActiveWindow, path_to_module, install_and_import from NetManager import Net from SimpleFrameEditor import FrameEditor +from which import which ########################################################### ### @@ -620,7 +622,7 @@ def OnEditor(self, event): if isinstance(mainW, ShapeCanvas): mainW = mainW.GetParent() - if builtins.__dict__['LOCAL_EDITOR'] and not zipfile.is_zipfile(model_path) and not python_path.startswith('http'): + if not builtins.__dict__['LOCAL_EDITOR'] and not zipfile.is_zipfile(model_path) and not python_path.startswith('http'): dial = wx.MessageDialog(mainW, _('Do you want to use your local programmer software?\n\n If you always want use the DEVSimPy code editor\n change the option in Editor panel preferences.'), name, wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) val = dial.ShowModal() else: @@ -630,20 +632,21 @@ def OnEditor(self, event): if val == wx.ID_YES: ### open with local editor if wx.Platform == '__WXMAC__': - os.system("open " + python_path) + subprocess.call(" ".join(['open',python_path]), shell=True) elif "wxMSW" in wx.PlatformInfo: os.startfile(python_path) elif "wxGTK" in wx.PlatformInfo: ### with gnome - if os.system('pidof gnome-session') != 256: + if os.system('pidof gedit') == 256: try: - soft = which('gnome-open') + soft = which('gedit') except: sys.stdout.write(_("Local programmer software not found!\n")) else: - os.system(soft+" openURL " + python_path) + subprocess.call(" ".join([soft,python_path]), shell=True) + ### with kde - elif os.system('pidof ksmserver') != 256: + elif os.system('pidof ksmserver') == 256: try: soft = which('kfmclient') except: @@ -654,7 +657,7 @@ def OnEditor(self, event): sys.stdout.write(_("Unknown Windows Manager!\n")) elif val != wx.ID_CANCEL: - # loading file in editor windows (self.text) + # loading file in DEVSimPy editor windows (self.text) try: editorFrame = Editor.GetEditor(None, wx.NewIdRef(), ''.join([name,' - ',model_path]), obj=self, file_type='block') diff --git a/DetachedFrame.py b/DetachedFrame.py index a364d227..9cebf3cd 100644 --- a/DetachedFrame.py +++ b/DetachedFrame.py @@ -94,8 +94,7 @@ def __init__(self, parent=None, ID=wx.NewIdRef(), title="", diagram=None, name=" ### Menu ToolBar toolbar = wx.ToolBar(self, wx.NewIdRef(), name='tb', style=wx.TB_HORIZONTAL | wx.NO_BORDER) - toolbar.SetToolBitmapSize((25,25)) # just for windows - self.SetToolBar(toolbar) + toolbar.SetToolBitmapSize((16,16)) if self.parent: self.toggle_list = wx.GetApp().GetTopWindow().toggle_list @@ -169,7 +168,8 @@ def __init__(self, parent=None, ID=wx.NewIdRef(), title="", diagram=None, name=" #======================================================================= toolbar.Realize() - + self.SetToolBar(toolbar) + ### if Detached frame from block (container or Code) ### save, save-as and simulation are disabled if not isinstance(self.parent, Container.ShapeCanvas): diff --git a/Editor.py b/Editor.py index 0668d8a2..c30546c4 100644 --- a/Editor.py +++ b/Editor.py @@ -1370,9 +1370,11 @@ def CreateTB(self): """ Create tool-bar """ - if not self.parent: - tb = self.CreateToolBar(wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT | wx.TB_TEXT) + tb = wx.ToolBar(self, wx.NewIdRef(), name='tb', style=wx.TB_HORIZONTAL | wx.NO_BORDER) + tb.SetToolBitmapSize((16, 16))# this required for non-standard size buttons on MSW + if not self.parent: + if wx.VERSION_STRING < '4.0': self.Bind(wx.EVT_TOOL, self.OnSaveFile, tb.AddTool(self.save.GetId(),wx.Bitmap(os.path.join(ICON_PATH, 'save.png')), _('Save'), '')) tb.AddSeparator() @@ -1389,9 +1391,6 @@ def CreateTB(self): self.Bind(wx.EVT_TOOL, self.QuitApplication, id = self.quit.GetId()) else: - tb = wx.ToolBar(self, -1) - tb.SetToolBitmapSize((16, 16))# this required for non-standard size buttons on MSW - if wx.VERSION_STRING < '4.0': tb.AddTool(self.save.GetId(), wx.Bitmap(os.path.join(ICON_PATH, 'save.png')), shortHelpString=_('Save'), longHelpString=_('Save the file')) tb.AddTool(self.cut.GetId(), wx.Bitmap(os.path.join(ICON_PATH,'cut.png')), shortHelpString=_('Cut'), longHelpString=_('Cut the selection')) @@ -1409,6 +1408,7 @@ def CreateTB(self): self.Bind(wx.EVT_TOOL, self.nb.OnPaste, id= self.paste.GetId()) tb.Realize() + return tb def GetNoteBook(self): @@ -1816,6 +1816,9 @@ def __init__(self, parent, id, title): self.toolbar = self.CreateTB() self.statusbar= self.GetStatusBar() + ### set the tool bar + self.SetToolBar(self.toolbar) + ### binding self.Bind(wx.EVT_CLOSE, self.QuitApplication) diff --git a/ImportLibrary.py b/ImportLibrary.py index 16ebbd99..d93cb23f 100644 --- a/ImportLibrary.py +++ b/ImportLibrary.py @@ -96,32 +96,63 @@ class DeleteBox(wx.Dialog): def __init__(self, *args, **kwargs): """ Constructor. """ - wx.Dialog.__init__(self, *args, **kwargs) + super(DeleteBox, self).__init__(*args, **kwargs) + + self.InitUI() + self.SetSize((250, 200)) + + def InitUI(self): + + pnl = wx.Panel(self) + vbox = wx.BoxSizer(wx.VERTICAL) + + sb = wx.StaticBox(pnl, label='Delete?') + sbs = wx.StaticBoxSizer(sb, orient=wx.VERTICAL) + self.rb1 = wx.RadioButton(pnl, label=_('label')) + self.rb2 = wx.RadioButton(pnl, label=_('label and files')) + sbs.Add(self.rb1) + sbs.Add(self.rb2) + + pnl.SetSizer(sbs) + + hbox2 = wx.BoxSizer(wx.HORIZONTAL) + okButton = wx.Button(self, wx.ID_OK, label='Ok') + closeButton = wx.Button(self, wx.ID_CANCEL, label='Close') + hbox2.Add(okButton) + hbox2.Add(closeButton, flag=wx.LEFT, border=5) + + vbox.Add(pnl, proportion=1, + flag=wx.ALL|wx.EXPAND, border=5) + vbox.Add(hbox2, flag=wx.ALIGN_CENTER|wx.TOP|wx.BOTTOM, border=10) + + self.SetSizer(vbox) + + self.Centre() ### Widgets - txt = wx.StaticText(self, wx.NewIdRef(), _('What do you want to delete:'), (15, 10)) - self.rb1 = wx.RadioButton(self, wx.NewIdRef() , _('label'), (20, 30)) - self.rb2 = wx.RadioButton(self, wx.NewIdRef() , _('label and files'), (20, 55)) - btn_cancel = wx.Button(self, wx.ID_CANCEL, pos = (35, 90), size = (80, -1)) - btn_ok = wx.Button(self, wx.ID_OK, pos = (135, 90), size = (80, -1)) +# txt = wx.StaticText(self, wx.NewIdRef(), _('What do you want to delete:'), (15, 10)) +# self.rb1 = wx.RadioButton(self, wx.NewIdRef() , _('label'), (20, 30)) +# self.rb2 = wx.RadioButton(self, wx.NewIdRef() , _('label and files'), (20, 55)) +# btn_cancel = wx.Button(self, wx.ID_CANCEL, pos = (35, 90), size = (80, -1)) +# btn_ok = wx.Button(self, wx.ID_OK, pos = (135, 90), size = (80, -1)) ### Sizers - hbox = wx.BoxSizer(wx.HORIZONTAL) - vbox = wx.BoxSizer(wx.VERTICAL) +# hbox = wx.BoxSizer(wx.HORIZONTAL) +# vbox = wx.BoxSizer(wx.VERTICAL) ### And into Sizers - hbox.Add(btn_cancel, 1, wx.EXPAND|wx.ALIGN_CENTER) - hbox.Add(btn_ok, 1, wx.EXPAND|wx.ALIGN_CENTER) +# hbox.Add(btn_cancel, 1, wx.EXPAND|wx.ALIGN_CENTER) +# hbox.Add(btn_ok, 1, wx.EXPAND|wx.ALIGN_CENTER) - vbox.Add(txt, 0, wx.ALIGN_TOP, 10) - vbox.Add(self.rb1, 1,wx.ALIGN_LEFT, 5) - vbox.Add(self.rb2, 1,wx.ALIGN_LEFT, 5) - vbox.Add(hbox, 1, wx.ALIGN_CENTER) +# vbox.Add(txt, 0, wx.ALIGN_TOP, 10) +# vbox.Add(self.rb1, 1,wx.ALIGN_LEFT, 5) +# vbox.Add(self.rb2, 1,wx.ALIGN_LEFT, 5) +# vbox.Add(hbox, 1, wx.ALIGN_CENTER) ### Set Sizer - self.SetSizer(vbox) +# self.SetSizer(vbox) - self.Centre() +# vbox.SetSizeHints(self) #------------------------------------------------------------------- class ImportLibrary(wx.Dialog): @@ -356,7 +387,7 @@ def OnDelete(self, evt): label = self._cb.GetItemText(index) ### diag to choose to delete label and/or source files - db = DeleteBox(self, -1, _("Delete Options"), size=(250, 110)) + db = DeleteBox(self, wx.NewIdRef(), _("Delete Options")) if db.ShowModal() == wx.ID_OK: diff --git a/LibPanel.py b/LibPanel.py index 82a58fbf..8e944fc5 100644 --- a/LibPanel.py +++ b/LibPanel.py @@ -77,7 +77,7 @@ def __init__(self, parent, name): chargedDomainList = eval(cfg_domain_list) if cfg_domain_list else [] self.tree.Populate(chargedDomainList) - + ### search tree that is hide when starting devsimpy (see __do_layout) self.searchTree = LibraryTree(self, wx.NewIdRef(), wx.DefaultPosition, style=wx.TR_DEFAULT_STYLE|wx.TR_HIDE_ROOT|wx.TR_MULTIPLE|wx.TR_LINES_AT_ROOT|wx.TR_HAS_BUTTONS|wx.SUNKEN_BORDER) @@ -108,7 +108,7 @@ def BuildToolbar(self): """ tb = wx.ToolBar(self, -1) - self.ToolBar = tb + #self.ToolBar = tb tb.SetToolBitmapSize((16,16))# this required for non-standard size buttons on MSW ### for Phoenix version @@ -144,6 +144,7 @@ def BuildToolbar(self): self.Bind(wx.EVT_TOOL, self.tree.OnMCCClick, id=Menu.ID_MCC_LIB) tb.Realize() + return tb def __set_tips(self): diff --git a/LibraryTree.py b/LibraryTree.py index 37f1084b..7dc44aa7 100644 --- a/LibraryTree.py +++ b/LibraryTree.py @@ -279,10 +279,10 @@ def OnDelete(self, evt): item = self.GetSelection() - + print(item) if item: ### msgbox to select what you wan to delete: file or/and item ? - db = DeleteBox(self, -1, _("Delete Options"), size=(250, 110)) + db = DeleteBox(self, wx.NewIdRef(), _("Delete Options")) if db.ShowModal() == wx.ID_OK: diff --git a/Menu.py b/Menu.py index dc12f55d..6df9d569 100644 --- a/Menu.py +++ b/Menu.py @@ -714,6 +714,9 @@ def __init__(self, parent): AppendItem(doc) AppendItem(update) + path = parent.GetItemPyData(item) + self.Enable(ID_EDIT_LIB, not path.endswith('pyc')) + self.Bind(wx.EVT_MENU, parent.OnItemEdit, id = ID_EDIT_LIB) # put before the popUpMenu self.Bind(wx.EVT_MENU, parent.OnItemRename, id = ID_RENAME_LIB) # put before the popUpMenu self.Bind(wx.EVT_MENU, parent.OnItemDocumentation, id = doc.GetId()) # put before the popUpMenu diff --git a/PreferencesGUI.py b/PreferencesGUI.py index c4638fc9..05b7e110 100644 --- a/PreferencesGUI.py +++ b/PreferencesGUI.py @@ -468,7 +468,8 @@ def OnApply(self, evt): ### enable the priority (DEVS select function) icon depending on the selected DEVS kernel mainW = wx.GetApp().GetTopWindow() - mainW.tb.EnableTool(Menu.ID_PRIORITY_DIAGRAM, not 'PyPDEVS' in builtins.__dict__['DEFAULT_DEVS_DIRNAME']) + tb = mainW.GetToolBar() + tb.EnableTool(Menu.ID_PRIORITY_DIAGRAM, not 'PyPDEVS' in builtins.__dict__['DEFAULT_DEVS_DIRNAME']) builtins.__dict__['SIMULATION_SUCCESS_SOUND_PATH'] = self.sim_success_sound_path builtins.__dict__['SIMULATION_ERROR_SOUND_PATH'] = self.sim_error_sound_path diff --git a/SpreadSheet.py b/SpreadSheet.py index e98e15a0..92ee4d62 100644 --- a/SpreadSheet.py +++ b/SpreadSheet.py @@ -125,8 +125,8 @@ def __init__(self, parent, id, title, aDEVS, separator=" "): self.model = aDEVS self.sep = separator - toolbar = wx.ToolBar(self, wx.NewIdRef(), style= wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT | wx.TB_TEXT) - toolbar.SetToolBitmapSize((25,25)) # just for windows + toolbar = wx.ToolBar(self, wx.NewIdRef(), style= wx.TB_HORIZONTAL | wx.NO_BORDER) + toolbar.SetToolBitmapSize((16,16)) ### for Phoenix version if wx.VERSION_STRING < '4.0': @@ -157,8 +157,8 @@ def __init__(self, parent, id, title, aDEVS, separator=" "): self.chart = toolbar.AddTool(wx.NewIdRef(), "", wx.Bitmap(os.path.join(ICON_PATH,'graph_guru.png')), _('Chart')) toolbar.EnableTool(self.chart.GetId(), False) + toolbar.Realize() - self.SetToolBar(toolbar) self.statusbar = self.CreateStatusBar() diff --git a/devsimpy.py b/devsimpy.py index 8dc87303..d60f472d 100644 --- a/devsimpy.py +++ b/devsimpy.py @@ -539,6 +539,7 @@ def MakeToolBar(self): pub.sendMessage('object.added', message=_('Making tools bar ...\n')) tb = wx.ToolBar(self, wx.NewIdRef(), name='tb', style=wx.TB_HORIZONTAL | wx.NO_BORDER) + tb.SetToolBitmapSize((16,16)) self.toggle_list = [wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef()] @@ -546,8 +547,6 @@ def MakeToolBar(self): ### Tools List - IDs come from Menu.py file if wx.VERSION_STRING < '4.0': - tb.SetToolBitmapSize((25,25)) # juste for windows - self.tools = [ tb.AddTool(wx.ID_NEW, wx.Bitmap(os.path.join(ICON_PATH,'new.png')), shortHelpString=_('New diagram (Ctrl+N)'),longHelpString=_('Create a new diagram in tab')), tb.AddTool(wx.ID_OPEN, wx.Bitmap(os.path.join(ICON_PATH,'open.png')), shortHelpString=_('Open File (Ctrl+O)'), longHelpString=_('Open an existing diagram')), tb.AddTool(wx.ID_PREVIEW_PRINT, wx.Bitmap(os.path.join(ICON_PATH,'print-preview.png')), shortHelpString=_('Print Preview (Ctrl+P)'), longHelpString=_('Print preview of current diagram')), diff --git a/wxPyMail.py b/wxPyMail.py index fa877cbc..7b770518 100644 --- a/wxPyMail.py +++ b/wxPyMail.py @@ -79,12 +79,11 @@ def createMenu(self): self.Bind(wx.EVT_MENU, self.OnClose, close_menu_item) def createToolbar(self): - toolbar = self.CreateToolBar(wx.TB_3DBUTTONS|wx.TB_TEXT) - toolbar.SetToolBitmapSize((31,31)) - bmp = wx.Bitmap(os.path.join(ICON_PATH_16_16,'mail.png')) - sendTool = toolbar.AddTool(-1, _('Send'), bmp, _('Sends Email')) + tb = wx.ToolBar(self, wx.NewIdRef(), name='tb', style=wx.TB_HORIZONTAL | wx.NO_BORDER) + tb.SetToolBitmapSize((16,16)) + sendTool = tb.AddTool(-1, _('Send'), wx.Bitmap(os.path.join(ICON_PATH_16_16,'mail.png')), _('Sends Email')) self.Bind(wx.EVT_MENU, self.OnSend, sendTool) - toolbar.Realize() + tb.Realize() def createWidgets(self): p = self.panel