Monday, November 18, 2024
Google search engine
HomeLanguagesHow to use Unicode and Special Characters in Tkinter ?

How to use Unicode and Special Characters in Tkinter ?

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 value}’

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:

 

 

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments