No error but not working, run function when text changes Tkinter

Viewed 132

If the mywidget entry changes it should run the function atado_enter. If i put some error into this function, it gives me error msg, but if i want to do something it strictly do nothing. Can someone explain me whats wrong with it?

#!usr/bin/python
#-*- coding: utf-8 -*-

import os
import time
import mysql.connector
import getpass
import smtplib
from email.mime.text import MIMEText
global atado_kartya_szam
global atvevo_kartya_szam
from PIL import Image, ImageTk
#from Tkinter import Tk, Text, TOP, BOTH, X, N, LEFT
from Tkinter import * 
from Tkinter import Tk as tk
from ttk import Frame, Style, Entry, Label

class Example(Frame):

    def __init__(self, parent):     
        Frame.__init__(self, parent)        
        self.parent = parent
        self.initUI()

    def initUI(self):
        def atado_enter(*args): 
            print("vmi")

        self.parent.title("Pozi")
        self.pack(fill = BOTH, expand=True)

        frame1 = Frame(self)
        frame1.pack(fill=X)

        lbl1 = Label(frame1, text = "ĂtadĂł kártyája", width = 15)
        lbl1.pack(side = LEFT, padx=5, expand=True)

        myvar = StringVar()
        myvar.set('')
        mywidget = Entry(frame1,textvariable=myvar,width=10)
        mywidget.pack()
        myvar.trace('w',atado_enter)

def main():

    root = Tk()
    root.geometry("550x450+300+300") # width x heigth + x + y (on screen)
    app = Example(root)
    root.mainloop()  


if __name__ == '__main__':
    main()  
2 Answers
Related