Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    voidtrance
    @voidtrance
    @neiljp I played with the loop.widget but that doesn't really do what I wanted. I guess what I meant is that I want something line Gnome's Dialog boxes that block the main application while the dialog is up. My guess is that they accomplish this with a separate event loop. Does zulip-terminal's implementation do the main application blocking that I am trying to describe?
    Neil Pilgrim
    @neiljp
    It seems to work for us, yes.
    voidtrance
    @voidtrance
    So, if I have a function calling controller.show_pop_up(), controller.show_pop_up() will not return until the popup is destroyed?
    Neil Pilgrim
    @neiljp
    I've not tested that directly, but the active UI becomes the "top" widget.
    voidtrance
    @voidtrance
    Yes, I can replicate the "active UI" behavior - only the popup is getting keystrokes. However, the "caller" is not blocked, which prevents a normal dialog sematics and would require some fancy signalling/callbacks.
    Mr-Mime
    @Mr-Mime_gitlab

    Hi all :)
    I am a bit lost, trying to get a key press for the following widget.
    In all previous widgets I had some kind of walkableList or Edit field, but this one only has "displaying" widgets.
    If I press ESC or "b" nothing happens.
    If I add an urwid.Edit in the msg_pile it works (pressing "b" adds a line).

    import urwid
    
    class TestWidget(urwid.WidgetWrap):
        def __init__(self):
            msg_pile =  urwid.Pile([urwid.Text("Connecting to emonio...")])
    
            content = urwid.BoxAdapter(urwid.LineBox(urwid.Filler(msg_pile, height="flow", valign="top"), title="Preparing"), 19)
            key_hints = urwid.Text("ESC - quit | b - back", align="center")
    
            self._w = urwid.Pile([content, key_hints])
            self.run()
    
        def run(self):
            self.add_new_line("Adding a test line...")
    
        def keypress(self, size, key):
            if key == "esc":
                raise urwid.ExitMainLoop()
            elif key == "b":
                self.add_new_line("Added a line via keypress()")
    
        def add_new_line(self, text):
            self._w.widget_list[0].original_widget.original_widget.original_widget.widget_list.append(urwid.Text(text))
    
    widget = urwid.Padding(urwid.Filler(TestWidget(), valign="top", height="flow", top=3), align="center", width=47)
    loop = urwid.MainLoop(widget)
    loop.run()

    I am thinking that it is because it has no widget, which reacts to any key, so no key event is passed all the way up to my TestWidget.

    PS: I am happy for each hint/ suggestion for improvement, as I am relatively new to urwid and still learning ;)

    mimansa-dev
    @mimansa-dev
    When I dynamically add more radio widgets to a group then should the display refresh automatically to show the newly added radio buttons
    ?
    r_button = urwid.RadioButton(g_radio_button_group, 'Hi', False, on_state_change=on_mode_button)
    locn_list_options = urwid.GridFlow(g_radio_button_group, 15, 3, 1, 'left')
    substitute_screen_pile = urwid.Pile([locn_list_options])
    For some reason, the only radio button is the one that i added in the beginning even though the program dynamically adds some more to g_radio_button_group (I confirmed it by logging the g_radio_button_group variable to file). What could be wrong?
    mimansa-dev
    @mimansa-dev
    I have created a simple minimum program to explain my error. The code is at https://pastebin.com/naK29hhR
    Anything can be entered on the first two input prompts to continue with the program flow. As we can see that on line 114 I am adding additional radio buttons to the group but they don't show up when we run the program and pass through the first two screens. Only the very first radio button with the text Hi shows up. Please guide.
    7 replies
    Mr-Mime
    @Mr-Mime_gitlab

    Hi all :)
    I am a bit lost, trying to get a key press for the following widget.
    In all previous widgets I had some kind of walkableList or Edit field, but this one only has "displaying" widgets.
    If I press ESC or "b" nothing happens.
    If I add an urwid.Edit in the msg_pile it works (pressing "b" adds a line).

    To answer my own question, I once again read the docs.
    This time I understood, that _selectable needs to be true, so that a keypress will be handled.

    So I set _selectable = True to for my widget and now it works :)

    mimansa-dev
    @mimansa-dev
    Could someone please help me with a urwid script? The code is at https://pastebin.com/zFzqTuGE
    I get an error AttributeError: 'ListBox' object has no attribute 'rows' and not sure why. Cannot seem to figure out. To run this script enter any value on the input field prompt.
    Niteesh Babu G S
    @gs-niteesh
    If I have to copy-paste multiline text in Edit widget what will be the right option?
    I tried using the Edit widget with multiline option, but then If I hit enter it adds a new line to the text inside of pushing the text
    If I disable the multiline option, on pasting the text on a new line it updates it.
    voidtrance
    @voidtrance
    If I have a ListBox of Buttons, the highlighted button decoration disappears when I change focus to a different widget. Is there a way to keep a button highlighted when the focus is on a different widget?
    raj86in
    @raj86in
    Hi I am new to urwid would appreciate any help. For our linux system we recently updated urwid library from 1.2.1 to 2.1.2 and python 2.7.9 to 3.7.8 . After that the output of the program is getting printed on serial port instead of LCD which was working fine before the updates. Is there any configuration/setup I am missing in urwid?
    milad.a
    @milad.a:matrix.org
    [m]
    are there good examples of how people handle prints in a urwid application for debugging purposes? I want the gui thread to halt when I call print in another thread otherwise I don't actually see the prints
    1 reply
    SquirrelCZE
    @SquirrelCZE
    hi folks, I am misunderstanding something, I have a 'Columns' widget of my custom widgets that are _selectable
    when I press left/right arrow the columns correctly changes the focus between the widgets
    the problem is: I try to change the way it renders if it is in focus by changing 'div_char' of Divider present there, but it is never redrawn
    any tips?
    the widget looks like this https://paste.vpsfree.cz/4JF78nAj/
    in the render() I try to change the way it renders by changing the char of divider, but no effect is visible
    SquirrelCZE
    @SquirrelCZE
    oh now I see it, I have to invalidate the divider
    SquirrelCZE
    @SquirrelCZE
    so, one more question: how to properly clear columns?
    I have a ListBox that contains three Columns widgets (effectively making thre rows of widgest on the screen)
    when event happens, I content.clear() all the columns and generate new set of widgets
    however, if one is not filled again and is empty, I get this error:
    IndexError: No focus_position, Columns is empty
    any ideas/
    ?
    Cielo
    @cielong
    Is there any example of how to properly use the event loop? And is it possible to add a callback (not watching a file descriptor and then trigger) after the main loop starts and in general how do one trigger data reload using the event loop?
    Dejan Lekic
    @dejlek_twitter
    Is there a generic implementation of a dialog that can show arbitrary form?
    Kim Albertsson
    @ashlaban
    Hi, I'm looking to control the color of individual characters in a text. What would be the best way to do this; Where in the manual should I be looking?
    It'd be something like text_widget.set_text([("red", "R"), ("green", "G"), ("blue", "B")])
    Robert Butler
    @lighth7015
    so I'm trying to write something similar to Asterisk's menuselect
    menuselect
    tonycpsu
    @tonycpsu
    @lighth7015 ...so do you have a question?
    Robert Butler
    @lighth7015
    @tonycpsu sorry! I keep being distracted by work. yeah, I'm wondering what the best way to handle the colored buttons with the shadow and the the multiline info panel next to the two buttons
    there lol
    Orpheus
    @orpheuslummis:one.ems.host
    [m]
    Hi! Is there a recommended (example) implementation for a table widget?
    tonycpsu
    @tonycpsu

    lookatme has a pretty clean table widget that could be a nice starting point.

    I developed a table widget as part of pawid, but it's not the cleanest code in the world and has more dependencies, so maybe not a great example to start from.

    Orpheus
    @orpheuslummis:one.ems.host
    [m]
    thanks @tonycpsu i really appreciate your input!
    adb
    @adbenitez:matrix.org
    [m]
    hi, is there a urwid component or recipe for an recyclerview-like list? (big list of items/messages in a chat app and I want to load them dynamically while scrolling) any tips or pointers to the right path? thanks in advance I like urwid great work!
    Ian Ward
    @wardi
    @adbenitez:matrix.org sounds like you want ListBox with a custom list walker
    1 reply
    greg-d128
    @greg-d128
    Hi. Is there a list of all the signals available for each component? Is there a documentation for how to create custom signals?
    2 replies
    N. Max Pierson
    @nomaxpi

    Hi All. I'm having a problem getting to edit widget text inside of a WidgetWrap and here's what the get_focus_widgets() function returns ...

    [<Padding selectable box/flow widget <Columns selectable box/flow widget> left=2 right=2>, <Columns selectable box/flow widget>, <AttrMap selectable flow widget <Edit selectable flow widget 'Text Goes Here' edit_pos=14> attr_map={None: 'focus options'}>]

    and here's the get_focus_path() function ...
    [2, 0, 1]

    self._w['body'].focus[1].edit_text --> this returns the following ...
    TypeError: 'Padding' object does not support indexing

    How can I access the edit widget text with self._w?