0

Description

What I'm trying to do is an app with a navbar on top that depending on which one is shows different things on the body of the app (below the navbar). I'm using the grid so I'm iterating through a list and adding a button to the body of the app and they have columnspan but they position in the middle of the columnspan

enter image description here

This is how it looks right now.

Desired Layout

enter image description here

This is a little sketch of the layout (the right bar below the navbar is a scrollbar which isn't implemented yet because I don't know yet how to do it)

Code

import modules.configManager as configManager
import tkinter as tk
from tkinter import messagebox
import tkinter.font as font
from os.path import dirname, abspath
from PIL import Image, ImageTk

imgDirectory = dirname(dirname(abspath(__file__))) + '\img'

logo = imgDirectory + '\logo2.jpg'


root = tk.Tk()


def linkMenu():
    links = configManager.readConfig()['linksList']
    i = 0
    for link in links:
        i = i+1
        linkB = tk.Button(root,text=link['link'],font=font.Font(font='Helvetica',size=8),width=30,relief='flat')
        linkB.grid(column=0,row=i,columnspan=4)

def navbar():

    buttonWidth = 18
    buttonHeight = 1
    myfont = font.Font(font='Helvetica',size=10,weight="bold")


    homeButton = tk.Button(root, text="Home",height=buttonHeight,width=buttonWidth,font=myfont)
    homeButton.grid(column=0,row=0)

    linkButton = tk.Button(root, text="Links",width=buttonWidth,font=myfont,command=linkMenu)
    linkButton.grid(column=1,row=0)

    groupsButton = tk.Button(root, text="Groups",width=buttonWidth,font=myfont)
    groupsButton.grid(column=2,row=0)

    resetButton = tk.Button(root, text="Reset",width=buttonWidth,font=myfont)
    resetButton.grid(column=3,row=0)

    exitButton = tk.Button(root,text="Exit",width=buttonWidth,font=myfont,command=exit)
    exitButton.grid(column=4,row=0)

def interface():
    navbar()

    root.title("LinkManager")
    root.geometry("1040x500")

    root.mainloop()

Thanks in advance and if it isn't clear tell me please :D

itasahobby
  • 301
  • 4
  • 15
  • Read about [notebook](https://tkdocs.com/tutorial/complex.html#notebook) and [gui layout using frames and grid](https://stackoverflow.com/questions/34276663/tkinter-gui-layout-using-frames-and-grid/34277295#34277295), [Adding a scrollbar to a group of widgets in Tkinter](https://stackoverflow.com/a/3092341/7414759) – stovfl Nov 23 '19 at 13:11
  • Oh thanks that would make it much easier thanks :D – itasahobby Nov 23 '19 at 13:19

0 Answers0