[matplotlib-devel] Pyside 1.0.8 compatibility patch

2011-10-29 Thread Trémouilles David

Hello,

I've recently switched to PySide 1.0.8 on my MacBook using macports.
It seems that it breaks part of matplotlib.

Not sure if this is pyside or matplotlib bug but
the attached change in matplotlib solved the issue for me.

Regards,

David


>From 1fd9b3c9e1a3caa59c42d161c222327f96b9f5b3 Mon Sep 17 00:00:00 2001
From: David Tremouilles 
Date: Sat, 29 Oct 2011 09:24:25 +0200
Subject: [PATCH] pyside 1.0.8 compatibility fix

---
 lib/matplotlib/backends/backend_qt4.py |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/lib/matplotlib/backends/backend_qt4.py 
b/lib/matplotlib/backends/backend_qt4.py
index a31191b..fa9769c 100644
--- a/lib/matplotlib/backends/backend_qt4.py
+++ b/lib/matplotlib/backends/backend_qt4.py
@@ -144,7 +144,11 @@ class FigureCanvasQT( QtGui.QWidget, FigureCanvasBase ):
 QtCore.Qt.Key_PageDown : 'pagedown',
}
 # left 1, middle 2, right 3
-buttond = {1:1, 2:3, 4:2}
+   #buttond = {1:1, 2:3, 4:2}
+buttond = {QtCore.Qt.LeftButton : 1,
+   QtCore.Qt.MiddleButton : 3,
+   QtCore.Qt.RightButton : 2}
+
 def __init__( self, figure ):
 if DEBUG: print 'FigureCanvasQt: ', figure
 _create_qApp()
-- 
1.7.7.1

--
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World™ now supports Android™ Apps 
for the BlackBerry® PlayBook™. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] Keybinding doc & close window

2011-10-29 Thread Antoine Levitt
Hi,

Is there any doc of the various bindable actions? I only found
http://matplotlib.sourceforge.net/users/customizing.html, and I'm not
sure all of them are in there. In particular, I'd like a simple "q"
keybinding to close the window, and ideally a way to run arbitrary
python code.

Antoine


--
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World™ now supports Android™ Apps 
for the BlackBerry® PlayBook™. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Keybinding doc & close window

2011-10-29 Thread Benjamin Root
On Saturday, October 29, 2011, Antoine Levitt 
wrote:
> Hi,
>
> Is there any doc of the various bindable actions? I only found
> http://matplotlib.sourceforge.net/users/customizing.html, and I'm not
> sure all of them are in there. In particular, I'd like a simple "q"
> keybinding to close the window, and ideally a way to run arbitrary
> python code.
>
> Antoine
>

I don't think there is a document for the default keymaps, and there has
been some talk about redoing default keybindings, because they are so hidden
and varies from backend to backend.

In the meantime, I would suggest checking out the "event handeling" section
of the examples page. You can have a function that you attach to the
"key_press_event", which takes an "event" object as an argument.  That event
object has the key that was pressed.  You can then have an if...elif...else
statement for all the keys and actions, or have a dictionary of key-action
pairs.

Hope that helps!
Ben Root
--
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World™ now supports Android™ Apps 
for the BlackBerry® PlayBook™. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Keybinding doc & close window

2011-10-29 Thread Antoine Levitt
29/10/11 19:39, Benjamin Root
> I don't think there is a document for the default keymaps, and there
> has been some talk about redoing default keybindings, because they are
> so hidden and varies from backend to backend.
>
> In the meantime, I would suggest checking out the "event handeling"
> section of the examples page. You can have a function that you attach
> to the "key_press_event", which takes an "event" object as an
> argument.  That event object has the key that was pressed.  You can
> then have an if...elif...else statement for all the keys and actions,
> or have a dictionary of key-action pairs.
>
> Hope that helps!
> Ben Root

That's pretty cool! However, I have to do it for every figure I create,
there doesn't seem to be a way to tell matplotlib : "whenever a figure
is created, associate this handler to this event".

I think I'll just wait for the keybinding stuff to get refactored, which
would definitely be a good idea (I only found out via very indirect
means, and had to change backend to get them working). It seems
worthwhile to have a "q" default binding to exit the plot.

--
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World™ now supports Android™ Apps 
for the BlackBerry® PlayBook™. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Keybinding doc & close window

