--- a/LDViewer.py Tue Aug 07 17:37:38 2007 +0200
+++ b/LDViewer.py Tue Aug 07 17:38:48 2007 +0200
@@ -22,7 +22,6 @@
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from wxPython.wx import *
import wx
from types import *
@@ -348,7 +347,7 @@
element.SetSelectedSegment(result[0])
else:
element.OnLeftUp(event, dc, self.Scaling)
- wxCallAfter(self.SetCursor, wxNullCursor)
+ wx.CallAfter(self.SetCursor, wx.NullCursor)
self.ReleaseMouse()
self.Refresh()
event.Skip()
@@ -369,7 +368,7 @@
else:
self.SelectedElement.SetSelected(True)
self.SelectedElement.OnRightUp(event, dc, self.Scaling)
- wxCallAfter(self.SetCursor, wxNullCursor)
+ wx.CallAfter(self.SetCursor, wx.NullCursor)
self.ReleaseMouse()
self.Refresh()
event.Skip()
@@ -397,8 +396,11 @@
if self.GetDrawingMode() == FREEDRAWING_MODE:
Viewer.OnChar(self, event)
else:
+ xpos, ypos = self.GetScrollPos(wx.HORIZONTAL), self.GetScrollPos(wx.VERTICAL)
+ xmax = self.GetScrollRange(wx.HORIZONTAL) - self.GetScrollThumb(wx.HORIZONTAL)
+ ymax = self.GetScrollRange(wx.VERTICAL) - self.GetScrollThumb(wx.VERTICAL)
keycode = event.GetKeyCode()
- if keycode == WXK_DELETE and self.SelectedElement:
+ if keycode == wx.WXK_DELETE and self.SelectedElement:
if self.IsBlock(self.SelectedElement):
self.SelectedElement.Delete()
elif self.IsWire(self.SelectedElement):
@@ -414,22 +416,22 @@
self.RefreshBuffer()
self.RefreshScrollBars()
self.Refresh()
- elif keycode == WXK_LEFT:
+ elif keycode == wx.WXK_LEFT:
if event.ControlDown() and event.ShiftDown():
self.Scroll(0, ypos)
elif event.ControlDown():
self.Scroll(max(0, xpos - 1), ypos)
- elif keycode == WXK_RIGHT:
+ elif keycode == wx.WXK_RIGHT:
if event.ControlDown() and event.ShiftDown():
self.Scroll(xmax, ypos)
elif event.ControlDown():
self.Scroll(min(xpos + 1, xmax), ypos)
- elif keycode == WXK_UP:
+ elif keycode == wx.WXK_UP:
if event.ControlDown() and event.ShiftDown():
self.Scroll(xpos, 0)
elif event.ControlDown():
self.Scroll(xpos, max(0, ypos - 1))
- elif keycode == WXK_DOWN:
+ elif keycode == wx.WXK_DOWN:
if event.ControlDown() and event.ShiftDown():
self.Scroll(xpos, ymax)
elif event.ControlDown():
@@ -453,7 +455,7 @@
varlist.append(self.Controler.GetCurrentElementEditingName())
dialog.SetVariables(varlist)
dialog.SetValues({"name":"","type":COIL_NORMAL})
- if dialog.ShowModal() == wxID_OK:
+ if dialog.ShowModal() == wx.ID_OK:
values = dialog.GetValues()
startx, starty = LD_OFFSET[0], 0
if len(self.Rungs) > 0:
@@ -539,7 +541,7 @@
varlist.append(var["Name"])
dialog.SetVariables(varlist)
dialog.SetValues({"name":"","type":CONTACT_NORMAL})
- if dialog.ShowModal() == wxID_OK:
+ if dialog.ShowModal() == wx.ID_OK:
values = dialog.GetValues()
points = wires[0].GetSelectedSegmentPoints()
id = self.GetNewId()
@@ -612,7 +614,7 @@
self.RefreshScrollBars()
self.Refresh()
else:
- message = wxMessageDialog(self, "You must select the wire where a contact should be added!", "Error", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(self, "You must select the wire where a contact should be added!", "Error", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
@@ -763,7 +765,7 @@
varlist.append(self.Controler.GetCurrentElementEditingName())
dialog.SetVariables(varlist)
dialog.SetValues({"name":"","type":COIL_NORMAL})
- if dialog.ShowModal() == wxID_OK:
+ if dialog.ShowModal() == wx.ID_OK:
values = dialog.GetValues()
powerrail = right_elements[0].GetParentBlock()
index = 0
@@ -833,16 +835,16 @@
self.RefreshScrollBars()
self.Refresh()
else:
- message = wxMessageDialog(self, "The group of block must be coherent!", "Error", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(self, "The group of block must be coherent!", "Error", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
else:
- message = wxMessageDialog(self, "You must select the block or group of blocks around which a branch should be added!", "Error", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(self, "You must select the block or group of blocks around which a branch should be added!", "Error", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
def AddLadderBlock(self):
- message = wxMessageDialog(self, "This option isn't available yet!", "Warning", wxOK|wxICON_EXCLAMATION)
+ message = wx.MessageDialog(self, "This option isn't available yet!", "Warning", wx.OK|wx.ICON_EXCLAMATION)
message.ShowModal()
message.Destroy()
@@ -1113,10 +1115,10 @@
if block in block_list:
wires = wire.EndConnected.GetWires()
endmiddlepoint = wires[0][0].StartConnected.GetPosition(False)[0] - LD_WIRE_SIZE
- points = [startpoint, wxPoint(middlepoint, startpoint.y),
- wxPoint(middlepoint, startpoint.y + offset),
- wxPoint(endmiddlepoint, startpoint.y + offset),
- wxPoint(endmiddlepoint, endpoint.y), endpoint]
+ points = [startpoint, wx.Point(middlepoint, startpoint.y),
+ wx.Point(middlepoint, startpoint.y + offset),
+ wx.Point(endmiddlepoint, startpoint.y + offset),
+ wx.Point(endmiddlepoint, endpoint.y), endpoint]
else:
if startpoint.y + offset != endpoint.y:
if isinstance(element, LD_PowerRail):
@@ -1140,8 +1142,8 @@
self.RefreshPosition(block, False)
endpoint = wire.EndConnected.GetPosition(False)
if not onlyone[i]:
- points = [startpoint, wxPoint(middlepoint, startpoint.y),
- wxPoint(middlepoint, endpoint.y), endpoint]
+ points = [startpoint, wx.Point(middlepoint, startpoint.y),
+ wx.Point(middlepoint, endpoint.y), endpoint]
else:
points = [startpoint, endpoint]
wire.SetPoints(points)
@@ -1181,7 +1183,7 @@
varlist.append(var["Name"])
dialog.SetVariables(varlist)
dialog.SetValues({"name":contact.GetName(),"type":contact.GetType()})
- if dialog.ShowModal() == wxID_OK:
+ if dialog.ShowModal() == wx.ID_OK:
values = dialog.GetValues()
contact.SetName(values["name"])
contact.SetType(values["type"])
@@ -1207,7 +1209,7 @@
varlist.append(self.Controler.GetCurrentElementEditingName())
dialog.SetVariables(varlist)
dialog.SetValues({"name":coil.GetName(),"type":coil.GetType()})
- if dialog.ShowModal() == wxID_OK:
+ if dialog.ShowModal() == wx.ID_OK:
values = dialog.GetValues()
coil.SetName(values["name"])
coil.SetType(values["type"])