我正在上课作业。我已经完成了大部分工作,我只需要获取最后的循环即可在图形窗口中显示Unicode代码。不知道我需要怎么做才能显示它。我已经尝试了几次迭代,但最终似乎无法正常工作。
from graphics import *
def main():
win = GraphWin("Unicode Window", 500, 500)
win.setCoords(0.0, 0.0, 10.0, 10.0)
text = Text(Point(5.0, 9.0), "This is a message coder to convert your message into Unicode.")
text.draw(win)
text2 = Text(Point(5.0, 8.0), "Enter your message below. Click the convert")
text2.draw(win)
text3 = Text(Point(5.0, 7.5), "button to see your message in Unicode.")
text3.draw(win)
message = Entry(Point(5.0, 6.0), 20)
message.setText("Enter the message here")
message.draw(win)
button = Text(Point(5.0, 4.5), "Convert")
button.draw(win)
rect = Rectangle(Point(4.0, 4.0), Point(6.0, 5.0))
rect.draw(win)
win.getMouse()
text4 = Text(Point(5.0, 3.0), "\nHere are the Unicode codes:")
text4.draw(win)
for i in message:
unit = Text(ord(i), end =" ")
unit.draw(win)
print()
main()