Python 3 Tkinter GUI Hello World Program

By | March 22, 2020

Topic: Python 3 Tkinter GUI Hello World Program

# Write a Python GUI program
# using tkinter module
# to diplay a window
# with title "Hello World"

import tkinter as tk

def main():
    window= tk.Tk()
    window.title("Hello World")

    window.mainloop()

main()

Output:

Python 3 Tkinter GUI Hello World Program

Python 3 Tkinter GUI Hello World Program

But we find that the title is not completely shown. Therefore we will add one more line of Python code to set (increase) size of the main window.

# Write a Python GUI program
# using tkinter module
# to diplay a window
# with title "Hello World"

import tkinter as tk

def main():
    window= tk.Tk()
    window.title("Hello World")
    window.geometry("400x200")

    window.mainloop()

main()

Here we have given the size dimentions to the main window 400×200 using geometry() method.

Output:

Python Tkinter GUI Program Hello World

Python Tkinter GUI Program Hello World

 

Loading

4 thoughts on “Python 3 Tkinter GUI Hello World Program

  1. Pingback: Adding Menus to Python 3 tkinter GUI Programs | EasyCodeBook.com

  2. Pingback: Python GUI Find Factorial by Recursive Function | EasyCodeBook.com

  3. Pingback: Python GUI Area of Triangle | EasyCodeBook.com

Leave a Reply

Your email address will not be published. Required fields are marked *