Tkinter Query - Solved it

Newt newt_e at blueyonder.co.uk
Fri Oct 11 18:02:36 EDT 2002


> Post that code...  Let's take a look.

Solved it !!! I've included the source (as Chaz requested) below.
Up until now, I've used the following line to create sval:
    sval = Label(wskill, text = "10").grid=(row=pos+2,col=2)

Below, I've split it into to two (after reading bits of the Python cookbook
amongst other things) as that seemed to be the recomended way.
And now it works fine. Stricly speaking, I guess I should use a textvariable
to hold the value. I might try that.

Thanks for everybodies help,

Newt


class SelectSkills:

    def __init__( self, parent ):
        global root
        wskill = Toplevel(root)
        allskills = ['Skill 1','Skilll 2','Skill 3','Skill 4']
        wskill.grid
        wskill.rowconfigure(0,minsize=10)
        wskill.columnconfigure(0,minsize=10)
        pos = 0
        self.svals = []
        for skill in allskills:

            sval = Label(wskill, text = "10")
            sval.grid(row=pos+2,col=2)
            self.svals.append(sval)
            dbut_callback = curry( self.down, pos,  parent )
            dbut = Button(wskill, text='<',
command=dbut_callback ).grid(row=pos+2,col=1)
            rbut = Button(wskill, text='>').grid(row=pos+2,col=3)
            pos = pos + 1

        wskill.grab_set()
        wskill.focus_set()
        wskill.wait_window()
        return

    def down( self, i, *crap):
        a = len(self.svals)
        sval = self.svals[i]
        self.svals[i].configure(text = '9')
        return







More information about the Python-list mailing list