0
Q:

add button python

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