Python Forum
[Tkinter] !finddialog problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] !finddialog problem
#1
Cant find the error, little help is appreciated.
class FindDialog(Toplevel):
    def __init__(self, parent, *args, **kwargs):
        Toplevel.__init__(self, parent, *args, **kwargs)
        self.parent = parent
        self.geometry("450x200+550+200")
        self.title("Find")
        self.resizable(False,False)
        txtFind=Label(self,text="Find: ")
        txtFind.place(x=20,y=20)
        txtReplace=Label(self,text="Replace :")
        txtReplace.place(x=20,y=60)
        self.findInput=Entry(self,width=30)
        self.replaceInput=Entry(self,width=30)
        self.findInput.place(x=100,y=20)
        self.replaceInput.place(x=100,y=60)
        self.btnFind=Button(self,text="Find",command=self.parent.findWords)
        self.btnReplace=Button(self,text="Replace",command=self.parent.replaceWords)
        self.btnFind.place(x=200,y=90)
        self.btnReplace.place(x=240,y=90)
    
def find(self):
    self.find=FindDialog(self)


        
class MainMenu(Menu):
        def __init__(self, parent, *args, **kwargs):
            Menu.__init__(self, parent, *args, **kwargs)
            self.parent = parent
            self.edit = Menu(self, tearoff = 0)
            self.edit.add_command(label = 'Find', accelerator = 'Ctrl+F', command = self.parent.find)
Error:
Exception in Tkinter callback Traceback (most recent call last):   File "E:\Python\lib\tkinter\__init__.py", line 1883, in __call__     return self.func(*args)   File "c:/Users/Desktop/TextEditor/main.py", line 405, in find     self.find=FindDialog(self)   File "c:/Users/Desktop/TextEditor/main.py", line 16, in __init__     Toplevel.__init__(self, parent, *args, **kwargs)   File "E:\Python\lib\tkinter\__init__.py", line 2619, in __init__     self.title(root.title()) TypeError: 'str' object is not callable
Reply
#2
please show all code needed to be able to run.
That includes all import statements.

Thank you
Reply
#3
if __name__ == '__main__':
    root = Tk()
    root.title = 'Text'
    MainApplication(root).pack(side = TOP, fill = BOTH, expand = True)
    root.geometry('1250x850')
    root.iconbitmap('icons/icon.ico')
    root.mainloop()

I found the error, it was 3rd line  - root.title('Text')
Reply


Forum Jump:

User Panel Messages

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