--- a/IDEFrame.py Fri Nov 23 11:01:20 2018 +0100
+++ b/IDEFrame.py Fri Nov 23 12:13:24 2018 +0100
@@ -23,14 +23,17 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from __future__ import absolute_import
+from __future__ import division
import sys
-import cPickle
-from types import TupleType
import base64
+from future.builtins import \
+ round, \
+ str as text
import wx
import wx.grid
import wx.aui
+from six.moves import cPickle, xrange
from editors.EditorPanel import EditorPanel
from editors.SFCViewer import SFC_Viewer
@@ -108,7 +111,7 @@
def DecodeFileSystemPath(path, is_base64=True):
if is_base64:
path = base64.decodestring(path)
- return unicode(path, sys.getfilesystemencoding())
+ return text(path, sys.getfilesystemencoding())
def AppendMenu(parent, help, id, kind, text):
@@ -200,22 +203,22 @@
raise ValueError("Not possible")
if tab["size"][0] == rect.width:
if tab["pos"][1] == rect.y:
- split = (wx.TOP, float(tab["size"][1]) / float(rect.height))
+ split = (wx.TOP, tab["size"][1] / rect.height)
split_rect = wx.Rect(rect.x, rect.y + tab["size"][1] + TAB_BORDER,
rect.width, rect.height - tab["size"][1] - TAB_BORDER)
elif tab["pos"][1] == rect.height + 1 - tab["size"][1]:
- split = (wx.BOTTOM, 1.0 - float(tab["size"][1]) / float(rect.height))
+ split = (wx.BOTTOM, 1.0 - tab["size"][1] / rect.height)
split_rect = wx.Rect(rect.x, rect.y,
rect.width, rect.height - tab["size"][1] - TAB_BORDER)
split_id = idx
break
elif tab["size"][1] == rect.height:
if tab["pos"][0] == rect.x:
- split = (wx.LEFT, float(tab["size"][0]) / float(rect.width))
+ split = (wx.LEFT, tab["size"][0] / rect.width)
split_rect = wx.Rect(rect.x + tab["size"][0] + TAB_BORDER, rect.y,
rect.width - tab["size"][0] - TAB_BORDER, rect.height)
elif tab["pos"][0] == rect.width + 1 - tab["size"][0]:
- split = (wx.RIGHT, 1.0 - float(tab["size"][0]) / float(rect.width))
+ split = (wx.RIGHT, 1.0 - tab["size"][0] / rect.width)
split_rect = wx.Rect(rect.x, rect.y,
rect.width - tab["size"][0] - TAB_BORDER, rect.height)
split_id = idx
@@ -833,7 +836,7 @@
return None
def LoadTabLayout(self, notebook, tabs, mode="all", first_index=None):
- if isinstance(tabs, ListType):
+ if isinstance(tabs, list):
if len(tabs) == 0:
return
raise ValueError("Not supported")
@@ -2435,7 +2438,7 @@
result = self.Controler.PastePou(pou_type, pou_xml)
- if not isinstance(result, TupleType):
+ if not isinstance(result, tuple):
self.ShowErrorMessage(result)
else:
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, PROJECTTREE, LIBRARYTREE)
@@ -2591,7 +2594,7 @@
def UPPER_DIV(x, y):
- return (x / y) + {True: 0, False: 1}[(x % y) == 0]
+ return (x // y) + {True: 0, False: 1}[(x % y) == 0]
class GraphicPrintout(wx.Printout):
@@ -2638,8 +2641,8 @@
ppiPrinterX, ppiPrinterY = self.GetPPIPrinter()
pw, ph = self.GetPageSizePixels()
dw, dh = dc.GetSizeTuple()
- Xscale = (float(dw) * float(ppiPrinterX)) / (float(pw) * 25.4)
- Yscale = (float(dh) * float(ppiPrinterY)) / (float(ph) * 25.4)
+ Xscale = (dw * ppiPrinterX) / (pw * 25.4)
+ Yscale = (dh * ppiPrinterY) / (ph * 25.4)
fontsize = self.FontSize * Yscale
@@ -2661,10 +2664,10 @@
# Calculate the position on the DC for centering the graphic
posX = area_width * ((page - 1) % self.PageGrid[0])
- posY = area_height * ((page - 1) / self.PageGrid[0])
-
- scaleX = float(area_width) / float(self.PageSize[0])
- scaleY = float(area_height) / float(self.PageSize[1])
+ posY = area_height * ((page - 1) // self.PageGrid[0])
+
+ scaleX = area_width / self.PageSize[0]
+ scaleY = area_height / self.PageSize[1]
scale = min(scaleX, scaleY)
# Set the scale and origin