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
26 changes: 13 additions & 13 deletions Components.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,19 +853,19 @@ def GetModule(filename):
module_name = os.path.basename(filename).split('.py')[0]

# find and load module
#try:
name, ext = os.path.splitext(module_name)
pkg = '.'.join(module_name.split('.')[0:-1])
module = importlib.import_module(name, package=pkg)

#f, fn, description = imp.find_module(module_name, [dir_name])
#module = imp.load_module(module_name, f, fn, description)
#f.close()
return module

#except Exception as info:
# sys.stderr.write(_("Module %s not imported from %s!\n"%(module_name,dir_name)))
# return sys.exc_info()
try:
name, ext = os.path.splitext(module_name)
pkg = '.'.join(module_name.split('.')[0:-1])
module = importlib.import_module(name, package=pkg)

#f, fn, description = imp.find_module(module_name, [dir_name])
#module = imp.load_module(module_name, f, fn, description)
#f.close()
return module

except Exception as info:
sys.stderr.write(_("Module %s not imported from %s!\n"%(module_name,dir_name)))
return sys.exc_info()

@staticmethod
def GetBlock(filename, label):
Expand Down
12 changes: 8 additions & 4 deletions Container.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##



import builtins

if builtins.__dict__.get('GUI_FLAG',True):
Expand Down Expand Up @@ -58,6 +56,7 @@
import types
import array

from abc import ABC
from tempfile import gettempdir
from traceback import format_exception
from math import * ### for eval
Expand Down Expand Up @@ -123,7 +122,6 @@
# #
##############################################################


def MsgBoxError(event, parent, msg):
""" Pop-up alert for error in the .py file of a model
"""
Expand Down Expand Up @@ -579,13 +577,19 @@ def makeDEVSInstance(diagram = None):
return diagram.getDEVSModel()

def SetParent(self, parent):
"""
"""
assert isinstance(parent, ShapeCanvas)
self.parent = parent

def GetParent(self):
"""
"""
return self.parent

def GetGrandParent(self):
"""
"""
return self.GetParent().GetParent()

@BuzyCursorNotification
Expand Down Expand Up @@ -1144,7 +1148,7 @@ def GetName(self):
return os.path.basename(self.last_name_saved)

# Generic Shape Event Handler---------------------------------------------------
class ShapeEvtHandler:
class ShapeEvtHandler(ABC):
""" Handler class
"""

Expand Down
16 changes: 14 additions & 2 deletions DetachedFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@

import Container
import Menu

import PrintOut

## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
#
# CLASS DEFIINTION
#
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##

class DetachedFrame(wx.Frame, PrintOut.Printable):
""" Detached Frame including a diagram.
"""
Expand Down Expand Up @@ -288,12 +293,19 @@ def OnClose(self, event):

event.Skip()

### ------------------------------------------------------------
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
#
# MAIN PROGRAM
#
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##

class TestApp(wx.App):
""" Testing application
"""

def OnInit(self):
""" Init the user interface.
"""

import gettext

Expand Down
52 changes: 42 additions & 10 deletions DiagramConstantsDialog.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,48 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
# DiagramConstantsDialog.py --- Dialog to define constantes in a diagram.
# --------------------------------
# Copyright (c) 2020
# L. CAPOCCHI (capocchi@univ-corse.fr)
# SPE Lab - SISU Group - University of Corsica
# --------------------------------
# Version 1.0 last modified: 08/11/20
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
#
# GENERAL NOTES AND REMARKS:
#
#
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##

import wx
import os
import builtins
import csv
import DSV
import gettext

ID_IMPORT = wx.NewIdRef()
ID_EXPORT = wx.NewIdRef()
ID_ADD = wx.NewIdRef()
ID_REMOVE = wx.NewIdRef()
ID_HELP = wx.NewIdRef()

import gettext
_ = gettext.gettext

class DiagramConstantsDialog(wx.Dialog):
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
#
# CLASS DEFIINTION
#
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##

class DiagramConstantsDialog(wx.Dialog):
""" Dialogue to define constantes in a diagram.
"""
def __init__(self, *args, **kw):
""" Constructor.
"""
super(DiagramConstantsDialog, self).__init__(*args, **kw)

### local copy
Expand All @@ -30,7 +54,7 @@ def __init__(self, *args, **kw):
self.InitUI()

def InitUI(self):
""" Init the user interface
""" Init the user interface.
"""

self.SetTitle(_("%s - Constants Manager")%(self.label))
Expand Down Expand Up @@ -115,7 +139,7 @@ def __set_events(self):
self.Bind(wx.EVT_BUTTON, self.OnCancel, self._button_cancel)

def Populate(self, data):
""" Populate the grid from a dictionary data
""" Populate the grid from a dictionary data.
"""

### populate the grid
Expand All @@ -127,12 +151,12 @@ def Populate(self, data):
self._grid.SetCellValue(i, 1, str(data[key]))

def OnAdd(self,evt):
""" Add line
""" Add line.
"""
self._grid.AppendRows()

def OnRemove(self, evt):
""" Delete selected lines
""" Delete selected lines.
"""

### only if the grid has rows
Expand All @@ -153,7 +177,7 @@ def OnRemove(self, evt):
self._grid.DeleteRows(row)

def OnImport(self, event):
""" csv file importing
""" csv file importing.
"""

dlg = wx.FileDialog(self, _("Choose a file"), os.getenv('USERPROFILE') or os.getenv('HOME') or HOME_PATH, "",
Expand Down Expand Up @@ -197,7 +221,7 @@ def logErrors(oldrow, newrow, expectedColumns, maxColumns, file = errorLog):
dlg.Destroy()

def OnExport(self,evt):
""" csv file exporting
""" csv file exporting.
"""

wcd = _("CSV files (*.csv)|*.csv|Text files (*.txt)|*.txt|All files (*.*)|*.*")
Expand Down Expand Up @@ -241,19 +265,27 @@ def OnOk(self,evt):
evt.Skip()

def GetData(self):
""" Return the constants stored in the grid as a dictionnary
""" Return the constants stored in the grid as a dictionnary.
"""
return self.data

def OnCancel(self,evt):
""" Close dialog
""" Close dialog.
"""
self.Destroy()

def OnHelp(self, event):
""" Help message dialogue.
"""
dial = wx.MessageDialog(self, _("In order to use constante:\n\nCall constante by using \"Name of Diagram\"[\'Name of constante\']\n"), _('Help Manager'), wx.OK|wx.ICON_INFORMATION)
dial.ShowModal()

## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
#
# MAIN PROGRAM
#
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##

### ------------------------------------------------------------
class TestApp(wx.App):
""" Testing application
Expand Down
Loading