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
2 changes: 2 additions & 0 deletions AttributeEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def MakeIcon(self, img):
def OnClose(self, event):
self.canvas.UpdateShapes()
self.Destroy()
event.Skip()

def AttributeEditor(*args,**kwargs):
""" Factory function
Expand Down Expand Up @@ -273,6 +274,7 @@ def Undo(self):
###
def OnClose(self, event):
self.Destroy()
event.Skip()

def main():
pass
Expand Down
16 changes: 12 additions & 4 deletions Container.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,8 @@ def OnClosePriorityGUI(self, event):
### we can update the devs priority list during the simulation ;-)
self.updateDEVSPriorityList()

event.Skip()

def OnAddConstants(self, event):
""" Method that add constant parameters in order to simplify the modling codeBlock model
"""
Expand Down Expand Up @@ -1204,14 +1206,16 @@ def OnConnect(self,event):
class Shape(ShapeEvtHandler):
""" Shape class
"""


FILL = ['#add8e6']

def __init__(self, x=[], y=[]):
""" Constructor
"""

self.x = array.array('d',x) # list of x coord
self.y = array.array('d',y) # list of y coords
self.fill= ['#add8e6'] # fill color
self.fill= Shape.FILL # fill color
self.pen = [self.fill[0] , 1, wx.SOLID] # pen color and size
self.font = [FONT_SIZE, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_ITALIC, wx.FONTWEIGHT_BOLD, u'Arial']

Expand Down Expand Up @@ -1976,11 +1980,13 @@ def OnCloseConnectionDialog(self, event):
self.deselect()
self.Refresh()

### destruction du dialogue
### Destroy the dialog
try:
self.dlgConnection.Destroy()
except:
pass

event.Skip()

def OnMiddleDown(self, event):
"""
Expand Down Expand Up @@ -3850,14 +3856,16 @@ class ContainerBlock(Block, Diagram):
""" ContainerBlock(label, inputs, outputs)
"""

FILL = ['#90ee90']

###
def __init__(self, label = 'ContainerBlock', nb_inputs = 1, nb_outputs = 1):
""" Constructor
"""
Block.__init__(self, label, nb_inputs, nb_outputs)
Diagram.__init__(self)
#Structurable.__init__(self)
self.fill = ['#90ee90']
self.fill = Container.FILL

###
def __setstate__(self, state):
Expand Down
2 changes: 2 additions & 0 deletions DetachedFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ def OnClose(self, event):
### Destroy the windows
self.Destroy()

event.Skip()