2011-10-29 Thread Benjamin Root
On Saturday, October 29, 2011, Antoine Levitt 
wrote:
> 29/10/11 19:39, Benjamin Root
>> I don't think there is a document for the default keymaps, and there
>> has been some talk about redoing default keybindings, because they are
>> so hidden and varies from backend to backend.
>>
>> In the meantime, I would suggest checking out the "event handeling"
>> section of the examples page. You can have a function that you attach
>> to the "key_press_event", which takes an "event" object as an
>> argument.  That event object has the key that was pressed.  You can
>> then have an if...elif...else statement for all the keys and actions,
>> or have a dictionary of key-action pairs.
>>
>> Hope that helps!
>> Ben Root
>
> That's pretty cool! However, I have to do it for every figure I create,
> there doesn't seem to be a way to tell matplotlib : "whenever a figure
> is created, associate this handler to this event".
>
> I think I'll just wait for the keybinding stuff to get refactored, which
> would definitely be a good idea (I only found out via very indirect
> means, and had to change backend to get them working). It seems
> worthwhile to have a "q" default binding to exit the plot.
>

The basic event handling isn't going to be refactored.  I was merely
speaking of how the default keymaps are set.  Yes, you will need to
mpl_connect for each figure object.  This is standard for any GUI control
system.  What you can do is make a function that produces a figure for you
as well as perform any event connections for you.

Ben Root
--
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World™ now supports Android™ Apps 
for the BlackBerry® PlayBook™. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Keybinding doc & close window

2011-10-29 Thread Antoine Levitt
29/10/11 21:20, Benjamin Root
> On Saturday, October 29, 2011, Antoine Levitt
>  wrote:
>> 29/10/11 19:39, Benjamin Root
>>> I don't think there is a document for the default keymaps, and
> there
>>> has been some talk about redoing default keybindings, because they
> are
>>> so hidden and varies from backend to backend.
>>>
>>> In the meantime, I would suggest checking out the "event handeling"
>>> section of the examples page. You can have a function that you
> attach
>>> to the "key_press_event", which takes an "event" object as an
>>> argument.  That event object has the key that was pressed.  You can
>>> then have an if...elif...else statement for all the keys and
> actions,
>>> or have a dictionary of key-action pairs.
>>>
>>> Hope that helps!
>>> Ben Root
>>
>> That's pretty cool! However, I have to do it for every figure I
> create,
>> there doesn't seem to be a way to tell matplotlib : "whenever a
> figure
>> is created, associate this handler to this event".
>>
>> I think I'll just wait for the keybinding stuff to get refactored,
> which
>> would definitely be a good idea (I only found out via very indirect
>> means, and had to change backend to get them working). It seems
>> worthwhile to have a "q" default binding to exit the plot.
>>
>
> The basic event handling isn't going to be refactored.  I was merely
> speaking of how the default keymaps are set.  Yes, you will need to
> mpl_connect for each figure object.  This is standard for any GUI
> control system.  What you can do is make a function that produces a
> figure for you as well as perform any event connections for you.
>
> Ben Root 

The problem is that I don't usually invoke figure(), I just do
plot(x,y), which will presumably call figure for me. So unless there's
some kind of event that's run after figure is called, I can't have a
generic way of adding my bindings.

--
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World™ now supports Android™ Apps 
for the BlackBerry® PlayBook™. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Keybinding doc & close window

2011-10-29 Thread Benjamin Root
On Saturday, October 29, 2011, Antoine Levitt 
wrote:
> 29/10/11 21:20, Benjamin Root
>> On Saturday, October 29, 2011, Antoine Levitt
>>  wrote:
>>> 29/10/11 19:39, Benjamin Root
 I don't think there is a document for the default keymaps, and
>> there
 has been some talk about redoing default keybindings, because they
>> are
 so hidden and varies from backend to backend.

 In the meantime, I would suggest checking out the "event handeling"
 section of the examples page. You can have a function that you
>> attach
 to the "key_press_event", which takes an "event" object as an
 argument.  That event object has the key that was pressed.  You can
 then have an if...elif...else statement for all the keys and
>> actions,
 or have a dictionary of key-action pairs.

 Hope that helps!
 Ben Root
