- a few Py3 changes

- add tags
This commit is contained in:
Werner F Bruhin
2014-05-26 12:58:45 +02:00
parent 98968746f9
commit ca162ee926
3 changed files with 19 additions and 14 deletions

View File

@@ -1514,11 +1514,11 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
Object.SetFillColor(colors[random.randint(0,len(colors)-1)])
Object.SetLineColor(colors[random.randint(0,len(colors)-1)])
Object.SetLineWidth(random.randint(1,7))
Object.SetLineStyle(FloatCanvas.DrawObject.LineStyleList.keys()[random.randint(0,5)])
Object.SetLineStyle(list(FloatCanvas.DrawObject.LineStyleList.keys())[random.randint(0,5)])
for Object in self.ColorObjectsLine:
Object.SetLineColor(colors[random.randint(0,len(colors)-1)])
Object.SetLineWidth(random.randint(1,7))
Object.SetLineStyle(FloatCanvas.DrawObject.LineStyleList.keys()[random.randint(0,5)])
Object.SetLineStyle(list(FloatCanvas.DrawObject.LineStyleList.keys())[random.randint(0,5)])
for Object in self.ColorObjectsColor:
Object.SetColor(colors[random.randint(0,len(colors)-1)])
for Object in self.ColorObjectsText:
@@ -1720,10 +1720,9 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
shorelines of the whole world, in MapGen format.
"""
import string
file = open(filename,'rt')
data = file.readlines()
data = map(string.strip,data)
data = [s.strip() for s in data]
Shorelines = []
segment = []
@@ -1733,7 +1732,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
if segment: Shorelines.append(N.array(segment))
segment = []
else:
segment.append(map(float,string.split(line)))
segment.append([float(e) for e in line.split()])
if segment: Shorelines.append(N.array(segment))
if stats:

View File

@@ -237,7 +237,6 @@ class DemoApp(wx.App):
"""
def OnInit(self):
wx.InitAllImageHandlers()
frame = DrawFrame(None, -1, "Simple Drawing Window",wx.DefaultPosition, (700,700) )
self.SetTopWindow(frame)
@@ -255,12 +254,11 @@ def Read_MapGen(filename,stats = False):
shorelines of the whole worls, in MapGen format.
"""
import string
from numpy import array
file = open(filename,'rt')
data = file.readlines()
data = map(string.strip,data)
data = [s.strip() for s in data]
Shorelines = []
segment = []
for line in data:

View File

@@ -9,7 +9,7 @@
# Version:
# Date:
# Licence:
# Tags: phoenix-port
# Tags: phoenix-port, unittest, documented, py3-port
#----------------------------------------------------------------------------
"""
This is the main module of the floatcanvas package, it contains the :class:`~lib.floatcanvas.FloatCanvas.FloatCanvas`
@@ -51,6 +51,7 @@ mac = sys.platform.startswith("darwin")
import numpy as N
from time import clock
import wx
from wx.lib import six
from .Utilities import BBox
from . import GUIMode
@@ -146,7 +147,7 @@ def _cycleidxs(indexcount, maxvalue, step):
if indexcount == 0:
yield ()
else:
for idx in xrange(0, maxvalue, step):
for idx in range(0, maxvalue, step):
for tail in _cycleidxs(indexcount - 1, maxvalue, step):
color = (idx, ) + tail
if not colormatch(color):
@@ -288,9 +289,16 @@ class DrawObject:
self._Canvas.MakeNewHTBitmap()
if not self.HitColor:
if not self._Canvas.HitColorGenerator:
# first call to prevent the background color from being used.
self._Canvas.HitColorGenerator = _colorGenerator()
self._Canvas.HitColorGenerator.next() # first call to prevent the background color from being used.
self.HitColor = self._Canvas.HitColorGenerator.next()
if six.PY3:
next(self._Canvas.HitColorGenerator)
else:
self._Canvas.HitColorGenerator.next()
if six.PY3:
self.HitColor = next(self._Canvas.HitColorGenerator)
else:
self.HitColor = self._Canvas.HitColorGenerator.next()
self.SetHitPen(self.HitColor,self.HitLineWidth)
self.SetHitBrush(self.HitColor)
# put the object in the hit dict, indexed by it's color
@@ -1187,7 +1195,7 @@ class ArrowLine(PointsObjectMixin, LineOnlyMixin, DrawObject):
Points = self.Points
n = Points.shape[0]
self.ArrowPoints = N.zeros((n-1, 3, 2), N.float)
for i in xrange(n-1):
for i in range(n-1):
dx, dy = self.Points[i] - self.Points[i+1]
theta = N.arctan2(dy, dx)
AP = N.array( (