Hey, when I execute the following code I get "App instance has no attribute rolls" I have no clue as to why this is and any help would be awesome, Thanks.

import Tkinter

class App:

    def __init__(self, master):
        self.sticky_all = Tkinter.N+Tkinter.W+Tkinter.E+Tkinter.S
        self.frame = Tkinter.Frame(master)

        # Dice Buttons.
        self.bd4 = Tkinter.Button(self.frame, text="D4", command = self.roll_dice()) # Button for D4.

        # Text Field.
        self.rolls = Tkinter.Text(self.frame, width=15, height=1)
        self.rolls.tag_configure("center", justify='center')

        # Grid.
        self.rolls.grid(row=0, column=1)
        self.bd4.grid(row=0, column=0)

    def roll_dice(self):
        self.rolls.insert('end', 'text', 'center')

root = Tkinter.Tk()
app = App(root)

Ah, okay.
I was sending the Result of the function, not the actual function itself.
To fix this I used lambda between the = and my function.

self.bd4 = Tkinter.Button(self.frame, text="D4", command = lambda: self.roll_dice())

Since you are not passing any args, this will do:
self.bd4 = Tkinter.Button(self.frame, text="D4", command=self.roll_dice)

self.sticky_all = 'ewns'

Edited 3 Years Ago by bumsfeld

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