0

The goal is to have a character sprite that can move around in a box. The box to the left is where the visuals are, and the right are descriptions (etc). At the bottom there is a text box so the user can enter commands. Here's an image to demonstrate. I don't want the character to be able to move into the text. How would I go about doing this using Tkinter? Here's the code for setting up the 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
H. Owens
  • 59
  • 1
  • 1
  • 9
  • 2
    A Label has no ability to display multiple images. Something like this would normally be done with a Canvas, which can display any number of images or other shapes, which can then be individually moved. – jasonharper Apr 01 '19 at 20:11
  • Something like this would be done with PhotoImage library. Don't use labels as labels are used to display text when there is no canvas. –  Apr 01 '19 at 21:22
  • Try this approach [How to make a tkinter canvas background transparent?](https://stackoverflow.com/a/53047086/7414759). – stovfl Apr 02 '19 at 10:09

0 Answers0