diff --git a/CheckerGUI.py b/CheckerGUI.py index b37fbf9a..68cd1a56 100644 --- a/CheckerGUI.py +++ b/CheckerGUI.py @@ -40,6 +40,12 @@ if path not in sys.path: sys.path.append(path) 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')} + from wx.lib.mixins.listctrl import ListCtrlAutoWidthMixin, ColumnSorterMixin from Utilities import GetMails, getInstance @@ -236,7 +242,8 @@ def getColumnText(self, index, col): """ """ item = self.GetItem(index, col) - return item.GetText() + return item.GetItemLabelText() + #return item.GetText() #--------------------------------------------------- # These methods are callbacks for implementing the @@ -286,7 +293,7 @@ class CheckerGUI(wx.Frame): """ Class which report the code checking of python file """ - def __init__(self, parent, diagram): + def __init__(self, parent, D): """ Constructor. """ wx.Frame.__init__(self, parent, wx.NewIdRef(), _("DEVS Model Checking"), size=(900,400), style = wx.DEFAULT_FRAME_STYLE) @@ -297,17 +304,16 @@ def __init__(self, parent, diagram): ### local copy self.parent = parent - self.diagram = diagram ##############################################" comment for unitest ### prepare dictionary - - D = self.diagram.DoCheck() - self.list = self.getList(D) + try: + self.list = self.getList(D) + except: + self.list = VirtualList(self, D) + sys.stdout.write(_('Alone mode for CheckerGUI: List of plugins is not generated from a diagram.\n')) ################################################# - ### self.list = VirtualList(self,D) - self.mainSizer = wx.BoxSizer(wx.VERTICAL) controlSizer = wx.StdDialogButtonSizer() #wx.BoxSizer(wx.HORIZONTAL) self.listSizer = wx.BoxSizer(wx.VERTICAL) @@ -329,7 +335,6 @@ def __init__(self, parent, diagram): self.SetSizer(self.mainSizer) self.Center() - ### just for windows e = wx.SizeEvent(self.GetSize()) self.ProcessEvent(e) @@ -338,15 +343,10 @@ def __init__(self, parent, diagram): self.Bind(wx.EVT_BUTTON, self.OnOK, id = ok_btn.GetId()) self.Bind(wx.EVT_BUTTON, self.OnUpdate, id = update_btn.GetId()) - def OnClose(self,evt): - """ - """ - self.Close() - - def OnOK(self, evt): - """ + def SetDiagram(self, diagram): + """ Set the diagram. """ - self.Close() + self.diagram = diagram def getList(self, D): """ Return list to populate de virtualList @@ -393,24 +393,33 @@ def OnUpdate(self, evt): """ Update list has been invocked """ -# mainW = wx.GetApp().GetTopWindow() -# canvas = mainW.nb2.GetCurrentPage() -# diagram = canvas.GetDiagram() - ### get list by ckecking all block models of the diagram - D = self.diagram.DoCheck() - L = self.getList(D) + if hasattr(self, 'diagram'): + D = self.diagram.DoCheck() + L = self.getList(D) + + if isinstance(L, VirtualList): + self.list = L + + ### display the updated list + self.listSizer.Hide(0) + self.listSizer.Remove(0) + self.listSizer.Add(self.list, 1, wx.EXPAND, 10) + self.Layout() + else: + sys.stdou.write(_('List not updated!')) + else: + sys.stdout.write(_('Call the SetDiagram method to define the diagram object.')) - if isinstance(L, VirtualList): - self.list = L + def OnClose(self,evt): + """ + """ + self.Close() - ### display the updated list - self.listSizer.Hide(0) - self.listSizer.Remove(0) - self.listSizer.Add(self.list, 1, wx.EXPAND, 10) - self.Layout() - else: - sys.stdou.write(_('List not updated!')) + def OnOK(self, evt): + """ + """ + self.Close() ### ------------------------------------------------------------ class TestApp(wx.App): diff --git a/Container.py b/Container.py index 73984d83..dcb39f57 100644 --- a/Container.py +++ b/Container.py @@ -763,12 +763,13 @@ def OnCheck(self, event): if dial.ShowModal() == wx.ID_YES: self.OnSimulation(event) else: - frame = CheckerGUI.CheckerGUI(win, self) + frame = CheckerGUI.CheckerGUI(win, self.DoCheck()) + frame.SetDiagram(self) frame.Show() ### no models in diagram else: - wx.MessageBox(_("Diagram is empty.\n\nPlease, drag-and-drop model from libraries control panel to build a diagram."),_('Error Manager')) + wx.MessageBox(_("Diagram is empty.\n\nPlease, drag-and-drop model from libraries control panel to build a diagram or load an existing diagram."),_('Error Manager')) def OnSimulation(self, event): """ Method calling the simulationGUI @@ -800,7 +801,8 @@ def OnSimulation(self, event): playSound(SIMULATION_ERROR_SOUND_PATH) if dial.ShowModal() == wx.ID_YES: - frame = CheckerGUI.CheckerGUI(win, self) + frame = CheckerGUI.CheckerGUI(win, self.DoCheck()) + frame.SetDiagram(self) frame.Show() return False @@ -868,7 +870,7 @@ def OnSimulation(self, event): return True else: - wx.MessageBox(_("Diagram is empty. \nPlease, drag-and-drop model from libraries control panel to build a diagram."),_('Simulation Manager')) + wx.MessageBox(_("Diagram is empty.\n\nPlease, drag-and-drop model from libraries control panel to build a diagram or load an existing diagram.."),_('Simulation Manager')) return False def AddShape(self, shape, after = None): diff --git a/Editor.py b/Editor.py index 4ad9f5c8..8366d4bd 100644 --- a/Editor.py +++ b/Editor.py @@ -21,7 +21,6 @@ ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## - import wx import os import sys diff --git a/FTPGUI.py b/FTPGUI.py index 0b328985..2ff215fa 100644 --- a/FTPGUI.py +++ b/FTPGUI.py @@ -1,12 +1,33 @@ -#! /usr/bin/python +# -*- coding: utf-8 -*- + +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## +# FTPGUI.py --- +# -------------------------------- +# Copyright (c) 2020 +# L. CAPOCCHI (capocchi@univ-corse.fr) +# SPE Lab - SISU Group - University of Corsica +# -------------------------------- +# Version 1.0 last modified: 20/15/20 +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## +# +# GENERAL NOTES AND REMARKS: +# +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## + +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## +# +# GLOBAL VARIABLES AND FUNCTIONS +# +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## from ftplib import FTP, all_errors import wx import os class FTPStatusBar(wx.StatusBar): - def __init__(self, parent): - wx.StatusBar.__init__(self, parent) + + def __init__(self, *args, **kw): + super(FTPStatusBar, self).__init__(*args, **kw) self.SetFieldsCount(2) self.SetStatusText('Welcome to DEVSimPy server', 0) @@ -25,34 +46,75 @@ def OnSize(self, event): class FTPFrame(wx.Frame): """ """ - def __init__(self, parent, id, title): - """ Construcotr. - """ + def __init__(self, *args, **kw): + super(FTPFrame, self).__init__(*args, **kw) - wx.Frame.__init__(self, parent, id, title, size=(260, 270)) + self.ftp = None + self.OnInit() + def OnInit(self): - wx.StaticText(self, wx.NewIdRef(), 'Ftp site', (20, 20)) - wx.StaticText(self, wx.NewIdRef(), 'Login', (20, 60)) - wx.StaticText(self, wx.NewIdRef(), 'Password', (20, 100)) + panel = wx.Panel(self) - self.ftpsite = wx.TextCtrl(self, wx.NewIdRef(), 'http://lcapocchi.free.fr', (110, 15), (120, -1)) - self.login = wx.TextCtrl(self, wx.NewIdRef(), 'lcapocchi', (110, 55), (120, -1)) - self.password = wx.TextCtrl(self, wx.NewIdRef(), '', (110, 95), (120, -1), style=wx.TE_PASSWORD) + vbox = wx.BoxSizer(wx.VERTICAL) - self.ftp = None + hbox1 = wx.BoxSizer(wx.HORIZONTAL) + st1 = wx.StaticText(panel, label=_('Ftp site')) + hbox1.Add(st1, flag=wx.RIGHT, border=8) + self.ftpsite = wx.TextCtrl(panel, wx.NewIdRef(), 'http://lcapocchi.free.fr') + hbox1.Add(self.ftpsite, proportion=1) + vbox.Add(hbox1, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=10) + + vbox.Add((-1, 10)) + + hbox2 = wx.BoxSizer(wx.HORIZONTAL) + st2 = wx.StaticText(panel, label=_('Login')) + hbox2.Add(st2, flag=wx.RIGHT, border=8) + self.login = wx.TextCtrl(panel, wx.NewIdRef(), 'lcapocchi') + hbox2.Add(self.login, proportion=1) + vbox.Add(hbox2, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=10) + + vbox.Add((-1, 10)) - con = wx.Button(self, 1, 'Connect', (20, 160)) - discon = wx.Button(self, 2, 'DisConnect', (150, 160)) + hbox3 = wx.BoxSizer(wx.HORIZONTAL) + st3 = wx.StaticText(panel, label=_('Password')) + hbox3.Add(st3, flag=wx.RIGHT, border=8) + self.password = wx.TextCtrl(panel, wx.NewIdRef(), '', style=wx.TE_PASSWORD) + hbox3.Add(self.password, proportion=1) + vbox.Add(hbox3, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=10) - self.Bind(wx.EVT_BUTTON, self.OnConnect, id=1) - self.Bind(wx.EVT_BUTTON, self.OnDisConnect, id=2) + vbox.Add((-1, 10)) + + hbox4 = wx.BoxSizer(wx.HORIZONTAL) + con = wx.Button(panel, label=_('Connect'), size=(70, 30)) + hbox4.Add(con) + discon = wx.Button(panel, label=_('DisConnect'), size=(100, 30)) + hbox4.Add(discon, flag=wx.LEFT|wx.BOTTOM, border=5) + vbox.Add(hbox4, flag=wx.ALIGN_RIGHT|wx.RIGHT, border=10) + + #wx.StaticText(self.panel, wx.NewIdRef(), _('Ftp site'), (20, 20)) + #wx.StaticText(self.panel, wx.NewIdRef(), _('Login'), (20, 60)) + #wx.StaticText(self.panel, wx.NewIdRef(), _('Password'), (20, 100)) + + #self.ftpsite = wx.TextCtrl(self.panel, wx.NewIdRef(), 'http://lcapocchi.free.fr', (110, 15), (120, -1)) + #self.login = wx.TextCtrl(self.panel, wx.NewIdRef(), 'lcapocchi', (110, 55), (120, -1)) + #self.password = wx.TextCtrl(self.panel, wx.NewIdRef(), '', (110, 95), (120, -1), style=wx.TE_PASSWORD) + + #con = wx.Button(self.panel, wx.NewIdRef(), _('Connect'), (20, 160)) + #discon = wx.Button(self.panel, wx.NewIdRef(), _('DisConnect'), (120, 160)) + + self.Bind(wx.EVT_BUTTON, self.OnConnect, id=con.GetId()) + self.Bind(wx.EVT_BUTTON, self.OnDisConnect, id=discon.GetId()) self.statusbar = FTPStatusBar(self) self.SetStatusBar(self.statusbar) + + panel.SetSizer(vbox) self.Centre() def OnConnect(self, event): + """ + """ if not self.ftp: ftpsite = self.ftpsite.GetValue() login = self.login.GetValue() @@ -61,27 +123,54 @@ def OnConnect(self, event): try: self.ftp = FTP(ftpsite) var = self.ftp.login(login, password) - self.statusbar.SetStatusText('User connected') + self.statusbar.SetStatusText(_('User connected')) self.statusbar.icon.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16, 'connect_network.png'))) self.OnSend() except AttributeError: self.statusbar.SetForegroundColour(wx.RED) - self.statusbar.SetStatusText('Incorrect params') + self.statusbar.SetStatusText(_('Incorrect params')) self.ftp = None except all_errors as err: self.statusbar.SetStatusText(str(err)) self.ftp = None - def OnSend(self, fn='out.kml'): + """ + """ with open(fn, 'rb') as f: sftp.storbinary('STOR %s'%"devsimpy/"+fn, f) # Send the file def OnDisConnect(self, event): + """ + """ if self.ftp: self.ftp.quit() self.ftp = None self.statusbar.SetStatusText('User disconnected') self.statusbar.icon.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16, 'disconnect_network.png'))) +### ------------------------------------------------------------ +class TestApp(wx.App): + """ Testing application + """ + + def OnInit(self): + + import gettext + import builtins + + builtins.__dict__['ICON_PATH']='icons' + builtins.__dict__['ICON_PATH_16_16']=os.path.join(ICON_PATH,'16x16') + builtins.__dict__['_'] = gettext.gettext + + self.frame = FTPFrame(None, -1, 'Test') + self.frame.Show() + return True + + def OnQuit(self, event): + self.Close() + +if __name__ == '__main__': + app = TestApp(0) + app.MainLoop() \ No newline at end of file diff --git a/LabelGUI.py b/LabelGUI.py index 22d4c922..d87e8004 100644 --- a/LabelGUI.py +++ b/LabelGUI.py @@ -25,7 +25,18 @@ import wx from wx import xrc -from AttributeEditor import AttributeBase +### just for individual test +if __name__ == '__main__': + import builtins + + 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')} +else: + from AttributeEditor import AttributeBase __res = None @@ -65,8 +76,6 @@ def __init__(self, parent, block=None): ### local copy self.block = block self.parent = parent - - self.canvas = self.parent.canvas _xrcName = "LabelEditorFrame" @@ -120,12 +129,17 @@ def SetProperties(self): self.old_label = txt self.old_pos = self.block.label_pos + def SetCanvas(self, canvas): + """ + """ + self.canvas = canvas + def OnTextChange(self, evt): """ Text in CtrlText change dynamic update of label during edition """ txt = self.label_txtCtrl.GetValue() - if txt != "" and self.block: + if hasattr(self, 'canvas') and txt != "" and self.block: self.block.label=txt ### update of block from canvas diff --git a/Menu.py b/Menu.py index ccb99930..0efe865d 100644 --- a/Menu.py +++ b/Menu.py @@ -628,8 +628,8 @@ def __init__(self, parent): close = wx.MenuItem(self, ID_EXIT_DIAGRAM, _('Close'), _('Close diagram')) detach = wx.MenuItem(self, ID_DETACH_DIAGRAM, _('Detach'), _('Detach tab to window')) - rename = wx.MenuItem(self, ID_RENAME_DIAGRAM, _('Rename...'), _('Rename diagram')) - clear = wx.MenuItem(self, ID_CLEAR_DIAGRAM, _('Clear...'), _('Clear diagram')) + rename = wx.MenuItem(self, ID_RENAME_DIAGRAM, _('Rename'), _('Rename diagram')) + clear = wx.MenuItem(self, ID_CLEAR_DIAGRAM, _('Clear'), _('Clear diagram')) close.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16,'close.png'))) detach.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16,'detach.png'))) diff --git a/Mixins/Selectable.py b/Mixins/Selectable.py index 04ddfc2b..635b6736 100644 --- a/Mixins/Selectable.py +++ b/Mixins/Selectable.py @@ -61,6 +61,7 @@ def DoLabelDialog(self, canvas): ### ask new label d = LabelGUI.LabelDialog(canvas, self) + d.SetCanvas(canvas) d.ShowModal() ### update priority list if label is different and update panel properties only if is active diff --git a/PluginsGUI.py b/PluginsGUI.py index 2fa01598..bbe3d2ee 100644 --- a/PluginsGUI.py +++ b/PluginsGUI.py @@ -1,10 +1,30 @@ # -*- coding: utf-8 -*- +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## +# PluginGUI.py --- +# -------------------------------- +# Copyright (c) 2020 +# L. CAPOCCHI (capocchi@univ-corse.fr) +# SPE Lab - SISU Group - University of Corsica +# -------------------------------- +# Version 1.0 last modified: 03/20/20 +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## +# +# GENERAL NOTES AND REMARKS: +# +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## + +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## +# +# GLOBAL VARIABLES AND FUNCTIONS +# +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## + import wx import os import datetime import sys -import imp +import importlib import abc import re import zipimport @@ -40,10 +60,7 @@ def __init__(self, parent): self.id = -100000000 self.map = {} - images = [ os.path.join(ICON_PATH_16_16,'disable_plugin.png'), - os.path.join(ICON_PATH_16_16,'enable_plugin.png'), - os.path.join(ICON_PATH_16_16,'no_ok.png') - ] + images = [os.path.join(ICON_PATH_16_16,s) for s in ('disable_plugin.png','enable_plugin.png','no_ok.png')] self.il = wx.ImageList(16, 16) for i in images: @@ -293,7 +310,7 @@ def Importing(self, root, basename): ### if module is exception (or tuple) if not inspect.ismodule(module): error = str(module) - module = imp.new_module(basename) + module = importlib.new_module(basename) module.__doc__ = error module.__file__ = None @@ -488,6 +505,7 @@ def IsInPackage(model_path): """ Return True if plugins.py file is in plug-ins package Warning : importer.is_package('plug-ins') don't work !!! """ + zf = zipfile.ZipFile(model_path, 'r') nl = zf.namelist() zf.close() @@ -497,15 +515,12 @@ def IsInPackage(model_path): def IsInRoot(model_path): """ Return True is plugins.py is in zipfile """ + zf = zipfile.ZipFile(model_path, 'r') nl = zf.namelist() zf.close() return any([re.search("^plugins.py$", s) for s in nl]) - #return 'plugins.py' in nl - #importer = zipimport.zipimporter(model_path) - #return importer.find_module('plug-ins') is not None - def GetPluginsList(self, model_path): """ Get plug-ins list from plug-in file """ @@ -573,6 +588,7 @@ def GetPluginsList(self, model_path): def Clear(self): """ Delete all items of list """ + self.DeleteAllItems() self.is_populate = False @@ -594,8 +610,8 @@ def __init__(self, parent): hbox = wx.BoxSizer(wx.HORIZONTAL) ### Panels - self.leftPanel = wx.Panel(self, wx.NewIdRef()) - self.rightPanel = wx.Panel(self, wx.NewIdRef()) + self.leftPanel = wx.Panel(self) + self.rightPanel = wx.Panel(self) ### plug-in documentation area self.log = wx.TextCtrl(self.rightPanel, wx.NewIdRef(), size=(-1,150), style=wx.TE_MULTILINE) @@ -624,21 +640,21 @@ def __init__(self, parent): self.vbox2.Add((-1, 15)) self.vbox2.Add(selBtn, 0, wx.TOP, 5) self.vbox2.Add(desBtn, 0, wx.TOP, 5) - self.vbox2.Add(wx.StaticLine(self.leftPanel), 0, wx.ALL|wx.EXPAND, 5) - self.vbox2.Add(self.configBtn) + self.vbox2.Add(wx.StaticLine(self.leftPanel), 0, wx.EXPAND|wx.TOP, 5) + self.vbox2.Add(self.configBtn, 0, wx.TOP, 5) - self.vbox1.Add(self.check_list, 1, wx.EXPAND | wx.TOP) + self.vbox1.Add(self.check_list, 1, wx.EXPAND|wx.TOP, 5) self.vbox1.Add((-1, 10)) - self.vbox1.Add(self.log, 0.5, wx.EXPAND) + self.vbox1.Add(self.log, 1, wx.EXPAND|wx.ALL, 5) hbox.Add(self.rightPanel, 1, wx.EXPAND|wx.ALL) - hbox.Add(self.leftPanel, 0, wx.EXPAND | wx.RIGHT|wx.ALL, 5) - hbox.Add((3, -1)) + hbox.Add(self.leftPanel, 0, wx.EXPAND|wx.ALL, 5) + #hbox.Add((3, -1)) ### Set Sizer self.leftPanel.SetSizer(self.vbox2) self.rightPanel.SetSizer(self.vbox1) - self.SetSizer(hbox) + self.SetSizerAndFit(hbox) #self.SetAutoLayout(True) ### Binding @@ -801,7 +817,7 @@ def __init__(self, **kwargs): self.CheckList.OnEdit = self.OnEdit self.CenterOnParent(wx.BOTH) - self.Layout() + self.Fit() @staticmethod def GetEditor(parent, model, filename=None): @@ -933,9 +949,10 @@ def OnInit(self): import gettext builtins.__dict__['HOME_PATH'] = os.getcwd() + builtins.__dict__['ICON_PATH_16_16']=os.path.join('icons','16x16') builtins.__dict__['_'] = gettext.gettext - frame = ModelPluginsManager(parent=None, id=-1, title="Test", model=None) + frame = ModelPluginsManager(parent=None, title="Test", model=None) frame.Show() return True diff --git a/PreferencesGUI.py b/PreferencesGUI.py index a2ee3c8b..fda30968 100644 --- a/PreferencesGUI.py +++ b/PreferencesGUI.py @@ -44,8 +44,8 @@ from HtmlWindow import HtmlFrame -from PluginsGUI import PluginsPanel, GeneralPluginsList, ModelPluginsManager -from Utilities import playSound, GetUserConfigDir, GetWXVersionFromIni, getPYFileListFromInit, AddToInitFile, DelToInitFile +from PluginsGUI import PluginsPanel, GeneralPluginsList +from Utilities import playSound, GetUserConfigDir, GetWXVersionFromIni, AddToInitFile, DelToInitFile import ReloadModule import Menu diff --git a/PrintOut.py b/PrintOut.py index 8cd11fc7..21bd8a86 100644 --- a/PrintOut.py +++ b/PrintOut.py @@ -117,8 +117,11 @@ def PrintButton(self, event): if printer.Print(parent, printout, True): self.printData = wx.PrintData(printer.GetPrintDialogData().GetPrintData()) - printout.Destroy() - + printout.Destroy() + return True + else: + printout.Destroy() + return False def PrintPreview(self, event): @@ -141,9 +144,11 @@ def PrintPreview(self, event): pfrm.SetPosition((300, 200)) pfrm.SetSize((550, 700)) pfrm.Show(True) + return True else: sys.stderr.write(_("Problem on print preview...\n")) + return False def PageSetup(self, evt): psdd = wx.PageSetupDialogData(self.printData) diff --git a/PriorityGUI.py b/PriorityGUI.py index 59a203b8..d3658cbe 100644 --- a/PriorityGUI.py +++ b/PriorityGUI.py @@ -41,7 +41,7 @@ def __init__(self, parent, id, title, priorityList): if wx.VERSION_STRING >= '4.0': self.listCtrl.SetToolTipString = self.listCtrl.SetToolTip - self.listCtrl.SetToolTipString(_('Drag and drop a model in order to define its priority')) + self.listCtrl.SetToolTipString(_('Drag and drop a model in order to define its priority.')) ### id list not empty, first item is selected if self.listCtrl.GetItemCount(): @@ -131,7 +131,8 @@ class TestApp(wx.App): """ def OnInit(self): - + """ + """ import builtins import gettext @@ -147,6 +148,5 @@ def OnQuit(self, event): self.Close() if __name__ == '__main__': - app = TestApp(0) app.MainLoop() \ No newline at end of file diff --git a/PropertiesGridCtrl.py b/PropertiesGridCtrl.py index ea9aaeec..cf0a790f 100644 --- a/PropertiesGridCtrl.py +++ b/PropertiesGridCtrl.py @@ -934,6 +934,7 @@ def SelectProp(self, evt): elif prop == 'label': d = LabelGUI.LabelDialog(self.parent, self.parent.model) + d.SetCanvas(self.parent.canvas) d.ShowModal() self.SetCellValue(row,1,str(self.parent.model.label)) diff --git a/WizardGUI.py b/WizardGUI.py index 28e3e608..8a0ec953 100644 --- a/WizardGUI.py +++ b/WizardGUI.py @@ -1,5 +1,25 @@ # -*- coding: utf-8 -*- +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## +# WizardGUI.py --- +# -------------------------------- +# Copyright (c) 2020 +# L. CAPOCCHI (capocchi@univ-corse.fr) +# SPE Lab - SISU Group - University of Corsica +# -------------------------------- +# Version 1.0 last modified: 20/15/20 +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## +# +# GENERAL NOTES AND REMARKS: +# +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## + +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## +# +# GLOBAL VARIABLES AND FUNCTIONS +# +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## + import wx if wx.VERSION_STRING >= '4.0': diff --git a/devsimpy.py b/devsimpy.py index e4bceedc..29c97a62 100644 --- a/devsimpy.py +++ b/devsimpy.py @@ -812,7 +812,7 @@ def OnRestorePerspective(self, event): id = event.GetId() item = self.GetMenuBar().FindItemById(id) mgr = self.GetMGR() - mgr.LoadPerspective(self.perspectives[item.GetText()]) + mgr.LoadPerspective(self.perspectives[item.GetItemLabelText()]) def OnDeletePerspective(self, event): """ @@ -1151,15 +1151,25 @@ def OnPrint(self, event): """ self.nb2.print_canvas = self.nb2.GetCurrentPage() self.nb2.print_size = self.nb2.GetSize() - self.nb2.PrintButton(event) + + if self.nb2.PrintButton(event): + NotificationMessage(_('Information'), _('Print has been well done'), parent=self, timeout=5) + else: + NotificationMessage(_('Error'), _('Print not possible!\n Check the trace in background for more informations.'), parent=self, flag=wx.ICON_ERROR, timeout=5) + ### def OnPrintPreview(self, event): """ Print preview of current diagram """ - self.nb2.print_canvas = self.nb2.GetCurrentPage() self.nb2.print_size = self.nb2.GetSize() - self.nb2.PrintPreview(event) + + if self.nb2.PrintPreview(event): + NotificationMessage(_('Information'), _('Print has been well done'), parent=self, timeout=5) + else: + NotificationMessage(_('Error'), _('Print not possible!\n Check the trace in background for more informations.'), parent=self, flag=wx.ICON_ERROR, timeout=5) + ### + ### def OnScreenCapture(self, event): """ Print preview of current diagram @@ -1182,10 +1192,12 @@ def OnScreenCapture(self, event): currentPage.deselect() diagram = currentPage.GetDiagram() + last_name_saved = getattr(diagram,'last_name_saved', os.path.join(HOME_PATH, 'screenshot.png')) + ### options building wcd = _("PNG files (*.png)|*.png|All files (*)|*)") - home = self.home or os.path.dirname(getattr(diagram,'last_name_saved', False)) or HOME_PATH if self.openFileList == ['']*NB_OPENED_FILE else self.home or os.path.dirname(self.openFileList[0]) - save_dlg = wx.FileDialog(self, message=_('Save file as...'), defaultDir=home, defaultFile='screenshot.png', wildcard=wcd, style=wx.SAVE | wx.OVERWRITE_PROMPT) + home = self.home or os.path.dirname(last_name_saved) or HOME_PATH if self.openFileList == ['']*NB_OPENED_FILE else self.home or os.path.dirname(self.openFileList[0]) + save_dlg = wx.FileDialog(self, message=_('Save file as...'), defaultDir=home, defaultFile=os.path.basename(last_name_saved), wildcard=wcd, style=wx.SAVE | wx.OVERWRITE_PROMPT) if save_dlg.ShowModal() == wx.ID_OK: save_dlg.Destroy() @@ -1291,7 +1303,7 @@ def OnSaveFile(self, event): #if isinstance(diagram, Container.ContainerBlock): # Container.Block.OnExport(diagram, event) #else: - if diagram.last_name_saved: + if getattr(diagram,'last_name_saved', False): assert(os.path.isabs(diagram.last_name_saved)) @@ -1314,10 +1326,6 @@ def OnSaveAsFile(self, event): """ Save file menu as has been selected. """ - #obj = event.GetEventObject() - #if isinstance(obj, wx.ToolBar) and isinstance(obj.GetParent(), DetachedFrame): - # currentPage = obj.GetToolClientData(event.GetId()) - #else: currentPage = self.nb2.GetCurrentPage() ### deselect all model to initialize select attribut for all models @@ -1325,8 +1333,6 @@ def OnSaveAsFile(self, event): diagram = copy.deepcopy(currentPage.GetDiagram()) - last_name_saved = diagram.last_name_saved - ### options building msg = "DEVSimPy files (*.dsp)|*.dsp|" if builtins.__dict__['YAML_IMPORT']: @@ -1335,8 +1341,7 @@ def OnSaveAsFile(self, event): wcd = _(msg) home = self.home or os.path.dirname(diagram.last_name_saved) or HOME_PATH if self.openFileList == ['']*NB_OPENED_FILE else self.home or os.path.dirname(self.openFileList[0]) - save_dlg = wx.FileDialog(self, message=_('Save file as...'), defaultDir=home, defaultFile=last_name_saved, wildcard=wcd, style=wx.SAVE | wx.OVERWRITE_PROMPT) - + save_dlg = wx.FileDialog(self, message=_('Save file as...'), defaultDir=home, defaultFile=os.path.basename(diagram.last_name_saved), wildcard=wcd, style=wx.SAVE | wx.OVERWRITE_PROMPT) if save_dlg.ShowModal() == wx.ID_OK: path = os.path.normpath(save_dlg.GetPath())