Show Label and Button Widgets Python Tkinter Program

By | March 22, 2020

Topic: Show Label and Button Widgets Python Tkinter Program

# Write a Python GUI program
# using tkinter module
# to show a Label and button in window


import tkinter as tk

def main():
    window= tk.Tk()
    window.title("Show Label and Button Widgets")
    window.geometry("400x200")
    
    # create a label with some text 
    label1 = tk.Label(window, text="Hello I am a Label")
    
    # place this label in window at position x,y 
    label1.place(x=150,y=50)

    # create a button with text Button 1
    btn1 = tk.Button(window, text="Button1")
    # place this button in window at position x,y 
    btn1.place(x=150,y=100)
    window.mainloop()

main()

Output:

Python GUI Program show Label and Button tkinter module

Python GUI Program show Label and Button tkinter module

Loading

Leave a Reply

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