-1

I am using this method of frame switching for menus: Switch between two frames in tkinter. I don't know how I can set a background when using this, since I'm never making a window in a variable. I tried using window manager (wm), but it doesn't have any background functionality. Only geometry, and icon. I also tried to set a label with an image to hopefully get a background. Nothing worked. What can I do?

sh0tz
  • 15
  • 4

1 Answers1

0

There's nothing special you need to do. "making a window in a variable" is irrelevant. They are all just normal frame widgets.

For example, if you want PageOne to have a background image you can use place to create the image before creating the other widgets on that page. By using place, the placement of the image won't affect the placement or size of any other widgets.

class PageOne(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller

        # create a background image for this page
        self._background_image = tk.PhotoImage(...)
        bglabel = tk.Label(self, image=self._background_image)
        bglabel.place(relx=.5, rely=.5, anchor="center")

        ...
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685