--- a/Beremiz.py Tue Oct 27 16:32:54 2009 +0100
+++ b/Beremiz.py Mon Nov 02 15:38:49 2009 +0100
@@ -293,6 +293,8 @@
kind=wx.ITEM_NORMAL, text=_(u'Open\tCTRL+O'))
AppendMenu(parent, help='', id=wx.ID_SAVE,
kind=wx.ITEM_NORMAL, text=_(u'Save\tCTRL+S'))
+ AppendMenu(parent, help='', id=wx.ID_SAVEAS, + kind=wx.ITEM_NORMAL, text=_(u'Save as\tCTRL+SHIFT+S')) AppendMenu(parent, help='', id=wx.ID_CLOSE,
kind=wx.ITEM_NORMAL, text=_(u'Close Tab\tCTRL+W'))
AppendMenu(parent, help='', id=wx.ID_CLOSE_ALL,
@@ -314,6 +316,7 @@
self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW)
self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN)
self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE)
+ self.Bind(wx.EVT_MENU, self.OnSaveProjectAsMenu, id=wx.ID_SAVEAS) self.Bind(wx.EVT_MENU, self.OnCloseTabMenu, id=wx.ID_CLOSE)
self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, id=wx.ID_CLOSE_ALL)
self.Bind(wx.EVT_MENU, self.OnPageSetupMenu, id=wx.ID_PAGE_SETUP)
@@ -367,6 +370,7 @@
self.PLCConfig.SetBackgroundColour(wx.WHITE)
self.PLCConfig.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown)
self.PLCConfig.Bind(wx.EVT_SIZE, self.OnMoveWindow)
+ self.PLCConfig.Bind(wx.EVT_MOUSEWHEEL, self.OnPLCConfigScroll) self.BottomNoteBook.InsertPage(0, self.PLCConfig, _("Topology"), True)
self.LogConsole = wx.TextCtrl(id=ID_BEREMIZLOGCONSOLE, value='',
@@ -388,6 +392,8 @@
self.local_runtime_tmpdir = None
self.DisableEvents = False
+ # Variable allowing disabling of PLCConfig scroll when Popup shown + self.ScrollingEnabled = True @@ -477,39 +483,46 @@
infos = self.PluginRoot.ShowError(self.Log,
(int(first_line), int(first_column)),
(int(last_line), int(last_column)))
+ ## Function displaying an Error dialog in PLCOpenEditor. + # @return False if closing cancelled. + def CheckSaveBeforeClosing(self, title=_("Close Project")): + if self.PluginRoot.ProjectTestModified(): + dialog = wx.MessageDialog(self, + _("There are changes, do you want to save?"), + wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION) + answer = dialog.ShowModal() + if answer == wx.ID_YES: + self.PluginRoot.SaveProject() + elif answer == wx.ID_CANCEL: def OnCloseFrame(self, event):
- if self.PluginRoot is not None:
- if self.PluginRoot.ProjectTestModified():
- dialog = wx.MessageDialog(self,
- _("Close Application"),
- wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
- answer = dialog.ShowModal()
- if answer == wx.ID_YES:
- self.PluginRoot.SaveProject()
- elif answer == wx.ID_NO:
- self.KillLocalRuntime()
+ if self.PluginRoot is None or self.CheckSaveBeforeClosing(_("Close Application")): + self.KillLocalRuntime() def OnMoveWindow(self, event):
+ def EnableScrolling(self, enable): + self.ScrollingEnabled = enable + def OnPLCConfigScroll(self, event): + if self.ScrollingEnabled: def OnPanelLeftDown(self, event):
focused = self.FindFocus()
if isinstance(focused, TextCtrlAutoComplete.TextCtrlAutoComplete):
- focused._showDropDown(False)
+ focused.DismissListBox() def RefreshFileMenu(self):
@@ -533,6 +546,7 @@
self.FileMenu.Enable(wx.ID_PRINT, False)
self.FileMenu.Enable(wx.ID_PAGE_SETUP, True)
self.FileMenu.Enable(wx.ID_SAVE, True)
+ self.FileMenu.Enable(wx.ID_SAVEAS, True) self.FileMenu.Enable(wx.ID_PROPERTIES, True)
self.FileMenu.Enable(wx.ID_CLOSE_ALL, True)
@@ -541,6 +555,7 @@
self.FileMenu.Enable(wx.ID_PREVIEW, False)
self.FileMenu.Enable(wx.ID_PRINT, False)
self.FileMenu.Enable(wx.ID_SAVE, False)
+ self.FileMenu.Enable(wx.ID_SAVEAS, False) self.FileMenu.Enable(wx.ID_PROPERTIES, False)
self.FileMenu.Enable(wx.ID_CLOSE_ALL, False)
@@ -1201,7 +1216,7 @@
if isinstance(element_infos["type"], types.ListType):
combobox = wx.ComboBox(id=id, name=element_infos["name"], parent=parent,
- pos=wx.Point(0, 0), size=wx.Size(150, 28), style=wx.CB_READONLY)
+ pos=wx.Point(0, 0), size=wx.Size(300, 28), style=wx.CB_READONLY) boxsizer.AddWindow(combobox, 0, border=0, flag=0)
if element_infos["use"] == "optional":
@@ -1234,7 +1249,7 @@
if "max" in element_infos["type"]:
scmax = element_infos["type"]["max"]
spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=parent,
- pos=wx.Point(0, 0), size=wx.Size(150, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT)
+ pos=wx.Point(0, 0), size=wx.Size(300, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT) spinctrl.SetRange(scmin,scmax)
boxsizer.AddWindow(spinctrl, 0, border=0, flag=0)
spinctrl.SetValue(element_infos["value"])
@@ -1253,7 +1268,7 @@
spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=parent,
- pos=wx.Point(0, 0), size=wx.Size(150, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT)
+ pos=wx.Point(0, 0), size=wx.Size(300, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT) spinctrl.SetRange(scmin, scmax)
boxsizer.AddWindow(spinctrl, 0, border=0, flag=0)
spinctrl.SetValue(element_infos["value"])
@@ -1263,10 +1278,11 @@
textctrl = TextCtrlAutoComplete.TextCtrlAutoComplete(id=id,
name=element_infos["name"],
element_path=element_path,
boxsizer.AddWindow(textctrl, 0, border=0, flag=0)
@@ -1284,6 +1300,9 @@
self.DebugVariablePanel.SetDataProducer(None)
def OnNewProjectMenu(self, event):
+ if self.PluginRoot is not None and not self.CheckSaveBeforeClosing(): if not self.Config.HasEntry("lastopenedfolder"):
defaultpath = os.path.expanduser("~")
@@ -1309,6 +1328,9 @@
self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
def OnOpenProjectMenu(self, event):
+ if self.PluginRoot is not None and not self.CheckSaveBeforeClosing(): if not self.Config.HasEntry("lastopenedfolder"):
defaultpath = os.path.expanduser("~")
@@ -1337,21 +1359,12 @@
def OnCloseProjectMenu(self, event):
- if self.PluginRoot is not None:
- if self.PluginRoot.ProjectTestModified():
- dialog = wx.MessageDialog(self,
- _("Close Application"),
- wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
- answer = dialog.ShowModal()
- if answer == wx.ID_YES:
- self.PluginRoot.SaveProject()
- elif answer == wx.ID_CANCEL:
- self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
+ if self.PluginRoot is not None and not self.CheckSaveBeforeClosing(): + self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU) def OnSaveProjectMenu(self, event):
if self.PluginRoot is not None:
@@ -1359,6 +1372,13 @@
+ def OnSaveProjectAsMenu(self, event): + if self.PluginRoot is not None: + self.PluginRoot.SaveProjectAs() def OnPropertiesMenu(self, event):
@@ -1391,24 +1411,26 @@
return DeleteButtonFunction
def AddPlugin(self, PluginType, plugin):
- dialog = wx.TextEntryDialog(self, _("Please enter a name for plugin:"), _("Add Plugin"), "", wx.OK|wx.CANCEL)
- if dialog.ShowModal() == wx.ID_OK:
- PluginName = dialog.GetValue()
- plugin.PlugAddChild(PluginName, PluginType)
- self.RefreshPluginTree()
- self.PluginRoot.RefreshPluginsBlockLists()
+ if self.PluginRoot.CheckProjectPathPerm(): + dialog = wx.TextEntryDialog(self, _("Please enter a name for plugin:"), _("Add Plugin"), "", wx.OK|wx.CANCEL) + if dialog.ShowModal() == wx.ID_OK: + PluginName = dialog.GetValue() + plugin.PlugAddChild(PluginName, PluginType) + self.RefreshPluginTree() + self.PluginRoot.RefreshPluginsBlockLists() def DeletePlugin(self, plugin):
- dialog = wx.MessageDialog(self, _("Really delete plugin ?"), _("Remove plugin"), wx.YES_NO|wx.NO_DEFAULT)
- if dialog.ShowModal() == wx.ID_YES:
- self.PluginInfos.pop(plugin)
- self.PluginRoot.RefreshPluginsBlockLists()
- self.RefreshPluginTree()
+ if self.PluginRoot.CheckProjectPathPerm(): + dialog = wx.MessageDialog(self, _("Really delete plugin ?"), _("Remove plugin"), wx.YES_NO|wx.NO_DEFAULT) + if dialog.ShowModal() == wx.ID_YES: + self.PluginInfos.pop(plugin) + self.PluginRoot.RefreshPluginsBlockLists() + self.RefreshPluginTree() #-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
@@ -1436,10 +1458,8 @@
An unhandled exception (bug) occured. Bug report saved at :
-Please contact LOLITech at:
-or please be kind enough to send this file to:
-bugs_beremiz@lolitech.fr
+Please be kind enough to send this file to: +edouard.tisserant@gmail.com You should now restart Beremiz.