为Python Turtle TextInput设置重点
在我的Python项目(游戏)中,我有一个功能可以获取播放器(2)名称:
def get_names(self):
self.lp_name = turtle.textinput("Left Player", "Enter your Name")
self.rp_name = turtle.textinput("Right Player", "Enter your Name")
对于第一个(左播放器)TextInput字段处于活动状态 - 具有焦点,但对第二个(正确的播放器)没有焦点
In my python project (game) I have a function to get player (2) names:
def get_names(self):
self.lp_name = turtle.textinput("Left Player", "Enter your Name")
self.rp_name = turtle.textinput("Right Player", "Enter your Name")
For the first (Left Player) the textinput field is active - has focus but NOT for the second (Right Player)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
TextInput字段不活动,因为当您单击“确定”时,焦点从主窗口转移到弹出窗口。
(尝试单击主窗口,您可以看到TextInput字段变得活跃。),
因此您可以使用
screen.tracer()
函数在每个范围之后更新主屏幕输入。样本就像:
这应该有效。
The textinput field is not active because the focus shifts from the Main Window to the popup window when you click 'OK'.
(try clicking on the main window and you can see the textinput field becoming active.)
So you could use a
screen.tracer()
function to update the main screen after each input.sample would be like :
This should work.