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
356 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,270 points
967 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
• 58,090 points
739 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,270 points
1,593 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 1,143 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,067 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,486 views
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, 2020 in Python by sahil
• 580 points
1,470 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 13, 2018 in Python by SDeb
• 13,300 points
1,246 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP