--- a/LPCManager.py Thu Mar 30 08:19:00 2017 +0200
+++ b/LPCManager.py Thu Mar 30 13:15:17 2017 +0200
@@ -137,27 +137,41 @@
from ConfigTreeNode import ConfigTreeNode
from editors.ProjectNodeEditor import ProjectNodeEditor
from editors.CodeFileEditor import VariablesTable
+from editors.CodeFileEditor import VariablesEditor from WampOptionsEditor import WampOptionsEditor
+from VariableExporter import VariableWriter def LeftClick(self, event):
- if event.GetCol() == 6:
- options = [self.grid.GetCellValue(event.GetRow(), event.GetCol()), self.grid.GetCellValue(event.GetRow(), event.GetCol()-1)]
- desc = self.grid.GetCellValue(event.GetRow(), event.GetCol()-2)
- dialog = WampOptionsEditor(self.Parent.Parent, options, desc)
- answer = dialog.ShowModal()
- opt,OnChange,value,description = dialog.GetOptions()
- self.grid.SetCellValue(event.GetRow(), event.GetCol(), str(opt))
- self.grid.SetCellValue(event.GetRow(), event.GetCol()-1, value)
- self.grid.SetCellValue(event.GetRow(), event.GetCol()-2, description)
- self.Parent.RefreshModel()
+ if event.GetCol() == self.grid.GetNumberCols()-1: + options = [self.grid.GetCellValue(event.GetRow(), event.GetCol()), self.grid.GetCellValue(event.GetRow(), event.GetCol()-1)] + desc = self.grid.GetCellValue(event.GetRow(), event.GetCol()-2) + if hasattr(self, "dialog"): + self.dialog.SetOptions(options, desc) + answer = self.dialog.ShowModal() + #self.dialog.SetOptions(options, desc) + self.dialog = WampOptionsEditor(self.Parent.Parent, options, desc) + answer = self.dialog.ShowModal() + opt,OnChange,value,description = self.dialog.GetOptions() + self.grid.SetCellValue(event.GetRow(), event.GetCol(), str(opt)) + self.grid.SetCellValue(event.GetRow(), event.GetCol()-1, value) + self.grid.SetCellValue(event.GetRow(), event.GetCol()-2, description) + self.Parent.RefreshModel()
VariablesTable.LeftClick = LeftClick
+def VariablesEditorSetCollSize(self): + ColSizes = [20, 150] + [130] * (len(self.VariablesDefaultValue) - 2) + [300] + for col in range(self.Table.GetNumberCols()): + self.VariablesGrid.SetColSize(col, ColSizes[col]) +VariablesEditor.VariablesEditorSetCollSize = VariablesEditorSetCollSize def _updateColAttrs(self, grid):
wxGrid -> update the column attributes to add the
@@ -188,8 +202,13 @@
grid.SetCellRenderer(row, col, renderer)
grid.SetCellBackgroundColour(row, col, wx.WHITE)
- self.ResizeRow(grid, row)
- self.grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.LeftClick)
+ self.grid.SetRowMinimalHeight + # updated column width, with function VariablesEditorSetCollSize added in VariablesEditor class + self.Parent.VariablesEditorSetCollSize() + # added left click option on grid, with function LeftClick added in VariablesTable class + self.grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.LeftClick) VariablesTable._updateColAttrs = _updateColAttrs
from PLCControler import PLCControler, LOCATION_MODULE, LOCATION_GROUP, \
@@ -224,6 +243,7 @@
# havecanfestival = False
WINDOW_COLOUR = wx.Colour(240, 240, 240)
TITLE_COLOUR = wx.Colour(200, 200, 220)
CHANGED_TITLE_COLOUR = wx.Colour(220, 200, 220)
@@ -1329,6 +1349,9 @@
AppendMenu(parent, help='', id=wx.ID_PRINT,
kind=wx.ITEM_NORMAL, text=_(u'Print'))
+ AppendMenu(parent, help='', id=ID_EXPORT, + kind=wx.ITEM_NORMAL, text=_(u'Export')) + parent.AppendSeparator() AppendMenu(parent, help='', id=wx.ID_EXIT,
kind=wx.ITEM_NORMAL, text=_(u'Quit\tCTRL+Q'))
@@ -1337,11 +1360,14 @@
self.Bind(wx.EVT_MENU, self.OnPageSetupMenu, id=wx.ID_PAGE_SETUP)
self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW)
self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT)
+ self.Bind(wx.EVT_MENU, lambda event: VariableWriter(self, event, self.CTR.ProjectPath), id=ID_EXPORT) self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT)
self.AddToMenuToolBar([(wx.ID_SAVE, "save", _(u'Save'), None),
(wx.ID_PRINT, "print", _(u'Print'), None)])
def _init_ctrls(self, prnt):
Beremiz._init_ctrls(self, prnt)
@@ -1367,6 +1393,16 @@
self.CTR.KillDebugThread()
+ # close wxGlade if running + config = wx.ConfigBase.Get() + wxGladePid = str(config.Read("BeremizRoot.wxGlade")) + os.kill(int(wxGladePid), signal.SIGTERM) + config.Write("BeremizRoot.wxGlade", str(wxGladePid)) lpcberemiz_cmd.Log.write("Closed\n")
@@ -1859,6 +1895,12 @@
lpcberemiz_cmd = LPCBeremiz_Cmd(CTR, Log)
+ # reset pid of running wxGlade + config = wx.ConfigBase.Get() + config.Write("BeremizRoot.wxGlade", str(wxGladePid)) Log = StdoutPseudoFile(port)
@@ -1881,4 +1923,6 @@
frame = LPCBeremiz(None, ctr=CTR, debug=True)