Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    sanjeev zerocode
    @sanjeev_zero_twitter
    can someone point me in the right direction
    Milad Alizadeh
    @mi-lad_gitlab
    Quick question about Display Attributes. So the idea of AttrMap is to change one set of attributes to others but this suggests that widgets can own Attributes in the first place. The only widget I see that has this is Text but how does this work for other widgets?
    2 replies
    So let's say I have a Columns container with a bunch of Text widget. I can do a attr = AttrMap(my_column, "some_colour") on the container to change the colour of everything in the column to a colour. At this point does my column have any attributes of itself?
    If sometime later I want to change the colour of my columns should I do attr2 = AttrMap(my_column, "some_other_colour") ? Or call set_attr_map on attr instance?
    If its the latter then do I want the new mapping to be {None: "some_other_colour"} or {"some_colour": "some_other_colour"}
    ?
    Ian Ward
    @wardi
    @mi-lad_gitlab you can wrap a widget with AttrMap and then put that into Columns, sure. If you put the Columns into another AttrMap then the column with the first AttrMap would be an example of a non-text widget that has attributes "already"
    1 reply
    Milad Alizadeh
    @mi-lad_gitlab
    Another question. I have the snippet below and I was expecting the Padding to put the Column widget in the middle of the screen but it remains left-aligned
    t1 = urwid.LineBox(urwid.Text("One"))
    t2 = urwid.LineBox(urwid.Text("Two"))
    col = urwid.Columns([(10, t1), (10, t2)])
    w = urwid.Padding(col, align="center")
    fill = urwid.Filler(w, "top")
    
    loop = urwid.MainLoop(fill)
    loop.run()
    which gives
    image.png
    Explicitly providing left to Padding does work but can't get it to work automatically with align
    Isn't Padding what I'd want to center-align a Column widget?
    Milad Alizadeh
    @mi-lad_gitlab
    and hopefully a simpler question. I want to have a pane where I can watch the output of a shell command into (something like tail -F log.txt). Isurwid.Terminal` the widget I want or is that an overkill? I only need it to be read-only so I thought I might be able to get away with something simpler
    Neil Pilgrim
    @neiljp
    What's the status of .pack(...) implementation? A contributor made a PR which used it, assuming it worked for many widgets, but apparently it's a work in progress? There doesn't seem to be an urwid issue tracking this, so I wanted to check if this was on the radar for upcoming work or if it had slipped through the net - and if there was an issue in urwid then we'd have something to refer to :+1:
    Milad Alizadeh
    @mi-lad_gitlab
    Is it possible to have handlers for when a widget loses focus? I have a SimpleFocusListWalker inside a ListBox and I want the last selected item in the list to remain highlighted even when the ListBox is not in focus anymore and I'm not sure how to go about that
    Ian Ward
    @wardi
    @mi-lad_gitlab you could put the listbox in a WidgetPlaceholder subclass that forces its child to render with focus=True always by overriding the render method.
    Milad Alizadeh
    @mi-lad_gitlab
    that interesting! Thanks for the tip
    Milad Alizadeh
    @mi-lad_gitlab
    Noob question. How can I move the focus to a particular widget? I want to define a keypress event on the top-level widget to move the focus to a particular Edit widget.
    Ian Ward
    @wardi
    set_focus_path IIRC
    Milad Alizadeh
    @mi-lad_gitlab
    Thanks Ian, that's what I needed
    :thumbsup:
    although I think that function gets me as far as the container
    so I had to also set the focus_position of the final container as well
    Milad Alizadeh
    @mi-lad_gitlab
    Thanks for helping with all my questions @wardi and @tonycpsu ! My project is almost ready to be released publicly. I'm pretty happy with how it turned out. urwid is cool
    Viktor Astakhov
    @tokilone
    Screenshot at 2020-08-16 15-34-39.png
    Is there a way to make this structure flat? I wanna have a tree for every user (nodes under SEARCH RESULTS). Should I use Pile for that? How would the widget structure look like?
    class Browser:
        def __init__(self, search_replies):
            self.top_node = BrowserParentNode(search_replies, key='SEARCH RESULTS')
            self.list_box = urwid.TreeListBox(urwid.TreeWalker(self.top_node))
            self.view = urwid.Frame(
                self.list_box,
            )
    
        def main(self):
            loop = asyncio.get_event_loop()
    
            main_loop = urwid.MainLoop(
                self.view,
                event_loop=urwid.AsyncioEventLoop(
                    loop=loop,
                ),
                unhandled_input=self.unhandled_input
            )
            main_loop.run()
    
        def unhandled_input(self, key):
            if key in ('q', 'Q'):
                raise urwid.ExitMainLoop
    I want to get rid of a SEARCH RESULTS node, basically.
    Neil Pilgrim
    @neiljp
    Has anyone used valid_char much? I'm experimenting with it, but it's a little frustrating needing to work around the urwid expanded forms of some keys. That is, since sometimes the 'char' can be eg. backspace whereas other times it'll be a standard unicode character.
    christiaandelrio
    @christiaandelrio
    Hey, I’m a begginer on using Urwid and I just don’t understand the tutorial of the official page. On my program I tríes
    *I tried to use a for loop and it always says syntax error
    do u know if urwid doesn’t support for loops?
    Neil Pilgrim
    @neiljp
    Do you have the code somewhere? Could you paste a small amount here? You can use backticks to quote code, or three (optionally with 'python' after) for a multiline block.
    TH-eMundo
    @TH-eMundo
    Hi! I'd like to change the height of a BoxAdapter dynamically (not at construction time) and it seems there is a property "height" which is also writable, but there is nothing about it in the documentation. Is that property safe to use?
    Cielo
    @cielong
    After I raise ExitMainLoop(), it seems it does not restore the terminal to the original state. So when I run the next command, such as git diff, I can still see last page of my tui mixed in the diff page. Is there any reason for that?
    Pm Ma
    @pmma1312
    Hello guys, does anyone know if it's possible to run multiple commands within the urwid Terminal widget? (using the command plus && doesn't seem to work)
    elenril
    @elenril
    hi, I've now run into trouble with Pile deciding whether it's selectable only when it is modified
    which breaks when the widget in it is a placeholder that is initially not selectable, but is later swapped for a selectable one
    should I just initialize it with a selectable placeholder? or should Pile stop caching _selectable and instead always delegate it when it's called?
    Ian Ward
    @wardi
    @elenril open a PR for discussion? For an immediate fix in your code base you can subclass Pile and override selectable to get the behaviour you want
    elenril
    @elenril
    my current workaround is using SelectableIcon('') as the initial placeholder child
    which works, but it was a bit nontrivial to figure out
    SquirrelCZE
    @SquirrelCZE
    Hi folks, I am new to urwid. I am trying to write code that uses ListBox and focuses on the last item in the ListWalker
    list_widgets = urwid.SimpleListWalker([])
    ...
    list_widgets.set_focus(list_widgets.positions(reverse=True)[0])
    but this shows only the item before the last one
    what am I doin wrong?
    (the hiearchy is Frame -> ListBox -> SImpleListWalker and everything is in default settings)
    SquirrelCZE
    @SquirrelCZE
    oh, mine fail, that was the last item actually, it's just longer than screen
    woky
    @woky
    Hello. Some time ago I asked about mnemonics in Urwid on StackOverflow. The question, quite short and with images, is here: https://stackoverflow.com/questions/61969402/urwid-button-mnemonic-keys. I haven't received any reply there. Is this feature available in Urwid under a different name?