Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
dda0cdc
navigation and toolbar coexistence
fariza Jan 23, 2014
10f5dc7
mod keypress in figuremanager
fariza Jan 23, 2014
08a6020
extra files
fariza Jan 23, 2014
c6c0ad3
helper methods in toolbar and navigation
fariza Jan 24, 2014
1fc29fa
Adding doc to base methods
fariza Jan 24, 2014
979875e
property for active_toggle
fariza Jan 26, 2014
c5c4f0f
simulate click
fariza Jan 27, 2014
97dfda7
pep8 backend_tools
fariza Jan 27, 2014
6b647ad
activate renamed to trigger
fariza Jan 28, 2014
99667aa
toggle tools using enable/disable from its trigger method
fariza Jan 29, 2014
6c19579
simplifying _handle_toggle
fariza Jan 29, 2014
0495aac
reducing number of locks
fariza Jan 29, 2014
fb46fc1
pep8 correction
fariza Jan 29, 2014
d49c431
changing toggle and persistent attributes for issubclass
fariza Feb 4, 2014
5ba6210
bug in combined key press
fariza Feb 4, 2014
7ca8626
untoggle zoom and pan from keypress while toggled
fariza Feb 4, 2014
dcc0f16
classmethods for default tools modification
fariza Feb 6, 2014
bc703e0
six fixes
fariza Apr 24, 2014
68dc711
adding zaxis and some pep8
fariza May 1, 2014
bb9f1c7
removing legacy method dynamic update
fariza May 6, 2014
2c2e649
tk backend
fariza May 6, 2014
a99367f
pep8
fariza May 6, 2014
3d1be34
example working with Tk
fariza May 6, 2014
afdd34c
cleanup
fariza May 7, 2014
5b49c7a
duplicate code in keymap tool initialization
fariza Jul 24, 2014
773db88
grammar corrections
fariza Jul 24, 2014
2ca6926
moving views and positions to tools
fariza Jul 24, 2014
661417d
The views positions mixin automatically adds the clear as axobserver
fariza Jul 25, 2014
90ab64f
bug when navigation was not defined
fariza Jul 25, 2014
55dd149
Small refactor so that we first initiate the Navigation (ToolManager)…
OceanWolf Jul 28, 2014
15ac091
Update for Sphinx documentation
OceanWolf Jul 28, 2014
8cd241c
Moved default_tool initilisation to FigureManagerBase and cleaned.
OceanWolf Jul 29, 2014
39f5b74
Fix navigation
OceanWolf Jul 29, 2014
b20dade
Temporary fix to backends
OceanWolf Jul 29, 2014
ff94301
Merge pull request #1 from OceanWolf/navigation-toolbar-coexistence-e…
fariza Jul 29, 2014
2cb4501
removing persistent tools
fariza Sep 3, 2014
9d3c977
removing unregister
fariza Sep 4, 2014
6e0b7e6
change cursor inmediately after toggle
fariza Sep 5, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pep8
  • Loading branch information
fariza committed May 6, 2014
commit a99367f48b9a27bbd1bdd38ce9d424a2edd54bc4
49 changes: 28 additions & 21 deletions lib/matplotlib/backends/backend_tkagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,13 @@ def notify_axes_change(fig):
'this will be called whenever the current axes is changed'
if self.navigation is not None:
self.navigation.update()
elif self.toolbar is not None: self.toolbar.update()
elif self.toolbar is not None:
self.toolbar.update()
self.canvas.figure.add_axobserver(notify_axes_change)

