Tkinter: How to add kwargs to a class you inherit from?
<p>How do I add keyword arguments (<a href="http://effbot.org/tkinterbook/frame.htm" rel="nofollow">**options</a>) to a Tkinter class that inherits from <code>tk.Frame</code>? For example, all I want to do is set the frame's <code>width</code> and <code>height</code> (or any other options).</p>

<p>The broader question is: how do I add **kwargs to the object the class itself inherits from?</p>

<pre><code>class profiles(tk.Frame):

  def __init__(self, parent, *args, **kwargs):
    self.parent = parent
    kwargs['width'] = 900
    kwargs['height'] = 600
    super(profiles, self).__init__(parent, *args, **kwargs)
</code></pre>

<p><strong>Edit</strong>:</p>

<p>Here's a complete code example of what I'm trying to understand. This is the entire code:</p>

<pre><code>import tkinter as tk

class profiles(tk.Frame):

  def __init__(self, parent, *args, **kwargs):
    self.parent = parent
    kwargs['width'] = 900
    kwargs['height'] = 600
    kwargs['background'] = 'red'
    #tk.Frame.__init__(self, parent, *args, **kwargs)
    super(profiles, self).__init__(parent, *args, **kwargs)

    #self.parent.geometry('900x600')

    self.profile_name_label = tk.Label(self.parent, text='Profile name:')
    self.profile_name_label.grid(row=0, column=0, padx=(20), pady=20)

    self.ProfileNameVar = tk.StringVar()
    self.profile_name_entry = tk.Entry(self.parent, textvariable=self.ProfileNameVar)
    self.profile_name_entry.grid(row=0, column=1, pady=(20))

root = tk.Tk()
profiles(root)
root.mainloop()
</code></pre>

<p>Questions about this code:</p>

<ol>
<li><p><code>self.parent.geometry('900x600')</code> does what I expect which is resizing the window. <strong>Should kwargs['width'] = 900 and kwargs['height'] = 600 do the same thing Since <code>tk.Frame</code> sits inside its parent <code>root</code>?</strong> It seems like none of the <code>kwargs</code> I add do anything.</p></li>
<li><p>Even if I add <code>kwargs['background'] = 'red'</code>, I see no effect. I've seen examples of people using this syntax: <a href="https://mail.python.org/pipermail/tutor/2006-August/048394.html" rel="nofollow">here</a>, <a href="http://stackoverflow.com/questions/14459993/tkinter-listbox-drag-and-drop-with-python/25023944#25023944">here</a>. <strong>Why doesn't the background color turn red?</strong></p></li>
</ol>

<p><a href="http://i.stack.imgur.com/WQ8wz.png" rel="nofollow"><img src="http://i.stack.imgur.com/WQ8wz.png" alt="picture of tkinter window"></a></p>

<p>Just add what you want to add directly, without adding it to <code>kwargs</code>:</p>

<pre><code>class profiles(tk.Frame):

    def __init__(self, master, *args, **kwargs):
        tk.Frame.__init__(self, master, width=900, height=800, *args, **kwargs)
</code></pre>

python class tkinter