python - TypeError : 'Tk' Object is not callable -


i'm writing program supposed connect server, check dbs , specific table (and how items in these tables), , i'm using tkinter gui. problem whenever try use it, have error "typeerror : 'tk' object not callable". program used work, doesn't anymore, have got idea this? (don't worry strange names, made i'm sure there no problems, variable having same name function or so)

import pyodbc import sys tkinter import *  #wrote down variables here remembered them username = '' password = '' server_name = '' database = '' table = 'véhicules' nom_instance = '' total = '' nb_vehic = '' master = tk()  label(master,text="what username ?").pack() yzx = entry(master) yzx.pack() username = yzx.get() yzx.delete(0, end)  label(master,text="what user's password?").pack() yxz = entry(master) yxz.pack() password = yxz.get() yxz.delete(0, end)  label(master, text="what server's ip adress ?").pack() zyx = entry(master) zyx.pack() server_name = zyx.get() zyx.delete(0, end)  label(master, text="which authority want connect ?").pack() #not sure traduction of word, original instance in french xyz = entry(master) xyz.pack() nom_instance=xyz.get() xyz.delete(0, end)   def surelydoesntexist():     connexion = "driver={sql server};server="+server_name+"\\"+nom_instance+";database=master;user id="+username+";password="+password #peut être ajouter trusted_connection=yes #at point, connect server , looks different dbs     connect = pyodbc.connect(connexion)     cursor = connect.cursor()      db in cursor.execute("select * sys.databases"):         try:             connexion = ("driver={sql server};server="+server_name+"\\"+nom_instance+";database="+db.name+";user id="+username+";password="+password)             print ('%s ' % connexion)             connect = pyodbc.connect(connexion)             cursor = connect.cursor()             cursor.execute("select count(*) véhicules")             row = cursor.fetchone()             nb_vehic = row.user_count             print ('%d items in db' % row.user_count)             total = total + int(nb_vehic)         except: # catch *all* exceptions             e = sys.exc_info()[0]             print( "error: %s" % e )  = button(master, text="connect !", command=surelydoesntexist).pack()  master() 

your code totally fine exception last line:

instead of master() need write master.mainloop() , should fine.


remark: tested this, had uncomment import pyodbc, fuction surelydoesntexist , button but because neither have needed packages nor connection sever.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -