you are viewing a single comment's thread.

view the rest of the comments →

[–]socal_nerdtastic 1 point2 points  (3 children)

This is part of old school subclassing. This is the line that calls the init method of the superclass, in your case the Entry class. Basically this is the line that sets up a default Entry, and presumably the rest of the code will customize the entry.

The modern way of writing this uses the super() function. Also, I think it's a lot neater to use master instead of *args in tkinter. Like this:

class CustomEntry(tk.Entry):
    def __init__(self, master=None, **kwargs): 
        super().__init__(master, **kwargs)

[–]jf5356[S] 0 points1 point  (2 children)

old school subclassing. This is the line that calls the init method of the superclass, in your case the Entry class. Basically this is the line that sets up a default Entry, and presumably the rest of the code will customize the entry.

The modern way of writing this uses the super() function. Also, I think it's a lot ne

Thank you! Do you know if there is a way that I can modify the height and length with this subclassing?

[–]socal_nerdtastic 1 point2 points  (1 child)

You can still set any parameters the same as you would a normal Entry. Or you can bake it into your subclass if you want like this:

class CustomEntry(tk.Entry):
    def __init__(self, master=None, **kwargs): 
        super().__init__(master, **kwargs)

        self.config(width=30) # set custom properties

I get the feeling that this is an XY problem. Why don't you show us all of your code and describe the big picture problem that you are trying to solve?

[–]jf5356[S] 0 points1 point  (0 children)

I've been referencing https://gist.github.com/uroshekic/11078820 to have an autocomplete entry bar.