Skip to content

Commit

Permalink
Use the same logic as MPL uses when picking Qt interface.
Browse files Browse the repository at this point in the history
Thanks to Michael Droettboom (matplotlib#2221 (comment))
  • Loading branch information
Daniel O'Connor committed Jul 17, 2013
1 parent 80b95ed commit f8855f2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
7 changes: 5 additions & 2 deletions examples/animation/old_animation/animation_blit_qt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas

try:
from matplotlib.backends import qt4_compat
use_pyside = qt4_compat.QT_API == qt4_compat.QT_API_PYSIDE

if use_pyside:
from PySide import QtCore, QtGui
except ImportError:
else:
from PyQt4 import QtCore, QtGui

ITERS = 1000
Expand Down
10 changes: 5 additions & 5 deletions examples/user_interfaces/embedding_in_qt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

from __future__ import unicode_literals
import sys, os, random
try:
from matplotlib.backends import qt4_compat
use_pyside = qt4_compat.QT_API == qt4_compat.QT_API_PYSIDE
if use_pyside:
from PySide import QtGui, QtCore
usepyside = True
except ImportError:
else:
from PyQt4 import QtGui, QtCore
usepyside = False

from numpy import arange, sin, pi
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
Expand Down Expand Up @@ -62,7 +62,7 @@ class MyDynamicMplCanvas(MyMplCanvas):
def __init__(self, *args, **kwargs):
MyMplCanvas.__init__(self, *args, **kwargs)
timer = QtCore.QTimer(self)
if usepyside:
if use_pyside:
timer.timeout.connect(self.update_figure)
else:
QtCore.QObject.connect(timer, QtCore.SIGNAL("timeout()"), self.update_figure)
Expand Down
7 changes: 5 additions & 2 deletions examples/user_interfaces/embedding_in_qt4_wtoolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
from matplotlib.backends.backend_qt4agg import (
FigureCanvasQTAgg as FigureCanvas,
NavigationToolbar2QTAgg as NavigationToolbar)
try:
from matplotlib.backends import qt4_compat
use_pyside = qt4_compat.QT_API == qt4_compat.QT_API_PYSIDE

if use_pyside:
from PySide.QtCore import *
from PySide.QtGui import *
except ImportError:
else:
from PyQt4.QtCore import *
from PyQt4.QtGui import *

Expand Down

0 comments on commit f8855f2

Please sign in to comment.