Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion AttributeEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ class AttributeEditorPanel(AttributeBase, wx.Panel):

def __init__(self, parent, ID, model, canvas):
""" Constructor.

"""
# pour gerer l'affichage dans la page de gauche dans le notebook
wx.Panel.__init__(self, parent, ID)
Expand Down
4 changes: 2 additions & 2 deletions Components.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from tempfile import gettempdir


if builtins.__dict__['GUI_FLAG']:
if builtins.__dict__.get('GUI_FLAG',True):
import wx

if wx.VERSION_STRING < '2.9':
Expand Down Expand Up @@ -531,7 +531,7 @@ def setBlock(self, devs):
if not hasattr(devs, 'debugger'):
setattr(devs.__class__, DEVSComponent.debugger.__name__, DEVSComponent.debugger)

if builtins.__dict__['GUI_FLAG']:
if builtins.__dict__.get('GUI_FLAG',True):
### to execute finish method of devs model (look at the SimulationGUI for message interception)
if hasattr(devs, 'finish'):
Publisher.subscribe(devs.finish, "%d.finished"%(id(devs)))
Expand Down
14 changes: 7 additions & 7 deletions Container.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import builtins

if builtins.__dict__['GUI_FLAG']:
if builtins.__dict__.get('GUI_FLAG',True):
import wx
import wx.lib.dragscroller
import wx.lib.dialogs
Expand Down Expand Up @@ -72,7 +72,7 @@

import DomainInterface.MasterModel

if builtins.__dict__['GUI_FLAG']:
if builtins.__dict__.get('GUI_FLAG',True):
import ConnectDialog
import DiagramConstantsDialog
import SpreadSheet
Expand All @@ -89,7 +89,7 @@

import Components

if builtins.__dict__['GUI_FLAG']:
if builtins.__dict__.get('GUI_FLAG',True):
import Menu

#import ReloadModule
Expand All @@ -113,7 +113,7 @@
from Utilities import HEXToRGB, RGBToHEX, relpath, GetActiveWindow, playSound, sendEvent, getInstance, FixedList, getObjectFromString, getTopLevelWindow, printOnStatusBar
from Patterns.Observer import Subject, Observer

if builtins.__dict__['GUI_FLAG']:
if builtins.__dict__.get('GUI_FLAG',True):
from DetachedFrame import DetachedFrame
from AttributeEditor import AttributeEditor, QuickAttributeEditor
from PropertiesGridCtrl import PropertiesGridCtrl
Expand Down Expand Up @@ -591,7 +591,7 @@ def GetParent(self):
def GetGrandParent(self):
return self.GetParent().GetParent()

@cond_decorator(builtins.__dict__['GUI_FLAG'], ProgressNotification("DEVSimPy open file"))
@cond_decorator(builtins.__dict__.get('GUI_FLAG',True), ProgressNotification("DEVSimPy open file"))
def LoadFile(self, fileName = None):
""" Function that load diagram from a file.
"""
Expand All @@ -613,7 +613,7 @@ def LoadFile(self, fileName = None):

return True

#@cond_decorator(builtins.__dict__['GUI_FLAG'], StatusBarNotification('Load'))
#@cond_decorator(builtins.__dict__.get('GUI_FLAG',True), StatusBarNotification('Load'))
def LoadConstants(self, label):
""" Load Constants to general builtin.
"""
Expand Down Expand Up @@ -1483,7 +1483,7 @@ def draw(self,dc):
self.graphic.fill = self.fill
self.graphic.draw(dc)