### ------------------------------------------------------------
class TestApp(wx.App):
""" Testing application
Expand Down
49 changes: 39 additions & 10 deletions FindGUI.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,53 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Find/Replace Dialog
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
# FindGUI.py ---
# --------------------------------
# Copyright (c) 2020
# L. CAPOCCHI (capocchi@univ-corse.fr)
# SPE Lab - SISU Group - University of Corsica
# --------------------------------
# Version 1.0 last modified: 03/22/20
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
#
# GENERAL NOTES AND REMARKS:
#
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##

## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
#
# GLOBAL VARIABLES AND FUNCTIONS
#
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##

import wx
import re

### just for individual test
if __name__ == '__main__':
import builtins
import os, sys

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')}

class FindReplace(wx.Dialog):
def __init__(self, parent, id, title):

wx.Dialog.__init__(self, parent, id, title, size=(255, 365))

vbox_top = wx.BoxSizer(wx.VERTICAL)
panel = wx.Panel(self, -1)
panel = wx.Panel(self)

vbox_top = wx.BoxSizer(wx.VERTICAL)
vbox = wx.BoxSizer(wx.VERTICAL)

# panel1
panel1 = wx.Panel(panel, -1)
grid1 = wx.GridSizer(2, 2)
panel1 = wx.Panel(panel)
grid1 = wx.GridSizer(2, 2, 0, 0)
self.input_find = wx.ComboBox(panel1, -1, size=(120, -1))
self.input_replace = wx.ComboBox(panel1, -1, size=(120, -1))
grid1.Add(wx.StaticText(panel1, -1, _('Find: '),(5, 5)), 0, wx.ALIGN_CENTER_VERTICAL)
Expand All @@ -29,7 +59,7 @@ def __init__(self, parent, id, title):
vbox.Add(panel1, 0, wx.BOTTOM | wx.TOP, 9)

# panel2
panel2 = wx.Panel(panel, -1)
panel2 = wx.Panel(panel)
hbox2 = wx.BoxSizer(wx.HORIZONTAL)
sizer21 = wx.StaticBoxSizer(wx.StaticBox(panel2, -1, _('Direction')), orient=wx.VERTICAL)
sizer21.Add(wx.RadioButton(panel2, -1, _('Forward'), style=wx.RB_GROUP))
Expand Down Expand Up @@ -63,7 +93,7 @@ def __init__(self, parent, id, title):

# panel4

panel4 = wx.Panel(panel, -1)
panel4 = wx.Panel(panel)
sizer4 = wx.GridSizer(2, 2, 2, 2)
find_btn = wx.Button(panel4, -1,_('Find'), size=(120, -1))
replace_find_btn = wx.Button(panel4, -1, _('Replace/Find'), size=(120, -1))
Expand All @@ -79,8 +109,7 @@ def __init__(self, parent, id, title):
vbox.Add(panel4, 0, wx.BOTTOM, 9)

# panel5

panel5 = wx.Panel(panel, -1)
panel5 = wx.Panel(panel)
sizer5 = wx.BoxSizer(wx.HORIZONTAL)
sizer5.Add((191, -1), 1, wx.EXPAND | wx.ALIGN_RIGHT)
close_btn = wx.Button(panel5, -1, _('Close'), size=(50, -1))
Expand Down
1 change: 1 addition & 0 deletions ImportLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ def OnAdd(self, evt):

def OnCloseWindow(self, event):
self.Destroy()
event.Skip()

### ------------------------------------------------------------
class TestApp(wx.App):
Expand Down
10 changes: 5 additions & 5 deletions LabelGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
# LabelGUI.py ---
# --------------------------------
# Copyright (c) 2020
# L. CAPOCCHI (capocchi@univ-corse.fr)
# SPE Lab - SISU Group - University of Corsica
# --------------------------------
# Copyright (c) 2013
# Laurent CAPOCCHI
# University of Corsica
# --------------------------------
# Version 1.0 last modified: 16/04/13
# Version 1.0 last modified: 03/22/20
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
#
# GENERAL NOTES AND REMARKS:
Expand Down
5 changes: 4 additions & 1 deletion Menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def __init__(self, parent):
AppendItem(wx.MenuItem(self, ID_DELETE_PROFILES, _("Delete all")))
self.Enable(ID_DELETE_PROFILES, self.GetMenuItemCount() > 2)

parent.Bind(wx.EVT_MENU, parent.OnDeleteProfiles, id = ID_DELETE_PROFILES)
parent.Bind(wx.EVT_MENU, parent.OnDeleteProfiles, id=ID_DELETE_PROFILES)

class RecentFileMenu(wx.Menu):
"""
Expand Down Expand Up @@ -349,6 +349,9 @@ def __init__(self, parent):
self.Append(ID, name)
parent.Bind(wx.EVT_MENU, parent.OnRestorePerspective, id=ID)

### Enable the delete function if the list of perspectives is not empty
deleteall.Enable(len(L)> 1)

parent.Bind(wx.EVT_MENU, parent.OnCreatePerspective, id=ID_NEW_PERSPECTIVE)
parent.Bind(wx.EVT_MENU, parent.OnDeletePerspective, id=ID_DELETE_PERSPECTIVE)
parent.Bind(wx.EVT_MENU, parent.OnRestorePerspective, id=ID_FIRST_PERSPECTIVE)
Expand Down
2 changes: 2 additions & 0 deletions PreferencesGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,9 +760,11 @@ def OnApply(self, evt):

def OnCancel(self, evt):
self.Close()
evt.Skip()

def OnClose(self, evt):
self.Close()
evt.Skip()

### ------------------------------------------------------------
class TestApp(wx.App):
Expand Down
1 change: 1 addition & 0 deletions Reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def OnClose(self, event):
""" User canceled the dialog. """

self.EndModal(wx.ID_CANCEL)
event.Skip()

def OnKeyUp(self, event):
""" Handles the wx.EVT_CHAR_HOOK event for the dialog. """
Expand Down
18 changes: 10 additions & 8 deletions SimulationGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,9 @@ def MsgBoxEmptyModel(self):
wx.OK|wx.ICON_EXCLAMATION)

if (dial.ShowModal() == wx.ID_OK) and (isinstance(self.parent, wx.Frame)):
self.DestroyWin()
self.PrepareDestroyWin()
### destroy the frame
self.Destroy()
else:
return

Expand All @@ -661,7 +663,7 @@ def SetFields(self):
else:
printOnStatusBar(self.statusbar, {i:'' for i in range(self.statusbar.GetFieldsCount())})

def DestroyWin(self):
def PrepareDestroyWin(self):
""" To destroy the simulation frame
"""

