Python Forum
Tkinter's strange error
Thread Rating:
  • 2 Vote(s) - 1.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tkinter's strange error
#1
What have caused it?

my_string = '1)from decimal import Decimal'
Error:
Exception in Tkinter callback Traceback (most recent call last): File "C:\Python34\lib\tkinter\__init__.py", line 1538, in __call__ return self.func(*args) File "C:/Users/Владелец/Desktop/programming/Pr_Python/Pr_Python.py", line 154, in find into_string.get_inf(output) File "C:/Users/Владелец/Desktop/programming/Pr_Python/Pr_Python.py", line 134, in get_inf reester.input_tk(k, road) File "C:/Users/Владелец/Desktop/programming/Pr_Python/Pr_Python.py", line 38, in input_tk road.insert(INSERT, my_string) File "C:\Python34\lib\tkinter\__init__.py", line 3145, in insert self.tk.call((self._w, 'insert', index, chars) + args) _tkinter.TclError: invalid command name ".40584808"
Reply
#2
Hi,

Can you provide details of what you are doing with the string? i.e. the code the is being used to process this string.
At the moment I cannot see exactly, what you are trying to achive.

Thanks

Bass

"The good thing about standards is that you have so many to choose from" Andy S. Tanenbaum
Reply
#3
I created programm with tkinter which has simple interface. It includs datebase and system for searching information. But I got a problem which I can't solve. I also can't find a reason of it. Please, help!!!

from tkinter import *
import shelve

root = Tk()
root.title('First stage')
root.geometry('750x500')
root.configure(background='darkblue')
searching = Text(root, height=2, width=35, bg='green', fg='black', font='Arial 14', wrap=WORD)
output = Text(root, height=8, width=35, bg='green', fg='black', font='Arial 14', wrap=WORD)
rememmber = Text(root, height=5, width=35, bg='green', fg='black', font='Arial 14', wrap=WORD)
classes_f = Text(root, height=2, width=25, bg='green', fg='black', font='Times 14',wrap=WORD)
deletion = Text(root, height=1, width=5, bg='green', fg='black', font='Times 14', wrap=WORD)


class Reester:
    def __init__(self):
        self.list = []
        self.into_range = 0
        self.special_inf = None
    def change(self, dich):
        self.list.append(dich)
    def deleting(self):
        bd = shelve.open('Data.db')
        for (a, b) in self.list:
            tik = bd[b]
            tik[1].pop(a)
            bd[b] = tik
        self.list = []
        self.into_range = 0
        bd.close()
    def take_it(self, STRING):
        self.special_inf = STRING
    def input_tk(self, STRING, road, value=True):
        if value:
            self.into_range += 1
            my_str = str(self.into_range)
            my_string = my_str + ')' + STRING + '\n'
            road.insert(INSERT, my_string)
        else:
            road.insert(STRING)
    def cleaning(self, road, waste=True):
        if waste:
            self.list = []
            self.into_range = 0
            road.get(0.1, 100.0)
        else:
            road.get(0.1, 100.0)
    def unknow(self, road):
        road.insert(INSERT, 'We havn\'t any information')

reester = Reester()

class Waiting:
    def __init__(self):
        self.name = 'Waiting'
        self.List = []

class Type:
    def __init__(self, List):
        self.name = List[0]
        self.key = List[2]
        self.List = [{}, []]
        bd = shelve.open('Data.db')
        for i in bd:
            if bd[i].name == 'Warning':
                pass
            else:
                tik = bd[i]
                tik.List[0][self.name] = []
                bd[i] = tik
        bd.close()
    def read_class(self, road):
        for b in self.List[1]:
            bd = shelve.open('Data.db')
            for k in b:
                reester.input_tk(k, road)
                reester.change((k, self.name))
        for b in self.List[0]:
            reester.input_tk(bd[b].List[1][self.List[0][b]], road)
            bd.close()
    def find_other(self):
        bd = shelve.open('Data.db')
        for i in bd:
            if bd[i].name == 'Warning':
                for k in bd[i].List:
                    if self.key in k:
                        self.List[1].append(k)
                        tik = bd['Warning']
                        tik.pop(k)
                        bd['Warning'] = tik
            else:
                for k in bd[i].List[1]:
                    if self.key in k:
                        self.List[0][i].append(i.List[1].index(k))
        bd.close()


class Inform:
    def __init__(self, STRING):
        self.STRING = STRING
    def rememb(self):
        bd = shelve.open('Data.db')
        Bool = False
        Bool_2 = None
        for i in bd:
            if bd[i].name == 'Waiting':
                pass
            else:
                if bd[i].key in self.STRING:
                    if not Bool_2:
                        tik = bd[i]
                        tik[1].append(self.STRING)
                        bd[i] = tik
                        Bool_2 = (tik[1].index(self.STRING), i)
                    else:
                        tik = bd[i]
                        for m in tik[0]:
                            if m == i:
                                tik[0][m].append(Bool_2[0])
                    Bool = True
        if not Bool:
            tik = bd['Waiting']
            tik.List.append(self.STRING)
            bd['Waiting'] = tik
        bd.close()
    def get_inf(self, road):
        bd = shelve.open('Data.db')
        Bool = False
        our_list = []
        for i in bd:
            if bd[i].name == 'Waiting':
                for k in bd['Waiting'].List:
                    if self.STRING in k:
                        reester.input_tk(k, road)
                        Bool = True
            else:
                for k in bd[i].List[1]:
                    if self.STRING in k:
                        our_list.append((k, i))
                        reester.input_tk(k, road)
                        Bool = True
        if Bool:
            for k in our_list:
                reester.change(k)
        else:
            reester.unknow(road)
        bd.close()


