Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d1701b2

Browse files
committed
Merge branch 'v1.0.x-maint'
Conflicts: setupext.py Resolved by keeping the modifications from v.0.x-maint.
2 parents b88b9c5 + d9ca8ba commit d1701b2

File tree

2 files changed

+40
-52
lines changed

2 files changed

+40
-52
lines changed

lib/matplotlib/backends/backend_tkagg.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ class FigureCanvasTkAgg(FigureCanvasAgg):
178178
def __init__(self, figure, master=None, resize_callback=None):
179179
FigureCanvasAgg.__init__(self, figure)
180180
self._idle = True
181+
self._idle_callback = None
181182
t1,t2,w,h = self.figure.bbox.bounds
182183
w, h = int(w), int(h)
183184
self._tkcanvas = Tk.Canvas(
@@ -253,7 +254,8 @@ def idle_draw(*args):
253254
self.draw()
254255
self._idle = True
255256

256-
if d: self._tkcanvas.after_idle(idle_draw)
257+
if d:
258+
self._idle_callback = self._tkcanvas.after_idle(idle_draw)
257259

258260
def get_tk_widget(self):
259261
"""returns the Tk widget used to implement FigureCanvasTkAgg.
@@ -444,13 +446,15 @@ def destroy(*args):
444446

445447

446448
def destroy(self, *args):
447-
if Gcf.get_num_fig_managers()==0 and not matplotlib.is_interactive():
448-
if self.window is not None:
449-
self.window.quit()
450449
if self.window is not None:
451450
#self.toolbar.destroy()
451+
if self.canvas._idle_callback:
452+
self.canvas._tkcanvas.after_cancel(self.canvas._idle_callback)
452453
self.window.destroy()
453-
self.window = None
454+
if Gcf.get_num_fig_managers()==0:
455+
if self.window is not None:
456+
self.window.quit()
457+
self.window = None
454458

455459
def set_window_title(self, title):
456460
self.window.wm_title(title)

setupext.py

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
'linux2-mips' : ['/usr/local', '/usr'],
5656
'linux2-sparc' : ['/usr/local', '/usr'],
5757
'linux2' : ['/usr/local', '/usr'],
58+
'linux3' : ['/usr/local', '/usr'],
5859
'linux' : ['/usr/local', '/usr',],
5960
'cygwin' : ['/usr/local', '/usr',],
6061
'_darwin' : ['/sw/lib/freetype2', '/sw/lib/freetype219', '/usr/local',
@@ -834,9 +835,11 @@ def query_tcltk():
834835
def parse_tcl_config(tcl_lib_dir, tk_lib_dir):
835836
import Tkinter
836837
tcl_poss = [tcl_lib_dir,
838+
os.path.normpath(os.path.join(tcl_lib_dir, '..')),
837839
"/usr/lib/tcl"+str(Tkinter.TclVersion),
838840
"/usr/lib"]
839841
tk_poss = [tk_lib_dir,
842+
os.path.normpath(os.path.join(tk_lib_dir, '..')),
840843
"/usr/lib/tk"+str(Tkinter.TkVersion),
841844
"/usr/lib"]
842845
for ptcl, ptk in zip(tcl_poss, tk_poss):
@@ -847,50 +850,31 @@ def parse_tcl_config(tcl_lib_dir, tk_lib_dir):
847850
if not (os.path.exists(tcl_config) and os.path.exists(tk_config)):
848851
return None
849852

850-
# These files are shell scripts that set a bunch of
851-
# environment variables. To actually get at the
852-
# values, we use ConfigParser, which supports almost
853-
# the same format, but requires at least one section.
854-
# So, we push a "[default]" section to a copy of the
855-
# file in a StringIO object.
856-
try:
857-
tcl_vars_str = StringIO("[default]\n" + open(tcl_config, "r").read())
858-
tk_vars_str = StringIO("[default]\n" + open(tk_config, "r").read())
859-
except IOError:
860-
# if we can't read the file, that's ok, we'll try
861-
# to guess instead
862-
return None
863-
864-
tcl_vars_str.seek(0)
865-
tcl_vars = configparser.RawConfigParser()
866-
tk_vars_str.seek(0)
867-
tk_vars = configparser.RawConfigParser()
868-
try:
869-
tcl_vars.readfp(tcl_vars_str)
870-
tk_vars.readfp(tk_vars_str)
871-
except configparser.ParsingError:
872-
# if we can't read the file, that's ok, we'll try
873-
# to guess instead
874-
return None
875-
876-
try:
877-
tcl_lib = tcl_vars.get("default", "TCL_LIB_SPEC")[1:-1].split()[0][2:]
878-
tcl_inc = tcl_vars.get("default", "TCL_INCLUDE_SPEC")[3:-1]
879-
880-
tk_lib = tk_vars.get("default", "TK_LIB_SPEC")[1:-1].split()[0][2:]
881-
if tk_vars.has_option("default", "TK_INCLUDE_SPEC"):
882-
# On Ubuntu 8.04
883-
tk_inc = tk_vars.get("default", "TK_INCLUDE_SPEC")[3:-1]
884-
else:
885-
# On RHEL4
886-
tk_inc = tcl_inc
887-
except (configparser.NoSectionError, configparser.NoOptionError):
888-
return None
853+
def get_var(file, varname):
854+
p = subprocess.Popen(
855+
'. %s ; eval echo ${%s}' % (file, varname),
856+
shell=True,
857+
executable="/bin/sh",
858+
stdout=subprocess.PIPE)
859+
result = p.communicate()[0]
860+
return result
861+
862+
tcl_lib_dir = get_var(tcl_config, 'TCL_LIB_SPEC').split()[0][2:]
863+
tcl_inc_dir = get_var(tcl_config, 'TCL_INCLUDE_SPEC')[2:]
864+
tcl_lib = get_var(tcl_config, 'TCL_LIB_FLAG')[2:].strip()
865+
866+
tk_lib_dir = get_var(tk_config, 'TK_LIB_SPEC').split()[0][2:]
867+
tk_inc_dir = get_var(tk_config, 'TK_INCLUDE_SPEC').strip()
868+
if tk_inc_dir == '':
869+
tk_inc_dir = tcl_inc_dir
870+
else:
871+
tk_inc_dir = tk_inc_dir[2:]
872+
tk_lib = get_var(tk_config, 'TK_LIB_FLAG')[2:].strip()
889873

890-
if not os.path.exists(os.path.join(tk_inc, 'tk.h')):
874+
if not os.path.exists(os.path.join(tk_inc_dir, 'tk.h')):
891875
return None
892876

893-
return tcl_lib, tcl_inc, tk_lib, tk_inc
877+
return tcl_lib_dir, tcl_inc_dir, tcl_lib, tk_lib_dir, tk_inc_dir, tk_lib
894878

895879
def guess_tcl_config(tcl_lib_dir, tk_lib_dir, tk_ver):
896880
if not (os.path.exists(tcl_lib_dir) and os.path.exists(tk_lib_dir)):
@@ -925,14 +909,14 @@ def guess_tcl_config(tcl_lib_dir, tk_lib_dir, tk_ver):
925909
if not os.path.exists(os.path.join(tk_inc, 'tk.h')):
926910
return None
927911

928-
return tcl_lib, tcl_inc, tk_lib, tk_inc
912+
return tcl_lib, tcl_inc, 'tcl' + tk_ver, tk_lib, tk_inc, 'tk' + tk_ver
929913

930914
def hardcoded_tcl_config():
931915
tcl_inc = "/usr/local/include"
932916
tk_inc = "/usr/local/include"
933917
tcl_lib = "/usr/local/lib"
934918
tk_lib = "/usr/local/lib"
935-
return tcl_lib, tcl_inc, tk_lib, tk_inc
919+
return tcl_lib, tcl_inc, 'tcl', tk_lib, tk_inc, 'tk'
936920

937921
def add_tk_flags(module):
938922
'Add the module flags to build extensions which use tk'
@@ -1033,10 +1017,10 @@ def add_tk_flags(module):
10331017
result = hardcoded_tcl_config()
10341018

10351019
# Add final versions of directories and libraries to module lists
1036-
tcl_lib, tcl_inc, tk_lib, tk_inc = result
1037-
module.include_dirs.extend([tcl_inc, tk_inc])
1038-
module.library_dirs.extend([tcl_lib, tk_lib])
1039-
module.libraries.extend(['tk' + tk_ver, 'tcl' + tk_ver])
1020+
tcl_lib_dir, tcl_inc_dir, tcl_lib, tk_lib_dir, tk_inc_dir, tk_lib = result
1021+
module.include_dirs.extend([tcl_inc_dir, tk_inc_dir])
1022+
module.library_dirs.extend([tcl_lib_dir, tk_lib_dir])
1023+
module.libraries.extend([tcl_lib, tk_lib])
10401024

10411025
return message
10421026

0 commit comments

Comments
 (0)