SourceForge logo
SourceForge logo
Menu

matplotlib-checkins

Revision: 5790
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5790&view=rev
Author: jdh2358
Date: 2008年07月18日 20:43:58 +0000 (2008年7月18日)
Log Message:
-----------
restored gtk quit on window close
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2008年07月18日 18:59:57 UTC (rev 5789)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2008年07月18日 20:43:58 UTC (rev 5790)
@@ -459,9 +459,9 @@
 if Gcf.get_num_fig_managers()==0 and \
 not matplotlib.is_interactive() and \
 gtk.main_level() >= 1:
- #gtk.main_quit()
- pass
+ gtk.main_quit()
 
+
 def show(self):
 # show the figure window
 self.window.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6409
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6409&view=rev
Author: mdboom
Date: 2008年11月17日 14:49:15 +0000 (2008年11月17日)
Log Message:
-----------
Reduce memory leakage in Gtk+-based backends. Still far from perfect.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2008年11月17日 14:39:49 UTC (rev 6408)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2008年11月17日 14:49:15 UTC (rev 6409)
@@ -162,7 +162,7 @@
 self._pixmap_height = -1
 self._lastCursor = None
 
- self.connect('scroll_event', self.scroll_event)
+ self.connect('scroll_event', self.scroll_event)
 self.connect('button_press_event', self.button_press_event)
 self.connect('button_release_event', self.button_release_event)
 self.connect('configure_event', self.configure_event)
@@ -177,8 +177,12 @@
 self.set_flags(gtk.CAN_FOCUS)
 self._renderer_init()
 
- gobject.idle_add(self.idle_event)
+ self._idle_id = gobject.idle_add(self.idle_event)
 
+ def destroy(self):
+ gtk.DrawingArea.destroy(self)
+ gobject.source_remove(self._idle_id)
+
 def scroll_event(self, widget, event):
 if _debug: print 'FigureCanvasGTK.%s' % fn_name()
 x = event.x
@@ -466,14 +470,17 @@
 
 def destroy(self, *args):
 if _debug: print 'FigureManagerGTK.%s' % fn_name()
+ self.vbox.destroy()
 self.window.destroy()
+ self.canvas.destroy()
+ self.toolbar.destroy()
+ self.__dict__.clear()
 
 if Gcf.get_num_fig_managers()==0 and \
 not matplotlib.is_interactive() and \
 gtk.main_level() >= 1:
 gtk.main_quit()
 
-
 def show(self):
 # show the figure window
 self.window.show()
@@ -529,10 +536,14 @@
 NavigationToolbar2.__init__(self, canvas)
 self._idleId = 0
 
- def destroy(*args):
- self.fileselect.destroy()
- self.connect("destroy", destroy)
+ self.connect("destroy", self.destroy)
 
+ def destroy(self, *args):
+ gtk.Toolbar.destroy(self)
+ self.fileselect.destroy()
+ self.tooltips.destroy()
+ self.canvas.destroy()
+
 def set_message(self, s):
 if self._idleId == 0:
 self.message.set_label(s)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6410
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6410&view=rev
Author: mdboom
Date: 2008年11月17日 15:20:06 +0000 (2008年11月17日)
Log Message:
-----------
Further memory leak fixes for Gtk
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2008年11月17日 14:49:15 UTC (rev 6409)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2008年11月17日 15:20:06 UTC (rev 6410)
@@ -156,7 +156,7 @@
 FigureCanvasBase.__init__(self, figure)
 gtk.DrawingArea.__init__(self)
 
- self._idleID = 0
+ self._idle_draw_id = 0
 self._need_redraw = True
 self._pixmap_width = -1
 self._pixmap_height = -1
@@ -177,11 +177,13 @@
 self.set_flags(gtk.CAN_FOCUS)
 self._renderer_init()
 
- self._idle_id = gobject.idle_add(self.idle_event)
+ self._idle_event_id = gobject.idle_add(self.idle_event)
 
 def destroy(self):
- gtk.DrawingArea.destroy(self)
- gobject.source_remove(self._idle_id)
+ #gtk.DrawingArea.destroy(self)
+ gobject.source_remove(self._idle_event_id)
+ if self._idle_draw_id != 0:
+ gobject.source_remove(self._idle_draw_id)
 
 def scroll_event(self, widget, event):
 if _debug: print 'FigureCanvasGTK.%s' % fn_name()
