How to make a window in python using keyword?
The most simple way to make a python root window is to use the module named Tkinter. In this module you can make a root window with the help of the function Tk().
In the code below we first import everything from tkinter and then make a variable named window and we store the function named Tk() which is the main keyword to create a window. Now we set the label in the window to do this we first make a variable named 'lbl' and the use the 'Label' function in which we first type in where we are going to put the label in. Then we type the text we are going to display in the window. Then the color of the label. Then the font of the text and size of it. But this window must be active continuously to see it, to do this we use '.mainloop()' function to set the loop. Other things like the title, label, size of the window is in these two function.
from tkinter import *
#keyword for root window
window=Tk()
# settings the Label
lbl=Label(window, text="Hello World!!!", fg='red', font=("Helvetica", 16))
# Placing the label is important to show the lable on the screen
lbl.place(x=60, y=50)
#setting the titel of the window
window.title('Hello World!!!')
# this is the size of the window
window.geometry("300x200+10+10")
#setting the loop
window.mainloop()
output =
Now that we have learned that how to make a window we can make a simple project using the module 'tkinter' and 'pydictionary'
Comments
Post a Comment
If you have any doubts please let me know