0
def __init__(self):
    self.root = Tk()

    self.title = Frame(self.root, width = 500, height = 35)
    self.title.pack(side = TOP, expand = True)

    self.frame = Frame(self.root, width = 574, height = 574)
    self.frame.grid(columnspan = 30, rowspan = 31)

    self.label = Label(self.title, width = 300, height = 30)
    self.label.pack()

    self.root.mainloop()

I want to be able to have a label on top of the grid but when I run the mainloop i get the error: "cannot use geometry manager grid inside .55652592 which already has slaves managed by pack." Thank you.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
Christopher Berry
  • 685
  • 2
  • 7
  • 18
  • What layout is it exactly you're after? If you want a label to appear on top of a grid you can use `place`. Otherwise put the gridded widgets inside a frame which can be packed. – Siwel Aug 26 '15 at 16:22

1 Answers1

0

I don't think it is possible to use both. I recommend using .grid() consistently because it has a wider range of options. Both .grid() and .pack() are window managers, and you can't have two window managers running at the same time (at least for the same program).

Instead of using a label, you might want to look into tkMessageBox, or designating a space for your labels to go (with grid, you can have one label replace the other).

This resource might be helpful:

http://effbot.org/tkinterbook/grid.htm

It advises to never mix the two managers in the same master window.

Best of luck, and happy coding!

Joseph Farah
  • 2,463
  • 2
  • 25
  • 36