Wrapping things inside a Class – Python GUI using Tkinter

  tkinter

Email

Wrapping things inside a Class – Python GUI using Tkinter

from tkinter import *

class MyButton:
    def __init__(self,master,text):
        frame= Frame(master)
        frame.pack()
        self.printButton = Button(frame, text=text, command=self.print1)

        self.printButton.pack()
    def prinf1(self):
        print("this is values")

    if __name__ == '__main__':
        root=Tk()
        MyButton(root, "My Button1")
        MyButton(root, "my Button2")
        root.mainloop()
Spread the Code

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of