if builtins.__dict__['GUI_FLAG']:
if builtins.__dict__.get('GUI_FLAG',True):
#-------------------------------------------------------------------------------
class ShapeCanvas(wx.ScrolledWindow, Abstractable, Subject):
""" ShapeCanvas class.
Expand Down
2 changes: 1 addition & 1 deletion Decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import pickle
import cProfile, pstats, io

if builtins.__dict__['GUI_FLAG']:
if builtins.__dict__.get('GUI_FLAG',True):
import wx
if wx.VERSION_STRING < '4.0':
import wx.aui
Expand Down
10 changes: 5 additions & 5 deletions ImportLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def InitUI(self):
#-------------------------------------------------------------------
class ImportLibrary(wx.Dialog):
def __init__(self, *args, **kwargs):
wx.Dialog.__init__(self, *args, **kwargs)
super(ImportLibrary, self).__init__(*args, **kwargs)

### local copy
self.parent = args[0]
Expand Down Expand Up @@ -238,11 +238,11 @@ def __init__(self, *args, **kwargs):
apply = wx.Button(rightPanel, id=wx.ID_OK, size=(100, -1))
cancel = wx.Button(rightPanel, id=wx.ID_CANCEL, size=(100, -1))

vbox2.Add(new, 0, wx.TOP, 2)
vbox2.Add(imp, 0, wx.TOP, 2)
vbox2.Add(new, 0, wx.TOP|wx.LEFT, 6)
vbox2.Add(imp, 0, wx.TOP|wx.LEFT, 6)
#vbox2.Add((-1, 5))
vbox2.Add(sel, 0, wx.TOP, 2)
vbox2.Add(des, 0, wx.TOP, 2)
vbox2.Add(sel, 0, wx.TOP|wx.LEFT, 6)
vbox2.Add(des, 0, wx.TOP|wx.LEFT, 6)

hbox1.Add(cancel, 1, wx.ALL|wx.ALIGN_CENTER, 2)
hbox1.Add(apply, 1, wx.ALL|wx.ALIGN_CENTER, 2)
Expand Down
6 changes: 3 additions & 3 deletions Mixins/Savable.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,8 @@ class Savable(object):
### static attribut to store le extention/class available
DB = DumpBase.PopulateDB()

@cond_decorator(builtins.__dict__['GUI_FLAG'], BuzyCursorNotification)
@cond_decorator(builtins.__dict__['GUI_FLAG'], StatusBarNotification('Sav'))
@cond_decorator(builtins.__dict__.get('GUI_FLAG',True), BuzyCursorNotification)
@cond_decorator(builtins.__dict__.get('GUI_FLAG',True), StatusBarNotification('Sav'))
def SaveFile(self, fileName = None):
""" Save object in fileName
"""
Expand All @@ -561,7 +561,7 @@ def SaveFile(self, fileName = None):
sys.stdout.write(_("\nUnknown extension: %s")%fileName)
return False

@cond_decorator(builtins.__dict__['GUI_FLAG'], StatusBarNotification('Load'))
@cond_decorator(builtins.__dict__.get('GUI_FLAG',True), StatusBarNotification('Load'))
def LoadFile(self, fileName = None):
""" Load object from fileName
"""
Expand Down
2 changes: 1 addition & 1 deletion SimulationGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ def terminate(self, error = False, msg = None):
else:
for m in [a for a in list(self.model.getFlatComponentSet().values()) if hasattr(a, 'finish')]:
### call finished method
if builtins.__dict__['GUI_FLAG']:
if builtins.__dict__.get('GUI_FLAG',True):
#if wx.VERSION_STRING < '2.9':
try:
pub.sendMessage('%d.finished'%(id(m)))
Expand Down
2 changes: 1 addition & 1 deletion Utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from io import StringIO

if builtins.__dict__['GUI_FLAG']:
if builtins.__dict__.get('GUI_FLAG',True):
import wx

### for Phoenix
Expand Down
72 changes: 36 additions & 36 deletions devsimpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
__date__ = str(datetime.datetime.now())
__version__ = '4.0'
__docformat__ = 'epytext'
__min_wx_version__ = ['4.0']
__min_wx_version__ = '4.0'

ABS_HOME_PATH = os.path.abspath(os.path.dirname(sys.argv[0]))

Expand Down Expand Up @@ -150,8 +150,7 @@
'DYNAMIC_STRUCTURE' : False, # Dynamic Structure for local PyPDEVS simulation
'REAL_TIME': False, ### PyPDEVS threaded real time simulation
'VERBOSE':False,
'TRANSPARENCY' : True, # Transparancy for DetachedFrame activated
'NOTIFICATION' : True, # Notification message activated
'TRANSPARENCY' : True, # Transparancy for DetachedFrame
'DEFAULT_PLOT_DYN_FREQ' : 100, # frequence of dynamic plot of QuickScope (to avoid overhead),
'DEFAULT_DEVS_DIRNAME':'PyDEVS', # default DEVS Kernel directory
'DEVS_DIR_PATH_DICT':{'PyDEVS':os.path.join(ABS_HOME_PATH,'DEVSKernel','PyDEVS'),
Expand Down Expand Up @@ -187,7 +186,7 @@
from PreferencesGUI import PreferencesGUI
from pluginmanager import load_plugins, enable_plugin
from which import which
from Utilities import GetUserConfigDir, install_and_import, printOnStatusBar, NotificationMessage, updatePackageWithPiP
from Utilities import GetUserConfigDir, install_and_import, updatePackageWithPiP
from Decorators import redirectStdout, BuzyCursorNotification
from DetachedFrame import DetachedFrame
from LibraryTree import LibraryTree
Expand Down Expand Up @@ -772,30 +771,20 @@ def EnableAbstractionButton(self):
### update text filed
level = self.spin.GetValue()

tb = self.GetToolBar()

### update doward and upward button
tb.EnableTool(self.toggle_list[4], level != 0)
tb.EnableTool(self.toggle_list[5], level != 0)
self.tb.EnableTool(self.toggle_list[4], level != 0)
self.tb.EnableTool(self.toggle_list[5], level != 0)

def OnDeleteRecentFiles(self, event):
""" Delete the recent files list
"""

dial = wx.MessageDialog(self, _('Do you want to clear the list of recent opened files?'), 'Clean Recent Opened Files List', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)

### if local editor
if dial.ShowModal() == wx.ID_YES:
# update openFileList variable
self.openFileList = ['']*NB_OPENED_FILE

# update config file
self.cfg.Write("openFileList", str(eval("self.openFileList")))
self.cfg.Flush()

NotificationMessage(_("Information"), _("Recent opened files list has been deleted!"), self, timeout=5)
# update openFileList variable
self.openFileList = ['']*NB_OPENED_FILE

dial.Destroy()
# update config file
self.cfg.Write("openFileList", str(eval("self.openFileList")))
self.cfg.Flush()

def OnCreatePerspective(self, event):
"""
Expand Down Expand Up @@ -1057,7 +1046,7 @@ def OnZoom(self, event):
currentPage.scaley=max(currentPage.scaley+.05,.3)
currentPage.Refresh()

