Hi again,

is there no idea on this topic? Does the update work for you as it
should?

I started to debugging it a bit by adding debug output to the
moveEvent()/resizeEvent() functions. I seems that the resizeEvents
(resp. moveEvents) come out of order. The following comes when one
resizes the window width:

figure resize to  PyQt4.QtCore.QSize(803, 474) <-- first event
figure resize to  PyQt4.QtCore.QSize(879, 474) <-- second event
scroll resize to  PyQt4.QtCore.QSize(879, 15)  <-- second event (wrong!!)
scroll resize to  PyQt4.QtCore.QSize(803, 15)  <-- first event

My interpretation of this is:
- the FigureCanvas gets the first resize event and repaints itself (*)
- during the repaint it gets the second resize event
- since it is already in the repaint process, the second request
  is ignored (or queued) and returns immediately
- this leads to the processing of the second resize for the scrollbar
- after the first repaint (*) is finished, the first resize of the 
  scrollbar is started

Who should be blamed for that? Is it
- Qt since they dont distribute the events in the order of occurrence to
  the layout childs?
- or FigureCanvas since it returns from the secons call while the first
  one is not finished yet?

How can I workaround this?

Best regards,

Ole

Ole Streicher <ole-usenet-s...@gmx.net> writes:
> Hi,
>
> I am using matplotlib for some data vizualization. To ensure a
> consistent user interface among the whole application, I do the
> scrolling/zooming stuff myself. So, for a diagram, a horizontal
> scrollbar is displayed below the diagram that enabled to shift along the
> x axis. This is (part of) the code:
>
> ------------------------8<-----------------------------------------------
> from PyQt4 import QtGui, QtCore
> from matplotlib.figure import Figure,SubplotParams
>
> class DiagramWidget(QtGui.QWidget):
>     def __init__(self, parent):
>         QtGui.QWidget.__init__(self, parent)
>         layout = QtGui.QVBoxLayout(self)
>         self.diagram = InnerDiagramWidget(self)
>         self.scrollbar = QtGui.QScrollBar(QtCore.Qt.Horizontal, self)
>         self.connect(self.scrollbar, QtCore.SIGNAL('valueChanged(int)'),
>                      self.diagram.scroll_event)
>         layout.addWidget(self.diagram)
>         layout.addWidget(self.scrollbar)
> # ...
>
> class InnerDiagramWidget(FigureCanvas):
>     def __init__(self, parent):
>         fig = Figure(facecolor = 'w', 
>                      subplotpars = SubplotParams(left = 0.08, right=0.96, 
>                                                  bottom = 0.1, top=0.98))
>         self.axes = fig.add_subplot(111)
>         FigureCanvas.__init__(self, fig)
>         FigureCanvas.setParent(self, parent)
>         FigureCanvas.setSizePolicy(self,
>                                    QtGui.QSizePolicy.Expanding,
>                                    QtGui.QSizePolicy.Expanding)
>         FigureCanvas.updateGeometry(self)
>
>     def scroll_event(self, x):
>         pass # here is real code ofcourse
> # ...
> ------------------------8<-----------------------------------------------
>
> However, when I put this DiagramWidget into a window and try to resize
> it vertically by mouse (with some data ... about 4000 points), the
> scrollbar is not alwas shown correctly.
>
> One can see that the diagram widget size does not change with every mouse
> move, and the scrollbar sometimes goes out of the visible window, where
> it is unusable.
>
> The similar occurres in the horizontal direction: sometimes the
> scrollbar gets not updated properly. This is the case when the Figure
> canvas takes a long time for update.
>
> If I put the scrollbar on top of the widget, everything is fine, except
> that is the wrong place for a scrollbar :-)
>
> Is this a bug in FigureCanvas, in Qt or in my code? How can I debug and
> solve this?
>
> Best regards
>
> Ole
>
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
> is a gathering of tech-side developers & brand creativity professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, & 
> iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
> Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to