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
6 changes: 6 additions & 0 deletions Menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
# Help menu identifiers
ID_HELP = wx.ID_HELP
ID_API_HELP = wx.NewIdRef()
ID_UPDATE_PIP_PACKAGE = wx.NewIdRef()
ID_CONTACT = wx.NewIdRef()
ID_ABOUT = wx.ID_ABOUT

Expand Down Expand Up @@ -475,10 +476,12 @@ def __init__(self, parent):

helpModel = wx.MenuItem(self, ID_HELP, _('&DEVSimPy Help\tF1'), _("Help for DEVSimPy user"))
apiModel = wx.MenuItem(self, ID_API_HELP, _('&DEVSimPy API\tF2'), _("API for DEVSimPy user"))
updatePipPackage = wx.MenuItem(self, ID_UPDATE_PIP_PACKAGE, _('Update PIP Packages\tF3'), _("Update pip packages"))
contactModel = wx.MenuItem(self, ID_CONTACT, _('Contact the Author...'), _("Send mail to the author"))
aboutModel = wx.MenuItem(self, ID_ABOUT, _('About DEVSimPy...'), _("About DEVSimPy"))

helpModel.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH,'search.png')))
updatePipPackage.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH,'update.png')))
apiModel.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH,'api.png')))
contactModel.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH,'mail.png')))
aboutModel.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH,'info.png')))
Expand All @@ -488,11 +491,14 @@ def __init__(self, parent):
AppendItem(helpModel)
AppendItem(apiModel)
self.AppendSeparator()
AppendItem(updatePipPackage)
self.AppendSeparator()
AppendItem(aboutModel)
AppendItem(contactModel)

parent.Bind(wx.EVT_MENU, parent.OnHelp, id=ID_HELP)
parent.Bind(wx.EVT_MENU, parent.OnAPI, id=ID_API_HELP)
parent.Bind(wx.EVT_MENU, parent.OnUpdatePiPPackage, id=ID_UPDATE_PIP_PACKAGE)
parent.Bind(wx.EVT_MENU, parent.OnAbout, id=ID_ABOUT)
parent.Bind(wx.EVT_MENU, parent.OnContact, id=ID_CONTACT)

Expand Down
16 changes: 14 additions & 2 deletions PreferencesGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,18 @@ def __init__(self, parent):
self.nb_history_undo.SetRange(2, 100)
self.nb_history_undo.SetValue(NB_HISTORY_UNDO)

### CheckBox
### CheckBox for transparancy
self.cb1 = wx.CheckBox(self, wx.NewIdRef(), _('Transparency'))
if wx.VERSION_STRING >= '4.0': self.cb1.SetToolTipString = self.cb1.SetToolTip
self.cb1.SetToolTipString(_("Transparency for the detached frame of diagrams"))
self.cb1.SetValue(builtins.__dict__['TRANSPARENCY'])

### CheckBox for notification
self.cb11 = wx.CheckBox(self, wx.NewIdRef(), _('Notififcations'))
if wx.VERSION_STRING >= '4.0': self.cb11.SetToolTipString = self.cb11.SetToolTip
self.cb1.SetToolTipString(_("Enable the notification messages"))
self.cb11.SetValue(builtins.__dict__['NOTIFICATION'])

### wxPython version
wxv = [wx.VERSION_STRING]

