Comments (1)
@ok100 : With apologies for the necro-post here: I have prepared an example that displays what set_focus_valign
is supposed to do:
import urwid
palette = [
('normal', 'light gray', 'black', '', "light gray", "black"),
('focused', 'light blue', 'black', '', "light blue", "black"),
]
class Ui:
def __init__(self):
self.header = urwid.Text('Hello World!')
layout = [
urwid.AttrMap(
urwid.Padding(urwid.SelectableIcon(str(n)), left=1, right=1),
attr_map={}, focus_map={None: "focused"}
)
for n in range(100)
]
self.listbox = urwid.ListBox(layout)
self.statusbar = urwid.Text('statusbar', align='right')
self.main_frame = urwid.Frame(self.listbox)
self.main_frame.set_footer(self.statusbar)
self.mainloop = urwid.MainLoop(
self.main_frame,
palette=palette, unhandled_input=self.unhandled_input
)
def unhandled_input(self, key):
if key in ('q', 'Q'):
raise urwid.ExitMainLoop()
elif key in ['G']:
self.listbox.set_focus(2)
self.listbox.set_focus_valign('bottom')
elif key in ['0']:
self.listbox.set_focus(5)
elif key in ['1']:
self.listbox.set_focus_valign('top')
self.listbox._invalidate()
elif key in ['2']:
self.listbox.set_focus_valign('middle')
self.listbox._invalidate()
elif key in ['3']:
self.listbox.set_focus_valign('bottom')
self.listbox._invalidate()
if __name__ == '__main__':
ui = Ui()
ui.mainloop.run()
To use it, try to scroll through the lines in the listbox, then type "1", "2", and "3" to change the valign among "top", "middle", "bottom". I believe in your example, there just aren't enough entries in the listbox to fill it on your screen, and it won't fill in the rest with blank space.
from urwid.
Related Issues (20)
- Remove .DS_Store
- [BUG] `Text.render()` raises `CanvasError` for some non-UTF-8 encodings when `1 <= maxcols < 3`
- [BUG] urwid.widget.pile.PileError: added content invalid: [(<SignalWrap selectable box widget>,(<WHSettings.WEIGHT: 'weight'>, 0.5))] HOT 2
- [BUG?] unsupported operand type(s) for +: 'ParentNode' and 'int' HOT 1
- [BUG] 2.4.2 introduced regression (or maybe the original code was wrong all along) HOT 10
- [BUG] Too many items in ListBox with ScrollBar tanks performance HOT 1
- [BUG] `MainLoop.watch_pipe` is closed after the first callback HOT 4
- [BUG] urwid.Overlay valign doesn't accept `relative` any more HOT 2
- [Question] how to update interface but not Block interface? HOT 5
- [BUG] Not receiving 'shift mouse press' events HOT 7
- [BUG] Type hints for Widget `row()` method are inconsistent with usage
- [BUG] ListBox wrapped in AttrMap is not scrollable with ScrollBar HOT 1
- [Question]how can i input Chinese encoding into the Edit widget? HOT 3
- How to scroll two listboxes together? HOT 4
- resume (fg) from suspend (^Z) doesn't work inside a shell script HOT 1
- [BUG] interface changes make example/browser.py doesn't work as before HOT 2
- [BUG] Test suite fails if `trio` is installed without `exceptiongroup` HOT 1
- Creating a GridFlow with no children raises a warning HOT 1
- [docs] Specify that Windows support is available only on Windows 10 or later
- [BUG] ScrollBar does not indicate mouse_event was handled with ListBox
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from urwid.