tkinter should i use tk.Frame or my own tk.Frame.__init__ class

Question

For my program i currently create a parent/frame by doing

tk.Frame(parent, bg = "#E6E6FA"...)

but i am curious if i should create my frame using my own class
class Parent(tk.Frame): def __init__(self, parent, *args): tk.Frame.__init__(self, parent, *args)

I would then create a frame by doing

Parent(parent, {"bg": "#E6E6FA", "width": 1280, "height": 720})

This is for my A-Level Computing coursework but i intend to carry on with computing at uni so i would like to know which to use.


Show source
| class   | python   | python-3.x   | object   | tkinter   2017-01-07 15:01 1 Answers

Answers ( 1 )

  1. 2017-01-07 18:01

    If you are not adding any special attributes or methods to the frame (ie: your __init__ is virtually empty), there's no reason to create your own class. You are merely adding complexity without adding any value.

◀ Go back