Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

enterned_text = enterned_text.get() UnboundLocalError: local variable 'enterned_text' referenced before assignment

i keep getting this error and i can’t solve it
i also get this error when i press the button : ‘line 1921, in call
return self.func(*args)’
i can’t solve any of these errors , i have done some corrections to the following code

from tkinter import *
from tkinter import ttk
def click():
    enterned_text = enterned_text.get()
    



if __name__ == "__main__":
     
    root = Tk()
    root.title("upatrasdoctor'sddegreesearchengine")
    root.configure(background="#EDD2F3")
 
    
Label(root, text = "Καλωσήρθατε στη Βάση Δεδομένων των Διδακτορικών Διατριβών", bg = "#EDD2F3", fg="black", font = "none 12 bold") .grid(row=5, column=0, sticky=W)

Label(root, text = "των Πολυτεχνικών Τμημάτων του Πανεπιστημίου Πατρών", bg = "#EDD2F3", fg="black", font = "none 12 bold") .grid(row=9, column=0, sticky=W)

Label(root, text = "Κατάλογος των Πολυτεχνικών Τμημάτων:", bg = "#EDD2F3", fg="black", font="none 12 bold") .grid(row=13, column=0, sticky=W) 

   

def comboclick(event):
    myLabel = Label(root, text = myCombo.get())

options = [
    "Τμήμα Αριτεκτόνων Μηχανικών",
    "Τμήμα Ηλεκτρολόγων Μηχανικών και Τεχνολογίας Υπολογιστών",
    "Τμήμα Μηχανολόγων και Αεροναυπηγών Μηχανικών",
    "Τμήμα Μηχανικών Ηλεκτρονικών Υπολογιστών και Πληροφορικής",
    "Τμήμα Μηχανικών Περιβάλλοντος",
    "Τμήμα Πολιτικών Μηχανικών",
    "Τμήμα Χημικών Μηχανικών"
]




myCombo = ttk.Combobox(root, value=options, width = 200)
myCombo.grid(row=17,column=0, sticky=W)
myCombo.bind("<<ComboboxSelected>>", comboclick)


Button(root, text="Επιλογή", width=6, command=click).grid(row=21, column=0, sticky=W)

root.mainloop()

> Blockquote

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You have to create a (global) variable :

enterned_text = StringVar()

Because .get() is a fonction from a tkinter class : StringVar
So you have to create the object before calling its function !

And I don’t understand why you are using : import tkinter as ttk if you already get the package with the line : from tkinter import *

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading