I have 3 python files: login
, teacher_ui
, and student_ui
. All three of these use tkinter. The login file takes a name as an input and if the name is a valid table in a database, the login file imports the student_ui
file to run it.
The problem I am having is that the student_ui file needs a variable called name
, which is the input in login
. I am struggling to import the variable into student_ui
as it changes all the time.
My code in login
to load the student_ui
file is:
elif name_data in names_list:
opening_window.destroy()
import student_ui
This then runs student_ui
, which provides a different interface. The code for name_data
is: name_data = name.get().lower()
The line of code in student_ui
that needs name_data
is: user_table_name = name_data
. This line is throwing a NameError
because name
is not defined.
Therefore, how would I make student_ui
take the name_data
from login
when login
loads student_ui
?
Some of the code for the student_ui
is:
number_words = {
"Forty Five" : 45,
...
"Nine Thousand, Eight Hundred and Sixty Four" : 9864
}
user_table_name = name_data
query = 'SELECT _45 FROM {} ORDER BY runid DESC LIMIT
3'.format(user_table_name)
c.execute(query)
status_1 = c.fetchall()
if ('true',) in status_1:
status_1 = True
else:
status_1 = False
There is also code for label, inputs, marking, and large amounts of database writing and reading.