Python Programmer
Discover 3 Hidden Gems: Tkinter Tips & Trick in Python!
Below are the two python files I used in this video and the actual video
The video files
The actual code in each file
Cool Tkinter Widgets
from tkinter import *
from tkinter.ttk import *
def on_click():
label2 = Label(text="Button clicked!")
label2.grid(row=3, column=0)
tree.insert('', 'end', text='Listbox', values=('15KB', 'Yesterday', 'mark'))
#p.step(amount=5)
win = Tk()
label1 = Label(text="Here is a cool ttk widget")
label1.grid(row=0, column=0)
button1 = Button(win, text="Click me!", command=on_click)
button1.grid(row=2, column=0)
"""p = Progressbar(win,orient=HORIZONTAL,length=200, mode='determinate')
p.grid(row=1, column=0)
"""
tree = Treeview(win)
tree.grid(row=1, columnspan=3)
# Inserted at the root, program chooses id:
tree.insert('', 'end', 'widgets', text='Widget Tour')
# Same thing, but inserted as first child:
tree.insert('', 0, 'gallery', text='Applications')
# Treeview chooses the id:
id = tree.insert('', 'end', text='Tutorial')
# Inserted underneath an existing node:
tree.insert('widgets', 'end', text='Canvas')
tree.insert(id, 'end', text='Tree')
tree['columns'] = ('size', 'modified', 'owner')
Tkinter Image Button
# Pillow is imported as PIL
from PIL import ImageTk, Image
import tkinter
def on_click():
label2 = tkinter.Label(text="Button clicked!")
label2.grid(row=2, column=0)
window = tkinter.Tk()
label1 = tkinter.Label(text="This is a tkinter program")
label1.grid(row=0,column=0)
image1 = Image.open("C:/PythonProgrammerLogo.png")
img=image1.resize((50, 50))
my_img=ImageTk.PhotoImage(img)
tkinter.Button(window, image= my_img, command=on_click).grid(row=1,column=0)