0

Please help me with the second method of the class.

I've searched a lot, and the other google solutions don't work.

The main problem is I think tkraise(), but I don't know how to solve, or get the code running without the method.

I don't know how to solve the following problem:


class Startconfig(tkinter.Tk):

 def __init__(self, *args, **kwargs):
    tkinter.Tk.__init__(self, *args, **kwargs)

    container = tkinter.Frame(self)
    container.pack(side = "top", fill = "both", expand = True)
    container.grid_rowconfigure(0, weight = 1)
    container.grid_columnconfigure(0, weight = 1)

    self.frames = {}

    self.frames["Startmenü"] = Startmenü(parent=container, controller=self)
    self.frames["Spiel_Starten"] = Spiel_Starten(parent=container, controller=self)

    ...

class Startmenü(tkinter.Frame):

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


    # this doesn't work
    canvas = tkinter.Canvas(self, width = 750, height = 499)
    zeichnung_burg = tkinter.PhotoImage(file = """image.gif""")
    canvas.create_image(0, 0, anchor=tkinter.NW, image=zeichnung_burg)#image = zeichnung_burg)
    canvas.pack()



    label = tkinter.Label(self, text = "publisher:")

    starten = tkinter.Button(self, text = "Starten", bg = "grey", fg = "black", width = 15, height = 2,
                            command = lambda: controller.show_frame(Spiel_Starten))
    einstellungen = tkinter.Button(self, text = "Einstellungen", bg = "grey", fg = "black", width = 15, height = 2,
                            command = lambda: controller.show_frame(Einstellungen))
    hilfe = tkinter.Button(self, text = "Hilfe", bg = "grey", fg = "black", width = 15, height = 2,
                            command = lambda: controller.show_frame(Hilfe))
    beenden = tkinter.Button(self, text = "Beenden", bg = "grey", fg = "black", width = 15, height = 2,
                             command = self.quit)

    #canvas.pack()
    starten.pack(side = tkinter.LEFT)
    einstellungen.pack(side = tkinter.LEFT)
    beenden.pack(side = tkinter.RIGHT)
    hilfe.pack(side = tkinter.RIGHT)
    label.pack(side = tkinter.LEFT, fill = tkinter.X, expand = 1)
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
  • What does this comment mean: _"# this doesn't work"_? Why doesn't it work? What does it do, and how is it different from what you expect? Please try to create a [mcve] - we can't reproduce your problem with the code you've posted. – Bryan Oakley Sep 18 '19 at 21:02
  • Read [Why does Tkinter image not show up if created in a function?](https://stackoverflow.com/a/16424553/7414759) – stovfl Sep 18 '19 at 22:03

0 Answers0