>>>
>>> That's pretty cool! However, I have to do it for every figure I
>> create,
>>> there doesn't seem to be a way to tell matplotlib : "whenever a
>> figure
>>> is created, associate this handler to this event".
>>>
>>> I think I'll just wait for the keybinding stuff to get refactored,
>> which
>>> would definitely be a good idea (I only found out via very indirect
>>> means, and had to change backend to get them working). It seems
>>> worthwhile to have a "q" default binding to exit the plot.
>>>
>>
>> The basic event handling isn't going to be refactored.  I was merely
>> speaking of how the default keymaps are set.  Yes, you will need to
>> mpl_connect for each figure object.  This is standard for any GUI
>> control system.  What you can do is make a function that produces a
>> figure for you as well as perform any event connections for you.
>>
>> Ben Root
>
> The problem is that I don't usually invoke figure(), I just do
> plot(x,y), which will presumably call figure for me. So unless there's
> some kind of event that's run after figure is called, I can't have a
> generic way of adding my bindings.
>

Try

gcf().canvas.mpl_connect(...)

Before any show() calls or after any particular plotting commands.

Ben Root
--
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World™ now supports Android™ Apps 
for the BlackBerry® PlayBook™. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Keybinding doc & close window

2011-10-29 Thread Antoine Levitt
29/10/11 21:50, Benjamin Root
> On Saturday, October 29, 2011, Antoine Levitt
>  wrote:
>> 29/10/11 21:20, Benjamin Root
>>> On Saturday, October 29, 2011, Antoine Levitt
>>>  wrote:
 29/10/11 19:39, Benjamin Root
> I don't think there is a document for the default keymaps, and
>>> there
> has been some talk about redoing default keybindings, because
> they
>>> are
> so hidden and varies from backend to backend.
>
> In the meantime, I would suggest checking out the "event
> handeling"
> section of the examples page. You can have a function that you
>>> attach
> to the "key_press_event", which takes an "event" object as an
> argument.  That event object has the key that was pressed.  You
> can
> then have an if...elif...else statement for all the keys and
>>> actions,
> or have a dictionary of key-action pairs.
>
> Hope that helps!
> Ben Root

 That's pretty cool! However, I have to do it for every figure I
>>> create,
 there doesn't seem to be a way to tell matplotlib : "whenever a
>>> figure
 is created, associate this handler to this event".

 I think I'll just wait for the keybinding stuff to get refactored,
>>> which
 would definitely be a good idea (I only found out via very
> indirect
 means, and had to change backend to get them working). It seems
 worthwhile to have a "q" default binding to exit the plot.

>>>
>>> The basic event handling isn't going to be refactored.  I was
> merely
>>> speaking of how the default keymaps are set.  Yes, you will need to
>>> mpl_connect for each figure object.  This is standard for any GUI
>>> control system.  What you can do is make a function that produces a
>>> figure for you as well as perform any event connections for you.
>>>
>>> Ben Root
>>
>> The problem is that I don't usually invoke figure(), I just do
>> plot(x,y), which will presumably call figure for me. So unless
> there's
>> some kind of event that's run after figure is called, I can't have a
>> generic way of adding my bindings.
>>
>
> Try
>
> gcf().canvas.mpl_connect(...)

Just typing f = gcf() displays a figure, which I don't want to do. I
want to be able to put something in my ipython init file that'd set my
bindings, without changing anything else.

--
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World™ now supports Android™ Apps 
for the BlackBerry® PlayBook™. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Keybinding doc & close window

2011-10-29 Thread John Hunter
On Sat, Oct 29, 2011 at 2:52 PM, Antoine Levitt
 wrote:
> Just typing f = gcf() displays a figure, which I don't want to do. I
> want to be able to put something in my ipython init file that'd set my
> bindings, without changing anything else.

This is a reasonable request, though there are some implementation
details to sort through.  For one, the rc file format is very simple,
and not amenable to putting in multil-ine functions.  But you could
write something like

  keybinding.q  : lambda event: plt.close(event.canvas.figure)

Eg, when a key is pressed for which you have associated a lambda, we
could call your lambda with the event that triggered, and you can
access attributes like canvas.figure to operate on them.  We could
eval your lambda in the pyplot namespace.  But more sophisticated
functions would be difficult to expose given the simplicity of rc
format.

If you are interested in taking a crack at this Antoine, we'd be happy
to evaluate a pull request.  If not, perhaps I or one of the other
developers can take a look.

Note that in most windowing systems, it is fairly easy to bind a
keystroke to close a window, so you could get the effect of 'q' w/o
modifying MPL, though you might need a two keystroke binding,

--
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World™ now supports Android™ Apps 
for the BlackBerry® PlayBook™. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
___
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel