'Can't Put Wingdings on a Python Tkinter Canvas
I want to use the Webdings font to draw some special characters on a Tkinter Canvas widget.
So, I wrote a little script that would print out all the webdings glyphs from 32 up to 255.
The code is below. I was just using the program to put the info on the screen where I could simply screen capture it.
However, some of the glyphs won't print and instead I get tofu.
Specifically, things go south at the character produced by chr(128) which should be the silhouette of a man (note that chr(129) produces the silhouette of a woman.
Note: Run the program and select page 3.
Any idea why this would happen?
Here is the code:
from tkinter import *
from tkinter import font
##########################################################################
# Main
##########################################################################
root = Tk()
# Create Title
root.title( "Webdings")
# specify size
root.geometry("1500x1000+0+0")
global number
number = 65
xoff = 20
yoff = 20
pages = [32, 92, 122, 182, 242]
pn = 7
while pn<1 or pn>5:
pn = input("What page do you want? [1, 2, 3, 4, or 5]? ")
pn = int(pn)
charrie = pages[pn-1]
vspace = 72
hspace = 30
slot = 8*hspace
c = Canvas(root, width=1500, height=1000)
for ro in range(10):
for co in range(6):
if charrie+co*10 < 256:
c.create_text(co*slot+xoff, ro*vspace+yoff,text=str(charrie+co*10), font=("Arial", 32), anchor="nw")
c.create_text(co*slot+4*hspace+xoff, ro*vspace+yoff,text=chr(charrie+co*10), font=("Arial", 32), anchor="nw")
c.create_text(co*slot+6*hspace+xoff, ro*vspace+yoff,text=chr(charrie+co*10), font=("Webdings", 32), anchor="nw")
charrie = charrie + 1
c.pack()
mainloop()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