@@ -280,10 +282,10 @@
 def draw_idle(self):
 def idle_draw(*args):
 self.draw()
- self._idleID = 0
+ self._idle_draw_id = 0
 return False
- if self._idleID == 0:
- self._idleID = gobject.idle_add(idle_draw)
+ if self._idle_draw_id == 0:
+ self._idle_draw_id = gobject.idle_add(idle_draw)
 
 
 def _renderer_init(self):
@@ -534,7 +536,7 @@
 self.win = window
 gtk.Toolbar.__init__(self)
 NavigationToolbar2.__init__(self, canvas)
- self._idleId = 0
+ self._idle_draw_id = 0
 
 self.connect("destroy", self.destroy)
 
@@ -543,9 +545,11 @@
 self.fileselect.destroy()
 self.tooltips.destroy()
 self.canvas.destroy()
+ if self._idle_draw_id != 0:
+ gobject.remove_source(self._idle_draw_id)
 
 def set_message(self, s):
- if self._idleId == 0:
+ if self._idle_draw_id == 0:
 self.message.set_label(s)
 
 def set_cursor(self, cursor):
@@ -587,16 +591,15 @@
 axrect = l,b,w,h
 self._imageBack = axrect, drawable.get_image(*axrect)
 drawable.draw_rectangle(gc, False, *rect)
- self._idleId = 0
+ self._idle_draw_id = 0
 else:
 def idle_draw(*args):
-
 drawable.draw_image(gc, imageBack, 0, 0, *lastrect)
 drawable.draw_rectangle(gc, False, *rect)
- self._idleId = 0
+ self._idle_draw_id = 0
 return False