def find():
    reester.cleaning(output)
    into_text = searching.get(0.1, 100.0).strip()
    into_string = Inform(into_text)
    root.after(100, into_string.get_inf(output))

def deleting():
    reester.deleting()
    reester.cleaning(output)

dels = Button(root, height=1, width=5, bg='black', fg='green', font='Arial 14', command=deleting, text='Delete')
go = Button(root, height=1, width=3, bg='black', fg='green', font='Arial 14', command=find, text='Find')

def know():
    reester.take_it(output.get(0.1, 100.0))
    reester.input_tk(reester.special_inf, rememmber, value=False)
know_it = Button(root, height=1, width=5, bg='black', fg='green', font='Arial 14', command=know, text='Collect')

def clean1():
    reester.cleaning(output)
cleaning = Button(root, height=1, width=6, bg='black', fg='green', font='Arial 14', command=clean1, text='Clean')

def clean2():
    reester.cleaning(searching, waste=False)
cleaning2 = Button(root, height=1, width=6, bg='black', fg='green', font='Arial 14', command=clean2, text='Clean')

def writing():
    into_text = searching.get(0.1, 100.0).strip()
    into_string = Inform(into_text)
    into_string.rememb()

def new_class():
    dicht = classes_f.get(0.1, 100.0).strip().split()
    new_type = Type(dicht)
    bd = shelve.open('Data.db')
    new_type.find_other()
    bd[new_type.name] = new_type
    bd.close()

def read_classes():
    into_text = classes_f.get(0.1, 100.0).strip()
    bd = shelve.open('Data.db')
    tik = bd(into_text)
    bd.close()
    tik.read_class(output)


def new_root():
    file = open('data.pkl', 'rb')
    some = pickle.load(file)
    root2 = Tk()
    root2.title('Text')
    root2.geometry('750x600')
    root2.configure(background = 'darkblue')
    out = Text(root2, height=40, width=100, bg='green', fg='black', font='Arial 14')
    out.insert(INSERT, ' '.join(some))
    out.place(x=10, y=10)
    mainloop()

out_read = Button(root, height=1, width=6, bg='black', fg='green', font='Arial 14', command=new_root, text='Show all')
write = Button(root, height=1, width=4, bg='black', fg='green', font='Arial 14', command=writing, text='Write')
classes_write = Button(root, height=1, width=8, bg='black', fg='green',font='Arial 13', text='New Class', command=new_class)
classes_find = Button(root, height=1, width=9, bg='black', fg='green', font='Arial 13', text='Read Class', command=read_classes)

searching.place(x = 50, y = 40)
go.place(x = 450, y = 40)
output.place(x = 50, y = 130)
know_it.place(x = 450, y = 150)
classes_write.place(x = 590, y = 220)
classes_f.place(x = 510, y = 270)
classes_find.place(x = 585, y = 335)
cleaning.place(x = 200, y = 460)
cleaning2.place(x = 590, y = 40)
dels.place(x = 595, y = 450)
rememmber.place(x = 50, y = 335)
deletion.place(x = 600, y = 400)
write.place(x = 500, y = 40)
out_read.place(x = 590, y = 100)
mainloop()
Error:
Exception in Tkinter callback Traceback (most recent call last): File "C:\Python34\lib\tkinter\__init__.py", line 1538, in __call__ return self.func(*args) File "C:/Users/Владелец/Desktop/programming/Pr_Python/Pr_Python.py", line 154, in find root.after(100, into_string.get_inf(output)) File "C:/Users/Владелец/Desktop/programming/Pr_Python/Pr_Python.py", line 134, in get_inf reester.input_tk(k, road) File "C:/Users/Владелец/Desktop/programming/Pr_Python/Pr_Python.py", line 38, in input_tk road.insert(INSERT, my_string) File "C:\Python34\lib\tkinter\__init__.py", line 3145, in insert self.tk.call((self._w, 'insert', index, chars) + args) _tkinter.TclError: invalid command name ".36062992"
Reply
#4
Your new thread has been merged into this one, since they're the same issue.
Likewise, the thread has been moved to the appropriate sub-forum.
Reply
#5
Hi,

It looks as though, Tk may be, being called incorrectly (possibly due to incorrect paramaters).

Could you look at line 40 and check to see if an additional parameter should be passed to indicate the position of where the string needs to be inserted? or does it default the value?

Bass

"The good thing about standards is that you have so many to choose from" Andy S. Tanenbaum
Reply
#6
What are the setup conditions to replicate the error?
I'll try it here and see what's going on, when I try to run it now, the initial screen comes up just fine.

   

click to enlarge
Reply
#7
Can anybody help me ? Sad
Reply
#8
Please don't PM, the forum is here for all, and any comments should be shared
My previous post was to state that I couldn't repeat your problem, and was looking
for the steps you took to get it in the first place.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020