Answers for "tkinter button attri"

15

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
3

button tkinter

import Tkinter
import tkMessageBox

top = Tkinter.Tk()

def helloCallBack():
   tkMessageBox.showinfo( "Hello Python", "Hello World")

B = Tkinter.Button(top, text ="Hello", command = helloCallBack)

B.pack()
top.mainloop()
Posted by: Guest on May-30-2020
0

how to create a button using tkinter

import tkinter as tk
window = tk.Tk()

button=tk.Button(window, text="CLICK ME: ", command=testCommand) 
"""creates the button and sets the location, text and what command to run once clicked"""


button.pack()
""" this loads the button in to the program.
you can use button.grid(row=1, column=1) as a another option to load this but both
cannot be used in a program together"""
window.mainloop()
Posted by: Guest on April-18-2022

Python Answers by Framework

Browse Popular Code Answers by Language