which List for a logger?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

which List for a logger?

Boiteux, Benoit

Hello,

 

I created a basic logger for custom purpose, and I used the following Enthought controls (similar to your Tabular Editor demo) :

-          A HasTraits class with column items (Str) : ItemsClass

-          A TabularAdapter to display the listview

-          And a main class (HasTraits) with a view that contains a List (ItemsClass) displayed with editor = myTabularAdapter.

Then a timer add data to the list (lot of data and fastly).

 

Unfortunately, the display blinks and it’s really not comfortable.

 

Could you advise me on which editor I would have to use, and maybe a better way to update data to avoid this blink effect ? (in 1 sentence: what’s the best solution to create a logger?)

 

Thanks

benoit

 

Benoît Boiteux
UMG/MIPE/WSIV  System Test - Tools
Office:    +33 (0)5 61 19 99 38
Mobile:  +33 (0)6 23 21 79 07

[hidden email]

Intel Corp.
134, av du Général Eisenhower
31023 TOULOUSE Cedex 1
France

 

 

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: which List for a logger?

bryce hendrix-2
Boiteux, Benoit wrote:

Hello,

 

I created a basic logger for custom purpose, and I used the following Enthought controls (similar to your Tabular Editor demo) :

-          A HasTraits class with column items (Str) : ItemsClass

-          A TabularAdapter to display the listview

-          And a main class (HasTraits) with a view that contains a List (ItemsClass) displayed with editor = myTabularAdapter.

Then a timer add data to the list (lot of data and fastly).

 

Unfortunately, the display blinks and it’s really not comfortable.

 

Could you advise me on which editor I would have to use, and maybe a better way to update data to avoid this blink effect ? (in 1 sentence: what’s the best solution to create a logger?)


If you look at the LoggerPlugin and LoggerView classes in EnthoughtBase, you'll see that we use a TabularEditor. We used to have issues with flashing, but as it is implemented, the flashing is now minimal (or was the last time I used it heavily).

You should be able to cut and paste most of the LoggerView code to reuse it. It is written to be used as an Envisage plugin, though 80% of the code could be reused outside of an Envisage app.

Bryce
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: which List for a logger?

Boiteux, Benoit

Thanks Bryce,

I’m gonna have a try right now !

 

benoit

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of bryce hendrix
Sent: Wednesday, March 10, 2010 6:28 PM
To: [hidden email]
Subject: Re: [Enthought-Dev] which List for a logger?

 

Boiteux, Benoit wrote:

Hello,

 

I created a basic logger for custom purpose, and I used the following Enthought controls (similar to your Tabular Editor demo) :

A HasTraits class with column items (Str) : ItemsClass

A TabularAdapter to display the listview

And a main class (HasTraits) with a view that contains a List (ItemsClass) displayed with editor = myTabularAdapter.

Then a timer add data to the list (lot of data and fastly).

 

Unfortunately, the display blinks and it’s really not comfortable.

 

Could you advise me on which editor I would have to use, and maybe a better way to update data to avoid this blink effect ? (in 1 sentence: what’s the best solution to create a logger?)


If you look at the LoggerPlugin and LoggerView classes in EnthoughtBase, you'll see that we use a TabularEditor. We used to have issues with flashing, but as it is implemented, the flashing is now minimal (or was the last time I used it heavily).

You should be able to cut and paste most of the LoggerView code to reuse it. It is written to be used as an Envisage plugin, though 80% of the code could be reused outside of an Envisage app.

Bryce

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: which List for a logger?

Boiteux, Benoit
In reply to this post by bryce hendrix-2

Hi Bryce,

 

I had a look at LoggerView, and I have similar code.

 

My code has a thread that get log messages, and for each new log message, I update a List(LogMsg) (the trait that uses tabulareditor) by appending new LogMsg item to it.

I can receive 100 to 1000m essage/s. Do you think it’s too much for this control ?

 

And then, how do you force the table to focus on the last added item ?

 

Thanks

benoit

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of bryce hendrix
Sent: Wednesday, March 10, 2010 6:28 PM
To: [hidden email]
Subject: Re: [Enthought-Dev] which List for a logger?

 

Boiteux, Benoit wrote:

Hello,

 

I created a basic logger for custom purpose, and I used the following Enthought controls (similar to your Tabular Editor demo) :

