Getting resize_event to work

Back in March, 2007, a user asked about getting the resize_even to work. No one responded to his question. I have the same problem. I tried hooking up a method that I hoped would be called every time the graph was resized (using the UI that is displayed by a show() call).

connect('resize_event', plotutils.recalculateTimeSeriesXLabels)

However, my method is never called, even when I maximize the window.

Here is his email as well:

Trying to get resize event to work, but either I don't understand the definition of when resize_event should work, or it's broken.

for example

···

=======================
from matplotlib import pylab , numerix

def GotResizeEvent( event ):
    print 'Resize event detected'

def GotDrawEvent( event ):
    print 'Draw event detected'

X = range(0, 200)
Y = pylab.sin(X)

r = pylab.plot(X,Y)
pylab.connect( 'resize_event', GotResizeEvent)
pylab.connect( 'draw_event', GotDrawEvent)
pylab.show()

Will only get draw_events as I zoom in on the data, never a resize event?
I also get draw_events as I resize the window itself, but never a resize_event.

So my question, .. what user activity triggers a resize event?

--
Jon Froehlich
PhD Student
Computer Science and Engineering
University of Washington
http://www.cs.washington.edu/homes/jfroehli

Jon Froehlich wrote:

Back in March, 2007, a user asked about getting the resize_even to work. No one responded to his question. I have the same problem. I tried hooking up a method that I hoped would be called every time the graph was resized (using the UI that is displayed by a show() call).

connect('resize_event', plotutils.recalculateTimeSeriesXLabels)

However, my method is never called, even when I maximize the window.

Here is his email as well:

Trying to get resize event to work, but either I don't understand the definition of when resize_event should work, or it's broken.

for example

from matplotlib import pylab , numerix

def GotResizeEvent( event ):
    print 'Resize event detected'

def GotDrawEvent( event ):
    print 'Draw event detected'

X = range(0, 200)
Y = pylab.sin(X)

r = pylab.plot(X,Y)
pylab.connect( 'resize_event', GotResizeEvent)
pylab.connect( 'draw_event', GotDrawEvent)
pylab.show()

Will only get draw_events as I zoom in on the data, never a resize event?
I also get draw_events as I resize the window itself, but never a resize_event.

So my question, .. what user activity triggers a resize event?

This sounds like a problem with a specific backend. It works for me (i.e., I get resize events when resizing the window) with mpl from svn, linux, gtkagg backend.

What are you using?

Eric

···

Hi Eric,

Thanks for the response. I am just calling show() within pylab and a
GUI automatically pops-up. A screenshot is attached. It looks like the
underlying GUI is TK? I am on Vista (unfortunately).

moz-screenshot-4.jpg

Jon

Eric Firing wrote:

···
-- Jon Froehlich
PhD Student
Computer Science and Engineering
University of Washington

http://www.cs.washington.edu/homes/jfroehli

Jon Froehlich wrote:

Hi Eric,

Thanks for the response. I am just calling show() within pylab and a GUI automatically pops-up. A screenshot is attached. It looks like the underlying GUI is TK? I am on Vista (unfortunately).

The problem is TK-specific, not Vista-specific. I can reproduce it with svn mpl on ubuntu hardy if I start with
import matplotlib
matplotlib.use('tkagg')

I have never looked into the tkagg backend; I hope there is a tk guru waiting in the wings to track this down and fix it.

Eric

···

Jon

Eric Firing wrote:

Jon Froehlich wrote:

Back in March, 2007, a user asked about getting the resize_even to work. No one responded to his question. I have the same problem. I tried hooking up a method that I hoped would be called every time the graph was resized (using the UI that is displayed by a show() call).

connect('resize_event', plotutils.recalculateTimeSeriesXLabels)

However, my method is never called, even when I maximize the window.

Here is his email as well:

Trying to get resize event to work, but either I don't understand the definition of when resize_event should work, or it's broken.

for example

from matplotlib import pylab , numerix

def GotResizeEvent( event ):
    print 'Resize event detected'

def GotDrawEvent( event ):
    print 'Draw event detected'

X = range(0, 200)
Y = pylab.sin(X)

r = pylab.plot(X,Y)
pylab.connect( 'resize_event', GotResizeEvent)
pylab.connect( 'draw_event', GotDrawEvent)
pylab.show()

Will only get draw_events as I zoom in on the data, never a resize event?
I also get draw_events as I resize the window itself, but never a resize_event.

So my question, .. what user activity triggers a resize event?

This sounds like a problem with a specific backend. It works for me (i.e., I get resize events when resizing the window) with mpl from svn, linux, gtkagg backend.

What are you using?

Eric

--
Jon Froehlich
PhD Student
Computer Science and Engineering
University of Washington
http://www.cs.washington.edu/homes/jfroehli

It looks like noone ever added support for it in tkagg -- I think all
that needs to be done is add

  self.resize_event()

to FigureCanvasTkAgg.resize. I just committed these changes to svn
r6159 -- it appears to work for the test case Jon posted...

JDH

···

On Mon, Oct 6, 2008 at 1:40 PM, Eric Firing <efiring@...202...> wrote:

Jon Froehlich wrote:

Hi Eric,

Thanks for the response. I am just calling show() within pylab and a GUI
automatically pops-up. A screenshot is attached. It looks like the
underlying GUI is TK? I am on Vista (unfortunately).

The problem is TK-specific, not Vista-specific. I can reproduce it with
svn mpl on ubuntu hardy if I start with
import matplotlib
matplotlib.use('tkagg')

I have never looked into the tkagg backend; I hope there is a tk guru
waiting in the wings to track this down and fix it.