Expand Down Expand Up @@ -696,9 +698,6 @@ def DestroyWin(self):
#sys.stdout.write(_("Empty mode over\n"))
pass

### destroy the frame
self.Destroy()

def OnQuit(self, event):
""" When the simulation are stopping
"""
Expand All @@ -713,13 +712,15 @@ def OnQuit(self, event):

### if user wants to stop simulation process
if dial.ShowModal() == wx.ID_YES:
self.DestroyWin()
self.thread.terminate(False)
self.PrepareDestroyWin()
else:
self.thread.resume_thread()

else:
self.DestroyWin()
self.PrepareDestroyWin()

event.Skip()

def ErrorManager(self, msg):
""" An error is occurred.
Expand Down Expand Up @@ -754,7 +755,8 @@ def ErrorManager(self, msg):
### Error dialog
if not Container.MsgBoxError(event, self.parent, msg.date if wx.VERSION_STRING < '2.9' else msg):
### if user dont want correct the error, we destroy the simulation windows
self.DestroyWin()
self.PrepareDestroyWin()
self.Destroy()
else:
### if user want to correct error through an editor, we stop simulation process for trying again after the error is corrected.
self.OnStop(event)
Expand Down
28 changes: 26 additions & 2 deletions devsimpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,8 @@ def OnDeleteRecentFiles(self, event):
def OnCreatePerspective(self, event):
"""
"""
dlg = wx.TextEntryDialog(self, _("Enter a new name:"), _("Perspective Manager"), _("Perspective %d")%(len(self.perspectives)))

dlg = wx.TextEntryDialog(self, _("Enter a new perspective:"), _("Perspective Manager"), _("Perspective %d")%(len(self.perspectives)))
if dlg.ShowModal() == wx.ID_OK:
txt = dlg.GetValue()

Expand All @@ -803,12 +804,20 @@ def OnCreatePerspective(self, event):
self.perspectivesmenu.Append(ID, txt)
self.perspectives[txt] = self._mgr.SavePerspective()

### Disable the delete function
self.perspectivesmenu.FindItemById(Menu.ID_DELETE_PERSPECTIVE).Enable(True)

### Bind right away to make activable the perspective without restart DEVSimPy
self.Bind(wx.EVT_MENU, self.OnRestorePerspective, id=ID)

NotificationMessage(_('Information'), _('%s has been added!')%txt, parent=self, timeout=5)

dlg.Destroy()

def OnRestorePerspective(self, event):
"""
"""

id = event.GetId()
item = self.GetMenuBar().FindItemById(id)
mgr = self.GetMGR()
Expand All @@ -817,18 +826,26 @@ def OnRestorePerspective(self, event):
def OnDeletePerspective(self, event):
"""
"""

# delete all path items
L = list(self.perspectivesmenu.GetMenuItems())
for item in L[4:]:
self.perspectivesmenu.RemoveItem(item)
self.perspectivesmenu.Remove(item)

# update config file
self.perspectives = {_("Default Startup"):self._mgr.SavePerspective()}
self.cfg.Write("perspectives", str(eval("self.perspectives")))
self.cfg.Flush()

### Disable the delete function
self.perspectivesmenu.FindItemById(Menu.ID_DELETE_PERSPECTIVE).Enable(False)

NotificationMessage(_('Information'), _('All perspectives have been deleted!'), parent=self, timeout=5)

###
def OnDragInit(self, event):
"""
"""

# version avec arbre
item = event.GetItem()
Expand All @@ -854,6 +871,9 @@ def OnDragInit(self, event):

###
def OnIdle(self, event):
"""
"""

if self.otherWin:
self.otherWin.Raise()
self.otherWin = None
Expand All @@ -862,6 +882,7 @@ def OnIdle(self, event):
def SaveLibraryProfile(self):
""" Update config file with the librairies opened during the last use of DEVSimPy.
"""

### Show is in position 2 on Menu Bar
show_menu = self.menuBar.GetMenu(2)
### Control is in position 1
Expand Down Expand Up @@ -921,6 +942,8 @@ def OnCloseWindow(self, event):
#win.Disconnect(-1, -1, wx.wxEVT_KILL_FOCUS)
#self.Destroy()

event.Skip()

def OnSpin(self, event):
""" Spin button has been invoked (on the toolbar of the main windows or detached frame)
"""
Expand Down Expand Up @@ -2216,6 +2239,7 @@ def OnClose(self, event):
""" Handles the wx.EVT_CLOSE event
"""
self.Show(False)
event.Skip()

#------------------------------------------------------------------------------
class PyOnDemandOutputWindow(threading.Thread):
Expand Down
Loading