urwid

How can I create an asynchronous program with urwid and asyncio?

☆樱花仙子☆ 提交于 2021-01-29 04:23:17
问题 I want to build a chatroom with aiortc. Frist of all, I want to build a mockup with urwid as cli and asyncio. The urwid part is already running fine, user input is possible. I know want to run a coroutine that generates random text and works as chat clients texting in that chatroom. I have tried to run my urwid function with the mainloop as an asyncio coroutine but without success. I don't know how to integrate an asynchronous function into my urwid mainloop. def unhandled(key): """ functin

Pulling content from a selected item in a ListBox (urwid)

情到浓时终转凉″ 提交于 2021-01-28 12:20:24
问题 I'm making a ListBox in urwid where each item is a URL pulled from a list of URLs. When an item is selected and ENTER is clicked, I'd like to pull the URL and open it in the browser. Here's my code so far: class SelectableText(urwid.Text): def selectable(self): return True def keypress(self, size, key): return key def handle_input(input): if input == "": # Open link focus_widget, idx = content_container.get_focus() # TODO: Open link from focus_widget elif input in ('q', 'Q'): # Quit raise

make child widget get the input keypress with urwid on python

↘锁芯ラ 提交于 2021-01-01 09:12:10
问题 I can make a widget inside another widget, as example an urwid.Frame father could have as body an urwid.Pile widget as child. In this situation, the father should process some input keys when the child have to treat some specific others keys. Like in this functional example: import urwid class NewFrame(urwid.Frame): def __init__(self, givenBody): super().__init__(urwid.Filler(givenBody, "top")) def keypress(self, size, key): if key in ('f'): print("We are in NewFrame object") return super

make child widget get the input keypress with urwid on python

被刻印的时光 ゝ 提交于 2021-01-01 09:09:12
问题 I can make a widget inside another widget, as example an urwid.Frame father could have as body an urwid.Pile widget as child. In this situation, the father should process some input keys when the child have to treat some specific others keys. Like in this functional example: import urwid class NewFrame(urwid.Frame): def __init__(self, givenBody): super().__init__(urwid.Filler(givenBody, "top")) def keypress(self, size, key): if key in ('f'): print("We are in NewFrame object") return super

Color pass-through in urwid or curses

浪尽此生 提交于 2020-01-25 07:29:07
问题 I would like to write a wrapper around git log , somewhat similar to gitk but on a terminal. I thought this should be easy because git log already formats the output, all I need to do is put it in a list view where I can select a commit. However, both urwid and curses mess up the color codes which git log is using. I tried to implement a custom urwid widget hoping it might leave the color codes alone but it does not behave any different. I considered to move the coloring of the output from

Command prompt messed up after running a Python program

别来无恙 提交于 2020-01-11 07:44:05
问题 The code below creates a layout and displays some text in the layout. Next the layout is displayed on the console screen using the raw display module from the Urwid library. (More information on my complete project can be gleaned from questions at Required widgets for displaying a 1D console application and Using Urwid to create a 2D console application . My skype help request being here. I can run the code to display the relevant information. On pressing F8 the code asks a dialog on screen

global variable in main not getting recognised in another function in python

瘦欲@ 提交于 2019-12-25 05:24:13
问题 code below creates a layout and displays some text in the layout. Next the layout is displayed on the console screen using raw display module from urwid library. However running the code fails as a global variable ui, declared in main, is not recognised in another function. Error code on running is : Traceback (most recent call last): File "./yamlUrwidUIPhase6.py", line 97, in <module> main() File "./yamlUrwidUIPhase6.py", line 90, in main form = FormDisplay() File "./yamlUrwidUIPhase6.py",

How do I determine the number of visible items in a listbox with urwid?

≯℡__Kan透↙ 提交于 2019-12-24 10:01:39
问题 I'd like to implement some hinting as to whether there remains items below or above the list of visible items in an urwid.ListBox when I scroll it up or down. The 'scroll down' hint should appear only when there remains items after the last visible item and it should disappear when the last, visible item is the last item in the list. The reverse applies with the 'scroll up' hint. I then need to know how many visible items there is in the list. Is there a way to retrieve the number of visible

Using urwid, how to display one line at a time with keypress?

百般思念 提交于 2019-12-24 00:29:38
问题 Trying to create a simple function that displays one line from a text file at a time when enter or page down key is pressed. I don't want the lines to clear each time. In other words, I need to pause the program until next key press. As it is it only displays the first line. I tried a while True: to no avail. Thanks for you help! # Handle key presses def handle_input(key): with open('mobydick_ch1.txt') as f: lines = f.readlines() line_counter = 0 if key == 'enter' or key == 'page down': text

Urwid: how to see errors?

≡放荡痞女 提交于 2019-12-23 01:28:25
问题 I am building application with interactive console interface (line htop, atop utilities) using urwid library, so my trouble is: as interface takes all the space in console window - I could not see python's errors, I tried to do that: import sys f = open("test_err", "w") original_stderr = sys.stderr sys.stderr = f print a #a is undefined sys.stderr = original_stderr f.close() It works when I dont use urwid, but not when I use it... 回答1: you could try redirecting errors to a file. after each