Strange resize behaviour for qt backend

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-spam@...361...> 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 :slight_smile:

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

Hi again,

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

should?

I am really busy with other things, and can’t offer suggestions unless you post a short, simple, standalone script that demonstrates the problem.

Darren

···

On Thu, May 28, 2009 at 7:55 AM, Ole Streicher <ole-usenet-spam@…361…> wrote:

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-spam@…361…> 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 :slight_smile:

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


“In our description of nature, the purpose is not to disclose the real essence of the phenomena but only to track down, so far as it is possible, relations between the manifold aspects of our experience” - Niels Bohr

“It is a bad habit of physicists to take their most successful abstractions to be real properties of our world.” - N. David Mermin

“Once we have granted that any physical theory is essentially only a model for the world of experience, we must renounce all hope of finding anything like the correct theory … simply because the totality of experience is never accessible to us.” - Hugh Everett III

Ole
wrote:

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

Remember,
this is not a multi-threaded system. You can’t receive a second repaint event
while the drawing code is happening because the event loop is not in a separate
thread. You can make calls that will put a repaint event on the X event queue.
When the resize code is finished, the event queue will then be processed in the
order they were received. I’d guess that something in your repaint/drawing
code is changing the size of the widgets which is probably should not be doing.

From: Darren Dale
[mailto:dsdale24@…287…]
Sent: Thursday, May 28, 2009 8:57 AM
To: Ole Streicher
Cc: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] Strange resize behaviour for qt backend

On Thu, May 28, 2009 at 7:55 AM, Ole Streicher <ole-usenet-spam@…361…> wrote:

Hi again,

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

I am really busy with other things, and can’t offer suggestions unless you post
a short, simple, standalone script that demonstrates the problem.

Darren

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-spam@…361…>
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 :slight_smile:

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


“In our description of nature, the purpose is not to disclose the real
essence of the phenomena but only to track down, so far as it is possible,
relations between the manifold aspects of our experience” - Niels Bohr

“It is a bad habit of physicists to take their most successful
abstractions to be real properties of our world.” - N. David Mermin

“Once we have granted that any physical theory is essentially only a model
for the world of experience, we must renounce all hope of finding anything like
the correct theory … simply because the totality of experience is never
accessible to us.” - Hugh Everett III

No virus
found in this incoming message.

Checked by AVG - www.avg.com

Version: 8.5.339 / Virus Database: 270.12.43/2138 - Release Date: 05/27/09
18:21:00