0

I have managed to create a new GUI (zoom_menu), but when I open it, it does not have any code. How do I insert all of the code below into the new GUI?

from tkinter import *
root =Tk()
root.title("Carbon Emission Calculator")
root.geometry("2560x1600")




def zoom_menu():
   top = Toplevel()
   top.title("Zoom Menu")
   
btn = Button(root, text = "Zoom", command = zoom_menu).pack()

#defining selections for radio buttons
x = IntVar()
y = IntVar()


#type of call
type_of_call = Label(root, text="Number of participants", font="Arial 20").pack(pady = 10)
Radiobutton(root,text= "1:1 call", variable= x, value=1).pack()
Radiobutton(root,text= "Group call", variable= x, value=2).pack()


#call quality
call_quality = Label(root, text="Call Quality", font="Arial 20").pack(pady = (40,10))
Radiobutton(root,text= "Default", variable= y, value=1).pack()
Radiobutton(root,text= "720p HD", variable= y, value=2).pack()
Radiobutton(root,text= "1080p HD", variable= y, value=3).pack()

#main title
main_title = Label(root, text="Carbon Emissions from Zoom Calls", font="Arial 25").pack(pady=75, padx=0)

root.mainloop()
dallenlee
  • 55
  • 3

1 Answers1

0

You can use the variable top as a replacement for the root variable, i.e the top variable works same as how the root variable works.

For example:

from tkinter import *

root = Tk()
root.title("Carbon Emission Calculator")
root.geometry("2560x1600")

def zoom_menu():
    top = Toplevel()
    top.title("Zoom Menu")
    btn = Button(top, text = "Zoom", command = zoom_menu).pack()

    x = IntVar()
    y = IntVar()

    #type of call
    type_of_call = Label(root, text="Number of participants", font="Arial 20").pack(pady = 10)
    Radiobutton(top,text= "1:1 call", variable= x, value=1).pack()
    Radiobutton(top,text= "Group call", variable= x, value=2).pack()

    #call quality
    call_quality = Label(top, text="Call Quality", font="Arial 20").pack(pady = (40,10))
    Radiobutton(top,text= "Default", variable= y, value=1).pack()
    Radiobutton(top,text= "720p HD", variable= y, value=2).pack()
    Radiobutton(top,text= "1080p HD", variable= y, value=3).pack()

    #main title
    main_title = Label(top, text="Carbon Emissions from Zoom Calls", font="Arial 25").pack(pady=75, padx=0)

    top.mainloop()

   
btn = Button(root, text = "Zoom", command = zoom_menu).pack()

#defining selections for radio buttons
x = IntVar()
y = IntVar()

#type of call
type_of_call = Label(root, text="Number of participants", font="Arial 20").pack(pady = 10)
Radiobutton(root,text= "1:1 call", variable= x, value=1).pack()
Radiobutton(root,text= "Group call", variable= x, value=2).pack()

#call quality
call_quality = Label(root, text="Call Quality", font="Arial 20").pack(pady = (40,10))
Radiobutton(root,text= "Default", variable= y, value=1).pack()
Radiobutton(root,text= "720p HD", variable= y, value=2).pack()
Radiobutton(root,text= "1080p HD", variable= y, value=3).pack()

#main title
main_title = Label(root, text="Carbon Emissions from Zoom Calls", font="Arial 25").pack(pady=75, padx=0)

root.mainloop()


Johan Jomy
  • 592
  • 2
  • 7
  • 22