我正在尝试移动文本输入窗口,但不知道该怎么做。
answer_state = screen.textinput(title="Guess the State", prompt="Enter a U.S state:")
不太确定从这里该做什么。
我正在尝试移动文本输入窗口,但不知道该怎么做。
answer_state = screen.textinput(title="Guess the State", prompt="Enter a U.S state:")
不太确定从这里该做什么。
我建议您放弃可以使用
screen.textinput()
来实现此目的的想法,因为由于问题评论中解释的原因,您不能这样做。
您可以在 Python 代码中使用适合您的特定平台的可用工具来控制凸起文本输入弹出框的位置。
或者,您可以使用 Python 编写自定义文本输入弹出框(如评论之一中的建议),并在您的 Turtle 脚本中使用此代码。
最后,假设
bash
和 xdotool
安装在您的系统上,作为最简单的方法,您可以使用“脏”技巧作为解决方法,这会产生活动窗口定位的延迟执行:
import os
os.system('bash -c "sleep 0.5;xdotool getactivewindow windowmove 10 10" &')
answer=screen.textinput(title="Guess the State", prompt="Enter an USA state")
将刚刚凸起的输入框重新定位为例如
( 10, 10 )
。
请随意查看更多
xdotool
选项,以仅重新定位具有给定标题的窗口而不是当前活动的窗口。