I am trying to design a GUI that hold a map the user can interact with (move around, zoom in and zoom out from, etc.) and some additional bottoms with different functions attached to them.
The way i want it to work is to have a main window that only contains the map, and a second window ("topwin" in the code) placed on top of it that contains a grid with different frames for the bottoms and labels.
Is there any way of creating the second window that does not involve using the tk.Frame function? Because that is what i have at the moment and when i run the code it only shows the map.
EDIT:I packed the topwin, but i still dont get the result i want, i will attach pictures of what i get now and what my goal is:
from tkinter import *
import tkinter as tk
from tkinter import messagebox
from PIL import Image
from PIL import ImageTk
from math import ceil
win = tk.Tk()
screen_width = win.winfo_screenwidth()
screen_height = win.winfo_screenheight()
win.geometry(f"{screen_width}x{screen_height}+0+0")
win.resizable(False, True)
win.title("Semi-Autonomous Fire Scout Drone Main Frame User Interface")
topwin = tk.Frame(win)
topwin.pack()
topwin.grid_columnconfigure(0, weight=1)
topwin.grid_columnconfigure(1, weight=1)
tenth_w = ceil(0.1*screen_width)
one_in_fifteen_w = ceil(0.015*screen_width)
one_in_fourfive_w = ceil(0.45*screen_width)
tenth_h = ceil(0.1*screen_height)
one_in_forty_h = ceil(0.4*screen_height)
one_in_fivefive_h = ceil(0.55*screen_height)
mapImg = img_resize("middle_earth_map.png", screen_width, screen_height)
logo_label = tk.Label(win, image=mapImg).pack()
def img_resize(file, width, height):
img = Image.open(file)
img = img.resize((width, height), Image.ANTIALIAS)
photoImg = ImageTk.PhotoImage(img)
return photoImg
topLeftFrame = tk.Frame(topwin)
topLeftFrame.grid(row=0, column=0, padx=10, sticky="w")
homeImg = img_resize("home_icon.png", tenth_h, tenth_h)
homeb = tk.Button(topLeftFrame, image=homeImg, command=homeMenu, width=tenth_h, height= tenth_h)
rgbmenuImg = img_resize("rgb_icon.png", tenth_h, tenth_h)
rgbmenub = tk.Button(topLeftFrame, image=rgbmenuImg, command=rgbmenu, height=tenth_h, width=tenth_h)
thermalmenuImg = img_resize("thermal_icon.png", tenth_h, tenth_h)
thermalmenub = tk.Button(topLeftFrame, image=thermalmenuImg, command=thermalmenu, height=tenth_h, width=tenth_h)
homeb.grid(row=0, column=0, padx=10, pady=10)
rgbmenub.grid(row=0, column=1, padx=10, pady=10)
thermalmenub.grid(row=0, column=2, padx=10, pady=10)
topRightFrame = tk.Frame(topwin)
topRightFrame.grid(row=0, column=2, padx=10, sticky="ne")
settImg = img_resize("settings_icon.png", tenth_h, tenth_h)
settingb = tk.Button(topRightFrame, image=settImg, command=settings, height=tenth_h, width=tenth_h)
infoImg = img_resize("copyright_icon.png", tenth_h, tenth_h)
infob = tk.Button(topRightFrame, image=infoImg, command=copyright, height=tenth_h, width=tenth_h)
loginImg = img_resize("login_icon.png", tenth_h, tenth_h)
loginb = tk.Button(topRightFrame, image=loginImg, command=login, height=tenth_h, width=tenth_h)
exitImg = img_resize("exit_icon.png", tenth_h, tenth_h)
exitb = tk.Button(topRightFrame, image=exitImg, command=quit, height=tenth_h, width=tenth_h)
settingb.grid(row=0, column=0, padx=10, pady=10)
infob.grid(row=0, column=1, padx=10, pady=10)
loginb.grid(row=0, column=2,padx=10, pady=10)
exitb.grid(row=0, column=3, padx=10, pady=10)
rightFrame = tk.Frame(topwin)
rightFrame.grid(row=1, column=2, padx=10, pady=10, sticky="e")
tempMap = img_resize("temp_heat_map.png", one_in_fifteen_w, one_in_forty_h)
tempMaplab = tk.Label(rightFrame, image=tempMap).grid(row=0, column=0, padx=10, pady=10)
bottomFrame = tk.Frame(topwin, relief='solid', bd=2)
bottomFrame.grid(row=2, column=1, padx=10, pady=10, sticky="s")
info = """Drone Speed = XXX Km/h Drone Distance = XXX m Wind Direction = XX Wind Force = XX Knots"""
info_botton = tk.Label(bottomFrame, justify=tk.CENTER, text=info, font = "arial 14 bold").grid(row=0, column=0, padx=10, pady=10)
win.mainloop()