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
19 changes: 11 additions & 8 deletions Components.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import string
import types
import importlib
import subprocess

import gettext
_ = gettext.gettext
Expand All @@ -50,9 +51,10 @@
#from DomainInterface.DomainBehavior import DomainBehavior
#from DomainInterface.DomainStructure import DomainStructure
from ReloadModule import recompile
from Utilities import GetActiveWindow, path_to_module
from Utilities import GetActiveWindow, path_to_module, install_and_import
from NetManager import Net
from SimpleFrameEditor import FrameEditor
from which import which

###########################################################
###
Expand Down Expand Up @@ -620,7 +622,7 @@ def OnEditor(self, event):
if isinstance(mainW, ShapeCanvas):
mainW = mainW.GetParent()

if builtins.__dict__['LOCAL_EDITOR'] and not zipfile.is_zipfile(model_path) and not python_path.startswith('http'):
if not builtins.__dict__['LOCAL_EDITOR'] and not zipfile.is_zipfile(model_path) and not python_path.startswith('http'):
dial = wx.MessageDialog(mainW, _('Do you want to use your local programmer software?\n\n If you always want use the DEVSimPy code editor\n change the option in Editor panel preferences.'), name, wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
val = dial.ShowModal()
else:
Expand All @@ -630,20 +632,21 @@ def OnEditor(self, event):
if val == wx.ID_YES:
### open with local editor
if wx.Platform == '__WXMAC__':
os.system("open " + python_path)
subprocess.call(" ".join(['open',python_path]), shell=True)
elif "wxMSW" in wx.PlatformInfo:
os.startfile(python_path)
elif "wxGTK" in wx.PlatformInfo:
### with gnome
if os.system('pidof gnome-session') != 256:
if os.system('pidof gedit') == 256:
try:
soft = which('gnome-open')
soft = which('gedit')
except:
sys.stdout.write(_("Local programmer software not found!\n"))
else:
os.system(soft+" openURL " + python_path)
subprocess.call(" ".join([soft,python_path]), shell=True)

### with kde
elif os.system('pidof ksmserver') != 256:
elif os.system('pidof ksmserver') == 256:
try:
soft = which('kfmclient')
except:
Expand All @@ -654,7 +657,7 @@ def OnEditor(self, event):
sys.stdout.write(_("Unknown Windows Manager!\n"))

elif val != wx.ID_CANCEL:
# loading file in editor windows (self.text)
# loading file in DEVSimPy editor windows (self.text)
try:

editorFrame = Editor.GetEditor(None, wx.NewIdRef(), ''.join([name,' - ',model_path]), obj=self, file_type='block')
Expand Down
6 changes: 3 additions & 3 deletions DetachedFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ def __init__(self, parent=None, ID=wx.NewIdRef(), title="", diagram=None, name="

### Menu ToolBar
toolbar = wx.ToolBar(self, wx.NewIdRef(), name='tb', style=wx.TB_HORIZONTAL | wx.NO_BORDER)
toolbar.SetToolBitmapSize((25,25)) # just for windows
self.SetToolBar(toolbar)
toolbar.SetToolBitmapSize((16,16))

if self.parent:
self.toggle_list = wx.GetApp().GetTopWindow().toggle_list
Expand Down Expand Up @@ -169,7 +168,8 @@ def __init__(self, parent=None, ID=wx.NewIdRef(), title="", diagram=None, name="
#=======================================================================

toolbar.Realize()

self.SetToolBar(toolbar)

### if Detached frame from block (container or Code)
### save, save-as and simulation are disabled
if not isinstance(self.parent, Container.ShapeCanvas):
Expand Down
13 changes: 8 additions & 5 deletions Editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1370,9 +1370,11 @@ def CreateTB(self):
""" Create tool-bar
"""

if not self.parent:
tb = self.CreateToolBar(wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT | wx.TB_TEXT)
tb = wx.ToolBar(self, wx.NewIdRef(), name='tb', style=wx.TB_HORIZONTAL | wx.NO_BORDER)
tb.SetToolBitmapSize((16, 16))# this required for non-standard size buttons on MSW

if not self.parent:

if wx.VERSION_STRING < '4.0':
self.Bind(wx.EVT_TOOL, self.OnSaveFile, tb.AddTool(self.save.GetId(),wx.Bitmap(os.path.join(ICON_PATH, 'save.png')), _('Save'), ''))
tb.AddSeparator()
Expand All @@ -1389,9 +1391,6 @@ def CreateTB(self):
self.Bind(wx.EVT_TOOL, self.QuitApplication, id = self.quit.GetId())
else:

tb = wx.ToolBar(self, -1)
tb.SetToolBitmapSize((16, 16))# this required for non-standard size buttons on MSW

if wx.VERSION_STRING < '4.0':
tb.AddTool(self.save.GetId(), wx.Bitmap(os.path.join(ICON_PATH, 'save.png')), shortHelpString=_('Save'), longHelpString=_('Save the file'))
tb.AddTool(self.cut.GetId(), wx.Bitmap(os.path.join(ICON_PATH,'cut.png')), shortHelpString=_('Cut'), longHelpString=_('Cut the selection'))
Expand All @@ -1409,6 +1408,7 @@ def CreateTB(self):
self.Bind(wx.EVT_TOOL, self.nb.OnPaste, id= self.paste.GetId())

tb.Realize()

return tb

def GetNoteBook(self):
Expand Down Expand Up @@ -1816,6 +1816,9 @@ def __init__(self, parent, id, title):
self.toolbar = self.CreateTB()
self.statusbar= self.GetStatusBar()

### set the tool bar
self.SetToolBar(self.toolbar)

### binding
self.Bind(wx.EVT_CLOSE, self.QuitApplication)

Expand Down
65 changes: 48 additions & 17 deletions ImportLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,32 +96,63 @@ class DeleteBox(wx.Dialog):
def __init__(self, *args, **kwargs):
""" Constructor.
"""
wx.Dialog.__init__(self, *args, **kwargs)
super(DeleteBox, self).__init__(*args, **kwargs)

self.InitUI()
self.SetSize((250, 200))

def InitUI(self):

pnl = wx.Panel(self)
vbox = wx.BoxSizer(wx.VERTICAL)

sb = wx.StaticBox(pnl, label='Delete?')
sbs = wx.StaticBoxSizer(sb, orient=wx.VERTICAL)
self.rb1 = wx.RadioButton(pnl, label=_('label'))
self.rb2 = wx.RadioButton(pnl, label=_('label and files'))
sbs.Add(self.rb1)
sbs.Add(self.rb2)

pnl.SetSizer(sbs)

hbox2 = wx.BoxSizer(wx.HORIZONTAL)
okButton = wx.Button(self, wx.ID_OK, label='Ok')
closeButton = wx.Button(self, wx.ID_CANCEL, label='Close')
hbox2.Add(okButton)
hbox2.Add(closeButton, flag=wx.LEFT, border=5)

vbox.Add(pnl, proportion=1,
flag=wx.ALL|wx.EXPAND, border=5)
vbox.Add(hbox2, flag=wx.ALIGN_CENTER|wx.TOP|wx.BOTTOM, border=10)

self.SetSizer(vbox)

self.Centre()

### Widgets
txt = wx.StaticText(self, wx.NewIdRef(), _('What do you want to delete:'), (15, 10))
self.rb1 = wx.RadioButton(self, wx.NewIdRef() , _('label'), (20, 30))
self.rb2 = wx.RadioButton(self, wx.NewIdRef() , _('label and files'), (20, 55))
btn_cancel = wx.Button(self, wx.ID_CANCEL, pos = (35, 90), size = (80, -1))
btn_ok = wx.Button(self, wx.ID_OK, pos = (135, 90), size = (80, -1))
# txt = wx.StaticText(self, wx.NewIdRef(), _('What do you want to delete:'), (15, 10))
# self.rb1 = wx.RadioButton(self, wx.NewIdRef() , _('label'), (20, 30))
# self.rb2 = wx.RadioButton(self, wx.NewIdRef() , _('label and files'), (20, 55))
# btn_cancel = wx.Button(self, wx.ID_CANCEL, pos = (35, 90), size = (80, -1))
# btn_ok = wx.Button(self, wx.ID_OK, pos = (135, 90), size = (80, -1))

### Sizers
hbox = wx.BoxSizer(wx.HORIZONTAL)
vbox = wx.BoxSizer(wx.VERTICAL)
# hbox = wx.BoxSizer(wx.HORIZONTAL)
# vbox = wx.BoxSizer(wx.VERTICAL)

### And into Sizers
hbox.Add(btn_cancel, 1, wx.EXPAND|wx.ALIGN_CENTER)
hbox.Add(btn_ok, 1, wx.EXPAND|wx.ALIGN_CENTER)
# hbox.Add(btn_cancel, 1, wx.EXPAND|wx.ALIGN_CENTER)
# hbox.Add(btn_ok, 1, wx.EXPAND|wx.ALIGN_CENTER)

vbox.Add(txt, 0, wx.ALIGN_TOP, 10)
vbox.Add(self.rb1, 1,wx.ALIGN_LEFT, 5)
vbox.Add(self.rb2, 1,wx.ALIGN_LEFT, 5)
vbox.Add(hbox, 1, wx.ALIGN_CENTER)
# vbox.Add(txt, 0, wx.ALIGN_TOP, 10)
# vbox.Add(self.rb1, 1,wx.ALIGN_LEFT, 5)
# vbox.Add(self.rb2, 1,wx.ALIGN_LEFT, 5)
# vbox.Add(hbox, 1, wx.ALIGN_CENTER)

### Set Sizer
self.SetSizer(vbox)
# self.SetSizer(vbox)

self.Centre()
# vbox.SetSizeHints(self)

#-------------------------------------------------------------------
class ImportLibrary(wx.Dialog):
Expand Down Expand Up @@ -356,7 +387,7 @@ def OnDelete(self, evt):
label = self._cb.GetItemText(index)

### diag to choose to delete label and/or source files
db = DeleteBox(self, -1, _("Delete Options"), size=(250, 110))
db = DeleteBox(self, wx.NewIdRef(), _("Delete Options"))

if db.ShowModal() == wx.ID_OK:

Expand Down
5 changes: 3 additions & 2 deletions LibPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(self, parent, name):
chargedDomainList = eval(cfg_domain_list) if cfg_domain_list else []

self.tree.Populate(chargedDomainList)

### search tree that is hide when starting devsimpy (see __do_layout)
self.searchTree = LibraryTree(self, wx.NewIdRef(), wx.DefaultPosition, style=wx.TR_DEFAULT_STYLE|wx.TR_HIDE_ROOT|wx.TR_MULTIPLE|wx.TR_LINES_AT_ROOT|wx.TR_HAS_BUTTONS|wx.SUNKEN_BORDER)

Expand Down Expand Up @@ -108,7 +108,7 @@ def BuildToolbar(self):
"""

tb = wx.ToolBar(self, -1)
self.ToolBar = tb
#self.ToolBar = tb
tb.SetToolBitmapSize((16,16))# this required for non-standard size buttons on MSW

### for Phoenix version
Expand Down Expand Up @@ -144,6 +144,7 @@ def BuildToolbar(self):
self.Bind(wx.EVT_TOOL, self.tree.OnMCCClick, id=Menu.ID_MCC_LIB)

tb.Realize()

return tb

def __set_tips(self):
Expand Down
4 changes: 2 additions & 2 deletions LibraryTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ def OnDelete(self, evt):

item = self.GetSelection()


print(item)
if item:
### msgbox to select what you wan to delete: file or/and item ?
db = DeleteBox(self, -1, _("Delete Options"), size=(250, 110))
db = DeleteBox(self, wx.NewIdRef(), _("Delete Options"))

if db.ShowModal() == wx.ID_OK:

Expand Down
3 changes: 3 additions & 0 deletions Menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,9 @@ def __init__(self, parent):
AppendItem(doc)
AppendItem(update)

path = parent.GetItemPyData(item)
self.Enable(ID_EDIT_LIB, not path.endswith('pyc'))

self.Bind(wx.EVT_MENU, parent.OnItemEdit, id = ID_EDIT_LIB) # put before the popUpMenu
self.Bind(wx.EVT_MENU, parent.OnItemRename, id = ID_RENAME_LIB) # put before the popUpMenu
self.Bind(wx.EVT_MENU, parent.OnItemDocumentation, id = doc.GetId()) # put before the popUpMenu
Expand Down
3 changes: 2 additions & 1 deletion PreferencesGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,8 @@ def OnApply(self, evt):

### enable the priority (DEVS select function) icon depending on the selected DEVS kernel
mainW = wx.GetApp().GetTopWindow()
mainW.tb.EnableTool(Menu.ID_PRIORITY_DIAGRAM, not 'PyPDEVS' in builtins.__dict__['DEFAULT_DEVS_DIRNAME'])
tb = mainW.GetToolBar()
tb.EnableTool(Menu.ID_PRIORITY_DIAGRAM, not 'PyPDEVS' in builtins.__dict__['DEFAULT_DEVS_DIRNAME'])

builtins.__dict__['SIMULATION_SUCCESS_SOUND_PATH'] = self.sim_success_sound_path
builtins.__dict__['SIMULATION_ERROR_SOUND_PATH'] = self.sim_error_sound_path
Expand Down
6 changes: 3 additions & 3 deletions SpreadSheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ def __init__(self, parent, id, title, aDEVS, separator=" "):
self.model = aDEVS
self.sep = separator

toolbar = wx.ToolBar(self, wx.NewIdRef(), style= wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT | wx.TB_TEXT)
toolbar.SetToolBitmapSize((25,25)) # just for windows
toolbar = wx.ToolBar(self, wx.NewIdRef(), style= wx.TB_HORIZONTAL | wx.NO_BORDER)
toolbar.SetToolBitmapSize((16,16))

### for Phoenix version
if wx.VERSION_STRING < '4.0':
Expand Down Expand Up @@ -157,8 +157,8 @@ def __init__(self, parent, id, title, aDEVS, separator=" "):
self.chart = toolbar.AddTool(wx.NewIdRef(), "", wx.Bitmap(os.path.join(ICON_PATH,'graph_guru.png')), _('Chart'))

toolbar.EnableTool(self.chart.GetId(), False)

toolbar.Realize()

self.SetToolBar(toolbar)

self.statusbar = self.CreateStatusBar()
Expand Down
Loading