python ui code example

Example 1: create window with python

# basic setup
from tkinter import *

app = Tk() # the application itself
app.title("Test") # title of window

label = Label(app, text="Testing testing one, two, three") # creates label
label.pack() # adds the label to the window

app.mainloop() # this must go at the end of your window code

Example 2: basic tkinter gui

import tkinter as tk
root = tk.Tk()
root.title("my title")
root.geometry('200x150')
root.configure(background='black')

#	enter widgets here

root.mainloop()

Example 3: python gui

# App python gui

import tkinter as tk
import webbrowser as wb


def Facebook():
    wb.open('facebook.com')


def Instagram():
    wb.open('instagram.com')


def Twitter():
    wb.open('twitter.com')


def Youtube():
    wb.open('youtube.com')


def Google():
    wb.open('google.com')


window = tk.Tk()
window.title('Browser')

google = tk.Button(window, text='Google', command=Google)
youtube = tk.Button(window, text='Youtube', bg='red', fg='white', command=Youtube)
twitter = tk.Button(window, text='Twitter', bg='powder blue', fg='white', command=Twitter)
Instagram = tk.Button(window, text='Instagram', bg='white', fg='black', command=Instagram)
facebook = tk.Button(window, text='Facebook', bg='blue', fg='white', command=Facebook)
facebook.pack()
Instagram.pack()
twitter.pack()
youtube.pack()
google.pack()

window.mainloop()

Example 4: python gui

import tkinter as tk
#Importing the main module
window = tk.Tk()
window.mainloop()

Example 5: python gui builder

from tkinter import *

def changel():
    if l['text']!='Stop it!':
        l['text']='Stop it!'
    else:
        l['text']='Are you over?'

w = Tk()
l = Label(w,text = 'GUI Interface')
b = Button(w,text = 'A normal button',command = changel )
t = w.title('A normal window')
l.pack()
b.pack()
w.mainloop()

Example 6: python gui library

### Answer to: "" ###

###
#  You can find thirteen gui libraries for python here:
#  https://medium.com/issuehunt/13-python-gui-libraries-a6196dfb694
#
#  Personally, I like "Kivy".
###