- if self._idleId == 0:
- self._idleId = gobject.idle_add(idle_draw)
+ if self._idle_draw_id == 0:
+ self._idle_draw_id = gobject.idle_add(idle_draw)
 
 
 def _init_toolbar(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6411
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6411&view=rev
Author: mdboom
Date: 2008年11月17日 19:34:28 +0000 (2008年11月17日)
Log Message:
-----------
Fixed all Gtk memory leaks exercised by D2Hitman's recent thread.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2008年11月17日 15:20:06 UTC (rev 6410)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2008年11月17日 19:34:28 UTC (rev 6411)
@@ -538,16 +538,6 @@
 NavigationToolbar2.__init__(self, canvas)
 self._idle_draw_id = 0
 
- self.connect("destroy", self.destroy)
-
- def destroy(self, *args):
- gtk.Toolbar.destroy(self)
- self.fileselect.destroy()
- self.tooltips.destroy()
- self.canvas.destroy()
- if self._idle_draw_id != 0:
- gobject.remove_source(self._idle_draw_id)
-
 def set_message(self, s):
 if self._idle_draw_id == 0:
 self.message.set_label(s)
@@ -635,11 +625,6 @@
 self.append_widget(self.message, None, None)
 self.message.show()
 
- self.fileselect = FileSelection(title='Save the figure',
- parent=self.win,)
-
-
-
 def _init_toolbar2_4(self):
 basedir = os.path.join(matplotlib.rcParams['datapath'],'images')
 self.tooltips = gtk.Tooltips()
@@ -670,15 +655,19 @@
 
 self.show_all()
 
- self.fileselect = FileChooserDialog(
- title='Save the figure',
- parent=self.win,
- filetypes=self.canvas.get_supported_filetypes(),
- default_filetype=self.canvas.get_default_filetype())
+ def get_filechooser(self):
+ if gtk.pygtk_version >= (2,4,0):
+ return FileChooserDialog(
+ title='Save the figure',
+ parent=self.win,
+ filetypes=self.canvas.get_supported_filetypes(),
+ default_filetype=self.canvas.get_default_filetype())
+ else:
+ return FileSelection(title='Save the figure',
+ parent=self.win,)
 
-
 def save_figure(self, button):
- fname, format = self.fileselect.get_filename_from_user()
+ fname, format = self.get_filechooser().get_filename_from_user()
 if fname:
 try:
 self.canvas.print_figure(fname, format=format)
@@ -781,11 +770,6 @@
 self.show_all()
 self.update()
 
- def destroy(*args):
- self.fileselect.destroy()
- del self.fileselect
- self.connect("destroy", destroy)
-
 def _create_toolitems_2_4(self):
 # use the GTK+ 2.4 GtkToolbar API
 iconSize = gtk.ICON_SIZE_SMALL_TOOLBAR
@@ -970,9 +954,19 @@
 self.canvas.draw()
 return True
 
+ def get_filechooser(self):
+ if gtk.pygtk_version >= (2,4,0):
+ return FileChooserDialog(
+ title='Save the figure',
+ parent=self.win,
+ filetypes=self.canvas.get_supported_filetypes(),
+ default_filetype=self.canvas.get_default_filetype())
+ else:
+ return FileSelection(title='Save the figure',
+ parent=self.win)
 
 def save_figure(self, button):
- fname, format = self.fileselect.get_filename_from_user()
+ fname, format = self.get_filechooser().get_filename_from_user()
 if fname:
 try:
 self.canvas.print_figure(fname, format=format)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6643
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6643&view=rev
Author: jdh2358
Date: 2008年12月17日 11:20:35 +0000 (2008年12月17日)
Log Message:
-----------
added per window icon from sf patch 2412313
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2008年12月17日 07:32:18 UTC (rev 6642)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2008年12月17日 11:20:35 UTC (rev 6643)
@@ -439,6 +439,8 @@
 
 self.window = gtk.Window()
 self.window.set_title("Figure %d" % num)
+ if (window_icon):
+ self.window.set_icon_from_file(window_icon)
 
 self.vbox = gtk.VBox()
 self.window.add(self.vbox)
@@ -694,6 +696,8 @@
 
 
 window = gtk.Window()
+ if (window_icon):
+ window.set_icon_from_file(window_icon)
 window.set_title("Subplot Configuration Tool")
 window.set_default_size(w, h)
 vbox = gtk.VBox()
@@ -1260,9 +1264,9 @@
 icon_filename = 'matplotlib.png'
 else:
 icon_filename = 'matplotlib.svg'
- gtk.window_set_default_icon_from_file (
- os.path.join (matplotlib.rcParams['datapath'], 'images', icon_filename))
+ window_icon = os.path.join(matplotlib.rcParams['datapath'], 'images', icon_filename)
 except:
+ window_icon = None
 verbose.report('Could not load matplotlib icon: %s' % sys.exc_info()[1])
 
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6840
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6840&view=rev
Author: mdboom
Date: 2009年01月27日 12:23:53 +0000 (2009年1月27日)
Log Message:
-----------
Remove oops in commit.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2009年01月26日 23:02:46 UTC (rev 6839)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2009年01月27日 12:23:53 UTC (rev 6840)
@@ -349,10 +349,7 @@
 if self._need_redraw:
 x, y, w, h = self.allocation
 self._pixmap_prepare (w, h)
- try:
- self._render_figure(self._pixmap, w, h)
- except:
- pass
+ self._render_figure(self._pixmap, w, h)
 self._need_redraw = False
 
 x, y, w, h = event.area
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7166
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7166&view=rev
Author: efiring
Date: 2009年06月01日 17:16:06 +0000 (2009年6月01日)
Log Message:
-----------
Removed support for gtk < 2.4
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2009年05月29日 21:45:55 UTC (rev 7165)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2009年06月01日 17:16:06 UTC (rev 7166)
@@ -10,7 +10,7 @@
 except ImportError:
 raise ImportError("Gtk* backend requires pygtk to be installed.")
 
-pygtk_version_required = (2,2,0)
+pygtk_version_required = (2,4,0)
 if gtk.pygtk_version < pygtk_version_required:
 raise ImportError ("PyGTK %d.%d.%d is installed\n"
 "PyGTK %d.%d.%d or later is required"
@@ -606,37 +606,9 @@
 
 def _init_toolbar(self):
 self.set_style(gtk.TOOLBAR_ICONS)
+ self._init_toolbar2_4()
 
- if gtk.pygtk_version >= (2,4,0):
- self._init_toolbar2_4()
- else:
- self._init_toolbar2_2()
 
-
- def _init_toolbar2_2(self):
- basedir = os.path.join(matplotlib.rcParams['datapath'],'images')
-
- for text, tooltip_text, image_file, callback in self.toolitems:
- if text is None:
- self.append_space()
- continue
-
- fname = os.path.join(basedir, image_file)
- image = gtk.Image()
- image.set_from_file(fname)
- w = self.append_item(text,
- tooltip_text,
- 'Private',
- image,
- getattr(self, callback)
- )
-
- self.append_space()
-
- self.message = gtk.Label()
- self.append_widget(self.message, None, None)
- self.message.show()
-
 def _init_toolbar2_4(self):
 basedir = os.path.join(matplotlib.rcParams['datapath'],'images')
 self.tooltips = gtk.Tooltips()
@@ -668,15 +640,11 @@
 self.show_all()
 
 def get_filechooser(self):
- if gtk.pygtk_version >= (2,4,0):
- return FileChooserDialog(
- title='Save the figure',
- parent=self.win,
- filetypes=self.canvas.get_supported_filetypes(),
- default_filetype=self.canvas.get_default_filetype())
- else:
- return FileSelection(title='Save the figure',
- parent=self.win,)
+ return FileChooserDialog(
+ title='Save the figure',
+ parent=self.win,
+ filetypes=self.canvas.get_supported_filetypes(),
+ default_filetype=self.canvas.get_default_filetype())
 
 def save_figure(self, button):
 fname, format = self.get_filechooser().get_filename_from_user()
@@ -768,19 +736,13 @@
 
 self.set_style(gtk.TOOLBAR_ICONS)
 
- if gtk.pygtk_version >= (2,4,0):
- self._create_toolitems_2_4()
- self.update = self._update_2_4
- self.fileselect = FileChooserDialog(
- title='Save the figure',
- parent=self.win,
- filetypes=self.canvas.get_supported_filetypes(),
- default_filetype=self.canvas.get_default_filetype())
- else:
- self._create_toolitems_2_2()
- self.update = self._update_2_2
- self.fileselect = FileSelection(title='Save the figure',
- parent=self.win)
+ self._create_toolitems_2_4()
+ self.update = self._update_2_4
+ self.fileselect = FileChooserDialog(
+ title='Save the figure',
+ parent=self.win,
+ filetypes=self.canvas.get_supported_filetypes(),
+ default_filetype=self.canvas.get_default_filetype())
 self.show_all()
 self.update()
 
@@ -860,46 +822,6 @@
 self.set_active(range(len(self._axes)))
 
 
- def _create_toolitems_2_2(self):
- # use the GTK+ 2.2 (and lower) GtkToolbar API
- iconSize = gtk.ICON_SIZE_SMALL_TOOLBAR
-
- for text, tooltip_text, image_num, callback, callback_arg, scroll \
- in self.toolitems:
- if text is None:
- self.append_space()
- continue
- image = gtk.Image()
- image.set_from_stock(image_num, iconSize)
- item = self.append_item(text, tooltip_text, 'Private', image,
- getattr(self, callback), callback_arg)
- if scroll:
- item.connect("scroll_event", getattr(self, callback))
-
- self.omenu = gtk.OptionMenu()
- self.omenu.set_border_width(3)
- self.insert_widget(
- self.omenu,
- 'Select axes that controls affect',
- 'Private', 0)
-
-
- def _update_2_2(self):
- # for GTK+ 2.2 and lower
- # called by __init__() and FigureManagerGTK
-
- self._axes = self.canvas.figure.axes
-
- if len(self._axes) >= 2:
- # set up the axis menu
- self.omenu.set_menu( self._make_axis_menu() )
- self.omenu.show_all()
- else:
- self.omenu.hide()
-
- self.set_active(range(len(self._axes)))
-
-
 def _make_axis_menu(self):
 # called by self._update*()
 
@@ -969,15 +891,11 @@
 return True
 
 def get_filechooser(self):
- if gtk.pygtk_version >= (2,4,0):
- return FileChooserDialog(
- title='Save the figure',
- parent=self.win,
- filetypes=self.canvas.get_supported_filetypes(),
- default_filetype=self.canvas.get_default_filetype())
- else:
- return FileSelection(title='Save the figure',
- parent=self.win)
+ return FileChooserDialog(
+ title='Save the figure',
+ parent=self.win,
+ filetypes=self.canvas.get_supported_filetypes(),
+ default_filetype=self.canvas.get_default_filetype())
 
 def save_figure(self, button):
 fname, format = self.get_filechooser().get_filename_from_user()
@@ -988,112 +906,81 @@
 error_msg_gtk(str(e), parent=self)
 
 
-if gtk.pygtk_version >= (2,4,0):
- class FileChooserDialog(gtk.FileChooserDialog):
- """GTK+ 2.4 file selector which remembers the last file/directory
- selected and presents the user with a menu of supported image formats
- """
- def __init__ (self,
- title = 'Save file',
- parent = None,
- action = gtk.FILE_CHOOSER_ACTION_SAVE,
- buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_SAVE, gtk.RESPONSE_OK),
- path = None,
- filetypes = [],
- default_filetype = None
- ):
- super (FileChooserDialog, self).__init__ (title, parent, action,
- buttons)
- self.set_default_response (gtk.RESPONSE_OK)
+class FileChooserDialog(gtk.FileChooserDialog):
+ """GTK+ 2.4 file selector which remembers the last file/directory
+ selected and presents the user with a menu of supported image formats
+ """
+ def __init__ (self,
+ title = 'Save file',
+ parent = None,
+ action = gtk.FILE_CHOOSER_ACTION_SAVE,
+ buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_SAVE, gtk.RESPONSE_OK),
+ path = None,
+ filetypes = [],
+ default_filetype = None
+ ):
+ super (FileChooserDialog, self).__init__ (title, parent, action,
+ buttons)
+ self.set_default_response (gtk.RESPONSE_OK)
 
- if not path: path = os.getcwd() + os.sep
+ if not path: path = os.getcwd() + os.sep
 
- # create an extra widget to list supported image formats
- self.set_current_folder (path)
- self.set_current_name ('image.' + default_filetype)
+ # create an extra widget to list supported image formats
+ self.set_current_folder (path)
+ self.set_current_name ('image.' + default_filetype)
 
- hbox = gtk.HBox (spacing=10)
- hbox.pack_start (gtk.Label ("File Format:"), expand=False)
+ hbox = gtk.HBox (spacing=10)
+ hbox.pack_start (gtk.Label ("File Format:"), expand=False)
 
- liststore = gtk.ListStore(gobject.TYPE_STRING)
- cbox = gtk.ComboBox(liststore)
- cell = gtk.CellRendererText()
- cbox.pack_start(cell, True)
- cbox.add_attribute(cell, 'text', 0)
- hbox.pack_start (cbox)
+ liststore = gtk.ListStore(gobject.TYPE_STRING)
+ cbox = gtk.ComboBox(liststore)
+ cell = gtk.CellRendererText()
+ cbox.pack_start(cell, True)
+ cbox.add_attribute(cell, 'text', 0)
+ hbox.pack_start (cbox)
 
- self.filetypes = filetypes
- self.sorted_filetypes = filetypes.items()
- self.sorted_filetypes.sort()
- default = 0
- for i, (ext, name) in enumerate(self.sorted_filetypes):
- cbox.append_text ("%s (*.%s)" % (name, ext))
- if ext == default_filetype:
- default = i
- cbox.set_active(default)
- self.ext = default_filetype
+ self.filetypes = filetypes
+ self.sorted_filetypes = filetypes.items()
+ self.sorted_filetypes.sort()
+ default = 0
+ for i, (ext, name) in enumerate(self.sorted_filetypes):
+ cbox.append_text ("%s (*.%s)" % (name, ext))
+ if ext == default_filetype:
+ default = i
+ cbox.set_active(default)
+ self.ext = default_filetype
 
- def cb_cbox_changed (cbox, data=None):
- """File extension changed"""
- head, filename = os.path.split(self.get_filename())
- root, ext = os.path.splitext(filename)
- ext = ext[1:]
- new_ext = self.sorted_filetypes[cbox.get_active()][0]
- self.ext = new_ext
+ def cb_cbox_changed (cbox, data=None):
+ """File extension changed"""
+ head, filename = os.path.split(self.get_filename())
+ root, ext = os.path.splitext(filename)
+ ext = ext[1:]
+ new_ext = self.sorted_filetypes[cbox.get_active()][0]
+ self.ext = new_ext
 
- if ext in self.filetypes:
- filename = root + '.' + new_ext
- elif ext == '':
- filename = filename.rstrip('.') + '.' + new_ext
+ if ext in self.filetypes:
+ filename = root + '.' + new_ext
+ elif ext == '':
+ filename = filename.rstrip('.') + '.' + new_ext
 
- self.set_current_name (filename)
- cbox.connect ("changed", cb_cbox_changed)
+ self.set_current_name (filename)
+ cbox.connect ("changed", cb_cbox_changed)
 
- hbox.show_all()
- self.set_extra_widget(hbox)
+ hbox.show_all()
+ self.set_extra_widget(hbox)
 
- def get_filename_from_user (self):
- while True:
- filename = None
- if self.run() != int(gtk.RESPONSE_OK):
- break
- filename = self.get_filename()
+ def get_filename_from_user (self):
+ while True:
+ filename = None
+ if self.run() != int(gtk.RESPONSE_OK):
 break
