Q:

tkinter button

from tkinter import *
def example():
	print("Example")
root = Tk()
clickMe = Button(root, text="Click Me", command=example)
#Would Print "Example" In The CL
6
# ... snip ...
button1 = Button(self, text = "Quit", command = self.quit, anchor = W)
button1.configure(width = 10, activebackground = "#33B5E5", relief = FLAT)
button1_window = canvas1.create_window(10, 10, anchor=NW, window=button1)
1
my_text = my_button.cget('text')
1
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"
1
import tkinter
button1 = ttk.Button(self, text="anything", command=random command)
        button1.pack()
1
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()
-1
from tkinter import *

wow = Tk()

def ree(hi):
  print(hi)
  
w = Button ( master=wow, command=ree('hi'), text="hi" )

Output:
  Tkinter:
    ______
   [  hi  ] <--- Button
    ------
  
  Shell:
    hi <--- on button pressed
-1
from tkinter import *


master = Tk()

#program you want the button to execute
def closewindow():
    exit()

#set up button
button = Button(master, text="close window", command=closewindow)

button.pack()

mainloop()
-1

New to Communities?

Join the community