Question: I have a link that is placed in `li` and when you hover on it, a block should appear with links that I will indicate in it

```
<li id="dropdown" class="li">
    <a href="/news/">Lessons</a>
</li>
<div class="dropdown-content">
    <a href="#">Link 1</a>
    <a href="#">Link 2</a>
    <a href="#">Link 3</a>
</div>

```

Answer: 
In this case, you don't have to declare `global`. Simply indent your `submitBtn` function inside `entry_Fn`:

```
def entry_Fn():
    level_1 = Toplevel(root)
    Label( level_1, text = "level one").pack()
    entry_1 = Entry(level_1)
    entry_1.pack()
    entry_2 = Entry(level_1)
    entry_2.pack()
    def submitBtn():
        val_1= entry_1.get()
        val_2= entry_2.get()
        sum_var.set(int(val_1)+ int(val_2))
        level_1.destroy()
    Button(level_1, text= "submit", command=submitBtn).pack()

```

But generally it is easier to make a class so you can avoid this kind of scope problems, like below:

```
from tkinter import *

class GUI(Tk):
    def __init__(self):
        super().__init__()
        self.geometry('600x400')
        self.sum_var= StringVar()
        Label(self, text="Main window").pack()
        Button(self, text="To enter Data", command=self.entry_Fn).pack()
        sum = Label(self, textvariable=self.sum_var)
        sum.pack()

    def entry_Fn(self):
        self.level_1 = Toplevel(self)
        Label(self.level_1, text = "level one").pack()
        self.entry_1 = Entry(self.level_1)
        self.entry_1.pack()
        self.entry_2 = Entry(self.level_1)
        self.entry_2.pack()
        Button(self.level_1, text="submit", command=self.submitBtn).pack()

    def submitBtn(self):
        val_1 = self.entry_1.get()
        val_2 = self.entry_2.get()
        self.sum_var.set(int(val_1)+ int(val_2))
        self.level_1.destroy()

root = GUI()

root.mainloop()

```
You can subclass `tk.TopLevel`, and use a `tk.IntVar` to transfer the data back to root:

```
import tkinter as tk

class EntryForm(tk.Toplevel):

    def __init__(self, master, sum_var):
        super().__init__(master)
        tk.Label(self, text="level one").pack()
        self.sum_var = sum_var
        self.entry_1 = tk.Entry(self)
        self.entry_1.pack()
        self.entry_2 = tk.Entry(self)
        self.entry_2.pack()
        tk.Button(self, text="submit", command=self.submitBtn).pack()

    def submitBtn(self):
        val_1 = self.entry_1.get()
        val_2 = self.entry_2.get()
        self.sum_var.set(int(val_1) + int(val_2))
        self.destroy()

def spawn_entry_popup():
    EntryForm(root, sum_var)

root= tk.Tk()
root.geometry('600x400')
sum_var = tk.IntVar()
tk.Label(root, text = "Main window").pack()
tk.Button(root, text= "To enter Data", command=spawn_entry_popup).pack()
sum_label = tk.Label(root, textvariable=sum_var)
sum_label.pack()

root.mainloop()

```

You can also place your app inside a class:

```
import tkinter as tk

class EntryForm(tk.Toplevel):

    def __init__(self, master, sum_var):
        super().__init__(master)
        tk.Label(self, text="level one").pack()
        self.sum_var = sum_var
        self.entry_1 = tk.Entry(self)
        self.entry_1.pack()
        self.entry_2 = tk.Entry(self)
        self.entry_2.pack()
        tk.Button(self, text="submit", command=self.submitBtn).pack()

    def submitBtn(self):
        val_1 = self.entry_1.get()
        val_2 = self.entry_2.get()
        self.sum_var.set(int(val_1) + int(val_2))

class GUI(tk.Tk):

    def __init__(self):    
        super().__init__()
        self.geometry('600x400')
        self.sum_var = tk.IntVar()
        tk.Label(self, text = "Main window").pack()
        tk.Button(self, text= "To enter Data", command=self.spawn_entry_popup).pack()
        sum_label = tk.Label(self, textvariable=self.sum_var)
        sum_label.pack()

    def spawn_entry_popup(self):
        EntryForm(self, self.sum_var)

GUI().mainloop()

```