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
73 changes: 41 additions & 32 deletions CheckerGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
if path not in sys.path:
sys.path.append(path)
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')}


from wx.lib.mixins.listctrl import ListCtrlAutoWidthMixin, ColumnSorterMixin
from Utilities import GetMails, getInstance
Expand Down Expand Up @@ -236,7 +242,8 @@ def getColumnText(self, index, col):
"""
"""
item = self.GetItem(index, col)
return item.GetText()
return item.GetItemLabelText()
#return item.GetText()

#---------------------------------------------------
# These methods are callbacks for implementing the
Expand Down Expand Up @@ -286,7 +293,7 @@ class CheckerGUI(wx.Frame):
""" Class which report the code checking of python file
"""

def __init__(self, parent, diagram):
def __init__(self, parent, D):
""" Constructor.
"""
wx.Frame.__init__(self, parent, wx.NewIdRef(), _("DEVS Model Checking"), size=(900,400), style = wx.DEFAULT_FRAME_STYLE)
Expand All @@ -297,17 +304,16 @@ def __init__(self, parent, diagram):

### local copy
self.parent = parent
self.diagram = diagram

##############################################" comment for unitest
### prepare dictionary

D = self.diagram.DoCheck()
self.list = self.getList(D)
try:
self.list = self.getList(D)
except:
self.list = VirtualList(self, D)
sys.stdout.write(_('Alone mode for CheckerGUI: List of plugins is not generated from a diagram.\n'))
#################################################

### self.list = VirtualList(self,D)

self.mainSizer = wx.BoxSizer(wx.VERTICAL)
controlSizer = wx.StdDialogButtonSizer() #wx.BoxSizer(wx.HORIZONTAL)
self.listSizer = wx.BoxSizer(wx.VERTICAL)
Expand All @@ -329,7 +335,6 @@ def __init__(self, parent, diagram):
self.SetSizer(self.mainSizer)
self.Center()


### just for windows
e = wx.SizeEvent(self.GetSize())
self.ProcessEvent(e)
Expand All @@ -338,15 +343,10 @@ def __init__(self, parent, diagram):
self.Bind(wx.EVT_BUTTON, self.OnOK, id = ok_btn.GetId())
self.Bind(wx.EVT_BUTTON, self.OnUpdate, id = update_btn.GetId())

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

def OnOK(self, evt):
"""
def SetDiagram(self, diagram):
""" Set the diagram.
"""
self.Close()
self.diagram = diagram

def getList(self, D):
""" Return list to populate de virtualList
Expand Down Expand Up @@ -393,24 +393,33 @@ def OnUpdate(self, evt):
""" Update list has been invocked
"""

# mainW = wx.GetApp().GetTopWindow()
# canvas = mainW.nb2.GetCurrentPage()
# diagram = canvas.GetDiagram()

### get list by ckecking all block models of the diagram
D = self.diagram.DoCheck()
L = self.getList(D)
if hasattr(self, 'diagram'):
D = self.diagram.DoCheck()
L = self.getList(D)

if isinstance(L, VirtualList):
self.list = L

### display the updated list
self.listSizer.Hide(0)
self.listSizer.Remove(0)
self.listSizer.Add(self.list, 1, wx.EXPAND, 10)
self.Layout()
else:
sys.stdou.write(_('List not updated!'))
else:
sys.stdout.write(_('Call the SetDiagram method to define the diagram object.'))

if isinstance(L, VirtualList):
self.list = L
def OnClose(self,evt):
"""
"""
self.Close()

### display the updated list
self.listSizer.Hide(0)
self.listSizer.Remove(0)
self.listSizer.Add(self.list, 1, wx.EXPAND, 10)
self.Layout()
else:
sys.stdou.write(_('List not updated!'))
def OnOK(self, evt):
"""
"""
self.Close()

### ------------------------------------------------------------
class TestApp(wx.App):
Expand Down
10 changes: 6 additions & 4 deletions Container.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,12 +763,13 @@ def OnCheck(self, event):
if dial.ShowModal() == wx.ID_YES:
self.OnSimulation(event)
else:
frame = CheckerGUI.CheckerGUI(win, self)
frame = CheckerGUI.CheckerGUI(win, self.DoCheck())
frame.SetDiagram(self)
frame.Show()