printOnStatusBar(self.statusbar,{0:_('Zoom In')})
self.statusbar.SetStatusText(_('Zoom In'))

###
def OnUnZoom(self, event):
Expand All @@ -1074,7 +1063,7 @@ def OnUnZoom(self, event):
currentPage.scaley=currentPage.scaley-.05
currentPage.Refresh()

printOnStatusBar(self.statusbar,{0:_('Zoom Out')})
self.statusbar.SetStatusText(_('Zoom Out'))

###
def AnnuleZoom(self, event):
Expand All @@ -1091,7 +1080,7 @@ def AnnuleZoom(self, event):
currentPage.scaley = 1.0
currentPage.Refresh()

printOnStatusBar(self.statusbar,{0:_('No Zoom')})
self.statusbar.SetStatusText(_('No Zoom'))

###
def OnNew(self, event):
Expand Down Expand Up @@ -1296,9 +1285,10 @@ def OnSaveFile(self, event):
# Refresh canvas
currentPage.Refresh()

tb = self.GetToolBar()
### enable save button on status bar
tb.EnableTool(Menu.ID_SAVE, diagram.modify)
self.tb.EnableTool(Menu.ID_SAVE, diagram.modify)

#self.statusbar.SetStatusText(_('%s saved')%diagram.last_name_saved)
else:
wx.MessageBox( _('Error saving file.') ,_('Error'), wx.OK | wx.ICON_ERROR)
else:
Expand Down Expand Up @@ -1372,9 +1362,8 @@ def OnSaveAsFile(self, event):
else:
self.nb2.AddEditPage(label, diagram)

