Posts

Showing posts from September, 2021

tkinter assignment

Image
 Fundamental structure of a tkinter program Do the following programs to learn the concept Hello world Basic tkinter program from tkinter import * # writing code needs to # create the main window of # the application creating # main window object named root root = Tk() # giving title to the main window 400x400 root.geometry('400x400') root.title("First_Program") # Label is what output will be # show on the window label = Label(root, text ="Hello World !") label.pack() #button shows a command button = Button(root, text ='Close',command=root.destroy)  button.pack(side='bottom')       # calling mainloop method which is used # when your application is ready to run # and it tells the code to keep displaying root.mainloop() Drawing some simple shapes in canvas from tkinter import * root = Tk() C = Canvas(root, bg="yellow",height=250, width=300) line = C.create_line(108,120,320, 40,fill="green") arc = C.create_arc(180, 150, 80,21...

Interfaces in Python

An abstract class and interface appear similar in Python. The only difference in two is that the abstract class may have some non-abstract methods, while all methods in interface must be abstract, and the implementing class must override all the abstract methods. Rules for implementing Python Interfaces We need to consider the following points while creating and implementing interfaces in Python  Methods defined inside an interface must be abstract. Creating object of an interface is not allowed. A class implementing an interface needs to define all the methods of that interface. In case, a class is not implementing all the methods defined inside the interface, the class must be declared abstract. Ways to implement Interfaces in Python We can create and implement interfaces in two ways − Formal Interface Informal Interface Formal Interface Formal interfaces in Python are implemented using abstract base class (ABC). To use this class, you need to import it from the abc module. Examp...