From: John H. <jdh...@ac...> - 2004-12-15 22:52:32
|
>>>>> "Eli" == Eli Glaser <eg...@se...> writes: Eli> Hello, Is there an easy way to set the initial position of a Eli> Figure? I'm using Windows XP and new figures seem to pop up Eli> in the typical Windows fashion where subsequent figures Eli> appear about 20 pixels down and 20 pixels to the right of Eli> previous figures. How can I tell each figure where to pop up Eli> on screen? matplotlib doesn't provide explicit support for this, but it is possible. What backend are you using. The matplotlib Figure is embedded in a FigureCanvas which is typically a GUI widget embedded in a GUI Window. In the pylab interface, the canvas is managed by a FigureManager, which has a window attribute on most of the backends. Eg for the GTK backend, for example, you could do from pylab import * import gtk figure(1) plot([1,2,3]) manager = get_current_fig_manager() # see gtk.Window class docs at # http://www.pygtk.org/pygtk2reference/class-gtkwindow.html manager.window.set_position(gtk.WIN_POS_CENTER) figure(2) plot([1,2,3]) manager = get_current_fig_manager() # see gtk.Window class docs at # http://www.pygtk.org/pygtk2reference/class-gtkwindow.html manager.window.set_position(gtk.WIN_POS_NONE) show() For the WX* backend, manager.window is a wxFrame - http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin_wxframe.html#wxframe For the TkAgg backend, manager.window is a Tkinter.Tk instance - http://starship.python.net/crew/fredrik/tkclass/ClassToplevel.html Off the top of my head I don't know the right incantation for each backend, but hopefully the classdocs I referenced above will help. Perhaps Todd or Matthew can chime in with more Tk and WX information. While this arrangement may be suboptimal, we are resisting the urge to become a GUI library. The temptations to abstract GUI functions for use in matplotlib are many, and we are trying to keep this to a manageable core (some event handling, some basic window management, etc.). It's been on my list of things to do to investigate anygui, however - http://anygui.sourceforge.net - which would appear to solve our problems but might require a substantial refactoring of the matplotlib backends. If you want full GUI control, you can embed matplotlib in your own GUI application, following one of the many embedding_in_*.py examples in the examples subdirectory of the matplotlib src distribution. If you come up with example code for your backend, please post it to the list. JDH |