Christian Scharkus | 2 Jan 2009 02:58

ä,ö,ü and ß again

Hi :)

I've already send a mail because of ä,ö,ü and ß in Input-fields but now I think I have isolated something about that in my own code:

    def onKeyPressed(self, size, key):
        KeckzBaseIOTab.onKeyPressed(self, size, key)
        if key == 'tab':
            input = self.Input.get_edit_text()
            if len(input) is not 0:
                input,crap=input[:self.Input.edit_pos].split(),input[self.Input.edit_pos:]
                nick = input.pop().lower()
                solutions=[]
                for i in self.completion:
                    if nick in str(i[:len(nick)]).lower():
                        solutions.append(i)
                if len(solutions) != 0 and len(solutions) != 1:
                    self.addLine(" ".join(solutions))
                elif len(solutions) is not 0:
                    input.append(solutions[0])
                    if len(input) is not 1:
                        self.Input.set_edit_text(" ".join(input)+" "+crap)
                    else:
                        self.Input.set_edit_text(" ".join(input)+", "+crap)
                    self.Input.set_edit_pos(len(self.Input.get_edit_text())-len(crap))
        else:
            self.keypress(size, key)

This snippet is used to complete nicknames in the inputfield and works fine except you type some unicode-letters like ä,ö,ü and ß after using the nickcompletion.
Any ideas about how I could circumvent this?

Thanks
Christian

_______________________________________________
Urwid mailing list
Urwid <at> lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
Ian Ward | 2 Jan 2009 05:08
Favicon
Gravatar

Re: ä,ö,ü and ß again

Christian Scharkus wrote:
> Hi :)
>
> I've already send a mail because of ä,ö,ü and ß in Input-fields but 
> now I think I have isolated something about that in my own code:
>
>     def onKeyPressed(self, size, key):
>         KeckzBaseIOTab.onKeyPressed(self, size, key)
>         if key == 'tab':
>             input = self.Input.get_edit_text()
>             if len(input) is not 0:
>                 
> input,crap=input[:self.Input.edit_pos].split(),input[self.Input.edit_pos:]
>                 nick = input.pop().lower()
>                 solutions=[]
>                 for i in self.completion:
>                     if nick in str(i[:len(nick)]).lower():
>                         solutions.append(i)
>                 if len(solutions) != 0 and len(solutions) != 1:
>                     self.addLine(" ".join(solutions))
>                 elif len(solutions) is not 0:
>                     input.append(solutions[0])
>                     if len(input) is not 1:
>                         self.Input.set_edit_text(" ".join(input)+" "+crap)
>                     else:
>                         self.Input.set_edit_text(" ".join(input)+", 
> "+crap)
>                     
> self.Input.set_edit_pos(len(self.Input.get_edit_text())-len(crap))
>         else:
>             self.keypress(size, key)
>
> This snippet is used to complete nicknames in the inputfield and works 
> fine except you type some unicode-letters like ä,ö,ü and ß after using 
> the nickcompletion.
> Any ideas about how I could circumvent this?
I would first suggest that you use only unicode strings in your 
application.  Urwid accepts either regular strings or unicode strings, 
but that's mostly just a historical artifact.  If all your strings are 
unicode you shouldn't have problems with concatenation.

Ian
Ian Ward | 17 Jan 2009 01:42
Favicon
Gravatar

Re: Installing 0.9.8.3 with Python 2.6 fails

Friedrich Weber wrote:
> Joern Koerner <koerner <at> in.tu-clausthal.de> writes:
> 
>> Hi again!
>>
>> I tried to setup the current urwid within Python 2.6, which fails with the 
>> following error:
>>
>> $python setup.py install
>> Traceback (most recent call last):
>>   File "setup.py", line 29, in <module>
>>     import urwid
>>   File "/root/urwid/urwid/__init__.py", line 49, in <module>
>>     from listbox import *
>>   File "/root/urwid/urwid/listbox.py", line 85, in <module>
>>     class SimpleListWalker(MonitoredList, ListWalker):
>>   File "/usr/lib/python2.6/abc.py", line 76, in __new__
>>     cls = super(ABCMeta, mcls).__new__(mcls, name, bases, namespace)
>> TypeError: Error when calling the metaclass bases
>>     metaclass conflict: the metaclass of a derived class must be a (non-
>> strict) subclass of the metaclasses of all its bases
>>
> 
> Hi, 
> 
> I had the same problem and fixed it by deriving MonitoredList from list, not
> UserList. Additionally, I added some __hash__ methods.
> 
> All *seems* to work (did only test a few examples) and should also work with
> python 2.5.
> 
> The patch: http://paste.pocoo.org/show/90455/
> 
> Cheers,
> 
> Friedrich

Looks like it works with 2.3 as well. I have committed your changes here:
https://excess.org/hg/urwid/rev/dd731ccf570a

Ian
Christian Scharkus | 17 Jan 2009 19:09

Suspend Urwid-Interface and Key-Combos with return?

Hi folks.
It's time for some more questions I think :D

I would like to know if there is any possibility to suspend the curses_display of urwid to start something like links from my app to show websites etc.

Second it would be nice to have keycombos given from get_input() like "shift enter", "ctrl enter" because I would like to be able to make some newlines in the chat-client I currently write.

Thanks at this point for any ideas you may come up with :)

