Mathieu Paurisse
Mathieu Paurisse

Reputation: 470

Class functions and Tkinter

I am currently stuck on a problem with Python and Tkinter. I want to create a simple application with its UI made on Tkinter. To do so, I created a class to define my application and I want to create my GUI layout in a separate class function. However, when I call it, it has no effect on my Tk window (in this particular example, the title is not modified) Here is the code

from Tkinter import *

fen =Tk()

class test_Tk_class:
    def __init__(self):
        self.make_title

    def make_title(self):
        fen.title("Test")


a = test_Tk_class()
fen.mainloop()

Thanks for any help !

Upvotes: 0

Views: 146

Answers (1)

falsetru
falsetru

Reputation: 369124

You're missing () after self.make_title:

from Tkinter import *

fen =Tk()

class test_Tk_class:
    def __init__(self):
        self.make_title() # <------------

    def make_title(self):
        fen.title("Test")


a = test_Tk_class()
fen.mainloop()

Upvotes: 2

Related Questions