Create a new window screen by tkinter in python by R4R Team

-For create a GUI application, we firstly need a window screen at which we can add our widget.


program-


from tkinter import *

win=Tk()
win.mainloop()


output-




-In this program, firstly we import everything from the tkinter module by from tkinter import *, Then we create a window by calling the constructor by Tk() and make object of the window named as 'win' which deals with the every operation on the window screen.
-Here win.mailoop() are used to hold the Screen, we need to write this line in every Tkinter program otherwise output screen is not display.

Change The Title , geometry and background-color of the window screen-



program-


from tkinter import *

win=Tk()

win.title("My first page")
win.geometry("700x400")
win.config(bg="red")

win.mainloop()


output-





-In this program, win.title() change the title of the window screen which shows at the top-left of the window screen.
-win.geometry("700x400") changes the size of the window screen where x=700 and y=400.
-Here 'bg' is used to change the back-ground of the window screen.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!