adding an unsupported event on a wxpython widget

Hi list,

I'm trying to add the support of wx.EVT_RIGHT_UP/DOWN to
ObjectListView, but I'm far from understanding how this
work internally I fail.

I naively supposed that adding 2 bindings & 2 methods only
containing "event.Skip()" would be sufficient for OLV to
send these events up to the ListCtrl that it is based on,
but it still don't work and I'm out of options.

JY

···

--

Due to various aspects of the nature of wx.ListCtrl (a composite control on GTK and Mac, and a native control on MSW) it is difficult or impossible to get the low-level mouse events before they are consumed by the listctrl. Luckily it turns them into higher level events for you that you can use instead. What is it you are wanting to do? Perhaps it can be done with one of EVT_CONTEXT_MENU, EVT_LIST_ITEM_RIGHT_CLICK, EVT_LIST_COL_RIGHT_CLICK, etc.

···

On 12/27/11 3:00 PM, Jean-Yves F. Barbier wrote:

Hi list,

I'm trying to add the support of wx.EVT_RIGHT_UP/DOWN to
ObjectListView, but I'm far from understanding how this
work internally I fail.

I naively supposed that adding 2 bindings& 2 methods only
containing "event.Skip()" would be sufficient for OLV to
send these events up to the ListCtrl that it is based on,
but it still don't work and I'm out of options.

--
Robin Dunn
Software Craftsman

My goal is to have a popup appearing on a right-click into the list
(quite a standard behavior for many GUIs) to have small menu with
2 lines: Choose columns (and their order), Come back to original
order.

The main PB is a "grep RIGHT *py" into OVL source don't return
anything linked to events:( - nor does CONTEXT (but I'm not tough
enough to say if it's really a PB)

And I don't know if it's even possible as I don't know how I'll
"recharge" my new column set into a living widget.

JY

···

On Tue, 27 Dec 2011 17:51:10 -0800 Robin Dunn <robin@alldunn.com> wrote:

On 12/27/11 3:00 PM, Jean-Yves F. Barbier wrote:
> Hi list,
>
> I'm trying to add the support of wx.EVT_RIGHT_UP/DOWN to
> ObjectListView, but I'm far from understanding how this
> work internally I fail.
>
> I naively supposed that adding 2 bindings& 2 methods only
> containing "event.Skip()" would be sufficient for OLV to
> send these events up to the ListCtrl that it is based on,
> but it still don't work and I'm out of options.

Due to various aspects of the nature of wx.ListCtrl (a composite control
on GTK and Mac, and a native control on MSW) it is difficult or
impossible to get the low-level mouse events before they are consumed by
the listctrl. Luckily it turns them into higher level events for you
that you can use instead. What is it you are wanting to do? Perhaps it
can be done with one of EVT_CONTEXT_MENU, EVT_LIST_ITEM_RIGHT_CLICK,
EVT_LIST_COL_RIGHT_CLICK, etc.

--
Most men would never get laid if it weren't for the pity fuck.

Jean-Yves,

...

My goal is to have a popup appearing on a right-click into the list
(quite a standard behavior for many GUIs) to have small menu with
2 lines: Choose columns (and their order), Come back to original
order.

self.myOlv.Bind(wx.EVT_CONTEXT_MENU, self.onListContextMenu)

I am starting to sound like a sales person for MediaLocker;-) . Run it add a book or two and then right click on the list, it will show you three items, two for a report and the third will eventually allow to save the column configuration. BTW - have to look into it why the start up is slowish.

It is done with the above Bind and the code building the menu is in mlsrc.libui.olvbase.

The main PB is a "grep RIGHT *py" into OVL source don't return
anything linked to events:( - nor does CONTEXT (but I'm not tough
enough to say if it's really a PB)

I am not sure but I think this is all "out of the box" stuff of the listctrl which OLV is built on.

And I don't know if it's even possible as I don't know how I'll
"recharge" my new column set into a living widget.

You mean reload the total list? Are you allowing to add columns on the fly?

I haven't done that but I guess it should be possible by first doing myOlv.ClearAll() and then loading your ColumnDef's and objects again.

Werner

···

On 12/28/2011 03:12 AM, Jean-Yves F. Barbier wrote:

>
self.myOlv.Bind(wx.EVT_CONTEXT_MENU, self.onListContextMenu)

YEEESSS! Thanks Werner!
Robin also told me about it this night but I had to sleep before:)

I learned one other thing: this one doesn't appear into the OVL
source but is processed anyway (sometime logical things don't
seem so logical).

I am starting to sound like a sales person for MediaLocker;-) . Run it
add a book or two and then right click on the list, it will show you
three items, two for a report and the third will eventually allow to
save the column configuration. BTW - have to look into it why the start
up is slowish.

I had a rapid dive in the code: some things are too advanced for me
at this time but I understand most of it.

My first approach was also to use SA, as it seems a wonderful tool
from outside; however it has several drawbacks:
* some queries aren't as effective as manual ones (some cases even
  trigger multiple queries - was like that 2 years ago),
* it drives the DB (but it should be the contrary),
* the worse: it must have a direct access to the basic data, in
  opposition to what is done by any DB conceptor: keep base data
  unreachable and access them through views & stored procedures.

I choose an inverse solution: the pgm is adapting itself to DB
modifications & rights changes (drawback: start is very long, the
time to recover all rights, kind of data, etc from DB).