greetings
Christian Scharkus

_______________________________________________
Urwid mailing list
Urwid <at> lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
Ian Ward | 18 Jan 2009 03:45
Favicon
Gravatar

Re: Suspend Urwid-Interface and Key-Combos with return?

Christian Scharkus wrote:
> Hi folks.
> It's time for some more questions I think :D
> 
> I would like to know if there is any possibility to suspend the 
> curses_display of urwid to start something like links from my app to 
> show websites etc.

Yes, you can use curses_display.Screen.stop() and start()

> Second it would be nice to have keycombos given from get_input() like 
> "shift enter", "ctrl enter" because I would like to be able to make some 
> newlines in the chat-client I currently write.

I don't think a regular terminal app can detect shift-enter and 
ctrl-enter.  When I run "input_test.py" I see only a single "10" value 
from the terminal when I press enter regardless of shift and ctrl state.

It would be possible to detect the shift and ctrl state with some 
trickery like connecting to the X server where the app is running, but 
Urwid doesn't try doing that at the moment.

Ian
Ian Ward | 19 Jan 2009 18:10
Favicon
Gravatar

Urwid High Colour Support

(from http://excess.org/article/2009/01/urwid-high-colour-support/ )

The latest [development version of Urwid][1]'s `raw_display` module now 
supports 88 and 256-colour modes. Colour modes now also support 
`underline`, `standout`, and `bold` (separate from bright colours when 
available.)

The default high colour palettes include a colour cube (4x4x4 or 6x6x6) 
and a gray scale (8 or 24 values.)  I made the assumption that most 
application developers won't care whether a user has 88 or 256 colours, 
just that they have more than the usual 16.  This led me to the 
following naming scheme for high colours:

  * `#000` .. `#fff` for colours in the colour-cube
  * `g0` ... `g100` for values in the gray scale (`g#00` .. `g#ff` also 
work)
  * `h0` ... `h87` or `h255` for a precise colour

For colour cube and gray scale values Urwid will choose the closest 
match available in the high colour mode that is active.  The 
[palette_test.py][2] application shows all the available values in each 
mode.

When creating a palette the high-colour foreground and background 
settings now follow the monochrome setting.  The `standout`, `underline` 
and `bold` settings may now be appended to the normal and high-colour 
foreground colours with a comma, eg: `'light gray,underline'`.  The 
monochrome settings used to have to be in a tuple, but now a 
comma-separated string will work as well: `('underline','bold')` becomes 
`'underline,bold'`.

[1]: https://excess.org/hg/urwid/
[2]: https://excess.org/hg/urwid/file/a5314d585db4/palette_test.py
Christian Scharkus | 20 Jan 2009 00:32

Re: Suspend Urwid-Interface and Key-Combos with return?

Hi Ian.

I tried to call stop() and 20 seconds afterwards start() but stop()
seems to have no effect at all and start() drops an AssertionError.
I use urwid-0.9.8.3hg149 with twisted as mainloop called with
run_wrapper(). I hope you can help me.

Christian Scharkus

2009/1/18 Ian Ward <ian <at> excess.org>:
> Christian Scharkus wrote:
>> Hi folks.
>> It's time for some more questions I think :D
>>
>> I would like to know if there is any possibility to suspend the
>> curses_display of urwid to start something like links from my app to
>> show websites etc.
>
> Yes, you can use curses_display.Screen.stop() and start()
>
>> Second it would be nice to have keycombos given from get_input() like
>> "shift enter", "ctrl enter" because I would like to be able to make some
>> newlines in the chat-client I currently write.
>
> I don't think a regular terminal app can detect shift-enter and
> ctrl-enter.  When I run "input_test.py" I see only a single "10" value
> from the terminal when I press enter regardless of shift and ctrl state.
>
> It would be possible to detect the shift and ctrl state with some
> trickery like connecting to the X server where the app is running, but
> Urwid doesn't try doing that at the moment.
>
> Ian
>
>
> _______________________________________________
> Urwid mailing list
> Urwid <at> lists.excess.org
> http://lists.excess.org/mailman/listinfo/urwid
>
>
Ian Ward | 20 Jan 2009 03:09
Favicon
Gravatar

Re: Suspend Urwid-Interface and Key-Combos with return?

Thanks Christian, it looks like a bug.  Try the attached patch.

Ian

Christian Scharkus wrote:
> Hi Ian.
> 
> I tried to call stop() and 20 seconds afterwards start() but stop()
> seems to have no effect at all and start() drops an AssertionError.
> I use urwid-0.9.8.3hg149 with twisted as mainloop called with
> run_wrapper(). I hope you can help me.
> 
> Christian Scharkus
> 
> 2009/1/18 Ian Ward <ian <at> excess.org>:
>> Christian Scharkus wrote:
>>> Hi folks.
>>> It's time for some more questions I think :D
>>>
>>> I would like to know if there is any possibility to suspend the
>>> curses_display of urwid to start something like links from my app to
>>> show websites etc.
>> Yes, you can use curses_display.Screen.stop() and start()
>>
>>> Second it would be nice to have keycombos given from get_input() like
>>> "shift enter", "ctrl enter" because I would like to be able to make some
>>> newlines in the chat-client I currently write.
>> I don't think a regular terminal app can detect shift-enter and
>> ctrl-enter.  When I run "input_test.py" I see only a single "10" value
>> from the terminal when I press enter regardless of shift and ctrl state.
>>
>> It would be possible to detect the shift and ctrl state with some
>> trickery like connecting to the X server where the app is running, but
>> Urwid doesn't try doing that at the moment.
>>
>> Ian
>>
>>
>> _______________________________________________
>> Urwid mailing list
>> Urwid <at> lists.excess.org
>> http://lists.excess.org/mailman/listinfo/urwid
>>
>>
> 
> 
> _______________________________________________
> Urwid mailing list
> Urwid <at> lists.excess.org
> http://lists.excess.org/mailman/listinfo/urwid
> 

Attachment (curses-stop-fix.patch): text/x-diff, 382 bytes
_______________________________________________
Urwid mailing list
Urwid <at> lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
Leif Theden | 20 Jan 2009 13:55
Picon
Gravatar

animation and widgets

Greetings!  I am a first time user of urwid.  I was wondering if
anyone has attempted animation of widgets before?

I have looked at the graph.py example, and I don't think that that is
what exactly I am looking for.

I have an individual widget that displays a dungeon map from a game,
and I would like to have the rendering function animated, and possibly
animated characters while the widget is being viewed.

My current implimentation simply diables caching and renders the
canvas over and over, creating animation.  It works, but since it is
grossly ineffecient, I wanted to ask people who may know a better way.

Sorry, I don't have the source to post.

Cheers!
Ian Ward | 20 Jan 2009 17:00
Favicon
Gravatar

Re: animation and widgets

Leif Theden wrote:
> Greetings!  I am a first time user of urwid.  I was wondering if
> anyone has attempted animation of widgets before?
> 
> I have looked at the graph.py example, and I don't think that that is
> what exactly I am looking for.
> 
> I have an individual widget that displays a dungeon map from a game,
> and I would like to have the rendering function animated, and possibly
> animated characters while the widget is being viewed.
> 
> My current implimentation simply diables caching and renders the
> canvas over and over, creating animation.  It works, but since it is
> grossly ineffecient, I wanted to ask people who may know a better way.

Animation is just changing the contents widgets at regular intervals.
If you have a widget that changes say, every 0.5 seconds, you could set
max_wait to 0.25 with screen.set_input_timeouts() and each time through
your loop you calculate which state the widget should be in based on the
current time.  If the widget is changed make sure it calls its
self._invalidate() method.

This way the widget will still use its cache and not update when it
doesn't need to, and you can easily have many widgets animating at
different rates.

Ian

Gmane