def _get_toolbar(self, canvas):
if matplotlib.rcParams['toolbar']=='toolbar2':
toolbar = NavigationToolbar2TkAgg( canvas, self.window )
if matplotlib.rcParams['toolbar'] == 'toolbar2':
toolbar = NavigationToolbar2TkAgg(canvas, self.window)
elif matplotlib.rcParams['toolbar'] == 'navigation':
self.navigation = NavigationTk(canvas, ToolbarTk)
toolbar = self.navigation.toolbar
Expand Down Expand Up @@ -898,16 +899,21 @@ def draw_rubberband(self, event, caller, x0, y0, x1, y1):
if not self.canvas.widgetlock.available(caller):
return
height = self.canvas.figure.bbox.height
y0 = height-y0
y1 = height-y1
try: self.lastrect
except AttributeError: pass
else: self.canvas._tkcanvas.delete(self.lastrect)
y0 = height - y0
y1 = height - y1
try:
self.lastrect
except AttributeError:
pass
else:
self.canvas._tkcanvas.delete(self.lastrect)
self.lastrect = self.canvas._tkcanvas.create_rectangle(x0, y0, x1, y1)

def remove_rubberband(self, event, caller):
try: self.lastrect
except AttributeError: pass
try:
self.lastrect
except AttributeError:
pass
else:
self.canvas._tkcanvas.delete(self.lastrect)
del self.lastrect
Expand All @@ -917,7 +923,7 @@ class ToolbarTk(ToolbarBase, Tk.Frame):
def __init__(self, manager):
ToolbarBase.__init__(self, manager)
xmin, xmax = self.manager.canvas.figure.bbox.intervalx
height, width = 50, xmax-xmin
height, width = 50, xmax - xmin
Tk.Frame.__init__(self, master=self.manager.window,
width=int(width), height=int(height),
borderwidth=2)
Expand All @@ -931,15 +937,14 @@ def _add_toolitem(self, name, tooltip_text, image_file, position,
if tooltip_text is not None:
ToolTip.createToolTip(button, tooltip_text)
self._toolitems[name] = button

def _Button(self, text, file, toggle):
extension='.ppm'
if file is not None:
img_file = os.path.join(rcParams['datapath'], 'images', file )
img_file = os.path.join(rcParams['datapath'], 'images', file)
im = Tk.PhotoImage(master=self, file=img_file)
else:
im = None

if not toggle:
b = Tk.Button(
master=self, text=text, padx=2, pady=2, image=im,
Expand All @@ -951,7 +956,7 @@ def _Button(self, text, file, toggle):
b._ntimage = im
b.pack(side=Tk.LEFT)
return b

def _button_click(self, name):
self.manager.navigation._toolbar_callback(name)

Expand Down Expand Up @@ -979,6 +984,7 @@ def _remove_toolitem(self, name):
def set_toolitem_visibility(self, name, visible):
pass


class SaveFigureTk(SaveFigureBase):
def trigger(self, *args):
from six.moves import tkinter_tkfiledialog, tkinter_messagebox
Expand Down Expand Up @@ -1023,7 +1029,8 @@ def trigger(self, *args):
rcParams['savefig.directory'] = initialdir
else:
# save dir for next time
rcParams['savefig.directory'] = os.path.dirname(six.text_type(fname))
rcParams['savefig.directory'] = os.path.dirname(
six.text_type(fname))
try:
# This method will handle the delegation to the correct type
self.figure.canvas.print_figure(fname)
Expand All @@ -1034,16 +1041,16 @@ def trigger(self, *args):
class ConfigureSubplotsTk(ConfigureSubplotsBase):
def __init__(self, *args, **kwargs):
ConfigureSubplotsBase.__init__(self, *args, **kwargs)
toolfig = Figure(figsize=(6,3))
toolfig = Figure(figsize=(6, 3))
self.window = Tk.Tk()

canvas = FigureCanvasTkAgg(toolfig, master=self.window)
toolfig.subplots_adjust(top=0.9)
tool = SubplotTool(self.figure, toolfig)
_tool = SubplotTool(self.figure, toolfig)
canvas.show()
canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
self.window.protocol("WM_DELETE_WINDOW", self.destroy)

def trigger(self, event):
self.window.lift()

Expand Down