I am beginning to write a tkinter program that will generate a DnD 3.5 Character Sheet.
I haven't gotten very far.
I'm using Python 3, and for some reason the sticky option of the .grid() method isn't working. When I run the code below, I get an error that says:
unknown option "-sticky"
At first I thought that maybe sticky had been renamed from Python 2, but I couldn't find any indication of this.
I must be doing something wrong, but I can't figure out what. It works fine when I leave out the sticky option, but it just looks silly.
I appreciate any help,

~MoosePasteInventor

from tkinter import *

class DnD35:
    def __init__(self, parent):
        self.DnDFrame = Frame(parent)
        self.DnDFrame.grid()
        self.playerInfo = Frame(parent)
        self.playerInfo.grid(in_=self.DnDFrame, column=0, row=0)
        self.VitalStats = Frame(parent)
        self.VitalStats.grid(in_=self.DnDFrame, column=0, row=1)

        self.playerLabel = Label(self.playerInfo, text="Player:", relief=GROOVE, sticky=E)
        self.playerLabel.grid(in_=self.playerInfo, column=0, row=0)
        self.playerEntry = Entry(self.playerInfo)
        self.playerEntry.grid(in_=self.playerInfo, column=1, row=0)

        self.nameLabel = Label(self.VitalStats, text="Name:", relief=GROOVE, sticky=E)
        self.nameLabel.grid(in_=self.VitalStats, column=0, row=0)
        self.nameEntry = Entry(self.VitalStats)
        self.nameEntry.grid(in_=self.VitalStats, column=1, row=0)

        self.ageLabel = Label(self.VitalStats, text="Age:", relief=GROOVE, sticky=E)
        self.ageLabel.grid(in_=self.VitalStats, column=2, row=0)
        self.ageEntry = Entry(self.VitalStats)
        self.ageEntry.grid(in_=self.VitalStats, column=3, row=0)

        self.raceLabel = Label(self.VitalStats, text="Race:", relief=GROOVE, sticky=E)
        self.raceLabel.grid(in_=self.VitalStats, column=4, row=0)
        self.raceEntry = Entry(self.VitalStats)
        self.raceEntry.grid(in_=self.VitalStats, column=5, row=0)

        self.heightLabel = Label(self.VitalStats, text="Height:", relief=GROOVE, sticky=E)
        self.heightLabel.grid(in_=self.VitalStats, column=0, row=1)
        self.heightEntry = Entry(self.VitalStats)
        self.heightEntry.grid(in_=self.VitalStats, column=1, row=1)

        self.weightLabel = Label(self.VitalStats, text="Weight:", relief=GROOVE, sticky=E)
        self.weightLabel.grid(in_=self.VitalStats, column=2, row=1)
        self.weightEntry = Entry(self.VitalStats)
        self.weightEntry.grid(in_=self.VitalStats, column=3, row=1)

        self.sizeLabel = Label(self.VitalStats, text="Size:", relief=GROOVE, sticky=E)
        self.sizeLabel.grid(in_=self.VitalStats, column=4, row=1)
        self.sizeEntry = Entry(self.VitalStats)
        self.sizeEntry.grid(in_=self.VitalStats, column=5, row=1)

        self.languagesLabel = Label(self.VitalStats, text="Languages:", relief=GROOVE, sticky=NE)
        self.languagesLabel.grid(in_=self.VitalStats, column=0, row=2)
        self.languagesText = Text(self.VitalStats, height=5, width=20)
        self.languagesText.grid(in_=self.VitalStats, column=1, row=2)

        self.racialLabel = Label(self.VitalStats, text="Racial Traits:", relief=GROOVE, sticky=NE)
        self.racialLabel.grid(in_=self.VitalStats, column=2, row=2)
        self.racialText = Text(self.VitalStats, height=5, width=40)
        self.racialText.grid(in_=self.VitalStats, column=3, row=2, columnspan=3)

root = Tk()
root.title("DnD35")
myapp = DnD35(root)
root.mainloop()

Look up the docs for sticky (you have to learn to help yourself). A hint is that there are no variables in your program named E, NE, etc.

Edited 6 Years Ago by woooee: n/a

I looked up the docs, and fixed my mistake. I changed it from

sticky=E

to

sticky="e"

, but it still gave me the same error. It says the error is in __init__.py, and that the error is: unknown option "-sticky".

Wow I feel stupid now. I just realized my mistake.
I put the "sticky" option in the Label() method rather than the grid() method.
The problem you pointed out, woooee, wasn't actually a problem. It recognizes both sticky=E and sticky="e" as valid, and they both work in exactly the same way.

The problem you pointed out, woooee, wasn't actually a problem. It recognizes both sticky=E and sticky="e" as valid, and they both work in exactly the same way.

E is recognized if you do a
from tkinter import *
which you can not rely on as normally "import tkinter" is used in my experience, especially if you are modifying someone else's code, and you are betting that E was not declared as a variable somewhere else in the program. "e" is always a good bet. Effbot's grid doc is a good reference http://effbot.org/tkinterbook/grid.htm And consider a function for all of those labels, passing the text, row, column, etc. to it. The same for the entry boxes, or one function to create the label and entry since entry column is always label column+1.

Edited 6 Years Ago by woooee: n/a

This question has already been answered. Start a new discussion instead.