{"id":1773,"library":"urwid","title":"Urwid Library","description":"Urwid is a full-featured console user interface library for Python, allowing developers to create robust terminal applications with widgets, event loops, and rich display capabilities. The current version is 4.0.0. It maintains a regular release cadence with frequent bug fixes and minor improvements, alongside less frequent major version updates.","status":"active","version":"4.0.0","language":"en","source_language":"en","source_url":"https://github.com/urwid/urwid","tags":["TUI","console","GUI","terminal","widget"],"install":[{"cmd":"pip install urwid","lang":"bash","label":"Install Urwid"}],"dependencies":[],"imports":[{"symbol":"urwid","correct":"import urwid"},{"symbol":"Text","correct":"import urwid\nurwid.Text(...)"},{"symbol":"MainLoop","correct":"import urwid\nurwid.MainLoop(...)"},{"symbol":"Button","correct":"import urwid\nurwid.Button(...)"}],"quickstart":{"code":"import urwid\n\ndef exit_on_q(key):\n    if key in ('q', 'Q'):\n        raise urwid.ExitMainLoop()\n\ndef show_message(button):\n    response = urwid.Text([u\"You clicked the button! \", ('bold', u\"Press Q to quit.\")])\n    done = urwid.Button(u'Ok')\n    urwid.connect_signal(done, 'click', exit_program)\n    top_frame = urwid.Frame(\n        header=urwid.Text(\"Message\"),\n        body=urwid.Filler(urwid.Pile([response, done]), 'top'),\n        footer=None\n    )\n    loop.widget = top_frame # Replace current widget with message\n\ndef exit_program(button):\n    raise urwid.ExitMainLoop()\n\n# Create a text widget\ntext_widget = urwid.Text(u\"Hello, Urwid! Press Space to click, Q to quit.\")\n\n# Create a button\nbutton = urwid.Button(u'Click me!')\nurwid.connect_signal(button, 'click', show_message)\n\n# Arrange widgets in a pile, then fill the screen\npile = urwid.Pile([\n    urwid.Text(\"Welcome to Urwid\"),\n    urwid.Divider(),\n    text_widget,\n    urwid.AttrMap(button, None, focus_map='reversed') # Add focus highlight\n])\nfiller = urwid.Filler(pile, 'top')\n\n# Create the main loop\nloop = urwid.MainLoop(filler, unhandled_input=exit_on_q)\nloop.run()","lang":"python","description":"This quickstart initializes a basic Urwid application displaying text and a button. Clicking the button updates the display with a message, and pressing 'Q' at any point exits the application. It demonstrates key concepts like widgets (Text, Button, Pile, Filler), event handling (connect_signal), and the main event loop (MainLoop)."},"warnings":[{"fix":"Review upgrade notes for `urwid` 4.0.0 and replace calls to removed methods with their non-deprecated equivalents or current API patterns. If possible, update code to use direct attribute access or new helper functions.","message":"Version 4.0.0 removed several public and protected methods that were previously deprecated. Examples include `Filler.get_body()`, `Filler.set_body()`, and various methods from `Canvas` and `AttrSpec`.","severity":"breaking","affected_versions":"4.0.0+"},{"fix":"Migrate existing code using these deprecated components to modern `urwid` widget classes and composition patterns. Refer to `urwid` documentation for alternatives.","message":"Version 3.0.0 removed several legacy widgets and properties, including `FlowWidget`, `BoxWidget`, `FixedWidget`, and the `__super` property. Code relying on these will fail.","severity":"breaking","affected_versions":"3.0.0+"},{"fix":"Test `urwid` applications thoroughly on target Windows environments. Consider using WSL2 for a more consistent terminal experience if extensive `urwid` features are required on Windows.","message":"Windows support for `urwid` is primarily for Windows 10+ and relies on the default console host (conhost). There may be visual quirks, performance issues, or incomplete feature support (e.g., mouse events) compared to Linux/macOS terminals.","severity":"gotcha","affected_versions":"All versions on Windows"},{"fix":"For new code, prefer `user_args=(arg1, arg2)` when connecting signals. For existing code, `user_arg` should continue to function in 3.0.5+ but be aware of its history if encountering warnings in older 3.x versions.","message":"While `user_arg` for `urwid.connect_signal` was briefly deprecated (v3.0.4) and then un-deprecated (v3.0.5), it can still lead to confusion. The `user_args` parameter (as a tuple) is generally preferred for passing multiple arguments or for consistency with other callback patterns.","severity":"gotcha","affected_versions":"3.0.4, 3.0.5+"},{"fix":"Design your `unhandled_input` function carefully to handle unexpected keys or provide an escape mechanism. For debugging, consider redirecting output or using an external debugger that can attach to the process without interfering with `urwid`'s input loop.","message":"Urwid's main loop typically captures all input, including mouse events and keyboard input. This can make debugging or external interaction with the terminal challenging. Ensure your `unhandled_input` handler or event filtering is robust.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}