User interface gui显示字符串操作

User interface gui显示字符串操作,user-interface,text,graphics,python-3.2,User Interface,Text,Graphics,Python 3.2,我学习Python是为了给我的孙子们留下深刻的印象——希望没有人有年龄歧视!我的项目是让我用QuickBasic编写的刽子手游戏在Windows7下运行。 我已经成功地准备了一个Hangedman图形,并编写了从一个大型csv文件中提取随机单词的例程。现在我想编写用户界面,但尝试返回到已使用的位置会导致覆盖-我无法删除现有字符串。 下面的例行程序是为了探索如何在给定位置写入字符串,并为游戏目的将其擦除: # attempt to write and erase text at point loc

我学习Python是为了给我的孙子们留下深刻的印象——希望没有人有年龄歧视!我的项目是让我用QuickBasic编写的刽子手游戏在Windows7下运行。 我已经成功地准备了一个Hangedman图形,并编写了从一个大型csv文件中提取随机单词的例程。现在我想编写用户界面,但尝试返回到已使用的位置会导致覆盖-我无法删除现有字符串。 下面的例行程序是为了探索如何在给定位置写入字符串,并为游戏目的将其擦除:

# attempt to write and erase text at point locations
# all works OK until returned to location already used
#
# 23 FEB 14

from graphics import *
import tkinter

def main():
# make window
win = GraphWin("Display text locator", 600, 500)
# click 1 to start    
win.getMouse()   
# establish first location
output = Text(Point(400,400),"")
output.draw(win)
# and print simulated hangman word length
output.setText("  _ _ _ _ _ _ _ _ ")
# click 2 for first string replacement
win.getMouse()
output.setText("     ABCZYX W     ")
# click 3 to blank out first string
win.getMouse()
output.setText("                   ")
# click 4 to show new string
win.getMouse()
output.setText(" and here we are again  ")
# click 5 points to new text location and display
win.getMouse()    
output = Text(Point(100,100),"")
output.draw(win)
# first string at new location
output.setText(" here's the new position ")
# click 6 to show new string
win.getMouse()
output.setText("    blank that out    ")
# click 7 to erase it
win.getMouse()
output.setText("                      ")
# click 8 points back to first location
win.getMouse()     
output = Text(Point(400,400),"")
output.draw(win)
# should blank out existing string (but fails)
output.setText("          -                 ")
# click 9 to display new string (but simply overwrites)
win.getMouse()
output.setText(" BACK TO THE FIRST POSITION ")
# click 10 exits
win.getMouse() 
win.close()

main()
感激地接受所有建议(无需笑!) 非常感谢-杰里米/