It is done with the above Bind and the code building the menu is in
mlsrc.libui.olvbase.

> The main PB is a "grep RIGHT *py" into OVL source don't return
> anything linked to events:( - nor does CONTEXT (but I'm not tough
> enough to say if it's really a PB)

I am not sure but I think this is all "out of the box" stuff of the
listctrl which OLV is built on.

Yep, and this is why I'm confused (see my §2): I tried with
EVT_RIGHT_UP/DOWN, which are *also* LC intrinsics and... it didn't
work!

> And I don't know if it's even possible as I don't know how I'll
> "recharge" my new column set into a living widget.

You mean reload the total list?

No, an example:
* I've 6 columns candidate to be displayed, but in my opinion 4 are
  enough to run, so I present cols 0,3,5,6,
* user, for any reason, wants to see all of them in a different
  order, so by the popup menu he choose that option,

Here is the PB: how can I tell my running widget to get rid of old
cols list & reload the new one without stopping it?
I need to re-read the docs deeply because I remember a primitive
that suppress the running list of displayed columns, so the inverse
must exists as well.

Are you allowing to add columns on the fly?

No, in the whole bunch of pgms I tested (O-S & Cial), it is often an
option such as having different views and switch between them, but
experience shows it is only a gadget and once people has stabilize
its choice it don't change anymore.
So, I have only 2 options: change cols & their order or return to
original choice.

But may be I understand wrong what you're saying.

I haven't done that but I guess it should be possible by first doing
myOlv.ClearAll() and then loading your ColumnDef's and objects again.

I think so because a widget that don't support this possibility
would be useless in a production environment.

JY

···

On Wed, 28 Dec 2011 09:59:48 +0100 werner <wbruhin@free.fr> wrote:
--

Hi Jean-Yves,

...
going off topic here, hope Robin and others won't mind.

I had a rapid dive in the code: some things are too advanced for me
at this time but I understand most of it.

My first approach was also to use SA, as it seems a wonderful tool
from outside; however it has several drawbacks:
* some queries aren't as effective as manual ones (some cases even
   trigger multiple queries - was like that 2 years ago),

I assume you talk about things like relationship stuff when using the ORM, this can be tuned see "lazyload", "eagerload", "subqueryload", "immediateload" and IIRC the defaults have been improved in version 0.6 and 0.7.

* it drives the DB (but it should be the contrary),

Hhm, hopefully the developer/architect is driving it all;-) .

* the worse: it must have a direct access to the basic data, in
   opposition to what is done by any DB conceptor: keep base data
   unreachable and access them through views& stored procedures.

As of 0.6 you can use views - see Views · sqlalchemy/sqlalchemy Wiki · GitHub

There is some support for SP's but not sure how far it goes.

I choose an inverse solution: the pgm is adapting itself to DB
modifications& rights changes (drawback: start is very long, the
time to recover all rights, kind of data, etc from DB).

You could do that with "autoload" but very slow if your db is big (as in many tables etc which I guess it will be - worked with SAP AG on a hotel project some years ago). There is also Google Code Archive - Long-term storage for Google Code Project Hosting. which generates the SA stuff - didn't work well for me with Firebird SQL but should be fine with postgre.

...

Yep, and this is why I'm confused (see my �2): I tried with
EVT_RIGHT_UP/DOWN, which are *also* LC intrinsics and... it didn't
work!

IIRC they need to be bound to the list and it won't work if you bind to the panel or frame.

And I don't know if it's even possible as I don't know how I'll
"recharge" my new column set into a living widget.

You mean reload the total list?

No, an example:
* I've 6 columns candidate to be displayed, but in my opinion 4 are
   enough to run, so I present cols 0,3,5,6,
* user, for any reason, wants to see all of them in a different
   order, so by the popup menu he choose that option,

Currently I support that through a separate dialog, would like to do it with a popup but with < 2.9.2.4 one can't get at the current column position. I.e. if you have column 0, 1, 2 and move 2 to the position of 0 you can't find this out.

Here is the PB: how can I tell my running widget to get rid of old
cols list& reload the new one without stopping it?

self.panel.Freeze()
self.list.ClearAll()
self.list.yourmethodToLoadCols() - which in turn calls olv.ColumnDefn and olv.SetColumns
self.list.yourmethodToLoadObjects() - which in turn calls olv.SetObjects
self.panel.Thaw()

Werner

···

On 12/28/2011 03:12 PM, Jean-Yves F. Barbier wrote:

> Yep, and this is why I'm confused (see my §2): I tried with
> EVT_RIGHT_UP/DOWN, which are *also* LC intrinsics and... it didn't
> work!
>
IIRC they need to be bound to the list and it won't work if you bind to
the panel or frame.

I'm a silly donkey: my code bound it to the Frame:(
...

> Here is the PB: how can I tell my running widget to get rid of old
> cols list& reload the new one without stopping it?
self.panel.Freeze()
self.list.ClearAll()
self.list.yourmethodToLoadCols() - which in turn calls olv.ColumnDefn
and olv.SetColumns
self.list.yourmethodToLoadObjects() - which in turn calls olv.SetObjects
self.panel.Thaw()

Once again tanks Werner.

···

On Wed, 28 Dec 2011 18:42:52 +0100 werner <wbruhin@free.fr> wrote:

--
BOFH excuse #385:
Dyslexics retyping hosts file on servers