Answers for "create button with tkinter"

13

Function to a button in tkinter

from tkinter import *
#Creating a win
win = Tk()
#Giving a Function To The Button
def btn1():
  print("I Don't Know Your Name")
#Creating The Button
button1 =  Button(win, text="Click Me To Print SomeThing", command=btn1)
#put on screen
button1.pack()
win.mainloop()
#NB:This programme Will Print Something In The Terminal
#Check My Profile To See How We Print On The Screen Or Type In Google "Tkinter Label"
Posted by: Guest on April-21-2020
1

how to make custom buttons tkinter

from tkinter import *

root = Tk()

button = Button(root, text="Click me!")
img = PhotoImage(file="C:/path to image/example.gif") # make sure to add "/" not ""
button.config(image=img)
button.pack() # Displaying the button

root.mainloop()
Posted by: Guest on July-18-2020

Code answers related to "create button with tkinter"

Python Answers by Framework

Browse Popular Code Answers by Language