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

Skip to content

Commit c337b3d

Browse files
committed
fixed qt subplots button. added FigureManager.resize method
svn path=/trunk/matplotlib/; revision=2628
1 parent cee76c6 commit c337b3d

6 files changed

Lines changed: 25 additions & 10 deletions

File tree

API_CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
FigureManager.resize(width, height): resize the window
2+
specified in pixels
3+
14
barh: x and y args have been renamed to width and bottom
25
respectively, and their order has been swapped to maintain
36
a (position, value) order.

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2006-07-28 Added resize method to FigureManager class
2+
for Qt and Gtk backend - CM
3+
4+
2006-07-28 Added subplots_adjust button to Qt backend - CM
5+
16
2006-07-22 Fixed bug #1209354 - DSD
27

38
2006-07-22 make scatter() work with the kwarg "color". Closes bug

lib/matplotlib/backend_bases.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,11 @@ def destroy(self):
10041004

10051005
def full_screen_toggle (self):
10061006
pass
1007+
1008+
def resize(self, w, h):
1009+
'For gui backends: resize window in pixels'
1010+
pass
1011+
10071012
def key_press(self, event):
10081013

10091014
# these bindings happen whether you are over an axes or not

lib/matplotlib/backends/backend_gtk.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,12 @@ def _get_toolbar(self, canvas):
470470
return toolbar
471471

472472

473-
def set_canvas_size(self, width, height):
473+
def resize(self, width, height):
474474
'set the canvas size in pixels'
475-
_, _, cw, ch = self.canvas.allocation
476-
_, _, ww, wh = self.window.allocation
477-
self.window.resize (width-cw+ww, height-ch+wh)
475+
#_, _, cw, ch = self.canvas.allocation
476+
#_, _, ww, wh = self.window.allocation
477+
#self.window.resize (width-cw+ww, height-ch+wh)
478+
self.window.resize(width, height)
478479

479480

480481
class NavigationToolbar2GTK(NavigationToolbar2, gtk.Toolbar):

lib/matplotlib/backends/backend_qt.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ class FigureCanvasQT( qt.QWidget, FigureCanvasBase ):
8181
buttond = {1:1, 2:3, 4:2}
8282
def __init__( self, figure ):
8383
if DEBUG: print 'FigureCanvasQt: ', figure
84-
FigureCanvasBase.__init__( self, figure )
8584
qt.QWidget.__init__( self, None, "QWidget figure" )
85+
FigureCanvasBase.__init__( self, figure )
8686
self.figure = figure
8787
self.setMouseTracking( True )
8888

@@ -220,7 +220,7 @@ def _get_toolbar(self, canvas, parent):
220220
toolbar = None
221221
return toolbar
222222

223-
def set_canvas_size(self, width, height):
223+
def resize(self, width, height):
224224
'set the canvas size in pixels'
225225
self.window.resize(width, height)
226226

@@ -329,7 +329,7 @@ def draw_rubberband( self, event, x0, y0, x1, y1 ):
329329
self.canvas.drawRectangle( rect )
330330

331331
def configure_subplots(self):
332-
self.adj_window = qt.QMainWindow()
332+
self.adj_window = qt.QMainWindow(None, None, qt.Qt.WDestructiveClose)
333333
win = self.adj_window
334334
win.setCaption("Subplot Configuration Tool")
335335

@@ -339,6 +339,7 @@ def configure_subplots(self):
339339
h = int (toolfig.bbox.height())
340340

341341
canvas = self._get_canvas(toolfig)
342+
self.canvas.figure.canvas = self.canvas # Weirdness but needed
342343
tool = SubplotTool(self.canvas.figure, toolfig)
343344
centralWidget = qt.QWidget(win)
344345
canvas.reparent(centralWidget, qt.QPoint(0, 0))

lib/matplotlib/backends/backend_qtagg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def paintEvent( self, e ):
8787
"""
8888

8989
FigureCanvasQT.paintEvent( self, e )
90-
if DEBUG: print 'FigureCanvasQtAgg.paintEvent: ', \
90+
if DEBUG: print 'FigureCanvasQtAgg.paintEvent: ', self, \
9191
self.get_width_height()
9292

9393
p = qt.QPainter( self )
@@ -140,10 +140,10 @@ def draw( self ):
140140
Draw the figure when xwindows is ready for the update
141141
"""
142142

143-
if DEBUG: print "FigureCanvasQtAgg.draw"
143+
if DEBUG: print "FigureCanvasQtAgg.draw", self
144144
self.replot = True
145145
self.repaint( False )
146-
146+
147147
def blit(self, bbox=None):
148148
"""
149149
Blit the region in bbox

0 commit comments

Comments
 (0)