Home > other >  Using a variable from an other class tkinter python
Using a variable from an other class tkinter python

Time:05-07

I'm using Tkinter (with python) to create a UI. How can I use the entry (which defines the user name) from one page on another page (thus another class)? Basically, I need the user name to appear on several pages without asking the user to enter it each time.

CodePudding user response:

you can make it a global variable.

global password
password_entry = tk.Entry(screen1, show="*", textvariable=password)

And then use it anywhere in your program

CodePudding user response:

I don't know do you have any database which includes the usernames. If yes you can get it from there. if not, so you can use global variable to keep username.

global username
username = textbox.get("1.0","end")
  • Related