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
10 changes: 1 addition & 9 deletions Components.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@

if builtins.__dict__['GUI_FLAG']:
import wx

_ = wx.GetTranslation

if wx.VERSION_STRING < '2.9':
from wx.lib.pubsub import Publisher
Expand All @@ -51,7 +49,7 @@
#from DomainInterface.DomainBehavior import DomainBehavior
#from DomainInterface.DomainStructure import DomainStructure
from ReloadModule import recompile
from Utilities import GetActiveWindow, path_to_module, install_and_import
from Utilities import GetActiveWindow, path_to_module, install_and_import, printOnStatusBar
from NetManager import Net
from SimpleFrameEditor import FrameEditor
from which import which
Expand All @@ -62,12 +60,6 @@
###
###########################################################

def printOnStatusBar(statusbar, data={}):
""" Send data on status bar
"""
for k,v in list(data.items()):
statusbar.SetStatusText(v, k)

def getClassMember(python_file = ''):
""" Get class member from python file.
"""
Expand Down
10 changes: 2 additions & 8 deletions Container.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
sys.modules['Savable'] = sys.modules['Mixins.Savable']

from Decorators import BuzyCursorNotification, StatusBarNotification, ProgressNotification, Pre_Undo, Post_Undo, cond_decorator
from Utilities import HEXToRGB, RGBToHEX, relpath, GetActiveWindow, playSound, sendEvent, getInstance, FixedList, getObjectFromString, getTopLevelWindow
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']:
Expand Down Expand Up @@ -212,12 +212,6 @@ def MsgBoxError(event, parent, msg):
else:
wx.MessageBox(_("There is errors in python file.\nTrying to translate error informations: %s %s %s")%(typ, val, tb), _("Error"), wx.OK|wx.ICON_ERROR)

def printOnStatusBar(statusbar, data={}):
""" Send data on status bar
"""
for k,v in list(data.items()):
statusbar.SetStatusText(v, k)

def CheckClass(m):
""" Check if class is ok and return it.
"""
Expand Down Expand Up @@ -3466,7 +3460,7 @@ def OnExport(self, event):
try:
### Block is Savable
self.SaveFile(path)

printOnStatusBar(mainW.statusbar, {0:_('%s Exported')%label, 1:''})

except IOError as error:
Expand Down
3 changes: 2 additions & 1 deletion DiagramNotebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

from DetachedFrame import DetachedFrame
from PrintOut import Printable
from Utilities import printOnStatusBar

_ = wx.GetTranslation

Expand Down Expand Up @@ -194,7 +195,7 @@ def OnPageChanged(self, evt):
if hasattr(self.parent, 'statusbar'):
diagram = canvas.GetDiagram()
txt = _('%s modified')%(self.GetPageText(id)) if diagram.modify else ""
self.parent.statusbar.SetStatusText(txt)
printOnStatusBar(self.parent.statusbar,{0:txt})

### propagate event also error in OnClosePage because GetSelection is wrong
evt.Skip()
Expand Down
4 changes: 2 additions & 2 deletions Editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from wx import stc

from Decorators import redirectStdout
from Utilities import path_to_module, PrintException
from Utilities import path_to_module, PrintException, printOnStatusBar

import ReloadModule
import ZipManager
Expand Down Expand Up @@ -1645,7 +1645,7 @@ def Notification(self, modify, *args):

if hasattr(self, 'statusbar'):
for i, s in enumerate(args):
self.statusbar.SetStatusText(s, i)
printOnStatusBar(self.statusbar, {i:s})

### NOTE: Editor :: StatusBar => Create a status bar
def GetStatusBar(self):
Expand Down
5 changes: 3 additions & 2 deletions LibPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SearchLib(wx.SearchCtrl):
def __init__(self, *args, **kwargs):
"""
"""
wx.SearchCtrl.__init__(self, *args, **kwargs)
super(SearchLib, self).__init__(*args, **kwargs)

self.treeChildren = []
self.treeCopy = None
Expand Down Expand Up @@ -63,7 +63,7 @@ class LibPanel(wx.Panel):
"""
"""
def __init__(self, parent, name):
wx.Panel.__init__(self, parent=parent, id=wx.NewIdRef(), name=name)
super(LibPanel, self).__init__(parent, name=name)

libSizer = wx.BoxSizer(wx.VERTICAL)