tb = self.GetToolBar()
### enable save button on status bar
tb.EnableTool(Menu.ID_SAVE, diagram.modify)
self.tb.EnableTool(Menu.ID_SAVE, diagram.modify)
else:
wx.MessageBox(_('Error saving file.'), _('Error'), wx.OK | wx.ICON_ERROR)

Expand Down Expand Up @@ -2003,17 +1992,15 @@ def OnHelp(self, event):
else:
self.help.Display(os.path.join('html','toc.html'))

def OnUpdatePiPPackage(self, event):
updatePackageWithPiP()

def OnAPI(self, event):
""" Shows the DEVSimPy API help file. """

#webbrowser.open_new(opj(self.installDir + "/docs/api/index.html"))
wx.MessageBox(_("This option has not been implemented yet."), _('Info'), wx.OK|wx.ICON_INFORMATION)

def OnUpdatePiPPackage(self, event):
""" Update all pip package
"""
updatePackageWithPiP()

@BuzyCursorNotification
def OnAbout(self, event):
""" About menu has been pressed.
Expand Down Expand Up @@ -2054,7 +2041,7 @@ def OnAbout(self, event):
def OnContact(self, event):
""" Launches the mail program to contact the DEVSimPy author. """

frame = SendMailWx(None)
frame = SendMailWx()
frame.Show()

##-------------------------------------------------------------------
Expand Down Expand Up @@ -2179,7 +2166,7 @@ def ShowMain(self):

self.app.frame = MainApplication(None, wx.NewIdRef(), 'DEVSimPy %s'%__version__)

printOnStatusBar(self.app.frame.statusbar,{1:_('wxPython %s - python %s'%(wx.version(),platform.python_version()))})
self.app.frame.statusbar.SetStatusText(_('wxPython %s - python %s'%(wx.version(),platform.python_version())),1)

# keep in a attribute of stdio which is invisible until now
self.app.frame.stdioWin = self.app.stdioWin
Expand Down Expand Up @@ -2270,7 +2257,7 @@ def __init__(self, redirect=False, filename=None):
wx.App.__init__(self, redirect, filename)

# make sure we can create a GUI
if not self.IsDisplayAvailable() and not builtins.__dict__['GUI_FLAG']:
if not self.IsDisplayAvailable() and not builtins.__dict__.get('GUI_FLAG',True):

if wx.Platform == '__WXMAC__':
msg = """This program needs access to the screen.
Expand Down Expand Up @@ -2347,10 +2334,23 @@ def OnInit(self):
the main frame when it is time to do so.
"""

# Check runtime version
if wx.VERSION_STRING < __min_wx_version__:
wx.MessageBox(caption=_("Warning"),
message=_("You're using version %s of wxPython, but DEVSimPy was written for min version %s.\n"
"There may be some version incompatibilities...")
% (wx.VERSION_STRING, __min_wx_version__))
# For debugging
#self.SetAssertMode(wx.PYAPP_ASSERT_DIALOG|wx.PYAPP_ASSERT_EXCEPTION)

wx.SystemOptions.SetOption("mac.window-plain-transition", 1)
self.SetAppName("DEVSimPy")

# start our application with splash
splash = AdvancedSplashScreen(self)
splash.Show()


return True

def SetExceptionHook(self):
Expand Down