How do I add a button - Python

0 votes
How do I add a button using python? A button such that when I click on it, it should display a message "Welcome to my page"
Jul 22 in Python by Vaishu
12 views

1 answer to this question.

0 votes

Try this:

# Import required packages
import Tkinter
import tkMessageBox

top = Tkinter.Tk()

# Create a message box
def helloCallBack():
   tkMessageBox.showinfo("Click Me", "Welcome to my Page")
# Create a button
B = Tkinter.Button(top, text ="Click Me", command = helloCallBack)

B.pack()
top.mainloop()
answered Jul 22 by Ashish

Related Questions In Python

0 votes
2 answers

How do I copy a file in python?

copy a file in python  from shutil ...READ MORE

answered Mar 27 in Python by rajesh
• 1,210 points
52 views
0 votes
1 answer

How do I copy a file in python?

Use the shutil module. copyfile(src, dst) Copy the contents ...READ MORE

answered Jul 31, 2018 in Python by Priyaj
• 56,200 points
31 views
0 votes
2 answers

How do I connect to a MySQL Database in Python?

connect mysql database with python import MySQLdb db = ...READ MORE

answered Mar 28 in Python by rajesh
• 1,210 points
123 views
0 votes
1 answer

How do I generate some random numbers with a distribution using Python?

scipy.stats.rv_discrete is what you ned IMHO. You can supply ...READ MORE

answered Oct 31, 2018 in Python by Anirudh
• 2,070 points

edited Dec 14, 2018 by Anirudh 128 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 168 views
+4 votes
6 answers
0 votes
1 answer

In Python, how do I read a file line-by-line into a list?

with open(fname) as f:     content = f.readlines() # you ...READ MORE

answered Oct 9, 2018 in Python by SDeb
• 13,160 points
105 views
0 votes
1 answer

How do I convert a Python program to a runnable .exe Windows program?

Understand that every 'freezing' application for Python ...READ MORE

answered Oct 12, 2018 in Python by SDeb
• 13,160 points
48 views