Calling Tkinter Entry as Variable in another Script

119 views Asked by At

I'm stuck using an entry input as a variable in Tkinter. Currently I have a code that creates a textbox for the user to input a value:

gui_test.py"

from tkinter import *
class GUI:

    def __init__(self, window): 
       
        window.title("HyPep 1.0")
        window.geometry("700x700")
#ppm error

        ttk.Label(window, text='Input ppm error threshold:').grid(column=0,row=8)
        ppm_err = Entry(window)
        ppm_err.grid(column=1,row=8)
        err_tol = ppm_err.get()      



        ttk.Button(window, text = "Analyze", command = window.destroy).grid(row = 10,column=1, ipadx=5, ipady=15)

window = tkinter.Tk()
gui = GUI(window)
    
if __name__ == '__main__':
    window.mainloop()


I have another script, User_input.py

from gui_test import err_tol

ppm_err_gui = err_tol
print(ppm_err_gui)

This returns: ImportError: cannot import name 'err_tol' from 'gui_test'

What am I doing wrong?

ETA: more thorough code example.

0

There are 0 answers