Expand Down Expand Up @@ -154,6 +154,7 @@ def __set_tips(self):
"""

self.propToolTip =[_("Select model and instantiate it in the diagram (right part) using a drag-and-drop.")]

### for Phoenix version ()
if wx.VERSION_STRING < '4.0':
self.SetToolTipString(self.propToolTip[0])
Expand Down
75 changes: 47 additions & 28 deletions LibraryTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import Container
import Menu

from Utilities import replaceAll, getPYFileListFromInit, path_to_module
from Utilities import replaceAll, getPYFileListFromInit, path_to_module, printOnStatusBar, NotificationMessage, install_and_import
from Decorators import BuzyCursorNotification
from Components import BlockFactory, DEVSComponent, GetClass
from ZipManager import Zip, getPythonModelFileName
Expand Down Expand Up @@ -208,8 +208,7 @@ def OnLeftClick(self, evt):

self.UnselectAll()
mainW = wx.GetApp().GetTopWindow()
mainW.statusbar.SetStatusText('', 0)
mainW.statusbar.SetStatusText('', 1)
printOnStatusBar(mainW.statusbar, {0:'', 1:''})
#self.SetFocus()
evt.Skip()

Expand Down Expand Up @@ -834,29 +833,39 @@ def CheckItem(self, path):
### Check the class
info = Container.CheckClass(file_path)

### there is error during the chek of class ?
### there is error during the chek of class?
if isinstance(info, tuple):
### recompile if no error
info = recompile(path_to_module(file_path))

### there is error during recompilation ?
if isinstance(info, (Exception,str)):
### Until it has parent, we redifine icon to inform user
while(item):
### change image
self.SetItemImage(item, self.not_importedidx, wx.TreeItemIcon_Normal)
### next parent item
item = self.GetItemParent(item)

### if module are missing, we propose to install him with pip
if ModuleNotFoundError in info:
package = info[1].name
if install_and_import(package):
wx.CallAfter(self.UpdateAll)

### else there is an error in the code of the model...
else:
### change image
self.SetItemImage(item, self.pythonfileidx, wx.TreeItemIcon_Normal)

#### Until it has parent, we redifine icon to inform user
### recompile if no error
info = recompile(path_to_module(file_path))

### there is error during recompilation?
if isinstance(info, (Exception,str)):
### Until it has parent, we redifine icon to inform user
while(item):
#### change image
self.SetItemImage(item, self.fldropenidx if self.IsExpanded(item) else self.fldridx, wx.TreeItemIcon_Normal)
#### next parent item
### change image
self.SetItemImage(item, self.not_importedidx, wx.TreeItemIcon_Normal)
### next parent item
item = self.GetItemParent(item)
else:
### change image
self.SetItemImage(item, self.pythonfileidx, wx.TreeItemIcon_Normal)

#### Until it has parent, we redifine icon to inform user
while(item):
#### change image
self.SetItemImage(item, self.fldropenidx if self.IsExpanded(item) else self.fldridx, wx.TreeItemIcon_Normal)
#### next parent item
item = self.GetItemParent(item)
else:
sys.stdout.write("File %s is not checked!")

Expand Down Expand Up @@ -912,6 +921,8 @@ def OnUpdateAll(self, event):
""" Update all imported domain
"""
self.UpdateAll()

NotificationMessage(_('Information'), _("All librairies have been succeffully updated!"), self, timeout=5)

def OnMCCClick(self, event):
"""
Expand Down Expand Up @@ -989,14 +1000,22 @@ def OnItemRefresh(self, evt):
""" Refresh action has been invoked.
"""

item = self.GetSelection()
path = self.GetItemPyData(item)
ext = os.path.splitext(path)[1]
try:
item = self.GetSelection()
path = self.GetItemPyData(item)
ext = os.path.splitext(path)[1]

if ext in (".py",".pyc"):
self.CheckItem(os.path.splitext(path)[0])
else:
self.CheckItem(path)
except:
NotificationMessage(_('Error'), _("Error updating the model %s")%self.GetItemText(item), self, timeout=5)
finally:
if self.GetItemImage(item) != 1:

NotificationMessage(_('Information'), _("Model %s has been succeffully updated!")%self.GetItemText(item), self, flag=wx.ICON_ERROR, timeout=5)

