Цель состоит в том, чтобы получить спрайт персонажа, который может перемещаться в коробке. Поле слева - это изображение, а справа - описание (и т. Д.). Внизу есть текстовое поле, чтобы пользователь мог вводить команды. Вот изображение для демонстрации. Я не хочу, чтобы персонаж мог двигаться в текст. Как бы я поступил так, используя 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