gpt4 book ai didi

python - 诅咒中的多个文本框

转载 作者:太空宇宙 更新时间:2023-11-04 11:18:52 25 4
gpt4 key购买 nike

我需要在 curses 中创建两个文本框,并在按 Enter 时在它们之间切换

当我为第二个文本框按下回车键时,这段代码将光标放在屏幕的左上角,但我无法阻止它。

import curses
import curses.textpad as textpad

def main(screen):
"""screen is a curses screen passed from the wrapper"""

while True:
event = screen.getch()
if event :
textpad.Textbox(curses.newwin(1,13,4,0), insert_mode=True).edit()
textpad.Textbox(curses.newwin(1,13,4,16), insert_mode=True).edit()
screen.refresh()

if __name__ == '__main__':
curses.wrapper(main)

最佳答案

看起来你甚至不需要调用 getch() 因为这就足够了:

import curses
import curses.textpad as textpad

def main(screen):
"""screen is a curses screen passed from the wrapper"""
while True:
textpad.Textbox(curses.newwin(1,13,4,0), insert_mode=True).edit()
textpad.Textbox(curses.newwin(1,13,4,16), insert_mode=True).edit()

if __name__ == '__main__':
curses.wrapper(main)

关于python - 诅咒中的多个文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19513832/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com