if ext in (".py",".pyc"):
self.CheckItem(os.path.splitext(path)[0])
else:
self.CheckItem(path)
###
def OnItemEdit(self, evt):
""" Edition menu has been invoked.
Expand Down
30 changes: 13 additions & 17 deletions SimulationGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
'PyDEVS':os.path.join(os.pardir,'DEVSKernel','PyDEVS'),\
'PyPDEVS':os.path.join(os.pardir,'DEVSKernel','PyPDEVS')}

from Utilities import IsAllDigits, playSound
from Utilities import IsAllDigits, playSound, printOnStatusBar
from pluginmanager import trigger_event, is_enable
from Patterns.Strategy import *
from Decorators import BuzyCursorNotification, hotshotit
Expand Down Expand Up @@ -492,9 +492,9 @@ def OnOk(self, event):
#self._gauge.SetMax(self.current_master.FINAL_TIME)

self.statusbar.SetBackgroundColour('')
self.statusbar.SetStatusText("", 1)
printOnStatusBar(self.statusbar, {1:""})
if self.statusbar.GetFieldsCount() > 2:
self.statusbar.SetStatusText("", 2)
printOnStatusBar(self.statusbar, {2:""})

if (self.thread is None) or (not self.timer.IsRunning()):

Expand Down Expand Up @@ -573,10 +573,10 @@ def OnStop(self, event):

self._gauge.SetValue(0)
self.statusbar.SetBackgroundColour('')
self.statusbar.SetStatusText(_('Interrupted'), 0)
self.statusbar.SetStatusText("", 1)
printOnStatusBar(self.statusbar, {0:_('Interrupted')})
printOnStatusBar(self.statusbar, {1:""})
if self.statusbar.GetFieldsCount() > 2:
self.statusbar.SetStatusText("", 2)
printOnStatusBar(self.statusbar, {2:""})

###
def OnSuspend(self, event):
Expand All @@ -592,7 +592,7 @@ def OnSuspend(self, event):
if self.count == 0 or self.count >= 100 or not self.timer.IsRunning():
return

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

# way to interact with the model
#self.parent.Enable(True)
Expand Down Expand Up @@ -633,13 +633,12 @@ def OnTimer(self, event):

### update the status bar
self.statusbar.SetBackgroundColour('')
self.statusbar.SetStatusText(_("Completed!"), 0)
self.statusbar.SetStatusText(self.GetClock(), 1)

printOnStatusBar(self.statusbar, {0:_("Completed!"), 1:self.GetClock()})

### is no time limit add some informations in status bar
if not self.ntl:
if self.statusbar.GetFieldsCount() > 2:
self.statusbar.SetStatusText(str(100)+"%", 2)
printOnStatusBar(self.statusbar, {2:str(100)+"%"})

### stop the timer
self.timer.Stop()
Expand All @@ -649,14 +648,12 @@ def OnTimer(self, event):

### udpate the status bar
self.statusbar.SetBackgroundColour('GREY')
self.statusbar.SetStatusText(_("Processing..."), 0)
self.statusbar.SetStatusText(self.GetClock(), 1)
#self.statusbar.SetStatusText("%0.4f s"%(self.thread.cpu_time), 1)
printOnStatusBar(self.statusbar, {0:_("Processing..."), 1:self.GetClock()})

### is no time limit, add some information in status bar
if not self.ntl:
if self.statusbar.GetFieldsCount() > 2:
self.statusbar.SetStatusText(str(self.count)[:4]+"%", 2)
printOnStatusBar(self.statusbar, {2:str(self.count)[:4]+"%"})

#wx.Yield()
wx.YieldIfNeeded()
Expand Down Expand Up @@ -691,8 +688,7 @@ def SetFields(self):
if wx.VERSION_STRING < '4.0':
self.statusbar.SetFields([""]*self.statusbar.GetFieldsCount())
else:
for i in range(self.statusbar.GetFieldsCount()):
self.statusbar.SetStatusText("",i)
printOnStatusBar(self.statusbar, {i:'' for i in range(self.statusbar.GetFieldsCount())})

def DestroyWin(self):
""" To destroy the simulation frame
Expand Down
5 changes: 3 additions & 2 deletions SpreadSheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#from Container import *
from PlotGUI import *
from Utilities import printOnStatusBar

###
class MySheet(sheet.CSheet):
Expand Down Expand Up @@ -251,7 +252,7 @@ def EnableGraphIcon(self, msg):
else:
toolbar = self.GetToolBar()
toolbar.EnableTool(self.chart.GetId(), msg)
self.statusbar.SetStatusText("", 0)
printOnStatusBar(self.statusbar, {0:""})

###
def OnTab(self, event):
Expand All @@ -265,7 +266,7 @@ def OnProgress(self, msg):
""" Update status bar with loading data progression
"""
pourcent = 100*float(msg)
self.statusbar.SetStatusText(_("Loading data... (%d %%)")%int(pourcent), 0)
printOnStatusBar(self.statusbar, {0:_("Loading data... (%d %%)")%int(pourcent)})

###
def AddPage(self, data = [[]], label = ""):
Expand Down
Loading