目标是让角色精灵可以在盒子中移动。左侧的框是视觉效果所在的位置,右侧的框是说明(等)。底部有一个文本框,因此用户可以输入命令。 Here's an image to demonstrate.我不希望角色能够移动到文本中。我将如何使用Tkinter进行此操作?这是设置GUI的代码:
def setUpGui(self):
self.pack(fill = BOTH, expand = 1)
#Setting up player input region of the GUI
Game.player_input = Entry(self, bg = "white")
#Executes process when enter pressed
Game.player_input.bind("<Return>", self.process)
#Stretches it across the bottom
Game.player_input.pack(side = BOTTOM, fill = X)
#Makes this the focus upon running the program
Game.player_input.focus()
img =None
Game.image = Label(self, width = WIDTH/2, image = img)
Game.image.image = img
Game.image.pack(side = LEFT, fill = Y)
Game.image.pack_propagate(False)
text_frame = Frame(self, width = WIDTH/2)
Game.text = Text(text_frame, bg = "lightgrey", state = DISABLED)
Game.text.pack(side = RIGHT, fill = Y)
text_frame.pack(side = RIGHT, fill = Y)
text_frame.pack_propagate(False)
def setRoomImage(self):
if (Game.currentRoom == None):
Game.img = PhotoImage(file = "skull.gif")
else:
Game.img = PhotoImage(file = Game.currentRoom.image)
Game.image.config(image = Game.img)
Game.image.image = Game.img