0

At first, excuse me for my english. Will try to explain as good as I can :)

Right now im starting of with TkInter. Seems to work quite logical, but it seems I do not get what my problem is. I want to have a small framework of 2 columns, but the 'headercolumn' has to columnspan on the two below it. The framework is right.

Now I do want to add a couple buttons in the menuFrame. Some kinda way, the configBtn is in the right place, but the connectBtn has been sticked to NW, in the headerFrame.

If I'm looking into my code, i am telling it to be in MenuFrame.

Picture of the problem here! OLD!

Why is this exactly happening, and maybe the most important one, how do I fix this? :)

Below the GUI Code I wrote!

Thanks in advance!

UPDATE (21-7 - 15:28) Cause of the reactions i've changed some stuff.

The problem I have now, is that the buttons are getting stacked on eachother.

import tkinter as tk

gui = tk.Tk()
gui.title("*** - Main Menu")
gui.resizable(0, 0)

gui.grid_rowconfigure(1, weight=1)
gui.grid_columnconfigure(1, weight=1)

canvas = tk.Canvas(gui, width=650, height=650)
canvas.grid(columnspan=2, rowspan=2)

# Declare frames
tk.Frame(gui, padx=1, pady=1, borderwidth=0, relief='sunken').grid(row=0, column=0, sticky="nswe", columnspan=2)
tk.Frame(gui, padx=1, pady=1, borderwidth=2, relief='sunken').grid(row=1, column=0, sticky="nswe")
tk.Frame(gui, padx=1, pady=1, borderwidth=2, relief='sunken').grid(row=1, column=1, sticky="nswe")

# Declare images
m_logo = tk.PhotoImage(file="img/logo_1.png",)
i_logo = tk.PhotoImage(file="img/logo_1.png",)
tk.Label(gui, image=i_logo).grid(row=0, column=0, padx=5, pady=5, sticky="W")
tk.Label(gui, image=m_logo).grid(row=0, column=1, padx=5, pady=5, sticky="E")

# Declare buttons
connectBtn = tk.Button(gui, text="Connect", state=tk.ACTIVE, width=15, height=1, command="function", padx=5, pady=5).grid(column=0, row=1, sticky="NEW")
configBtn = tk.Button(gui, text="Config", state=tk.ACTIVE, width=15, height=1, command="function", padx=5, pady=5).grid(column=0, row=1, sticky="NEW")

gui.mainloop()
DJurres
  • 1
  • 1
  • 2
    Try printing `menuFrame` then look at this: [Tkinter: AttributeError: NoneType object has no attribute ](https://stackoverflow.com/questions/1101750/tkinter-attributeerror-nonetype-object-has-no-attribute-attribute-name) – TheLizzard Jul 21 '21 at 13:08
  • first of don't do this: `variable_name = .layout_manager()`, it returns `None` and is later unusable, also: I strongly advise against using wildcard (`*`) when importing something, You should either import what You need, e.g. `from module import Class1, func_1, var_2` and so on or import the whole module: `import module` then You can also use an alias: `import module as md` or sth like that, the point is that don't import everything unless You actually know what You are doing; name clashes are the issue. – Matiiss Jul 21 '21 at 13:08
  • @Matiiss So, i've solved that problem you've mentioned. I imported whole tkinter as tk, and editted everything. Thanks for your explanation! Its updated in the OP! – DJurres Jul 21 '21 at 13:34
  • @TheLizzard thanks for that. Now I've solved that and put everything in 'gui' instead of 'menuFrame'. When i'm giving it a grid position the buttons are stacking now. – DJurres Jul 21 '21 at 13:34
  • The buttons are getting stacked because you are putting them in the same row/column. Either change the column of `configBtn` to 1 or the row to 2. – Henry Jul 21 '21 at 14:30

0 Answers0