A HasTraits class with column items (Str) : ItemsClass

A TabularAdapter to display the listview

And a main class (HasTraits) with a view that contains a List (ItemsClass) displayed with editor = myTabularAdapter.

Then a timer add data to the list (lot of data and fastly).

 

Unfortunately, the display blinks and it’s really not comfortable.

 

Could you advise me on which editor I would have to use, and maybe a better way to update data to avoid this blink effect ? (in 1 sentence: what’s the best solution to create a logger?)


If you look at the LoggerPlugin and LoggerView classes in EnthoughtBase, you'll see that we use a TabularEditor. We used to have issues with flashing, but as it is implemented, the flashing is now minimal (or was the last time I used it heavily).

You should be able to cut and paste most of the LoggerView code to reuse it. It is written to be used as an Envisage plugin, though 80% of the code could be reused outside of an Envisage app.

Bryce

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: which List for a logger?

bryce hendrix-2
Boiteux, Benoit wrote:

Hi Bryce,

 

I had a look at LoggerView, and I have similar code.

 

My code has a thread that get log messages, and for each new log message, I update a List(LogMsg) (the trait that uses tabulareditor) by appending new LogMsg item to it.

I can receive 100 to 1000m essage/s. Do you think it’s too much for this control ?


No, it should be okay. The wx version of the TabularEditor buffers to some small factor of the number of visible rows, so the UI should remain pretty smooth. I'm guessing the qt control does something similar.

 

And then, how do you force the table to focus on the last added item ?


You'll have to write some code specific to the backend (wx or Qt) and use a handler. Something like this should get you to close (none of it is tested and may contain errors):


class MyHandler(Handler):

    def object_update_visible_row_changed(self, info):
        # look for your control in info.ui, get the row and call SetFocus on it
        return

class MyView(HasTraits):
    items = List()
    update_visible_row_changed = Event

    def _items_changed(self):
        self.update_visible_row_changed = True

Bryce

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: which List for a logger?

Boiteux, Benoit

Hi,

 

The focus cannot be done directly in the TabularAdapter?

 

Benoit

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of bryce hendrix
Sent: Wednesday, March 17, 2010 4:57 PM
To: [hidden email]
Subject: Re: [Enthought-Dev] which List for a logger?

 

Boiteux, Benoit wrote:

Hi Bryce,

 

I had a look at LoggerView, and I have similar code.

 

My code has a thread that get log messages, and for each new log message, I update a List(LogMsg) (the trait that uses tabulareditor) by appending new LogMsg item to it.

I can receive 100 to 1000m essage/s. Do you think it’s too much for this control ?


No, it should be okay. The wx version of the TabularEditor buffers to some small factor of the number of visible rows, so the UI should remain pretty smooth. I'm guessing the qt control does something similar.


 

And then, how do you force the table to focus on the last added item ?


You'll have to write some code specific to the backend (wx or Qt) and use a handler. Something like this should get you to close (none of it is tested and may contain errors):


class MyHandler(Handler):

    def object_update_visible_row_changed(self, info):
        # look for your control in info.ui, get the row and call SetFocus on it
        return

class MyView(HasTraits):
    items = List()
    update_visible_row_changed = Event

    def _items_changed(self):
        self.update_visible_row_changed = True

Bryce

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: which List for a logger?

bryce hendrix-2
Boiteux, Benoit wrote:

Hi,

 

The focus cannot be done directly in the TabularAdapter?

 

Benoit



You can set the selected row or cell, but I don't think doing so will set the focus. Here is the code which is triggered when the selected row changes in wxListCtrl:

    def _selected_row_changed ( self, old, new ):
        """ Handles the editor's 'selected_index' trait being changed.
        """
        if not self._no_update:
            if new < 0:
                if old >= 0:
                    self.control.SetItemState( old, 0, wx.LIST_STATE_SELECTED )
            else:
                self.control.SetItemState( new, wx.LIST_STATE_SELECTED,
                                                wx.LIST_STATE_SELECTED )


You could subclass the wxListCtrl and TabularEditor to do something different, but using a Handler may be a bit less code. If you choose to go the subclassing route, TabularEditor should only need its __init__ method subclassed. You can copy the original and change the name of the control to the one you created as a subclass of wxListCtrl.

Bryce


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev