[Urwid] EPICS in urwid

Krempasky Juraj juraj.krempasky at psi.ch
Mon Jul 26 10:16:48 EDT 2010


Dear Ian, 

Thank you for your suggestions. The idea to subclass urwid.Text came to
me from the FloatEdit example which does subclass urwid.Edit. In order
to set a float value the FloatEdit uses AttrWrap. However, I cannot
figure out how the AttrWrap manage to set new value since FloatEdit
implementation does not seem to care about AttrWrap at all. 

Yes, I need many of these and customized widgets is the right way to go.
I'd be happy for some example if anybody came across a similar situation
and needed to subclass WidgetWrap to display something from a callback. 

Thanks in advance, best regards

Juraj Krempasky

-----Original Message-----
From: urwid-bounces at lists.excess.org
[mailto:urwid-bounces at lists.excess.org] On Behalf Of Ian Ward
Sent: Montag, 26. Juli 2010 15:38
To: urwid at lists.excess.org
Subject: Re: [Urwid] EPICS in urwid

Hello, sorry for the slow reply

Krempasky Juraj wrote on 2010-07-14 10:08:
> Hello,
> 
> I am newbie to urwid and I am looking for a solution to integrate 
> urwid ui into EPICS large scale instrumentation control.
> 
> In the simplest case the point is to make
> urwid.AttrMap(urwid.Text(value)) update from EPICS callback mechanisms

> that understand the alarm state and value to be changed in ui. First 
> question I have is that one could access the text and its color 
> attributes via AttrMap base_widget. Is there some other solution?

If you are creating many of these you might want to create a custom
widget.  Subclass from WidgetWrap and use the AttrMap(Text) as the
display widget.  This lets you hide the implementation, and lets you
define your own interface without potential conflicts with AttrMap.

> Second question: building up the ui as
> Frame->ListBox->(Columns,Pile,Text) is pretty straightforward. 
> Frame->ListBox->However,
> is there some way to insert into the
> Frame->ListBox->(Columns,Pile,Text) ui configuration also the EPICS
> callback mechanism such that the urwid.MainLoop will not complain?
> 
> In principle I need to create an object like
> 
> class epicsText(epics, urwid.Text):
>     def __init__(self, epicsChannel):
>            epics.__init__(self)
>            self.search_and_connect(epicsChannel, self.connectCB)
>            urwid.AttrMap(urwid.Text(epicsChannel))
>            ...
> 
>     def connectCB(self,...)
>            .....
> 
>     def valueCB(self,...):
>            ...set text attributes
> 
> directly in Frame->ListBox->(Columns,Pile,EpicsText) such that the 
> listbox would initialize the EPICS part correctly and urwid.MainLoop 
> will stay happy.

MainLoop staying happy is the tricky part at the moment.  You need to
call loop.draw_screen() when the screen needs to be updated.  Either
call it as part of the callback (not appropriate for a widget method) or
have set up a timer to update the screen (if redrawing on every callback
would be too costly)

Ian

> Looking forward for suggestions, best regards.
> 
> Juraj Krempasky

_______________________________________________
Urwid mailing list
Urwid at lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid



More information about the Urwid mailing list