- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 604 Articles for Tkinter
![Dev Prakash Sharma](https://www.tutorialspoint.com/assets/profiles/302800/profile/60_4750-1612521296.jpg)
686 Views
Using Tkinter.Menu, we can create menus and submenus. Also, there are some other properties which are used with tkinter menus.Tearoff property makes the menus in the window as tearable. tearoff attribute accepts a Boolean value to separate the menu from the main window or the parent window. With tearoff attribute, we have two options, If tearoff=0, make the menu stick to the Window.If tearoff=1, it display a “----” empty dotted lines on the menus through which we can separate our menu from the window.Example#Importing the tkinter library from tkinter import * win= Tk() win.title("Tearoff Example") win.geometry("600x500") #Define a Function ... Read More
![Dev Prakash Sharma](https://www.tutorialspoint.com/assets/profiles/302800/profile/60_4750-1612521296.jpg)
459 Views
Tkinter bell() method produces the default event or dialogue sound of the system. This method can be invoked in the default window or frame. We can change the sound of the window by going to the system configuration.In this example, we will create a button that will make the default sound.Example#Import the library from tkinter import * #Create an instance of tkinter frame win= Tk() #Define the size of the window win.geometry("700x150") win.resizable(0, 0) #Define the Bell function def click(): win.bell() Button(win, text= "Click Me", command= click).pack(pady=20) win.mainloop()OutputRunning the above code will create ... Read More
![Dev Prakash Sharma](https://www.tutorialspoint.com/assets/profiles/302800/profile/60_4750-1612521296.jpg)
348 Views
In this article, we will see how to create a functional application that calculates the ratio. In order to make it fully functional, we will use SpinBox method that generally creates an ideal spinner for a value. This value can be modified using the spinner widget in the frame. Thus, a SpinBox object takes values in the range from minimum to maximum.First, we will create a tkinter frame inside which we will define some widgets.Examplefrom tkinter import * win = Tk() win.title("Ratio Calculator") win.geometry("600x500") win.resizable(0, 0) #Create text Label for Ratio Calculator label= Label(win, text="Ratio Calculator", font=('Times New ... Read More
![Dev Prakash Sharma](https://www.tutorialspoint.com/assets/profiles/302800/profile/60_4750-1612521296.jpg)
2K+ Views
Let us consider that we have a value x and we have to calculate the sum of sine(x) series. In a sine(x) series, there are multiple terms such that, sine(x) = x− x^3/fact(3) + x^5/fact(5) −x^7/fact(7)....In order to solve the particular series-based problem, we will first take the degree as the input and convert it into radian. To find out the sum of the total number of terms in this series, we will first iterate over all the given terms and find out the sum by operations.Approach to solve this ProblemTake input of Limit and degree.Iterate over the terms and ... Read More
![Dev Prakash Sharma](https://www.tutorialspoint.com/assets/profiles/302800/profile/60_4750-1612521296.jpg)
9K+ Views
Let us suppose that we have a string and we have to calculate the total number of digits and letters present in the string.For ExampleInput −s = “tutorialsP0int”Output −Letters: 13 Digits: 1Explanation −Total number of letters and digits present in the given string are 13 and 1.Approach to Solve this ProblemTo calculate the total number of letters and digits in the given string, we have to first iterate over the whole string. If we get an alphabet, then we increment the letter count; otherwise, if we extract a digit, then increment the digit count.Take an input string.While iterating over the whole string, ... Read More
![Dev Prakash Sharma](https://www.tutorialspoint.com/assets/profiles/302800/profile/60_4750-1612521296.jpg)
2K+ Views
Tkinter provides features for adding different kinds of widgets necessary for an application. Some of these widgets are: Button widget, Entry Widget, Text Box, Slider, etc. In this article, we will see how we can create an application with a button such that it can either be on or off.In this example, we will use these two buttons for demonstration, Switch OnSwitch OffExample# Import tkinter in the notebook from tkinter import * # Create an instance of window of frame win =Tk() # set Title win.title('On/Off Demonstration') # Set the Geometry win.geometry("600x400") win.resizable(0, 0) #Create a variable ... Read More
![Dev Prakash Sharma](https://www.tutorialspoint.com/assets/profiles/302800/profile/60_4750-1612521296.jpg)
946 Views
Sometimes we need to add unicode and special charset in our Tkinter application. We can add unicode characters in our labels or widgets concatenating the signature as, u ‘/’. You can find the list of all unicode characters from hereIn this example, we will add a unicode character in the button widget.Example# Import the required Libraries from tkinter import * #Create an instance of tkinter frame win= Tk() win.geometry("700x200") #Create a button Button(win, text='Click'+u'\u01CF', font=('Poppins bold', 10)).pack(pady=20) #Keep running the window or frame win.mainloop()OutputRunning the above code will create a button with a unicode character (u01CF).Read More
![Dev Prakash Sharma](https://www.tutorialspoint.com/assets/profiles/302800/profile/60_4750-1612521296.jpg)
6K+ Views
With Tkinter, we can call multiple functions at a time using Threading. It provides asynchronous execution of some functions in an application.In order to use a thread in Python, we can import a module called threading and subclass its Thread class. Inside our new class, we need to overwrite the Run method and perform our logic in there.So, basically with threading, we can do multiple work at a time. To achieve threading in our application, Tkinter provides the Thread() function.Let us take an example and create a thread which will sleep for some time and then execute another function in ... Read More
![Dev Prakash Sharma](https://www.tutorialspoint.com/assets/profiles/302800/profile/60_4750-1612521296.jpg)
7K+ Views
If we will create an instance of Tkinter frame and display the window while keep running it, then it will show the default output canvas. However, we can add an image inside the Tkinter canvas as a background using PhotoImage methods and Canvas methods.Since image support in Tkinter is limited to Gif, PNG and PPM, the PhotoImage(GIF, PNG, PPM) function takes the location of the image file and displays the canvas with the image as a background.First, we will create a PhotoImage Object using the PhotoImage function.Examplefrom tkinter import * from PIL import ImageTk win = Tk() win.geometry("700x300") ... Read More
![Dev Prakash Sharma](https://www.tutorialspoint.com/assets/profiles/302800/profile/60_4750-1612521296.jpg)
727 Views
In Tkinter, we can create and customize buttons using images. These images can be uploaded by using the Python PhotoImage(file) function.However, PhotoImage() supports only a few image types such as PNG, PPM, and GIF. In addition, we can create buttons using BitMap images too. A bitmap image is nothing but a set of dots aligned in a matrix which represents a pixel of the image. The following types of bitmap attributes are available in Tkinter, "error""gray75""gray50""gray25""gray12""hourglass""info""questhead""question""warning"Examplefrom tkinter import * #Create an instance of tkinter frame win = Tk() win.geometry("700x300") win.resizable(0, 0) Button(win, relief=RAISED, bitmap="info").pack(pady=10) Button(win, relief=RAISED, bitmap="gray50").pack(pady=10) ... Read More