Creating the GUI as a class (4)

        self.s = StringVar() # variable to be attached to s_label
        s_label = Label(rframe, textvariable=self.s, width=12)
        s_label.pack(side='left')

        # finally, make a quit button:
        quit_button = Button(top, text='Goodbye, GUI World!',
                             command=self.quit,
                             background='yellow', foreground='blue')
        quit_button.pack(side='top', pady=5, fill='x')
        self.parent.bind('<q>', self.quit)

    def quit(self, event=None):
        self.parent.quit()

    def comp_s(self, event=None):
        self.s.set('%g' % math.sin(float(self.r.get())))

previousnexttable of contents