summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/asymptote/GUI
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-04-07 16:52:56 +0000
committerKarl Berry <karl@freefriends.org>2016-04-07 16:52:56 +0000
commite1e1d6fa3224440612d3ad6595c413f88d552702 (patch)
treeeaa3301c9fecd1d01baa642b2e483fee4430bcee /Master/texmf-dist/asymptote/GUI
parent0eefec13710bb4d6aff6838a6efc463912506ee9 (diff)
asymptote 2.37
git-svn-id: svn://tug.org/texlive/trunk@40303 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/asymptote/GUI')
-rwxr-xr-xMaster/texmf-dist/asymptote/GUI/CubicBezier.py11
-rwxr-xr-xMaster/texmf-dist/asymptote/GUI/UndoRedoStack.py22
-rwxr-xr-xMaster/texmf-dist/asymptote/GUI/xasy.py11
-rwxr-xr-xMaster/texmf-dist/asymptote/GUI/xasy2asy.py79
-rwxr-xr-xMaster/texmf-dist/asymptote/GUI/xasyActions.py6
-rwxr-xr-xMaster/texmf-dist/asymptote/GUI/xasyBezierEditor.py7
-rwxr-xr-xMaster/texmf-dist/asymptote/GUI/xasyCodeEditor.py5
-rwxr-xr-xMaster/texmf-dist/asymptote/GUI/xasyColorPicker.py40
-rwxr-xr-xMaster/texmf-dist/asymptote/GUI/xasyFile.py54
-rwxr-xr-xMaster/texmf-dist/asymptote/GUI/xasyGUIIcons.py30
-rwxr-xr-xMaster/texmf-dist/asymptote/GUI/xasyMainWin.py137
-rwxr-xr-xMaster/texmf-dist/asymptote/GUI/xasyOptions.py20
-rwxr-xr-xMaster/texmf-dist/asymptote/GUI/xasyOptionsDialog.py46
-rwxr-xr-xMaster/texmf-dist/asymptote/GUI/xasyVersion.py2
14 files changed, 241 insertions, 229 deletions
diff --git a/Master/texmf-dist/asymptote/GUI/CubicBezier.py b/Master/texmf-dist/asymptote/GUI/CubicBezier.py
index 6455b700a79..2eb62577b0a 100755
--- a/Master/texmf-dist/asymptote/GUI/CubicBezier.py
+++ b/Master/texmf-dist/asymptote/GUI/CubicBezier.py
@@ -82,16 +82,19 @@ if __name__ == '__main__':
pointList = makeBezier((-80,0),(-150,40),(150,120),(80,0),0.5)
from timeit import Timer
t = Timer('makeBezier((-80,0),(-40,-40),(40,120),(80,0),1)','from __main__ import makeBezier')
- print pointList
- print len(pointList)
+ print (pointList)
+ print (len(pointList))
iterations = 1000
time = t.timeit(iterations)
- print "%d iterations took %f seconds (%f ms for each)."%(iterations,time,1000.0*time/iterations)
+ print ("{:d} iterations took {:f} seconds ({:f} ms for each).".format(iterations,time,1000.0*time/iterations))
points = []
for point in pointList:
points.append(point[0])
points.append(-point[1])
- from Tkinter import *
+ if sys.version_info >= (3, 0):
+ from tkinter import *
+ else:
+ from Tkinter import *
root = Tk()
canv = Canvas(root,scrollregion=(-100,-100,100,100))
canv.pack()
diff --git a/Master/texmf-dist/asymptote/GUI/UndoRedoStack.py b/Master/texmf-dist/asymptote/GUI/UndoRedoStack.py
index f4a247a411d..779d0330a81 100755
--- a/Master/texmf-dist/asymptote/GUI/UndoRedoStack.py
+++ b/Master/texmf-dist/asymptote/GUI/UndoRedoStack.py
@@ -13,10 +13,10 @@ class action:
self.act = act
self.inv = inv
def undo(self):
- #print "Undo:",self
+ #print ("Undo:",self)
self.inv()
def redo(self):
- #print "Redo:",self
+ #print ("Redo:",self)
self.act()
def __str__(self):
return "A generic action"
@@ -33,7 +33,7 @@ class actionStack:
def add(self,action):
self.undoStack.append(action)
- #print "Added",action
+ #print ("Added",action)
self.redoStack = []
def undo(self):
@@ -54,13 +54,13 @@ class actionStack:
op.undo()
self.redoStack.append(op)
elif op is endActionGroup:
- raise Exception,"endActionGroup without previous beginActionGroup"
+ raise Exception("endActionGroup without previous beginActionGroup")
else:
self.redoStack.append(op)
op.undo()
- #print "undid",op
+ #print ("undid",op)
else:
- pass #print "nothing to undo"
+ pass #print ("nothing to undo")
def redo(self):
if len(self.redoStack) > 0:
@@ -80,13 +80,13 @@ class actionStack:
op.redo()
self.undoStack.append(op)
elif op is endActionGroup:
- raise Exception,"endActionGroup without previous beginActionGroup"
+ raise Exception("endActionGroup without previous beginActionGroup")
else:
self.undoStack.append(op)
op.redo()
- #print "redid",op
+ #print ("redid",op)
else:
- pass #print "nothing to redo"
+ pass #print ("nothing to redo")
def setCommitLevel(self):
self.commitLevel = len(self.undoStack)
@@ -105,9 +105,9 @@ class actionStack:
if __name__=='__main__':
import sys
def opq():
- print "action1"
+ print ("action1")
def unopq():
- print "inverse1"
+ print ("inverse1")
q = action(opq,unopq)
w = action(lambda:sys.stdout.write("action2\n"),lambda:sys.stdout.write("inverse2\n"))
e = action(lambda:sys.stdout.write("action3\n"),lambda:sys.stdout.write("inverse3\n"))
diff --git a/Master/texmf-dist/asymptote/GUI/xasy.py b/Master/texmf-dist/asymptote/GUI/xasy.py
index ffca16a1e2d..f160404c19a 100755
--- a/Master/texmf-dist/asymptote/GUI/xasy.py
+++ b/Master/texmf-dist/asymptote/GUI/xasy.py
@@ -10,8 +10,11 @@
############################################################################
import getopt,sys,signal
-from Tkinter import *
import xasyMainWin
+if sys.version_info >= (3, 0):
+ from tkinter import *
+else:
+ from Tkinter import *
signal.signal(signal.SIGINT,signal.SIG_IGN)
@@ -22,11 +25,11 @@ try:
if(len(opts)>=1):
mag = float(opts[0][1])
except:
- print "Invalid arguments."
- print "Usage: xasy.py [-x magnification] [filename]"
+ print ("Invalid arguments.")
+ print ("Usage: xasy.py [-x magnification] [filename]")
sys.exit(1)
if(mag <= 0.0):
- print "Magnification must be positive."
+ print ("Magnification must be positive.")
sys.exit(1)
if(len(args)>=1):
app = xasyMainWin.xasyMainWin(root,args[0],mag)
diff --git a/Master/texmf-dist/asymptote/GUI/xasy2asy.py b/Master/texmf-dist/asymptote/GUI/xasy2asy.py
index 3a2c1bcbe7b..06c0dbd7f54 100755
--- a/Master/texmf-dist/asymptote/GUI/xasy2asy.py
+++ b/Master/texmf-dist/asymptote/GUI/xasy2asy.py
@@ -12,10 +12,15 @@ import sys,os,signal,threading
from subprocess import *
from string import *
import xasyOptions
-import Queue
-from Tkinter import *
from tempfile import mkdtemp
+if sys.version_info >= (3, 0):
+ from tkinter import *
+ import queue
+else:
+ from Tkinter import *
+ import Queue as queue
+
# PIL support is now mandatory due to rotations
try:
from PIL import ImageTk
@@ -50,14 +55,21 @@ def startQuickAsy():
AsyTempDir=mkdtemp(prefix="asy_")+os.sep
if sys.platform[:3] == 'win':
quickAsy=Popen([xasyOptions.options['asyPath'],"-noV","-multiline","-q",
- "-o"+AsyTempDir,"-inpipe=0","-outpipe=2"],stdin=PIPE,stderr=PIPE)
+ "-o"+AsyTempDir,"-inpipe=0","-outpipe=2"],stdin=PIPE,
+ stderr=PIPE,universal_newlines=True)
fout=quickAsy.stdin
fin=quickAsy.stderr
else:
(rx,wx) = os.pipe()
(ra,wa) = os.pipe()
+ if sys.version_info >= (3, 4):
+ os.set_inheritable(rx, True)
+ os.set_inheritable(wx, True)
+ os.set_inheritable(ra, True)
+ os.set_inheritable(wa, True)
quickAsy=Popen([xasyOptions.options['asyPath'],"-noV","-multiline","-q",
- "-o"+AsyTempDir,"-inpipe="+str(rx),"-outpipe="+str(wa)])
+ "-o"+AsyTempDir,"-inpipe="+str(rx),"-outpipe="+str(wa)],
+ close_fds=False)
fout=os.fdopen(wx,'w')
fin=os.fdopen(ra,'r')
if quickAsy.returncode != None:
@@ -111,7 +123,7 @@ class asyTransform:
self.x,self.y,self.xx,self.xy,self.yx,self.yy = initTuple
self.deleted = delete
else:
- raise Exception,"Illegal initializer for asyTransform"
+ raise Exception("Illegal initializer for asyTransform")
def getCode(self):
"""Obtain the asy code that represents this transform"""
@@ -135,7 +147,7 @@ class asyTransform:
elif len(other) == 2:
return ((self.t[0]+self.t[2]*other[0]+self.t[3]*other[1]),(self.t[1]+self.t[4]*other[0]+self.t[5]*other[1]))
else:
- raise Exception, "Illegal multiplier of %s"%str(type(other))
+ raise Exception("Illegal multiplier of {:s}".format(str(type(other))))
elif isinstance(other,asyTransform):
result = asyTransform((0,0,0,0,0,0))
result.x = self.x+self.xx*other.x+self.xy*other.y
@@ -147,7 +159,7 @@ class asyTransform:
result.t = (result.x,result.y,result.xx,result.xy,result.yx,result.yy)
return result
else:
- raise Exception, "Illegal multiplier of %s"%str(type(other))
+ raise Exception("Illegal multiplier of {:s}".format(str(type(other))))
def identity():
return asyTransform((0,0,1,0,0,1))
@@ -181,7 +193,7 @@ class asyPen(asyObj):
def updateCode(self,mag=1.0):
"""Generate the pen's code"""
- self.asyCode = "rgb(%g,%g,%g)"%self.color+"+"+str(self.width)
+ self.asyCode = "rgb({:g},{:g},{:g})+{:s}".format(self.color[0], self.color[1], self.color[2],str(self.width))
if len(self.options) > 0:
self.asyCode += "+"+self.options
@@ -226,23 +238,7 @@ class asyPen(asyObj):
def tkColor(self):
"""Return the tk version of the pen's color"""
self.computeColor()
- r,g,b = self.color
- r,g,b = int(256*r),int(256*g),int(256*b)
- if r == 256:
- r = 255
- if g == 256:
- g = 255
- if b == 256:
- b = 255
- r,g,b = map(hex,(r,g,b))
- r,g,b = r[2:],g[2:],b[2:]
- if len(r) < 2:
- r += '0'
- if len(g) < 2:
- g += '0'
- if len(b) < 2:
- b += '0'
- return'#'+r+g+b
+ return '#{}'.format("".join(["{:02x}".format(min(int(256*a),255)) for a in self.color]))
class asyPath(asyObj):
"""A python wrapper for an asymptote path"""
@@ -353,7 +349,7 @@ class asyPath(asyObj):
line=fin.readline()
line=line.replace("\n","")
pathStrLines.append(line)
- oneLiner = "".join(split(join(pathStrLines)))
+ oneLiner = "".join(pathStrLines).replace(" ", "")
splitList = oneLiner.split("..")
nodes = [a for a in splitList if a.find("controls")==-1]
self.nodeSet = []
@@ -437,7 +433,7 @@ class xasyItem:
def asyfy(self,mag=1.0):
self.removeFromCanvas()
self.imageList = []
- self.imageHandleQueue = Queue.Queue()
+ self.imageHandleQueue = queue.Queue()
worker = threading.Thread(target=self.asyfyThread,args=(mag,))
worker.start()
item = self.imageHandleQueue.get()
@@ -461,23 +457,22 @@ class xasyItem:
fout.write("reset;\n")
fout.write("initXasyMode();\n")
fout.write("atexit(null);\n")
- global console
for line in self.getCode().splitlines():
fout.write(line+"\n");
- fout.write("deconstruct(%f);\n"%mag)
+ fout.write("deconstruct({:f});\n".format(mag))
fout.flush()
- format = "png"
- maxargs = int(split(fin.readline())[0])
+ maxargs = int(fin.readline().split()[0])
boxes=[]
batch=0
n=0
text = fin.readline()
- template=AsyTempDir+"%d_%d.%s"
+ # template=AsyTempDir+"%d_%d.%s"
+ fileformat = "png"
def render():
for i in range(len(boxes)):
- l,b,r,t = [float(a) for a in split(boxes[i])]
- name=template%(batch,i+1,format)
- self.imageHandleQueue.put((name,format,(l,b,r,t),i))
+ l,b,r,t = [float(a) for a in boxes[i].split()]
+ name="{:s}{:d}_{:d}.{:s}".format(AsyTempDir,batch,i+1,fileformat)
+ self.imageHandleQueue.put((name,fileformat,(l,b,r,t),i))
while text != "Done\n" and text != "Error\n":
boxes.append(text)
text = fin.readline()
@@ -595,14 +590,14 @@ class xasyShape(xasyDrawnItem):
def __str__(self):
"""Create a string describing this shape"""
- return "xasyShape code:%s"%("\n\t".join(self.getCode().splitlines()))
+ return "xasyShape code:{:s}".format("\n\t".join(self.getCode().splitlines()))
class xasyFilledShape(xasyShape):
"""A filled shape drawn on the GUI"""
def __init__(self,path,pen=asyPen(),transform=identity()):
"""Initialize this shape with a path, pen, and transform"""
if path.nodeSet[-1] != 'cycle':
- raise Exception,"Filled paths must be cyclic"
+ raise Exception("Filled paths must be cyclic")
xasyShape.__init__(self,path,pen,transform)
def updateCode(self,mag=1.0):
@@ -661,7 +656,7 @@ class xasyFilledShape(xasyShape):
def __str__(self):
"""Return a string describing this shape"""
- return "xasyFilledShape code:%s"%("\n\t".join(self.getCode().splitlines()))
+ return "xasyFilledShape code:{:s}".format("\n\t".join(self.getCode().splitlines()))
class xasyText(xasyItem):
"""Text created by the GUI"""
@@ -690,11 +685,11 @@ class xasyText(xasyItem):
if self.onCanvas == None:
self.onCanvas = canvas
elif self.onCanvas != canvas:
- raise Exception,"Error: item cannot be added to more than one canvas"
+ raise Exception("Error: item cannot be added to more than one canvas")
self.asyfy(mag)
def __str__(self):
- return "xasyText code:%s"%("\n\t".join(self.getCode().splitlines()))
+ return "xasyText code:{:s}".format("\n\t".join(self.getCode().splitlines()))
class xasyScript(xasyItem):
"""A set of images create from asymptote code. It is always deconstructed."""
@@ -718,7 +713,7 @@ class xasyScript(xasyItem):
for xform in self.transform:
if not isFirst:
self.asyCode+=",\n"
- self.asyCode += "indexedTransform(%d,%s)"%(count,str(xform))
+ self.asyCode += "indexedTransform({:d},{:s})".format(count,str(xform))
isFirst = False
count += 1
self.asyCode += ");\n"
@@ -754,7 +749,7 @@ class xasyScript(xasyItem):
if self.onCanvas == None:
self.onCanvas = canvas
elif self.onCanvas != canvas:
- raise Exception,"Error: item cannot be added to more than one canvas"
+ raise Exception("Error: item cannot be added to more than one canvas")
self.asyfy(mag)
def __str__(self):
diff --git a/Master/texmf-dist/asymptote/GUI/xasyActions.py b/Master/texmf-dist/asymptote/GUI/xasyActions.py
index 38aae1d5c7e..95411c5d9a4 100755
--- a/Master/texmf-dist/asymptote/GUI/xasyActions.py
+++ b/Master/texmf-dist/asymptote/GUI/xasyActions.py
@@ -9,9 +9,13 @@
#
###########################################################################
import math
+import sys
import UndoRedoStack
import xasy2asy
-from Tkinter import *
+if sys.version_info >= (3, 0):
+ from tkinter import *
+else:
+ from Tkinter import *
class translationAction(UndoRedoStack.action):
def __init__(self,owner,itemList,indexList,translation):
diff --git a/Master/texmf-dist/asymptote/GUI/xasyBezierEditor.py b/Master/texmf-dist/asymptote/GUI/xasyBezierEditor.py
index 998ee4c7c25..75ddeafa2d2 100755
--- a/Master/texmf-dist/asymptote/GUI/xasyBezierEditor.py
+++ b/Master/texmf-dist/asymptote/GUI/xasyBezierEditor.py
@@ -10,11 +10,16 @@
#
###########################################################################
-from Tkinter import *
import math
+import sys
from CubicBezier import *
import xasy2asy
+if sys.version_info >= (3, 0):
+ from tkinter import *
+else:
+ from Tkinter import *
+
class node:
def __init__(self,precontrol,node,postcontrol,uid,isTied = True):
self.node = node
diff --git a/Master/texmf-dist/asymptote/GUI/xasyCodeEditor.py b/Master/texmf-dist/asymptote/GUI/xasyCodeEditor.py
index d09196a41be..8f3de4034fe 100755
--- a/Master/texmf-dist/asymptote/GUI/xasyCodeEditor.py
+++ b/Master/texmf-dist/asymptote/GUI/xasyCodeEditor.py
@@ -15,7 +15,6 @@ from tempfile import mkstemp
from os import remove
from os import fdopen
from os import path
-from string import split
import xasyOptions
def getText(text=""):
@@ -26,7 +25,7 @@ def getText(text=""):
tempf.close()
try:
cmdpath,cmd = path.split(path.expandvars(xasyOptions.options['externalEditor']))
- split_cmd = split(cmd)
+ split_cmd = cmd.split()
cmdpart = [path.join(cmdpath,split_cmd[0])]
argpart = split_cmd[1:]+[temp[1]]
arglist = cmdpart+argpart
@@ -45,4 +44,4 @@ def getText(text=""):
if __name__ == '__main__':
#run a test
- print getText("Here is some text to edit")
+ print (getText("Here is some text to edit"))
diff --git a/Master/texmf-dist/asymptote/GUI/xasyColorPicker.py b/Master/texmf-dist/asymptote/GUI/xasyColorPicker.py
index 7415be205c4..217835bdbb0 100755
--- a/Master/texmf-dist/asymptote/GUI/xasyColorPicker.py
+++ b/Master/texmf-dist/asymptote/GUI/xasyColorPicker.py
@@ -10,8 +10,15 @@
#
############################################################################
-from Tkinter import *
-import tkColorChooser
+import sys
+
+if sys.version_info >= (3, 0):
+ from tkinter import *
+ from tkinter import colorchooser
+else:
+ from Tkinter import *
+ import tkColorChooser as colorchooser
+
asyColors = { "black":(0,0,0),
"white":(1,1,1),
"gray":(0.5,0.5,0.5),
@@ -145,28 +152,13 @@ def makeRGBfromTkColor(tkColor):
b /= 255.0
return (r,g,b)
-def RGBreal255((r,g,b)):
+def RGBreal255(rgb):
"""Convert an RGB color from 0-1 to 0-255"""
- a,b,c = (256*r,256*g,256*b)
- if a == 256:
- a = 255
- if b == 256:
- b = 255
- if c == 256:
- c = 255
- return map(int,(a,b,c))
+ return [min(int(256*a),255) for a in rgb]
-def RGB255hex((r,g,b)):
+def RGB255hex(rgb):
"""Make a color in the form #rrggbb in hex from r,g,b in 0-255"""
- rs,gs,bs = map(hex,(r,g,b))
- rs,gs,bs = rs[2:],gs[2:],bs[2:]
- if len(rs) < 2:
- rs += '0'
- if len(gs) < 2:
- gs += '0'
- if len(bs) < 2:
- bs += '0'
- return '#'+rs+gs+bs
+ return "#{}".format("".join(["{:02x}".format(a) for a in rgb]))
class xasyColorDlg(Toplevel):
"""A dialog for choosing an asymptote color. It displays the usual asy presets and allows custom rgb colors"""
@@ -216,8 +208,8 @@ class xasyColorDlg(Toplevel):
"""Close the dialog forcibly"""
self.destroy()
def getCustom(self):
- """Request a custom RGB color using a tkColorChooser"""
- result=tkColorChooser.askcolor(initialcolor=RGB255hex(RGBreal255(self.color)),title="Custom Color",parent=self)
+ """Request a custom RGB color using a colorchooser"""
+ result=colorchooser.askcolor(initialcolor=RGB255hex(RGBreal255(self.color)),title="Custom Color",parent=self)
if result != (None,None):
self.setColor((result[0][0]/255.0,result[0][1]/255.0,result[0][2]/255.0))
def cancel(self):
@@ -235,7 +227,7 @@ class xasyColorDlg(Toplevel):
"""Use this method to prompt for a color. It returns the new color or the old color if the user cancelled the operation.
e.g:
- print xasyColorDlg(Tk()).getColor((1,1,0))
+ print (xasyColorDlg(Tk()).getColor((1,1,0)))
"""
self.setColor(initialColor)
self.oldColor = initialColor
diff --git a/Master/texmf-dist/asymptote/GUI/xasyFile.py b/Master/texmf-dist/asymptote/GUI/xasyFile.py
index 890f1ad3eef..7516fc7d3b5 100755
--- a/Master/texmf-dist/asymptote/GUI/xasyFile.py
+++ b/Master/texmf-dist/asymptote/GUI/xasyFile.py
@@ -28,7 +28,7 @@ def parseFile(inFile):
#lines = [line for line in lines.splitlines() if not line.startswith("//")]
result = []
if lines[0] != "initXasyMode();":
- raise xasyFileError,"Invalid file format: First line must be \"initXasyMode();\""
+ raise xasyFileError("Invalid file format: First line must be \"initXasyMode();\"")
lines.pop(0)
lineCount = 2
lineNum = len(lines)
@@ -37,14 +37,14 @@ def parseFile(inFile):
lines.pop(0)
if not line.isspace() and len(line)>0:
try:
- #print "Line %d: %s"%(lineCount,line),
+ #print ("Line {:d}: {:s}".format(lineCount,line))
lineResult = parseLine(line.strip(),lines)
except:
- raise xasyParseError,"Parsing error: line %d in %s\n%s"%(lineCount,inFile.name,line)
+ raise xasyParseError("Parsing error: line {:d} in {:s}\n{:s}".format(lineCount,inFile.name,line))
if lineResult != None:
result.append(lineResult)
- #print "\tproduced: %s"%str(lineResult)
+ #print ("\tproduced: {:s}".format(str(lineResult)))
lineCount += lineNum-len(lines)
lineNum = len(lines)
return result
@@ -105,7 +105,7 @@ def parseTransformExpression(line):
global pendingTransforms
stackCmd = line[len(transformPrefix)+1:line.find("(")]
if line[-2:] != ");":
- raise xasyParseError,"Invalid syntax"
+ raise xasyParseError("Invalid syntax")
args = line[line.find("(")+1:-2]
if stackCmd == "push":
t = asyTransform(eval(args))
@@ -113,19 +113,19 @@ def parseTransformExpression(line):
elif stackCmd == "add":
parseIndexedTransforms(args)
else:
- raise xasyParseError,"Invalid transform stack command."
+ raise xasyParseError("Invalid transform stack command.")
return None
def parseLabel(line):
"""Parse an asy Label statement, returning an xasyText item"""
if not (line.startswith("Label(") and line.endswith(",align=SE)")):
- raise xasyParseError,"Invalid syntax"
+ raise xasyParseError("Invalid syntax")
args = line[6:-1]
loc2 = args.rfind(",align=SE")
loc1 = args.rfind(",",0,loc2-1)
loc = args.rfind(",(",0,loc1-1)
if loc < 2:
- raise xasyParseError,"Invalid syntax"
+ raise xasyParseError("Invalid syntax")
text = args[1:loc-1]
location = eval(args[loc+1:args.find("),",loc)+1])
pen = args[loc:loc2]
@@ -143,7 +143,7 @@ def parseLabelCommand(line):
e.g.: label(Label("Hello world!",(0,0),rgb(0,0,0)+0.5,align=SE));
"""
if line[-2:] != ");":
- raise xasyParseError,"Invalid syntax"
+ raise xasyParseError("Invalid syntax")
arguments = line[6:-2]
return parseLabel(arguments)
@@ -155,7 +155,7 @@ def parseDrawCommand(line):
e.g.: draw((0,0)..controls(0.33,0.33)and(0.66,0.66)..(1,1),rgb(1,0,1)+1.5);
"""
if line[-2:] != ");":
- raise xasyParseError,"Invalid syntax"
+ raise xasyParseError("Invalid syntax")
args = line[5:-2]
loc = args.rfind(",rgb")
path = args[:loc]
@@ -171,7 +171,7 @@ def parseFillCommand(line):
e.g.: fill((0,0)..controls(0.33,0.33)and(0.66,0.66)..(1,1)..controls(0.66,0)and(0.33,0)..cycle,rgb(1,0,1)+1.5);
"""
if line[-2:] != ");":
- raise xasyParseError,"Invalid syntax"
+ raise xasyParseError("Invalid syntax")
args = line[5:-2]
loc = args.rfind(",rgb")
path = args[:loc]
@@ -197,13 +197,13 @@ def parsePen(pen):
options = ""
return asyPen(color,width,options)
except:
- raise xasyParseError,"Invalid pen"
+ raise xasyParseError("Invalid pen")
def parsePathExpression(expr):
"""Parse an asy path returning an asyPath()"""
result = asyPath()
expr = "".join(expr.split())
- #print expr
+ #print (expr)
if expr.find("controls") != -1:
#parse a path with control points
tokens = expr.split("..")
@@ -211,18 +211,18 @@ def parsePathExpression(expr):
for a in range(len(nodes)):
if nodes[a] != "cycle":
nodes[a] = eval(nodes[a])
- controls = [map(eval,a.replace("controls","").split("and")) for a in tokens if a.startswith("controls")]
+ controls = [[eval(b) for b in a.replace("controls", "").split("and")] for a in tokens if a.startswith("controls")]
result.initFromControls(nodes, controls)
else:
#parse a path without control points
tokens = re.split(r"(::|--|\.\.)",expr)
linkSet = re.findall("::|--|\.\.",expr)
nodeSet = [a for a in tokens if not re.match(r"::|--|\.\.",a)]
- #print nodeSet
+ #print (nodeSet)
for a in range(len(nodeSet)):
if nodeSet[a] != "cycle":
nodeSet[a] = eval(nodeSet[a])
- #print nodeSet
+ #print (nodeSet)
result.initFromNodeList(nodeSet, linkSet)
return result
@@ -250,7 +250,7 @@ def parseLine(line,lines):
return parseFillCommand(takeUntilSemicolon(line,lines))
elif line.startswith("exitXasyMode();"):
return None
- raise Exception,"Could not parse the line"
+ raise Exception("Could not parse the line")
fileHeader = """initXasyMode();
// This file was generated by xasy. It may be edited manually, however, a strict
@@ -280,28 +280,28 @@ if __name__ == '__main__':
name = "../../xasyTest.asy"
f = open(name,"rt")
except:
- print "Could not open file."
+ print ("Could not open file.")
asy.quit()
sys.exit(1)
fileItems = []
try:
fileItems = parseFile(f)
- res = map(str,fileItems)
- print "----------------------------------"
- print "Objects in %s"%f.name
- print "----------------------------------"
+ res = [str(a) for a in fileItems]
+ print ("----------------------------------")
+ print ("Objects in {:s}".format(f.name))
+ print ("----------------------------------")
for a in res:
- print a
- print "----------------------------------"
- print "successful parse"
+ print (a)
+ print ("----------------------------------")
+ print ("successful parse")
f.close()
except:
f.close()
- print "parse failed"
+ print ("parse failed")
raise
- print "making a file"
+ print ("making a file")
f = open("testfile.asy","wt")
saveFile(f,fileItems)
f.close()
diff --git a/Master/texmf-dist/asymptote/GUI/xasyGUIIcons.py b/Master/texmf-dist/asymptote/GUI/xasyGUIIcons.py
index 3afecfd349c..7f07d5748d7 100755
--- a/Master/texmf-dist/asymptote/GUI/xasyGUIIcons.py
+++ b/Master/texmf-dist/asymptote/GUI/xasyGUIIcons.py
@@ -53,11 +53,11 @@ iconB64 = {
def createGIF(key):
"""Create a gif file from the data in the iconB64 list of icons"""
if key not in iconB64.keys():
- print "Error: %s not found in icon list."%key
- print "Available icons:",iconB64.keys()
+ print ("Error: {:s} not found in icon list.".format(key))
+ print ("Available icons:",iconB64.keys())
else:
- print "Generating %s.gif"%key
- open("%s.gif"%key,"w").write(base64.decodestring(iconB64[key]))
+ print ("Generating {:s}.gif".format(key))
+ open("{:s}.gif".format(key),"w").write(base64.decodestring(iconB64[key]))
def createGIFs():
"""Create the files for all the icons in iconB64"""
@@ -69,24 +69,24 @@ def createStrFromGif(gifFile):
return base64.encodestring(gifFile.read())
if __name__=='__main__':
- print "Testing the xasyGUIIcons module."
- print "Generating all the GIFs:"
+ print ("Testing the xasyGUIIcons module.")
+ print ("Generating all the GIFs:")
createGIFs()
- print "Checking consistency of all icons in iconB64"
+ print ("Checking consistency of all icons in iconB64")
allpassed = True
for icon in iconB64.keys():
- print ("Checking %s"%icon),
- if createStrFromGif(open("%s.gif"%icon,"rb")) == iconB64[icon]:
- print "\tPassed."
+ print ("Checking {:s}".format(icon))
+ if createStrFromGif(open("{:s}.gif".format(icon),"rb")) == iconB64[icon]:
+ print ("\tPassed.")
else:
- print "\tFailed."
+ print ("\tFailed.")
allpassed= False
if allpassed:
- print "All files succeeded."
+ print ("All files succeeded.")
s = raw_input("Delete generated files? (y/n)")
if s == "y":
for name in iconB64.keys():
- print "Deleting %s.gif"%name,
+ print ("Deleting {:s}.gif".format(name))
os.unlink(name+".gif")
- print "\tdone"
- print "Done"
+ print ("\tdone")
+ print ("Done")
diff --git a/Master/texmf-dist/asymptote/GUI/xasyMainWin.py b/Master/texmf-dist/asymptote/GUI/xasyMainWin.py
index 657d24ba81b..b0549e72f9c 100755
--- a/Master/texmf-dist/asymptote/GUI/xasyMainWin.py
+++ b/Master/texmf-dist/asymptote/GUI/xasyMainWin.py
@@ -11,15 +11,23 @@
###########################################################################
import os
+import sys
from string import *
import subprocess
import math
import copy
-from Tkinter import *
-import tkMessageBox
-import tkFileDialog
-import tkSimpleDialog
+if sys.version_info >= (3, 0):
+ # python3
+ from tkinter import *
+ from tkinter import filedialog, messagebox, simpledialog
+else:
+ # python2
+ # from Tkinter import *
+ import tkFileDialog as filedialog
+ import tkMessageBox as messagebox
+ import tkSimpleDialog as simpledialog
+
import threading
import time
@@ -56,12 +64,9 @@ class xasyMainWin:
self.bindGlobalEvents()
self.createWidgets()
self.resetGUI()
- if sys.platform[:3] == "win":
- site="http://effbot.org/downloads/PIL-1.1.7.win32-py2.7.exe"
- else:
- site="http://effbot.org/downloads/Imaging-1.1.7.tar.gz"
+ site=""
if not PILAvailable:
- tkMessageBox.showerror("Failed Dependencies","An error occurred loading the required PIL library. Please install "+site)
+ messagebox.showerror("Failed Dependencies","An error occurred loading the required PIL library. Please install Pillow from http://pypi.python.org/pypi/Pillow")
self.parent.destroy()
sys.exit(1)
if file != None:
@@ -449,12 +454,12 @@ class xasyMainWin:
#test the asyProcess
startQuickAsy()
if not quickAsyRunning():
- if tkMessageBox.askyesno("Xasy Error","Asymptote could not be executed.\r\nTry to find Asymptote automatically?"):
+ if messagebox.askyesno("Xasy Error","Asymptote could not be executed.\r\nTry to find Asymptote automatically?"):
xasyOptions.setAsyPathFromWindowsRegistry()
xasyOptions.save()
startQuickAsy()
while not quickAsyRunning():
- if tkMessageBox.askyesno("Xasy Error","Asymptote could not be executed.\r\nEdit settings?"):
+ if messagebox.askyesno("Xasy Error","Asymptote could not be executed.\r\nEdit settings?"):
xasyOptionsDialog.xasyOptionsDlg(self.parent)
xasyOptions.save()
startQuickAsy()
@@ -466,7 +471,7 @@ class xasyMainWin:
self.mainCanvas.delete("grid")
if not self.gridVisible:
return
- left,top,right,bottom = map(int,self.mainCanvas.cget("scrollregion").split())
+ left,top,right,bottom = [int(float(a)) for a in self.mainCanvas.cget("scrollregion").split()]
gridyspace = int(self.magnification*self.gridyspace)
gridxspace = int(self.magnification*self.gridxspace)
if gridxspace >= 3 and gridyspace >= 3:
@@ -484,7 +489,7 @@ class xasyMainWin:
self.mainCanvas.delete("axes")
if not self.axesVisible:
return
- left,top,right,bottom = map(int,self.mainCanvas.cget("scrollregion").split())
+ left,top,right,bottom = [int(float(a)) for a in self.mainCanvas.cget("scrollregion").split()]
self.mainCanvas.create_line(0,top,0,bottom,tags=("axes","yaxis"),fill=self.axiscolor)
self.mainCanvas.create_line(left,0,right,0,tags=("axes","xaxis"),fill=self.axiscolor)
axisxspace = int(self.magnification*self.axisxspace)
@@ -513,12 +518,12 @@ class xasyMainWin:
w,h = self.mainCanvas.winfo_width(),self.mainCanvas.winfo_height()
if right-left < w:
extraw = w-(right-left)
- right += extraw/2
- left -= extraw/2
+ right += extraw//2
+ left -= extraw//2
if bottom-top < h:
extrah = h-(bottom-top)
- bottom += extrah/2
- top -= extrah/2
+ bottom += extrah//2
+ top -= extrah//2
self.mainCanvas.config(scrollregion=(left,top,right,bottom))
#self.mainCanvas.xview(MOVETO,float(split(self.mainCanvas["scrollregion"])[0]))
#self.mainCanvas.yview(MOVETO,float(split(self.mainCanvas["scrollregion"])[1]))
@@ -549,7 +554,7 @@ class xasyMainWin:
self.bindEvents(item.IDTag)
def canQuit(self,force=False):
- #print "Quitting"
+ #print ("Quitting")
if not force and not self.testOrAcquireLock():
return
try:
@@ -557,10 +562,10 @@ class xasyMainWin:
except:
pass
if self.undoRedoStack.changesMade():
- result = tkMessageBox._show("xasy","File has been modified.\nSave changes?",icon=tkMessageBox.QUESTION,type=tkMessageBox.YESNOCANCEL)
- if str(result) == tkMessageBox.CANCEL:
+ result = messagebox._show("xasy","File has been modified.\nSave changes?",icon=messagebox.QUESTION,type=messagebox.YESNOCANCEL)
+ if str(result) == messagebox.CANCEL:
return
- elif result == tkMessageBox.YES:
+ elif result == messagebox.YES:
self.fileSaveCmd()
try:
os.rmdir(getAsyTempDir())
@@ -595,19 +600,19 @@ class xasyMainWin:
self.fileItems = xasyFile.parseFile(f)
f.close()
except IOError:
- tkMessageBox.showerror("File Opening Failed.","File could not be opened.")
+ messagebox.showerror("File Opening Failed.","File could not be opened.")
self.fileItems = []
except:
self.fileItems = []
self.autoMakeScript = True
- if self.autoMakeScript or tkMessageBox.askyesno("Error Opening File", "File was not recognized as an xasy file.\nLoad as a script item?"):
+ if self.autoMakeScript or messagebox.askyesno("Error Opening File", "File was not recognized as an xasy file.\nLoad as a script item?"):
try:
item = xasyScript(self.mainCanvas)
f.seek(0)
item.setScript(f.read())
self.addItemToFile(item)
except:
- tkMessageBox.showerror("File Opening Failed.","Could not load as a script item.")
+ messagebox.showerror("File Opening Failed.","Could not load as a script item.")
self.fileItems = []
self.populateCanvasWithItems()
self.populatePropertyList()
@@ -663,12 +668,12 @@ class xasyMainWin:
if(not self.testOrAcquireLock()):
return
self.releaseLock()
- #print "Create New File"
+ #print ("Create New File")
if self.undoRedoStack.changesMade():
- result = tkMessageBox._show("xasy","File has been modified.\nSave changes?",icon=tkMessageBox.QUESTION,type=tkMessageBox.YESNOCANCEL)
- if str(result) == tkMessageBox.CANCEL:
+ result = messagebox._show("xasy","File has been modified.\nSave changes?",icon=messagebox.QUESTION,type=messagebox.YESNOCANCEL)
+ if str(result) == messagebox.CANCEL:
return
- elif result == tkMessageBox.YES:
+ elif result == messagebox.YES:
self.fileSaveCmd()
self.resetGUI()
@@ -676,25 +681,25 @@ class xasyMainWin:
if(not self.testOrAcquireLock()):
return
self.releaseLock()
- #print "Open a file"
+ #print ("Open a file")
if self.undoRedoStack.changesMade():
- result = tkMessageBox._show("xasy","File has been modified.\nSave changes?",icon=tkMessageBox.QUESTION,type=tkMessageBox.YESNOCANCEL)
- if str(result) == tkMessageBox.CANCEL:
+ result = messagebox._show("xasy","File has been modified.\nSave changes?",icon=messagebox.QUESTION,type=messagebox.YESNOCANCEL)
+ if str(result) == messagebox.CANCEL:
return
- elif result == tkMessageBox.YES:
+ elif result == messagebox.YES:
self.fileSaveCmd()
- filename=tkFileDialog.askopenfilename(filetypes=[("asy files","*.asy"),("All files","*")],title="Open File",parent=self.parent)
+ filename=filedialog.askopenfilename(filetypes=[("asy files","*.asy"),("All files","*")],title="Open File",parent=self.parent)
if type(filename) != type((0,)) and filename != None and filename != '':
self.filename = filename
self.openFile(self.filename)
def fileSaveCmd(self):
- #print "Save current file"
+ #print ("Save current file")
if(not self.testOrAcquireLock()):
return
self.releaseLock()
if self.filename == None:
- filename=tkFileDialog.asksaveasfilename(defaultextension=".asy",filetypes=[("asy files","*.asy")],initialfile="newDrawing.asy",parent=self.parent,title="Save File")
+ filename=filedialog.asksaveasfilename(defaultextension=".asy",filetypes=[("asy files","*.asy")],initialfile="newDrawing.asy",parent=self.parent,title="Save File")
if type(filename) != type((0,)) and filename != None and filename != '':
self.filename = filename
if self.filename != None:
@@ -704,8 +709,8 @@ class xasyMainWin:
if(not self.testOrAcquireLock()):
return
self.releaseLock()
- #print "Save current file as"
- filename=tkFileDialog.asksaveasfilename(defaultextension=".asy",filetypes=[("asy files","*.asy")],initialfile="newDrawing.asy",parent=self.parent,title="Save File")
+ #print ("Save current file as")
+ filename=filedialog.asksaveasfilename(defaultextension=".asy",filetypes=[("asy files","*.asy")],initialfile="newDrawing.asy",parent=self.parent,title="Save File")
if type(filename) != type((0,)) and filename != None and filename != '':
self.filename = filename
self.saveFile(self.filename)
@@ -731,20 +736,20 @@ class xasyMainWin:
return
self.releaseLock()
if inFile == None:
- if tkMessageBox.askyesno("xasy","File has not been saved.\nSave?"):
+ if messagebox.askyesno("xasy","File has not been saved.\nSave?"):
self.fileSaveAsCmd()
inFile = self.filename
else:
return
elif self.undoRedoStack.changesMade():
- choice = tkMessageBox._show("xasy","File has been modified.\nOnly saved changes can be exported.\nDo you want to save changes?",icon=tkMessageBox.QUESTION,type=tkMessageBox.YESNOCANCEL)
+ choice = messagebox._show("xasy","File has been modified.\nOnly saved changes can be exported.\nDo you want to save changes?",icon=messagebox.QUESTION,type=messagebox.YESNOCANCEL)
choice = str(choice)
- if choice != tkMessageBox.YES:
+ if choice != messagebox.YES:
return
else:
self.fileSaveCmd()
name = os.path.splitext(os.path.basename(self.filename))[0]+'.'+outFormat
- outfilename = tkFileDialog.asksaveasfilename(defaultextension = '.'+outFormat,filetypes=[(outFormat+" files","*."+outFormat)],initialfile=name,parent=self.parent,title="Choose output file")
+ outfilename = filedialog.asksaveasfilename(defaultextension = '.'+outFormat,filetypes=[(outFormat+" files","*."+outFormat)],initialfile=name,parent=self.parent,title="Choose output file")
if type(outfilename)==type((0,)) or not outfilename or outfilename == '':
return
fullname = os.path.abspath(outfilename)
@@ -753,13 +758,13 @@ class xasyMainWin:
saver = subprocess.Popen(command,stdin=PIPE,stdout=PIPE,stderr=PIPE)
saver.wait()
if saver.returncode != 0:
- tkMessageBox.showerror("Export Error","Export Error:\n"+saver.stdout.read()+saver.stderr.read())
+ messagebox.showerror("Export Error","Export Error:\n"+saver.stdout.read()+saver.stderr.read())
self.status.config(text="Error exporting file")
else:
self.status.config(text="File exported successfully")
def fileExitCmd(self):
- #print "Exit xasy"
+ #print ("Exit xasy")
self.canQuit()
def editUndoCmd(self):
@@ -779,14 +784,14 @@ class xasyMainWin:
self.releaseLock()
def helpHelpCmd(self):
- print "Get help on xasy"
+ print ("Get help on xasy")
def helpAsyDocCmd(self):
- #print "Open documentation about Asymptote"
+ #print ("Open documentation about Asymptote")
asyExecute("help;\n")
def helpAboutCmd(self):
- tkMessageBox.showinfo("About xasy","A graphical interface for Asymptote "+xasyVersion)
+ messagebox.showinfo("About xasy","A graphical interface for Asymptote "+xasyVersion)
def updateSelectedButton(self,newB):
if(not self.testOrAcquireLock()):
@@ -847,8 +852,8 @@ class xasyMainWin:
self.unbindGlobalEvents()
try:
self.getNewText("// enter your code here")
- except Exception, e:
- tkMessageBox.showerror('xasy Error',e.message)
+ except Exception as e:
+ messagebox.showerror('xasy Error',e.message)
else:
self.addItemToFile(xasyScript(self.mainCanvas))
text = self.newText
@@ -963,7 +968,7 @@ class xasyMainWin:
self.setSelection(item.IDTag)
def propSelect(self,event):
- items = map(int, self.propList.curselection())
+ items = [int(a) for a in self.propList.curselection()]
if len(items)>0:
try:
self.selectItem(self.fileItems[len(self.fileItems)-items[0]-1])
@@ -979,7 +984,7 @@ class xasyMainWin:
else:
if item.IDTag == ID:
return item
- raise Exception,"Illegal operation: Item with matching ID could not be found."
+ raise Exception("Illegal operation: Item with matching ID could not be found.")
def findItemImageIndex(self,item,ID):
count = 0
@@ -988,7 +993,7 @@ class xasyMainWin:
return count
else:
count += 1
- raise Exception,"Illegal operation: Image with matching ID could not be found."
+ raise Exception("Illegal operation: Image with matching ID could not be found.")
return None
def raiseSomething(self,item,force=False):
@@ -1057,9 +1062,9 @@ class xasyMainWin:
return asyTransform((shift[0],shift[1],rotMat[0],rotMat[1],rotMat[2],rotMat[3]))
def rotateSomething(self,ID,theta,origin,specificItem=None,specificIndex=None):
- #print "Rotating by",theta*180.0/math.pi,"around",origin
+ #print ("Rotating by {} around {}".format(theta*180.0/math.pi,origin))
rotMat = self.makeRotationMatrix(theta,(origin[0]/self.magnification,origin[1]/self.magnification))
- #print rotMat
+ #print (rotMat)
if ID == -1:
item = specificItem
else:
@@ -1098,9 +1103,9 @@ class xasyMainWin:
p3 = rotMat2*(oldBbox[2],-oldBbox[1])
newTopLeft = (min(p0[0],p1[0],p2[0],p3[0]),-max(p0[1],p1[1],p2[1],p3[1]))#switch back to screen coords
shift = (newTopLeft[0]-oldBbox[0],newTopLeft[1]-oldBbox[3])
- #print theta*180.0/math.pi,origin,oldBbox,newTopLeft,shift
- #print item.imageList[index].originalImage.size
- #print item.imageList[index].image.size
+ #print (theta*180.0/math.pi,origin,oldBbox,newTopLeft,shift)
+ #print (item.imageList[index].originalImage.size)
+ #print (item.imageList[index].image.size)
#print
self.mainCanvas.coords(ID,oldBbox[0]+shift[0],oldBbox[3]+shift[1])
else:
@@ -1179,8 +1184,8 @@ class xasyMainWin:
oldText = item.script
try:
self.getNewText(oldText)
- except Exception,e:
- tkMessageBox.showerror('xasy Error',e.message)
+ except Exception as e:
+ messagebox.showerror('xasy Error',e.message)
else:
if self.newText != oldText:
self.undoRedoStack.add(editScriptAction(self,item,self.newText,oldText))
@@ -1189,7 +1194,7 @@ class xasyMainWin:
self.bindItemEvents(item)
self.bindGlobalEvents()
elif isinstance(item,xasyText):
- theText = tkSimpleDialog.askstring(title="Xasy - Text",prompt="Enter text to display:",initialvalue=item.label.text,parent=self.parent)
+ theText = simpledialog.askstring(title="Xasy - Text",prompt="Enter text to display:",initialvalue=item.label.text,parent=self.parent)
if theText != None and theText != "":
self.undoRedoStack.add(editLabelTextAction(self,item,theText,item.label.text))
item.label.text = theText
@@ -1264,7 +1269,7 @@ class xasyMainWin:
self.setSelection(CURRENT)
def itemToggleSelect(self,event):
- #print "control click"
+ #print ("control click")
x0,y0 = self.mainCanvas.canvasx(event.x),self.mainCanvas.canvasy(event.y)
x = x0/self.magnification
y = y0/self.magnification
@@ -1356,7 +1361,7 @@ class xasyMainWin:
elif self.selectedButton == self.toolFillEllipButton:
pass
elif self.selectedButton == self.toolTextButton:
- theText = tkSimpleDialog.askstring(title="Xasy - Text",prompt="Enter text to display:",initialvalue="",parent=self.parent)
+ theText = simpledialog.askstring(title="Xasy - Text",prompt="Enter text to display:",initialvalue="",parent=self.parent)
if theText != None and theText != "":
theItem = xasyText(theText,(x,-y),asyPen(self.penColor,self.penWidth,self.penOptions))
theItem.drawOnCanvas(self.mainCanvas,self.magnification)
@@ -1431,7 +1436,7 @@ class xasyMainWin:
self.releaseLock()
def canvLeftDown(self,event):
- #print "Left Mouse Down"
+ #print ("Left Mouse Down")
self.selectDragStart = (self.mainCanvas.canvasx(event.x),self.mainCanvas.canvasy(event.y))
theBbox = self.mainCanvas.bbox("selectedItem")
if theBbox != None:
@@ -1449,7 +1454,7 @@ class xasyMainWin:
self.startDraw(event)
def canvLeftUp(self,event):
- #print "Left Mouse Up"
+ #print ("Left Mouse Up")
# if we're busy, ignore it
if not self.testOrAcquireLock():
return
@@ -1543,11 +1548,11 @@ class xasyMainWin:
def canvRightDown(self,event):
pass
- #print "Right Mouse Down"
+ #print ("Right Mouse Down")
def canvRightUp(self,event):
pass
- #print "Right Mouse Up"
+ #print ("Right Mouse Up")
def configEvt(self,event):
self.updateCanvasSize()
@@ -1573,7 +1578,7 @@ class xasyMainWin:
self.itemEdit(self.itemPopupMenu.item)
def popupViewCode(self):
- tkMessageBox.showinfo("Item Code",self.itemPopupMenu.item.getCode())
+ messagebox.showinfo("Item Code",self.itemPopupMenu.item.getCode())
def popupClearTransform(self):
self.undoRedoStack.add(clearItemTransformsAction(self,self.itemPopupMenu.item,copy.deepcopy(self.itemPopupMenu.item.transform)))
diff --git a/Master/texmf-dist/asymptote/GUI/xasyOptions.py b/Master/texmf-dist/asymptote/GUI/xasyOptions.py
index 17d58d760e5..927490b77aa 100755
--- a/Master/texmf-dist/asymptote/GUI/xasyOptions.py
+++ b/Master/texmf-dist/asymptote/GUI/xasyOptions.py
@@ -81,16 +81,16 @@ def load():
try:
os.makedirs(thedir)
except:
- raise Exception,"Could not create configuration folder"
+ raise Exception("Could not create configuration folder")
if not os.path.isdir(thedir):
- raise Exception,"Configuration folder path does not point to a folder"
+ raise Exception("Configuration folder path does not point to a folder")
setDefaults()
try:
f = open(fileName,"rb")
newOptions = pickle.load(f)
for key in options.keys():
if type(newOptions[key]) != type(options[key]):
- raise Exception,"Bad type for entry in xasy settings"
+ raise Exception("Bad type for entry in xasy settings")
options = newOptions
except:
setDefaults()
@@ -103,24 +103,24 @@ def save():
pickle.dump(options,f)
f.close()
except:
- raise Exception,"Error saving preferences"
+ raise Exception("Error saving preferences")
load()
if __name__=='__main__':
- print settingsFileLocation()
- print "Current content"
+ print (settingsFileLocation())
+ print ("Current content")
load()
- print "Setting defaults"
+ print ("Setting defaults")
setDefaults()
save()
load()
options['showAxes'] = options['showGrid'] = False
save()
- print "Set to False"
+ print ("Set to False")
load()
options['showAxes'] = options['showGrid'] = True
save()
- print "Set to True"
+ print ("Set to True")
load()
- print options
+ print (options)
diff --git a/Master/texmf-dist/asymptote/GUI/xasyOptionsDialog.py b/Master/texmf-dist/asymptote/GUI/xasyOptionsDialog.py
index c3162e8673b..271070ea457 100755
--- a/Master/texmf-dist/asymptote/GUI/xasyOptionsDialog.py
+++ b/Master/texmf-dist/asymptote/GUI/xasyOptionsDialog.py
@@ -10,20 +10,26 @@
#
###########################################################################
-from Tkinter import *
-import xasyOptions
-import tkSimpleDialog
-import xasyColorPicker
-import tkMessageBox
-import tkFileDialog
-import tkColorChooser
import os
import sys
+import xasyOptions
+import xasyColorPicker
-class xasyOptionsDlg(tkSimpleDialog.Dialog):
+if sys.version_info >= (3, 0):
+ from tkinter import *
+ from tkinter import simpledialog, messagebox, filedialog
+else:
+ # python2
+ from Tkinter import *
+ import tkSimpleDialog as simpledialog
+ import tkMessageBox as messagebox
+ import tkFileDialog as filedialog
+ # import tkColorChooser as colorchooser
+
+class xasyOptionsDlg(simpledialog.Dialog):
"""A dialog to interact with users about their preferred settings"""
def __init__(self,master=None):
- tkSimpleDialog.Dialog.__init__(self,master,"xasy Options")
+ simpledialog.Dialog.__init__(self,master,"xasy Options")
def body(self,master):
optFrame = Frame(master)
@@ -116,9 +122,9 @@ class xasyOptionsDlg(tkSimpleDialog.Dialog):
def findEEPath(self):
if sys.platform[:3] == 'win': #for windows, wince, win32, etc
- file=tkFileDialog.askopenfile(filetypes=[("Programs","*.exe"),("All files","*")],title="Choose External Editor",parent=self)
+ file=filedialog.askopenfile(filetypes=[("Programs","*.exe"),("All files","*")],title="Choose External Editor",parent=self)
else:
- file=tkFileDialog.askopenfile(filetypes=[("All files","*")],title="Choose External Editor",parent=self)
+ file=filedialog.askopenfile(filetypes=[("All files","*")],title="Choose External Editor",parent=self)
if file != None:
name = os.path.abspath(file.name)
file.close()
@@ -128,9 +134,9 @@ class xasyOptionsDlg(tkSimpleDialog.Dialog):
def findAsyPath(self):
if sys.platform[:3] == 'win': #for windows, wince, win32, etc
- file=tkFileDialog.askopenfile(filetypes=[("Programs","*.exe"),("All files","*")],title="Find Asymptote Executable",parent=self)
+ file=filedialog.askopenfile(filetypes=[("Programs","*.exe"),("All files","*")],title="Find Asymptote Executable",parent=self)
else:
- file=tkFileDialog.askopenfile(filetypes=[("All files","*")],title="Find Asymptote Executable",parent=self)
+ file=filedialog.askopenfile(filetypes=[("All files","*")],title="Find Asymptote Executable",parent=self)
if file != None:
name = os.path.abspath(file.name)
file.close()
@@ -183,13 +189,13 @@ class xasyOptionsDlg(tkSimpleDialog.Dialog):
#validate the color
hexdigits = '0123456789abcdef'
if not self.validateAColor(self.pc):
- tkMessageBox.showerror("xasy Options","Invalid pen color.\r\n"+self.pc,parent=self)
+ messagebox.showerror("xasy Options","Invalid pen color.\r\n"+self.pc,parent=self)
return False
#validate the width
try:
test = float(self.pw.get())
except:
- tkMessageBox.showerror("xasy Options","Pen width must be a number.",parent=self)
+ messagebox.showerror("xasy Options","Pen width must be a number.",parent=self)
return False
#validate the options
@@ -200,7 +206,7 @@ class xasyOptionsDlg(tkSimpleDialog.Dialog):
test = int(self.axs.get())
test = int(self.ays.get())
except:
- tkMessageBox.showerror("xasy Options","Axes' x- and y-spacing must be numbers.",parent=self)
+ messagebox.showerror("xasy Options","Axes' x- and y-spacing must be numbers.",parent=self)
return False
#validate the grid spacing
@@ -208,15 +214,15 @@ class xasyOptionsDlg(tkSimpleDialog.Dialog):
test = int(self.gxs.get())
test = int(self.gys.get())
except:
- tkMessageBox.showerror("xasy Options","Grid's x- and y-spacing must be numbers.",parent=self)
+ messagebox.showerror("xasy Options","Grid's x- and y-spacing must be numbers.",parent=self)
return False
if not self.validateAColor(self.ac):
- tkMessageBox.showerror("xasy Options","Invalid axis color.\r\n"+self.ac,parent=self)
+ messagebox.showerror("xasy Options","Invalid axis color.\r\n"+self.ac,parent=self)
return False
if not self.validateAColor(self.gc):
- tkMessageBox.showerror("xasy Options","Invalid grid color.\r\n"+self.gc,parent=self)
+ messagebox.showerror("xasy Options","Invalid grid color.\r\n"+self.gc,parent=self)
return False
return True
@@ -225,4 +231,4 @@ if __name__ == '__main__':
root = Tk()
xasyOptions.load()
d = xasyOptionsDlg(root)
- print d.result
+ print (d.result)
diff --git a/Master/texmf-dist/asymptote/GUI/xasyVersion.py b/Master/texmf-dist/asymptote/GUI/xasyVersion.py
index 4d81598bbd8..83cd6c96fa7 100755
--- a/Master/texmf-dist/asymptote/GUI/xasyVersion.py
+++ b/Master/texmf-dist/asymptote/GUI/xasyVersion.py
@@ -1,2 +1,2 @@
#!/usr/bin/env python
-xasyVersion = "2.35"
+xasyVersion = "2.37"