-1

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

  • For a start I think you have a typo (`enterned_text` not `entered_text`) in your `click` function. This may not be the problem, but it can't be helping! – Christy Kail Jan 02 '22 at 10:32
  • You have nothing named `enterned_text` when you try `enterned_text.get()`. Where are you defining what `enterned_text` should be? – Christy Kail Jan 02 '22 at 10:38
  • Does this answer your question? [Python 3: UnboundLocalError: local variable referenced before assignment](https://stackoverflow.com/questions/10851906/python-3-unboundlocalerror-local-variable-referenced-before-assignment) – diggusbickus Jan 04 '22 at 17:24

1 Answers1

0

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 *

Tom Kuntz
  • 55
  • 1
  • 7