### no models in diagram
else:
wx.MessageBox(_("Diagram is empty.\n\nPlease, drag-and-drop model from libraries control panel to build a diagram."),_('Error Manager'))
wx.MessageBox(_("Diagram is empty.\n\nPlease, drag-and-drop model from libraries control panel to build a diagram or load an existing diagram."),_('Error Manager'))

def OnSimulation(self, event):
""" Method calling the simulationGUI
Expand Down Expand Up @@ -800,7 +801,8 @@ def OnSimulation(self, event):
playSound(SIMULATION_ERROR_SOUND_PATH)

if dial.ShowModal() == wx.ID_YES:
frame = CheckerGUI.CheckerGUI(win, self)
frame = CheckerGUI.CheckerGUI(win, self.DoCheck())
frame.SetDiagram(self)
frame.Show()

return False
Expand Down Expand Up @@ -868,7 +870,7 @@ def OnSimulation(self, event):

return True
else:
wx.MessageBox(_("Diagram is empty. \nPlease, drag-and-drop model from libraries control panel to build a diagram."),_('Simulation Manager'))
wx.MessageBox(_("Diagram is empty.\n\nPlease, drag-and-drop model from libraries control panel to build a diagram or load an existing diagram.."),_('Simulation Manager'))
return False

def AddShape(self, shape, after = None):
Expand Down
1 change: 0 additions & 1 deletion Editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##



import wx
import os
import sys
Expand Down
131 changes: 110 additions & 21 deletions FTPGUI.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
#! /usr/bin/python
# -*- coding: utf-8 -*-

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

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

from ftplib import FTP, all_errors
import wx
import os

class FTPStatusBar(wx.StatusBar):
def __init__(self, parent):
wx.StatusBar.__init__(self, parent)

def __init__(self, *args, **kw):
super(FTPStatusBar, self).__init__(*args, **kw)

self.SetFieldsCount(2)
self.SetStatusText('Welcome to DEVSimPy server', 0)
Expand All @@ -25,34 +46,75 @@ def OnSize(self, event):
class FTPFrame(wx.Frame):
"""
"""
def __init__(self, parent, id, title):
""" Construcotr.
"""
def __init__(self, *args, **kw):
super(FTPFrame, self).__init__(*args, **kw)

wx.Frame.__init__(self, parent, id, title, size=(260, 270))
self.ftp = None
self.OnInit()

def OnInit(self):

wx.StaticText(self, wx.NewIdRef(), 'Ftp site', (20, 20))
wx.StaticText(self, wx.NewIdRef(), 'Login', (20, 60))
wx.StaticText(self, wx.NewIdRef(), 'Password', (20, 100))
panel = wx.Panel(self)

self.ftpsite = wx.TextCtrl(self, wx.NewIdRef(), 'http://lcapocchi.free.fr', (110, 15), (120, -1))
self.login = wx.TextCtrl(self, wx.NewIdRef(), 'lcapocchi', (110, 55), (120, -1))
self.password = wx.TextCtrl(self, wx.NewIdRef(), '', (110, 95), (120, -1), style=wx.TE_PASSWORD)
vbox = wx.BoxSizer(wx.VERTICAL)

self.ftp = None
hbox1 = wx.BoxSizer(wx.HORIZONTAL)
st1 = wx.StaticText(panel, label=_('Ftp site'))
hbox1.Add(st1, flag=wx.RIGHT, border=8)
self.ftpsite = wx.TextCtrl(panel, wx.NewIdRef(), 'http://lcapocchi.free.fr')
hbox1.Add(self.ftpsite, proportion=1)
vbox.Add(hbox1, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=10)

vbox.Add((-1, 10))

hbox2 = wx.BoxSizer(wx.HORIZONTAL)
st2 = wx.StaticText(panel, label=_('Login'))
hbox2.Add(st2, flag=wx.RIGHT, border=8)
self.login = wx.TextCtrl(panel, wx.NewIdRef(), 'lcapocchi')
hbox2.Add(self.login, proportion=1)
vbox.Add(hbox2, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=10)

vbox.Add((-1, 10))

con = wx.Button(self, 1, 'Connect', (20, 160))
discon = wx.Button(self, 2, 'DisConnect', (150, 160))
hbox3 = wx.BoxSizer(wx.HORIZONTAL)
st3 = wx.StaticText(panel, label=_('Password'))
hbox3.Add(st3, flag=wx.RIGHT, border=8)
self.password = wx.TextCtrl(panel, wx.NewIdRef(), '', style=wx.TE_PASSWORD)
hbox3.Add(self.password, proportion=1)
vbox.Add(hbox3, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=10)

self.Bind(wx.EVT_BUTTON, self.OnConnect, id=1)
self.Bind(wx.EVT_BUTTON, self.OnDisConnect, id=2)
vbox.Add((-1, 10))

hbox4 = wx.BoxSizer(wx.HORIZONTAL)
con = wx.Button(panel, label=_('Connect'), size=(70, 30))
hbox4.Add(con)
discon = wx.Button(panel, label=_('DisConnect'), size=(100, 30))
hbox4.Add(discon, flag=wx.LEFT|wx.BOTTOM, border=5)
vbox.Add(hbox4, flag=wx.ALIGN_RIGHT|wx.RIGHT, border=10)

#wx.StaticText(self.panel, wx.NewIdRef(), _('Ftp site'), (20, 20))
#wx.StaticText(self.panel, wx.NewIdRef(), _('Login'), (20, 60))
#wx.StaticText(self.panel, wx.NewIdRef(), _('Password'), (20, 100))

#self.ftpsite = wx.TextCtrl(self.panel, wx.NewIdRef(), 'http://lcapocchi.free.fr', (110, 15), (120, -1))
#self.login = wx.TextCtrl(self.panel, wx.NewIdRef(), 'lcapocchi', (110, 55), (120, -1))
#self.password = wx.TextCtrl(self.panel, wx.NewIdRef(), '', (110, 95), (120, -1), style=wx.TE_PASSWORD)

#con = wx.Button(self.panel, wx.NewIdRef(), _('Connect'), (20, 160))
#discon = wx.Button(self.panel, wx.NewIdRef(), _('DisConnect'), (120, 160))

self.Bind(wx.EVT_BUTTON, self.OnConnect, id=con.GetId())
self.Bind(wx.EVT_BUTTON, self.OnDisConnect, id=discon.GetId())

self.statusbar = FTPStatusBar(self)
self.SetStatusBar(self.statusbar)

panel.SetSizer(vbox)
self.Centre()

def OnConnect(self, event):
"""
"""
if not self.ftp:
ftpsite = self.ftpsite.GetValue()
login = self.login.GetValue()
Expand All @@ -61,27 +123,54 @@ def OnConnect(self, event):
try:
self.ftp = FTP(ftpsite)
var = self.ftp.login(login, password)
self.statusbar.SetStatusText('User connected')
self.statusbar.SetStatusText(_('User connected'))
self.statusbar.icon.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16, 'connect_network.png')))
self.OnSend()
except AttributeError:
self.statusbar.SetForegroundColour(wx.RED)
self.statusbar.SetStatusText('Incorrect params')
self.statusbar.SetStatusText(_('Incorrect params'))
self.ftp = None
except all_errors as err:
self.statusbar.SetStatusText(str(err))
self.ftp = None


def OnSend(self, fn='out.kml'):
"""
"""
with open(fn, 'rb') as f:
sftp.storbinary('STOR %s'%"devsimpy/"+fn, f) # Send the file

def OnDisConnect(self, event):
"""
"""
if self.ftp:
self.ftp.quit()
self.ftp = None
self.statusbar.SetStatusText('User disconnected')
self.statusbar.icon.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16, 'disconnect_network.png')))

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

def OnInit(self):

import gettext
import builtins

builtins.__dict__['ICON_PATH']='icons'
builtins.__dict__['ICON_PATH_16_16']=os.path.join(ICON_PATH,'16x16')
builtins.__dict__['_'] = gettext.gettext

self.frame = FTPFrame(None, -1, 'Test')
self.frame.Show()
return True

def OnQuit(self, event):
self.Close()

if __name__ == '__main__':

app = TestApp(0)
app.MainLoop()
Loading