beremiz

5b294dcaae18
fix issue, then it wasn't possible to view FBD programs

the reason for that is possible wx-3.0-gtk2 bug that happens if
ALWAYS_SHOW_SB is set.

Traceback (most recent call last):
File "Beremiz.py", line 1045, in OnProjectTreeItemActivated
IDEFrame.OnProjectTreeItemActivated(self, event)
File "IDEFrame.py", line 1667, in OnProjectTreeItemActivated
self.EditProjectElement(item_infos["type"], item_infos["tagname"])
File "IDEFrame.py", line 1752, in EditProjectElement
new_window = Viewer(self.TabsOpened, tagname, self, self.Controler)
File "editors/Viewer.py", line 611, in __init__
EditorPanel.__init__(self, parent, tagname, window, controler, debug)
File "editors/EditorPanel.py", line 68, in __init__
self._init_ctrls(parent)
File "editors/EditorPanel.py", line 52, in _init_ctrls
self._init_Editor(self)
File "editors/Viewer.py", line 603, in _init_Editor
style=wx.HSCROLL | wx.VSCROLL | wx.ALWAYS_SHOW_SB)
File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/_windows.py", line 296, in __init__
_windows_.ScrolledWindow_swiginit(self,_windows_.new_ScrolledWindow(*args, **kwargs))
PyAssertionError: C++ assertion "scrolled" failed at ../src/gtk/scrolwin.cpp(205) in DoShowScrollbars(): window must be created
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import wx
import wx.stc
if wx.Platform == '__WXMSW__':
faces = { 'times': 'Times New Roman',
'mono' : 'Courier New',
'helv' : 'Arial',
'other': 'Comic Sans MS',
'size' : 10,
}
else:
faces = { 'times': 'Times',
'mono' : 'Courier',
'helv' : 'Helvetica',
'other': 'new century schoolbook',
'size' : 12,
}
NAVIGATION_KEYS = [
wx.WXK_END,
wx.WXK_HOME,
wx.WXK_LEFT,
wx.WXK_UP,
wx.WXK_RIGHT,
wx.WXK_DOWN,
wx.WXK_PAGEUP,
wx.WXK_PAGEDOWN,
wx.WXK_NUMPAD_HOME,
wx.WXK_NUMPAD_LEFT,
wx.WXK_NUMPAD_UP,
wx.WXK_NUMPAD_RIGHT,
wx.WXK_NUMPAD_DOWN,
wx.WXK_NUMPAD_PAGEUP,
wx.WXK_NUMPAD_PAGEDOWN,
wx.WXK_NUMPAD_END]
def GetCursorPos(old, new):
if old == "":
return 0
old_length = len(old)
new_length = len(new)
common_length = min(old_length, new_length)
i = 0
for i in xrange(common_length):
if old[i] != new[i]:
break
if old_length < new_length:
if common_length > 0 and old[i] != new[i]:
return i + new_length - old_length
else:
return i + new_length - old_length + 1
elif old_length > new_length or i < min(old_length, new_length) - 1:
if common_length > 0 and old[i] != new[i]:
return i
else:
return i + 1
else:
return None
class CustomStyledTextCtrl(wx.stc.StyledTextCtrl):
def __init__(self, *args, **kwargs):
wx.stc.StyledTextCtrl.__init__(self, *args, **kwargs)
self.Bind(wx.EVT_MOTION, self.OnMotion)
def OnMotion(self, event):
if wx.Platform == '__WXMSW__':
if not event.Dragging():
x, y = event.GetPosition()
margin_width = reduce(
lambda x, y: x + y,
[self.GetMarginWidth(i)
for i in xrange(3)],
0)
if x <= margin_width:
self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
else:
self.SetCursor(wx.StockCursor(wx.CURSOR_IBEAM))
else:
event.Skip()
else:
event.Skip()
def AppendText(self, text):
self.GotoPos(self.GetLength())
self.AddText(text)