<div>from Tkinter import *</div><div>import MySQLdb</div><div><br></div><div>class Snoop(Frame):</div><div>    def __init__(self, master):</div><div>        Frame.__init__(self, master)</div><div>        self.grid()</div><div>
        self.create_widgets()</div><div><br></div><div>    def create_widgets(self):</div><div>        Label(self, text = &quot;Database Name:&quot;).grid(row = 0, column = 0, sticky = W)</div><div>        self.txt_box = Entry(self, text = &quot;hool&quot;).grid(row = 0, column = 1, sticky = W)</div>
<div>        Button(self, text = &quot;Submit&quot;, command = self.connect_db).grid(row = 1, column = 1, sticky = W)</div><div>        Label(self, text = &quot;Tables:&quot;).grid(row = 2, column = 0, sticky = W)</div><div>
       </div><div>        Label(self, text = &quot;Information:&quot;).grid(row = 2, column = 1, sticky = W)</div><div>       # self.txt = Text(self, width = 40, height = 5, wrap = WORD).grid(row = 3, column = 1, sticky = W)</div>
<div>       </div><div>    def connect_db(self):</div><div>        db= MySQLdb.connect(host=&quot;localhost&quot;, user=&quot;root&quot; , passwd=&quot;&quot;)</div><div>        cursor = db.cursor()</div><div>        cursor.execute(&quot;show databases&quot;)</div>
<div><br></div><div>        self.favorite = StringVar()</div><div><br></div><div>        result = cursor.fetchall()</div><div>        i = 4</div><div>        for record in result:</div><div>            Radiobutton(self,</div>
<div>                     text = record,</div><div>                     variable = self.favorite,</div><div>                     value = record,</div><div>                     command = self.update_text</div><div>                     ).grid(row = i, column = 0, sticky = W)</div>
<div>            i+=1</div><div>        </div><div>        #print database</div><div>        #self.txt.delete(0.0, END)</div><div>        #self.get_db(database)</div><div>    def update_text(self):</div><div>        print self.favorite.get()</div>
<div>        trt = self.favorite.get()</div><div>        self.txt_box.insert(END,trt)</div><div><br></div><div>   </div><div><br></div><div>#db.close</div><div>root = Tk()</div><div>root.title(&quot;Snoop&quot;)</div><div>
start = Snoop(root)</div><div><br></div><div>root.mainloop()</div><div><br></div><div><br></div><div><br></div><div>The above code will snoop and fetch all d available databases using tkinter. When I select one of these databases, the name should be inserted in a text field instead it throws the following error ;</div>
<div><br></div><div>Exception in Tkinter callback</div><div>Traceback (most recent call last):</div><div>  File &quot;/usr/lib/python2.6/lib-tk/Tkinter.py&quot;, line 1413, in __call__</div><div>    return self.func(*args)</div>
<div>  File &quot;/home/NetBeansProjects/python/src/Xsnoop.py&quot;, line 45, in update_text</div><div>    self.txt_box.insert(END,trt)</div><div>AttributeError: &#39;NoneType&#39; object has no attribute &#39;insert&#39;</div>
<div>   </div><div><br></div><div>How can i correct this?</div><div><br></div>