From: Ted D. <ted...@jp...> - 2006-01-23 16:51:26
|
John & Fernando, I think the basic problem can be solved in a number of ways. Normally a GUI widget will have an initial size and when it is placed in a window, the window will layout around it (or to it's own size). However, once the window is drawn, changing the size of one or more widget that it contains doesn't mean you're changing the size of the window. Here's some ideas for how to fix this: 1) Tell people they have to use the resize method on the window object. Pro: simple. Con: not really the API that you want. 2) Write a resize method (but probably don't call it 'resize' because every widget system already uses that name) and have it emit a signal (callback). When you construct the window object, connect that signal to a resize method (again not called 'resize') on the window object that can compute it's correct size based on the new plot size. This way the plot doesn't know who's getting the signal and can remain independent of it's container. 3) Explore the different backends and see if there is a way to configure the window objects so they dynamically resize when a child widget is changed. I did a quick check through Qt and couldn't find anything for this but it might be there. It seems like 2) would be pretty simple to implement. In the Qt backend, I think you could do this by: backend_qtagg.py: In FigureCanvasQTAgg.resizeEvent, add an emit call to create a new signal. self.emit( qt.PYSIGNAL( "plotResize" ), ( w, h ) ) backend_qt.py: In FigureManagerQT.__init__, connect that signal to a new method resizeFromPlot( w, h ). This method should contain the code from the current __init__ method that resizes the window based on a given plot size. self.connect( self.canvas, PYSIGNAL( "plotResize" ), self.resizeFromPlot ) This should make it so that any size change to the plot will trigger a resize on the main window. There may be a circularity problem but we'd have to try it first an see if calling resize on the main window triggers a resize in the plot. Ted At 10:25 AM 1/22/2006, John Hunter wrote: > >>>>> "Fernando" == Fernando Perez <Fer...@co...> writes: > > > Fernando> TypeError: resize() takes exactly 2 arguments (3 given) > >Yes, this is basically broken on all GUIs except GTK*. There was a >fair amount of discussion back in octover on the devel list about how >to do this right, since basically it requires a child to call a method >on the parent and we don't know a-priori what the container will be. >In pylab we can make it work (but haven't yet across backends) because >we know the parent will be a FigureManager instance, but it would be >nice to come up with a generic method that works regardless of whether >you are using mpl in pylab or not. It's on the slow burner, >currently. > >JDH > > >------------------------------------------------------- >This SF.net email is sponsored by: Splunk Inc. Do you grep through log files >for problems? Stop! Download the new AJAX search engine that makes >searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! >http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 >_______________________________________________ >Matplotlib-devel mailing list >Mat...@li... >https://lists.sourceforge.net/lists/listinfo/matplotlib-devel |