Tkinter question
Martin Franklin
mfranklin1 at gatwick.westerngeco.slb.com
Wed Jun 15 02:39:10 EDT 2005
Nicholas.Vaidyanathan at aps.com wrote:
> I'm sure there must be a way to do this, but I can't figure it out for
> the life of me… I'm writing a program where I would like to use a
> button's text field as part of an if statement. I set up my button like
> this:
>
> i = [ "7", "8","9", "/", "4", "5", "6", "*", "1", "2", "3", "-", "0",
> ".", "=", "+"]
> t = 0 #iterator through the sequence
>
> for x in range(4):
> for y in range(4):
> self.buttonx = Button(self, text = "%s" %i[t] ,
> width=10, command = self.pressed)
> self.buttonx.grid( row=x+1, column = y, sticky = W+E+S)
> t+=1
>
> What I would like to do is is check which buttons' text values are
> digits, and if the text is, I would like to append the number to a
> label. But:
>
> if(self.buttonx.title.isdigit):
>
To get the text of a button:
self.buttonx["text"]
More information about the Python-list
mailing list