+ filename = self.get_filename()
+ break
 
- self.hide()
- return filename, self.ext
-else:
- class FileSelection(gtk.FileSelection):
- """GTK+ 2.2 and lower file selector which remembers the last
- file/directory selected
- """
- def __init__(self, path=None, title='Select a file', parent=None):
- super(FileSelection, self).__init__(title)
+ self.hide()
+ return filename, self.ext
 
- if path: self.path = path
- else: self.path = os.getcwd() + os.sep
-
- if parent: self.set_transient_for(parent)
-
- def get_filename_from_user(self, path=None, title=None):
- if path: self.path = path
- if title: self.set_title(title)
- self.set_filename(self.path)
-
- filename = None
- if self.run() == int(gtk.RESPONSE_OK):
- self.path = filename = self.get_filename()
- self.hide()
-
- ext = None
- if filename is not None:
- ext = os.path.splitext(filename)[1]
- if ext.startswith('.'):
- ext = ext[1:]
- return filename, ext
-
-
 class DialogLineprops:
 """
 A GUI dialog for controlling lineprops
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8203
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8203&view=rev
Author: efiring
Date: 2010年03月20日 22:49:25 +0000 (2010年3月20日)
Log Message:
-----------
backend_gtk: support new tooltip API for pygtk >= 2.12
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2010年03月20日 08:58:06 UTC (rev 8202)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2010年03月20日 22:49:25 UTC (rev 8203)
@@ -17,6 +17,8 @@
 % (gtk.pygtk_version + pygtk_version_required))
 del pygtk_version_required
 
+_new_tooltip_api = (gtk.pygtk_version[1] >= 12)
+
 import matplotlib
 from matplotlib import verbose
 from matplotlib._pylab_helpers import Gcf
@@ -448,7 +450,7 @@
 # diong a blanket catch here, but an not sure what a
 # better way is - JDH
 verbose.report('Could not load matplotlib icon: %s' % sys.exc_info()[1])
- 
+
 self.vbox = gtk.VBox()
 self.window.add(self.vbox)
 self.vbox.show()
@@ -618,7 +620,8 @@
 
 def _init_toolbar2_4(self):
 basedir = os.path.join(matplotlib.rcParams['datapath'],'images')
- self.tooltips = gtk.Tooltips()
+ if not _new_tooltip_api:
+ self.tooltips = gtk.Tooltips()
 
 for text, tooltip_text, image_file, callback in self.toolitems:
 if text is None:
@@ -630,7 +633,10 @@
 tbutton = gtk.ToolButton(image, text)
 self.insert(tbutton, -1)
 tbutton.connect('clicked', getattr(self, callback))
- tbutton.set_tooltip(self.tooltips, tooltip_text, 'Private')
+ if _new_tooltip_api:
+ tbutton.set_tooltip_text(tooltip_text)
+ else:
+ tbutton.set_tooltip(self.tooltips, tooltip_text, 'Private')
 
 toolitem = gtk.SeparatorToolItem()
 self.insert(toolitem, -1)
@@ -760,7 +766,8 @@
 def _create_toolitems_2_4(self):
 # use the GTK+ 2.4 GtkToolbar API
 iconSize = gtk.ICON_SIZE_SMALL_TOOLBAR
- self.tooltips = gtk.Tooltips()
+ if not _new_tooltip_api:
+ self.tooltips = gtk.Tooltips()
 
 for text, tooltip_text, image_num, callback, callback_arg, scroll \
 in self.toolitems:
@@ -778,15 +785,22 @@
 tbutton.connect('clicked', getattr(self, callback))
 if scroll:
 tbutton.connect('scroll_event', getattr(self, callback))
- tbutton.set_tooltip(self.tooltips, tooltip_text, 'Private')
+ if _new_tooltip_api:
+ tbutton.set_tooltip_text(tooltip_text)
+ else:
+ tbutton.set_tooltip(self.tooltips, tooltip_text, 'Private')
 
 # Axes toolitem, is empty at start, update() adds a menu if >=2 axes
 self.axes_toolitem = gtk.ToolItem()
 self.insert(self.axes_toolitem, 0)
- self.axes_toolitem.set_tooltip (
- self.tooltips,
- tip_text='Select axes that controls affect',
- tip_private = 'Private')
+ if _new_tooltip_api:
+ self.axes_toolitem.set_tooltip_text(
+ 'Select axes that controls affect')
+ else:
+ self.axes_toolitem.set_tooltip (
+ self.tooltips,
+ tip_text='Select axes that controls affect',
+ tip_private = 'Private')
 
 align = gtk.Alignment (xalign=0.5, yalign=0.5, xscale=0.0, yscale=0.0)
 self.axes_toolitem.add(align)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8251
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8251&view=rev
Author: ryanmay
Date: 2010年04月20日 19:41:38 +0000 (2010年4月20日)
Log Message:
-----------
Add TimerGTK and new_timer() method.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2010年04月20日 19:40:12 UTC (rev 8250)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2010年04月20日 19:41:38 UTC (rev 8251)
@@ -23,7 +23,7 @@
 from matplotlib import verbose
 from matplotlib._pylab_helpers import Gcf
 from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \
- FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors
+ FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors, TimerBase
 from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK
 from matplotlib.cbook import is_string_like, is_writable_file_like
 from matplotlib.colors import colorConverter
@@ -90,6 +90,46 @@
 return manager
 
 
+class TimerGTK(TimerBase):
+ '''
+ Subclass of :class:`backend_bases.TimerBase` that uses GTK for timer events.
+ 
+ Attributes:
+ * interval: The time between timer events in milliseconds. Default
+ is 1000 ms.
+ * single_shot: Boolean flag indicating whether this timer should
+ operate as single shot (run once and then stop). Defaults to False.
+ * callbacks: Stores list of (func, args) tuples that will be called
+ upon timer events. This list can be manipulated directly, or the
+ functions add_callback and remove_callback can be used.
+ '''
+ from gobject import timeout_add as _add_timeout
+ from gobject import source_remove as _remove_timeout
+ def _timer_start(self):
+ self._timer = self._add_timeout(self._interval, self._on_timer)
+
+ def _timer_stop(self):
+ if self._timer is not None:
+ self._remove_timeout(self._timer)
+ self._timer = None
+
+ def _timer_set_interval(self):
+ if self._timer is not None:
+ self._timer_stop()
+ self._timer_start()
+
+ def _on_timer(self):
+ TimerBase._on_timer(self)
+ 
+ # Gtk timeout_add() requires that the callback returns True if it
+ # is to be called again.
+ if len(self.callbacks) > 0 and not self._single:
+ return True
+ else:
+ self._timer = None
+ return False
+
+
 class FigureCanvasGTK (gtk.DrawingArea, FigureCanvasBase):
 keyvald = {65507 : 'control',
 65505 : 'shift',
@@ -410,6 +450,13 @@
 def get_default_filetype(self):
 return 'png'
 
+ def new_timer(self):
+ """
+ Creates a new backend-specific subclass of
+ :class:`backend_bases.TimerBase`. This is useful for getting periodic
+ events through the backend's native event loop.
+ """
+ return TimerGTK()
 
 def flush_events(self):
 gtk.gdk.threads_enter()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8257
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8257&view=rev
Author: ryanmay
Date: 2010年04月20日 20:01:28 +0000 (2010年4月20日)
Log Message:
-----------
Remove imports from earlier development.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2010年04月20日 19:59:23 UTC (rev 8256)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2010年04月20日 20:01:28 UTC (rev 8257)
@@ -103,14 +103,12 @@
 upon timer events. This list can be manipulated directly, or the
 functions add_callback and remove_callback can be used.
 '''
- from gobject import timeout_add as _add_timeout
- from gobject import source_remove as _remove_timeout
 def _timer_start(self):
- self._timer = self._add_timeout(self._interval, self._on_timer)
+ self._timer = gobject.timeout_add(self._interval, self._on_timer)
 
 def _timer_stop(self):
 if self._timer is not None:
- self._remove_timeout(self._timer)
+ gobject.source_remove(self._timer)
 self._timer = None
 
 def _timer_set_interval(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8400
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8400&view=rev
Author: efiring
Date: 2010年06月09日 03:02:34 +0000 (2010年6月09日)
Log Message:
-----------
remove spurious whitespace
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2010年06月09日 03:01:53 UTC (rev 8399)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2010年06月09日 03:02:34 UTC (rev 8400)
@@ -93,7 +93,7 @@
 class TimerGTK(TimerBase):
 '''
 Subclass of :class:`backend_bases.TimerBase` that uses GTK for timer events.
- 
+
 Attributes:
 * interval: The time between timer events in milliseconds. Default
 is 1000 ms.
@@ -118,7 +118,7 @@
 
 def _on_timer(self):
 TimerBase._on_timer(self)
- 
+
 # Gtk timeout_add() requires that the callback returns True if it
 # is to be called again.
 if len(self.callbacks) > 0 and not self._single:
@@ -453,9 +453,9 @@
 Creates a new backend-specific subclass of :class:`backend_bases.Timer`.
 This is useful for getting periodic events through the backend's native
 event loop. Implemented only for backends with GUIs.
- 
+
 optional arguments:
- 
+
 *interval*
 Timer interval in milliseconds
 *callbacks*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8466
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8466&view=rev
Author: efiring
Date: 2010年06月24日 21:17:30 +0000 (2010年6月24日)
Log Message:
-----------
backend_gtk: don't use idle events for draw_rubberband.
Use of idle events for draw_rubberband was a peculiarity of backend_gtk.
When using zoom-to-rect, it often caused a rubberband draw event
to occur after the canvas redraw at the end of the zoom, leaving
the canvas showing the state before the zoom action instead of
showing the result of the action.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2010年06月24日 18:25:16 UTC (rev 8465)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2010年06月24日 21:17:30 UTC (rev 8466)
@@ -611,11 +611,9 @@
 self.win = window
 gtk.Toolbar.__init__(self)
 NavigationToolbar2.__init__(self, canvas)
- self._idle_draw_id = 0
 
 def set_message(self, s):
- if self._idle_draw_id == 0:
- self.message.set_label(s)
+ self.message.set_label(s)
 
 def set_cursor(self, cursor):
 self.canvas.window.set_cursor(cursord[cursor])
@@ -644,7 +642,8 @@
 h = abs(y1 - y0)
 
 rect = [int(val)for val in min(x0,x1), min(y0, y1), w, h]
- try: lastrect, imageBack = self._imageBack
+ try:
+ lastrect, imageBack = self._imageBack
 except AttributeError:
 #snap image back
 if event.inaxes is None:
@@ -655,16 +654,9 @@
 b = int(height)-(b+h)
 axrect = l,b,w,h
 self._imageBack = axrect, drawable.get_image(*axrect)
- drawable.draw_rectangle(gc, False, *rect)
- self._idle_draw_id = 0
 else:
- def idle_draw(*args):
- drawable.draw_image(gc, imageBack, 0, 0, *lastrect)
- drawable.draw_rectangle(gc, False, *rect)
- self._idle_draw_id = 0
- return False
- if self._idle_draw_id == 0:
- self._idle_draw_id = gobject.idle_add(idle_draw)
+ drawable.draw_image(gc, imageBack, 0, 0, *lastrect)
+ drawable.draw_rectangle(gc, False, *rect)
 
 
 def _init_toolbar(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /