我想编写一个带有基于T ext的U ser I接口(TUI)的程序,它由几种形式组成.
这是我的尝试,它使用库npyscreen但不返回第一个表单.代码也不包含更改列表项的逻辑.
#! /usr/bin/env python3
# coding:utf8
import npyscreen
# content
headers = ["column 1", "column 2", "column 3", "column 4"]
entries = [["a1", "a2", "a3", "a4"],
["b1", "b2", "b3", "b4"],
["c1", "c2", "c3", "c4"],
["d1", "d2", "d3", "d4"],
["e1", "e2", "e3", "e4"]]
# returns a string in which the segments are padded with spaces.
def format_entry(entry):
return "{:10} | {:10} | {:10} | {:10}".format(entry[0], entry[1] , …Run Code Online (Sandbox Code Playgroud) 我希望 npyscreen 应用程序中某些小部件的高度随着终端大小的调整而调整。

具体来说,我希望在调整终端大小时,这两个列小部件继续占据终端高度的大约相同部分,而底部的行小部件在调整终端大小时保留在终端的底部。
我已经有一些东西可以工作,但是当终端调整大小时,整体渲染会出现问题,就像小部件不知道我希望它们在哪里绘制一样。可能出了什么问题?这应该如何正确完成?
import curses
import sys
import npyscreen
npyscreen.disableColor()
def main():
app = App()
app.run()
class App(npyscreen.NPSApp):
def main(self):
form = npyscreen.FormBaseNew(name = "COMMUNICATIONS")
column_height = terminal_dimensions()[0] - 9
widget_contacts = form.add(
Column,
name = "CONTACTS",
relx = 2,
rely = 2,
max_width = 20,
max_height = column_height
)
widget_messages = form.add(
Column,
name = "MESSAGES",
relx = 23,
rely = 2,
max_height = column_height
)
widget_input = form.add(
npyscreen.BoxTitle,
name = "INPUT",
max_height = 5
) …Run Code Online (Sandbox Code Playgroud)