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?
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 ;)
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])
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 anurwid.Edit
in themsg_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 :)
print
s 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
text_widget.set_text([("red", "R"), ("green", "G"), ("blue", "B")])
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.
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?