On Mar 5, 11:31 am, John Salerno <johnj...@gmail.com> wrote:
> Ok, so use pack when putting the frame into the root, since that's
> all that goes into the root directly. But just out of curiosity,
> what did I do wrong with using grid? How would it work with grid?

If you read my post carefully, i said: "You need to use
columnconfigure and rowconfigure on ROOT!". Here is the solution;
although, not the correct code you should use because pack is perfect
for this:

## START CODE ##
import tkinter as tk
import tkinter.ttk as ttk

class AppFrame(ttk.Frame):
    def __init__(self, parent, **kwargs):
        super().__init__(parent, **kwargs)
        self.create_widgets()

    def create_widgets(self):
        entry = ttk.Entry(self)
        entry.grid(row=0, column=1, sticky='nsew')
        label = ttk.Label(self, text='Name:')
        label.grid(row=0, column=0, sticky='nsew')

root = tk.Tk()
root.title('Test Application')
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
frame = AppFrame(root, borderwidth=15, relief='sunken')
frame.grid(row=0, column=0, sticky='nsew')
root.mainloop()
## END CODE ##

> I don't like importing things piecemeal. I suppose I could do:

So you prefer to pollute? How bout we just auto import the whole
Python stdlib so you can save a few keystrokes?

> import tkinter.constants as tkc (or something like that)
>
> and qualify each constant. Seems like more work, but it just seems
> better than having to manage each constant that I need in the import
> list.

Then do "from tkinter.constants import *". I have no complaints
against import all the constants during testing/building, however, you
should be a professional and import only the constants you are going
to use.

> Also, N+S+E+W and (N, S, E, W) don't seem to work unless qualified,

Of course not, you never imported them! How could that code possibly
work?

> so that's four more constants I'd have to explicitly import. And
> (tk.N, tk.S, tk.E, tk.W) is just horrible to look at.

Wah!

Stop whining and act like a professional! You complain about
qualifying constants but you happily type "self" until your fingers
bleed without even a whimper???

Look, either import ONLY the constants you need, or qualify each
constant with a module name/variable; that is the choices available to
a professional. Or, just be lazy and pollute your namespace.

FYI: Lazy coders get what they deserve in the end.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to