Expand Down Expand Up @@ -115,6 +121,7 @@ def __init__(self, parent):
vsizer.Add(self.out_dir, 1, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
vsizer.Add(hsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
vsizer.Add(self.cb1, 1, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
vsizer.Add(self.cb11, 1, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
box1.Add(vsizer, 1, wx.EXPAND)

### Set sizer
Expand All @@ -135,6 +142,7 @@ def OnApply(self, event):
self.OnPluginsDirChanged(event)
self.OnOutDirChanged(event)
self.OnTransparancyChanged(event)
self.OnNotificationChanged(event)
self.OnwxPythonVersionChanged(event)

### if the version of wx has been changed in OnwxPythonVersionChanged, we inform the user.
Expand Down Expand Up @@ -196,6 +204,10 @@ def OnOutDirChanged(self, event):
def OnTransparancyChanged(self, event):
builtins.__dict__['TRANSPARENCY'] = self.cb1.GetValue()

###
def OnNotificationChanged(self, event):
builtins.__dict__['NOTIFICATION'] = self.cb11.GetValue()

def OnwxPythonVersionChanged(self, event):
"""
"""
Expand Down Expand Up @@ -705,7 +717,7 @@ def __init__(self, parent, title):
hsizer = wx.BoxSizer(wx.HORIZONTAL)

hsizer.Add(self.cancel,0)
hsizer.Add(self.apply,0)
hsizer.Add(self.apply,0, wx.EXPAND|wx.LEFT, 5)
vsizer.Add(self.pref, 1, wx.ALL|wx.EXPAND, 5)
vsizer.Add(hsizer, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

Expand Down
54 changes: 37 additions & 17 deletions Utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
import pip
import importlib

from subprocess import call

# Used for smooth (spectrum)
try:
from numpy import *
Expand Down Expand Up @@ -79,23 +81,24 @@ def printOnStatusBar(statusbar, data={}):
statusbar.SetStatusText(v, k)

def NotificationMessage(title,message,parent,flag=wx.ICON_INFORMATION, timeout=False):
notify = wx.adv.NotificationMessage(
title=title,
message=message,
parent=parent, flags=flag)

# Various options can be set after the message is created if desired.
# notify.SetFlags(# wx.ICON_INFORMATION
# wx.ICON_WARNING
# # wx.ICON_ERROR
# )
# notify.SetTitle("Wooot")
# notify.SetMessage("It's a message!")
# notify.SetParent(self)
if timeout:
notify.Show(timeout=timeout) # 1 for short timeout, 100 for long timeout
else:
notify.Show()
if builtins.__dict__['NOTIFICATION']:
notify = wx.adv.NotificationMessage(
title=title,
message=message,
parent=parent, flags=flag)

# Various options can be set after the message is created if desired.
# notify.SetFlags(# wx.ICON_INFORMATION
# wx.ICON_WARNING
# # wx.ICON_ERROR
# )
# notify.SetTitle("Wooot")
# notify.SetMessage("It's a message!")
# notify.SetParent(self)
if timeout:
notify.Show(timeout=timeout) # 1 for short timeout, 100 for long timeout
else:
notify.Show()

def now():
""" Returns the current time formatted. """
Expand Down Expand Up @@ -151,6 +154,23 @@ def PyBuzyInfo(msg, time):

del busy

def updatePiP():
call("python -m pip install --upgrade pip", shell=True)

def updatePackageWithPiP():
""" Update all installed package using pip
"""

if pip.__version__ > '10.0.1':
import pkg_resources
packages = [dist.project_name for dist in pkg_resources.working_set if 'PyPubSub' not in dist.project_name]
call("pip install --upgrade -r requirements.txt", shell=True)
else:
packages = [dist.project_name for dist in pip.get_installed_distributions() if 'PyPubSub' not in dist.project_name]
call("pip install --upgrade " + ' '.join(packages), shell=True)

NotificationMessage(_('Information'), 'All pip packages have been updated!', None, timeout=5)

def install_and_import(package):
try:
importlib.import_module(package)
Expand Down
10 changes: 8 additions & 2 deletions devsimpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@
'DYNAMIC_STRUCTURE' : False, # Dynamic Structure for local PyPDEVS simulation
'REAL_TIME': False, ### PyPDEVS threaded real time simulation
'VERBOSE':False,
'TRANSPARENCY' : True, # Transparancy for DetachedFrame
'TRANSPARENCY' : True, # Transparancy for DetachedFrame activated
'NOTIFICATION' : True, # Notification message activated
'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 @@ -186,7 +187,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
from Utilities import GetUserConfigDir, install_and_import, printOnStatusBar, NotificationMessage, updatePackageWithPiP
from Decorators import redirectStdout, BuzyCursorNotification
from DetachedFrame import DetachedFrame
from LibraryTree import LibraryTree
Expand Down Expand Up @@ -2008,6 +2009,11 @@ def OnAPI(self, event):
#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
Binary file added icons/update.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.