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, 2019 in Python by Vaishu
54 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, 2019 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, 2019 in Python by rajesh
• 1,230 points
139 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
• 57,550 points
91 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, 2019 in Python by rajesh
• 1,230 points
480 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,080 points

edited Dec 14, 2018 by Anirudh 197 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, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,218 views
0 votes
0 answers
+4 votes
6 answers
0 votes
2 answers

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

readline function help to  read line in ...READ MORE

answered Jun 21 in Python by sahil
• 540 points
243 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,250 points
180 views