Skip to content
Related Articles

Related Articles

How to use Unicode and Special Characters in Tkinter ?
  • Last Updated : 24 Jan, 2021

Prerequisite: Tkinter

Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applications. 

In this article, we will learn how to use  Unicode & Special Characters in Tkinter.

Approach:

  • Make a list that contains Unicode values.
  • Iterate through all Unicode values and then pass in Label text
  • We will use the “u prefix” to display the Unicode value.

Syntax: u’\u {Unicode vlaue}’



Example:

for "Not sign" unicode value is "00AC"

Input
u'\u00AC'

Output
¬

Below is the Implementation:-

Python3




# Import Tkinter
from tkinter import *
  
# Create Object
root = Tk()
  
# Set geometry
root.geometry("100x200")
  
# Unicodes values
unicodes_values = [
'\u00A1',
'\u00A2',
'\u00A3',
'\u00A4',
'\u00A5',
'\u00A6',
'\u00A7'
]
  
# Iterate through all unicode values
for unicodes_value in unicodes_values:
    Label(root, text = u'{unicodes_value}'.format(
      unicodes_value = unicodes_value)).pack()
  
# Execute Tkinter
root.mainloop()

Output:

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :