Tkinter font not changing on python 3.6.8 on Ubuntu 18.04












0















I am not able to change the font family of the label in tkinter.



I have written the code to explain the issue. I have also attached a link to show the output. (for images please go to this link I have posted the same question here. https://stackoverflow.com/questions/54170918/tkinter-font-not-changing-on-python-3-6-8-ubuntu-18-04lts?noredirect=1#comment95171516_54170918)



from tkinter import *
from tkinter import ttk

win = Tk()
win.title("Fonts not Changing!")
win.geometry("400x400")

# Times label
label1 = ttk.Label(win, text = "Brown-Times", font = ("Times",15))
label1.grid(row = 0, column = 0, sticky = 'W')

label12 = ttk.Label(win, text = "Brown-times", font = ("times",15))
label12.grid(row = 0, column = 1, sticky = 'W')

# Arial label
label2 = ttk.Label(win, text = "Brown-Arial", font = ("Arial",15))
label2.grid(row = 1, column = 0, sticky = 'W')

label22 = ttk.Label(win, text = "Brown-arial", font = ("arial",15))
label22.grid(row = 1, column = 1, sticky = 'W')

# Courier label
label3 = ttk.Label(win, text = "Brown-courier", font = ("courier",15))
label3.grid(row = 2, column = 0, sticky = 'W')
# Helvetica label
label4 = ttk.Label(win, text = "Brown-Helvetica", font = ("Helvetica",15))
label4.grid(row = 3, column = 0, sticky = 'W')

win.mainloop()


enter image description here
Image of the output



I tried with the font families present



from tkinter import *  
from tkinter import ttk

win = Tk()
win.title("Fonts not Changing!")
win.geometry("400x400")

'''
'fangsong ti', 'fixed', 'clearlyu alternate glyphs', 'courier 10 pitch', 'open look glyph', 'bitstream charter', 'song ti', 'open look cursor', 'newspaper', 'clearlyu ligature', 'mincho', 'clearlyu devangari extra', 'clearlyu pua', 'clearlyu', 'clean', 'nil', 'clearlyu arabic', 'clearlyu devanagari', 'gothic', 'clearlyu arabic extra'
'''

# Times label
label1 = ttk.Label(win, text = "Brown-fangsong ti", font = ("fangsong ti",15))
label1.grid(row = 0, column = 0, sticky = 'W')

label12 = ttk.Label(win, text = "Brown-fixed", font = ("fixed",15))
label12.grid(row = 0, column = 1, sticky = 'W')

# Arial label
label2 = ttk.Label(win, text = "Brown-courier", font = ("courier",15))
label2.grid(row = 1, column = 0, sticky = 'W')

label22 = ttk.Label(win, text = "Brown-clearlyu pua", font = ("clearlyu pua",15))
label22.grid(row = 1, column = 1, sticky = 'W')

# Courier label
label3 = ttk.Label(win, text = "Brown-courier", font = ("courier",15))
label3.grid(row = 2, column = 0, sticky = 'W')
# Helvetica label
label4 = ttk.Label(win, text = "Brown-Helvetica", font = ("Helvetica",15))
label4.grid(row = 3, column = 0, sticky = 'W')

win.mainloop()


but the output is similar.



enter image description here



I have tried with all the basic fonts available with tcl code as well as Python. Please look at the difference.



TCL code



#!/usr/bin/wish

font create myFont1 -family {fangsong ti} -size 18 -weight bold
pack [label .labelVar1 -font myFont1 -text "Hello World"]

font create myFont2 -family fixed -size 18 -weight bold
pack [label .labelVar2 -font myFont2 -text "Hello World"]

font create myFont3 -family {clearlyu alternate glyphs} -size 18 -weight bold
pack [label .labelVar3 -font myFont3 -text "Hello World"]

font create myFont4 -family {courier 10 pitch} -size 18 -weight bold
pack [label .labelVar4 -font myFont4 -text "Hello World"]

font create myFont5 -family {open look glyph} -size 18 -weight bold
pack [label .labelVar5 -font myFont5 -text "Hello World"]

font create myFont6 -family {bitstream charter} -size 18 -weight bold
pack [label .labelVar6 -font myFont6 -text "Hello World"]

font create myFont7 -family {song ti} -size 18 -weight bold
pack [label .labelVar7 -font myFont7 -text "Hello World"]

font create myFont8 -family {open look cursor} -size 18 -weight bold
pack [label .labelVar8 -font myFont8 -text "Hello World"]

font create myFont9 -family newspaper -size 18 -weight bold
pack [label .labelVar9 -font myFont9 -text "Hello World"]

font create myFont10 -family {clearlyu ligature} -size 18 -weight bold
pack [label .labelVar10 -font myFont10 -text "Hello World"]

font create myFont11 -family mincho -size 18 -weight bold
pack [label .labelVar11 -font myFont11 -text "Hello World"]

font create myFont12 -family {clearlyu devangari extra} -size 18 -weight bold
pack [label .labelVar12 -font myFont12 -text "Hello World"]

font create myFont13 -family {clearlyu pua} -size 18 -weight bold
pack [label .labelVar13 -font myFont13 -text "Hello World"]

font create myFont14 -family clearlyu -size 18 -weight bold
pack [label .labelVar14 -font myFont14 -text "Hello World"]

font create myFont15 -family clean -size 18 -weight bold
pack [label .labelVar15 -font myFont15 -text "Hello World"]

font create myFont16 -family nil -size 18 -weight bold
pack [label .labelVar16 -font myFont16 -text "Hello World"]

font create myFont17 -family {clearlyu arabic} -size 18 -weight bold
pack [label .labelVar17 -font myFont17 -text "Hello World"]

font create myFont18 -family {clearlyu devanagari} -size 18 -weight bold
pack [label .labelVar18 -font myFont18 -text "Hello World"]

font create myFont19 -family gothic -size 18 -weight bold
pack [label .labelVar19 -font myFont19 -text "Hello World"]

font create myFont20 -family {clearlyu arabic extra} -size 18 -weight bold
pack [label .labelVar20 -font myFont20 -text "Hello World"]

puts [font families]


enter image description here



Python code



from tkinter import *
from tkinter import ttk

win = Tk()
win.title("Fonts not Changing!")
win.geometry("400x400")

fontList = ["{fangsong ti}", "fixed", "{clearlyu alternate glyphs}", "{courier 10 pitch}", "{open look glyph}", "{bitstream charter}", "{song ti}", "{open look cursor}", "newspaper", "{clearlyu ligature}", "mincho", "{clearlyu devangari extra}", "{clearlyu pua}", "clearlyu", "clean", "nil", "{clearlyu arabic}", "{clearlyu devanagari}", "gothic", "{clearlyu arabic extra}"]

label = [ttk.Label(win) for i in range(0,len(fontList))]

for i in range(0,len(fontList)):
label[i].config(text = "Brown-" + fontList[i], font = (fontList[i],18,"bold"))
label[i].grid(row = i, column = 0, sticky = 'W')

win.mainloop()


enter image description here



When these same fonts are ran using Python it's acting weirdly. As you can see how most of the fonts which were looking different using TCL codes are becoming the same font with Python (even though some fonts change).



I also removed tcl/tk and reinstalled (8.6 version) them. Even then it's of no use. Or is there any way that I can add more fonts to the tcl/tk?










share|improve this question

























  • Do you have the ttf-mscorefonts-installer Ubuntu package installed? You can check by running apt-cache policy ttf-mscorefonts-installer. This package provides Arial, Times, Courier (as well as others).

    – unutbu
    Jan 14 at 18:17













  • After creating the other fonts, did you run fc-cache -f -v /path/to/fonts/directory to make Ubuntu aware of the fonts?

    – unutbu
    Jan 14 at 18:35











  • I installed ttf-mscorefonts and ran fc-cache -f -v /path/to/fonts/directory but its not adding times new roman or any other fonts into the font families of tk.

    – Star Rider
    Jan 14 at 19:17











  • Are you using Anaconda's Python3? If so, this might be the issue. Related anaconda github issues: #6833 and #776.

    – unutbu
    Jan 14 at 19:40











  • Yes @unutbu I am using Anaconda's python 3. As per the link even though the post had some temporary solutions. It seems that Anaconda wont be solving this issue. Since they suggest using something more modern than tkinter.

    – Star Rider
    Jan 15 at 7:58


















0















I am not able to change the font family of the label in tkinter.



I have written the code to explain the issue. I have also attached a link to show the output. (for images please go to this link I have posted the same question here. https://stackoverflow.com/questions/54170918/tkinter-font-not-changing-on-python-3-6-8-ubuntu-18-04lts?noredirect=1#comment95171516_54170918)



from tkinter import *
from tkinter import ttk

win = Tk()
win.title("Fonts not Changing!")
win.geometry("400x400")

# Times label
label1 = ttk.Label(win, text = "Brown-Times", font = ("Times",15))
label1.grid(row = 0, column = 0, sticky = 'W')

label12 = ttk.Label(win, text = "Brown-times", font = ("times",15))
label12.grid(row = 0, column = 1, sticky = 'W')

# Arial label
label2 = ttk.Label(win, text = "Brown-Arial", font = ("Arial",15))
label2.grid(row = 1, column = 0, sticky = 'W')

label22 = ttk.Label(win, text = "Brown-arial", font = ("arial",15))
label22.grid(row = 1, column = 1, sticky = 'W')

# Courier label
label3 = ttk.Label(win, text = "Brown-courier", font = ("courier",15))
label3.grid(row = 2, column = 0, sticky = 'W')
# Helvetica label
label4 = ttk.Label(win, text = "Brown-Helvetica", font = ("Helvetica",15))
label4.grid(row = 3, column = 0, sticky = 'W')

win.mainloop()


enter image description here
Image of the output



I tried with the font families present



from tkinter import *  
from tkinter import ttk

win = Tk()
win.title("Fonts not Changing!")
win.geometry("400x400")

'''
'fangsong ti', 'fixed', 'clearlyu alternate glyphs', 'courier 10 pitch', 'open look glyph', 'bitstream charter', 'song ti', 'open look cursor', 'newspaper', 'clearlyu ligature', 'mincho', 'clearlyu devangari extra', 'clearlyu pua', 'clearlyu', 'clean', 'nil', 'clearlyu arabic', 'clearlyu devanagari', 'gothic', 'clearlyu arabic extra'
'''

# Times label
label1 = ttk.Label(win, text = "Brown-fangsong ti", font = ("fangsong ti",15))
label1.grid(row = 0, column = 0, sticky = 'W')

label12 = ttk.Label(win, text = "Brown-fixed", font = ("fixed",15))
label12.grid(row = 0, column = 1, sticky = 'W')

# Arial label
label2 = ttk.Label(win, text = "Brown-courier", font = ("courier",15))
label2.grid(row = 1, column = 0, sticky = 'W')

label22 = ttk.Label(win, text = "Brown-clearlyu pua", font = ("clearlyu pua",15))
label22.grid(row = 1, column = 1, sticky = 'W')

# Courier label
label3 = ttk.Label(win, text = "Brown-courier", font = ("courier",15))
label3.grid(row = 2, column = 0, sticky = 'W')
# Helvetica label
label4 = ttk.Label(win, text = "Brown-Helvetica", font = ("Helvetica",15))
label4.grid(row = 3, column = 0, sticky = 'W')

win.mainloop()


but the output is similar.



enter image description here



I have tried with all the basic fonts available with tcl code as well as Python. Please look at the difference.



TCL code



#!/usr/bin/wish

font create myFont1 -family {fangsong ti} -size 18 -weight bold
pack [label .labelVar1 -font myFont1 -text "Hello World"]

font create myFont2 -family fixed -size 18 -weight bold
pack [label .labelVar2 -font myFont2 -text "Hello World"]

font create myFont3 -family {clearlyu alternate glyphs} -size 18 -weight bold
pack [label .labelVar3 -font myFont3 -text "Hello World"]

font create myFont4 -family {courier 10 pitch} -size 18 -weight bold
pack [label .labelVar4 -font myFont4 -text "Hello World"]

font create myFont5 -family {open look glyph} -size 18 -weight bold
pack [label .labelVar5 -font myFont5 -text "Hello World"]

font create myFont6 -family {bitstream charter} -size 18 -weight bold
pack [label .labelVar6 -font myFont6 -text "Hello World"]

font create myFont7 -family {song ti} -size 18 -weight bold
pack [label .labelVar7 -font myFont7 -text "Hello World"]

font create myFont8 -family {open look cursor} -size 18 -weight bold
pack [label .labelVar8 -font myFont8 -text "Hello World"]

font create myFont9 -family newspaper -size 18 -weight bold
pack [label .labelVar9 -font myFont9 -text "Hello World"]

font create myFont10 -family {clearlyu ligature} -size 18 -weight bold
pack [label .labelVar10 -font myFont10 -text "Hello World"]

font create myFont11 -family mincho -size 18 -weight bold
pack [label .labelVar11 -font myFont11 -text "Hello World"]

font create myFont12 -family {clearlyu devangari extra} -size 18 -weight bold
pack [label .labelVar12 -font myFont12 -text "Hello World"]

font create myFont13 -family {clearlyu pua} -size 18 -weight bold
pack [label .labelVar13 -font myFont13 -text "Hello World"]

font create myFont14 -family clearlyu -size 18 -weight bold
pack [label .labelVar14 -font myFont14 -text "Hello World"]

font create myFont15 -family clean -size 18 -weight bold
pack [label .labelVar15 -font myFont15 -text "Hello World"]

font create myFont16 -family nil -size 18 -weight bold
pack [label .labelVar16 -font myFont16 -text "Hello World"]

font create myFont17 -family {clearlyu arabic} -size 18 -weight bold
pack [label .labelVar17 -font myFont17 -text "Hello World"]

font create myFont18 -family {clearlyu devanagari} -size 18 -weight bold
pack [label .labelVar18 -font myFont18 -text "Hello World"]

font create myFont19 -family gothic -size 18 -weight bold
pack [label .labelVar19 -font myFont19 -text "Hello World"]

font create myFont20 -family {clearlyu arabic extra} -size 18 -weight bold
pack [label .labelVar20 -font myFont20 -text "Hello World"]

puts [font families]


enter image description here



Python code



from tkinter import *
from tkinter import ttk

win = Tk()
win.title("Fonts not Changing!")
win.geometry("400x400")

fontList = ["{fangsong ti}", "fixed", "{clearlyu alternate glyphs}", "{courier 10 pitch}", "{open look glyph}", "{bitstream charter}", "{song ti}", "{open look cursor}", "newspaper", "{clearlyu ligature}", "mincho", "{clearlyu devangari extra}", "{clearlyu pua}", "clearlyu", "clean", "nil", "{clearlyu arabic}", "{clearlyu devanagari}", "gothic", "{clearlyu arabic extra}"]

label = [ttk.Label(win) for i in range(0,len(fontList))]

for i in range(0,len(fontList)):
label[i].config(text = "Brown-" + fontList[i], font = (fontList[i],18,"bold"))
label[i].grid(row = i, column = 0, sticky = 'W')

win.mainloop()


enter image description here



When these same fonts are ran using Python it's acting weirdly. As you can see how most of the fonts which were looking different using TCL codes are becoming the same font with Python (even though some fonts change).



I also removed tcl/tk and reinstalled (8.6 version) them. Even then it's of no use. Or is there any way that I can add more fonts to the tcl/tk?










share|improve this question

























  • Do you have the ttf-mscorefonts-installer Ubuntu package installed? You can check by running apt-cache policy ttf-mscorefonts-installer. This package provides Arial, Times, Courier (as well as others).

    – unutbu
    Jan 14 at 18:17













  • After creating the other fonts, did you run fc-cache -f -v /path/to/fonts/directory to make Ubuntu aware of the fonts?

    – unutbu
    Jan 14 at 18:35











  • I installed ttf-mscorefonts and ran fc-cache -f -v /path/to/fonts/directory but its not adding times new roman or any other fonts into the font families of tk.

    – Star Rider
    Jan 14 at 19:17











  • Are you using Anaconda's Python3? If so, this might be the issue. Related anaconda github issues: #6833 and #776.

    – unutbu
    Jan 14 at 19:40











  • Yes @unutbu I am using Anaconda's python 3. As per the link even though the post had some temporary solutions. It seems that Anaconda wont be solving this issue. Since they suggest using something more modern than tkinter.

    – Star Rider
    Jan 15 at 7:58
















0












0








0








I am not able to change the font family of the label in tkinter.



I have written the code to explain the issue. I have also attached a link to show the output. (for images please go to this link I have posted the same question here. https://stackoverflow.com/questions/54170918/tkinter-font-not-changing-on-python-3-6-8-ubuntu-18-04lts?noredirect=1#comment95171516_54170918)



from tkinter import *
from tkinter import ttk

win = Tk()
win.title("Fonts not Changing!")
win.geometry("400x400")

# Times label
label1 = ttk.Label(win, text = "Brown-Times", font = ("Times",15))
label1.grid(row = 0, column = 0, sticky = 'W')

label12 = ttk.Label(win, text = "Brown-times", font = ("times",15))
label12.grid(row = 0, column = 1, sticky = 'W')

# Arial label
label2 = ttk.Label(win, text = "Brown-Arial", font = ("Arial",15))
label2.grid(row = 1, column = 0, sticky = 'W')

label22 = ttk.Label(win, text = "Brown-arial", font = ("arial",15))
label22.grid(row = 1, column = 1, sticky = 'W')

# Courier label
label3 = ttk.Label(win, text = "Brown-courier", font = ("courier",15))
label3.grid(row = 2, column = 0, sticky = 'W')
# Helvetica label
label4 = ttk.Label(win, text = "Brown-Helvetica", font = ("Helvetica",15))
label4.grid(row = 3, column = 0, sticky = 'W')

win.mainloop()


enter image description here
Image of the output



I tried with the font families present



from tkinter import *  
from tkinter import ttk

win = Tk()
win.title("Fonts not Changing!")
win.geometry("400x400")

'''
'fangsong ti', 'fixed', 'clearlyu alternate glyphs', 'courier 10 pitch', 'open look glyph', 'bitstream charter', 'song ti', 'open look cursor', 'newspaper', 'clearlyu ligature', 'mincho', 'clearlyu devangari extra', 'clearlyu pua', 'clearlyu', 'clean', 'nil', 'clearlyu arabic', 'clearlyu devanagari', 'gothic', 'clearlyu arabic extra'
'''

# Times label
label1 = ttk.Label(win, text = "Brown-fangsong ti", font = ("fangsong ti",15))
label1.grid(row = 0, column = 0, sticky = 'W')

label12 = ttk.Label(win, text = "Brown-fixed", font = ("fixed",15))
label12.grid(row = 0, column = 1, sticky = 'W')

# Arial label
label2 = ttk.Label(win, text = "Brown-courier", font = ("courier",15))
label2.grid(row = 1, column = 0, sticky = 'W')

label22 = ttk.Label(win, text = "Brown-clearlyu pua", font = ("clearlyu pua",15))
label22.grid(row = 1, column = 1, sticky = 'W')

# Courier label
label3 = ttk.Label(win, text = "Brown-courier", font = ("courier",15))
label3.grid(row = 2, column = 0, sticky = 'W')
# Helvetica label
label4 = ttk.Label(win, text = "Brown-Helvetica", font = ("Helvetica",15))
label4.grid(row = 3, column = 0, sticky = 'W')

win.mainloop()


but the output is similar.



enter image description here



I have tried with all the basic fonts available with tcl code as well as Python. Please look at the difference.



TCL code



#!/usr/bin/wish

font create myFont1 -family {fangsong ti} -size 18 -weight bold
pack [label .labelVar1 -font myFont1 -text "Hello World"]

font create myFont2 -family fixed -size 18 -weight bold
pack [label .labelVar2 -font myFont2 -text "Hello World"]

font create myFont3 -family {clearlyu alternate glyphs} -size 18 -weight bold
pack [label .labelVar3 -font myFont3 -text "Hello World"]

font create myFont4 -family {courier 10 pitch} -size 18 -weight bold
pack [label .labelVar4 -font myFont4 -text "Hello World"]

font create myFont5 -family {open look glyph} -size 18 -weight bold
pack [label .labelVar5 -font myFont5 -text "Hello World"]

font create myFont6 -family {bitstream charter} -size 18 -weight bold
pack [label .labelVar6 -font myFont6 -text "Hello World"]

font create myFont7 -family {song ti} -size 18 -weight bold
pack [label .labelVar7 -font myFont7 -text "Hello World"]

font create myFont8 -family {open look cursor} -size 18 -weight bold
pack [label .labelVar8 -font myFont8 -text "Hello World"]

font create myFont9 -family newspaper -size 18 -weight bold
pack [label .labelVar9 -font myFont9 -text "Hello World"]

font create myFont10 -family {clearlyu ligature} -size 18 -weight bold
pack [label .labelVar10 -font myFont10 -text "Hello World"]

font create myFont11 -family mincho -size 18 -weight bold
pack [label .labelVar11 -font myFont11 -text "Hello World"]

font create myFont12 -family {clearlyu devangari extra} -size 18 -weight bold
pack [label .labelVar12 -font myFont12 -text "Hello World"]

font create myFont13 -family {clearlyu pua} -size 18 -weight bold
pack [label .labelVar13 -font myFont13 -text "Hello World"]

font create myFont14 -family clearlyu -size 18 -weight bold
pack [label .labelVar14 -font myFont14 -text "Hello World"]

font create myFont15 -family clean -size 18 -weight bold
pack [label .labelVar15 -font myFont15 -text "Hello World"]

font create myFont16 -family nil -size 18 -weight bold
pack [label .labelVar16 -font myFont16 -text "Hello World"]

font create myFont17 -family {clearlyu arabic} -size 18 -weight bold
pack [label .labelVar17 -font myFont17 -text "Hello World"]

font create myFont18 -family {clearlyu devanagari} -size 18 -weight bold
pack [label .labelVar18 -font myFont18 -text "Hello World"]

font create myFont19 -family gothic -size 18 -weight bold
pack [label .labelVar19 -font myFont19 -text "Hello World"]

font create myFont20 -family {clearlyu arabic extra} -size 18 -weight bold
pack [label .labelVar20 -font myFont20 -text "Hello World"]

puts [font families]


enter image description here



Python code



from tkinter import *
from tkinter import ttk

win = Tk()
win.title("Fonts not Changing!")
win.geometry("400x400")

fontList = ["{fangsong ti}", "fixed", "{clearlyu alternate glyphs}", "{courier 10 pitch}", "{open look glyph}", "{bitstream charter}", "{song ti}", "{open look cursor}", "newspaper", "{clearlyu ligature}", "mincho", "{clearlyu devangari extra}", "{clearlyu pua}", "clearlyu", "clean", "nil", "{clearlyu arabic}", "{clearlyu devanagari}", "gothic", "{clearlyu arabic extra}"]

label = [ttk.Label(win) for i in range(0,len(fontList))]

for i in range(0,len(fontList)):
label[i].config(text = "Brown-" + fontList[i], font = (fontList[i],18,"bold"))
label[i].grid(row = i, column = 0, sticky = 'W')

win.mainloop()


enter image description here



When these same fonts are ran using Python it's acting weirdly. As you can see how most of the fonts which were looking different using TCL codes are becoming the same font with Python (even though some fonts change).



I also removed tcl/tk and reinstalled (8.6 version) them. Even then it's of no use. Or is there any way that I can add more fonts to the tcl/tk?










share|improve this question
















I am not able to change the font family of the label in tkinter.



I have written the code to explain the issue. I have also attached a link to show the output. (for images please go to this link I have posted the same question here. https://stackoverflow.com/questions/54170918/tkinter-font-not-changing-on-python-3-6-8-ubuntu-18-04lts?noredirect=1#comment95171516_54170918)



from tkinter import *
from tkinter import ttk

win = Tk()
win.title("Fonts not Changing!")
win.geometry("400x400")

# Times label
label1 = ttk.Label(win, text = "Brown-Times", font = ("Times",15))
label1.grid(row = 0, column = 0, sticky = 'W')

label12 = ttk.Label(win, text = "Brown-times", font = ("times",15))
label12.grid(row = 0, column = 1, sticky = 'W')

# Arial label
label2 = ttk.Label(win, text = "Brown-Arial", font = ("Arial",15))
label2.grid(row = 1, column = 0, sticky = 'W')

label22 = ttk.Label(win, text = "Brown-arial", font = ("arial",15))
label22.grid(row = 1, column = 1, sticky = 'W')

# Courier label
label3 = ttk.Label(win, text = "Brown-courier", font = ("courier",15))
label3.grid(row = 2, column = 0, sticky = 'W')
# Helvetica label
label4 = ttk.Label(win, text = "Brown-Helvetica", font = ("Helvetica",15))
label4.grid(row = 3, column = 0, sticky = 'W')

win.mainloop()


enter image description here
Image of the output



I tried with the font families present



from tkinter import *  
from tkinter import ttk

win = Tk()
win.title("Fonts not Changing!")
win.geometry("400x400")

'''
'fangsong ti', 'fixed', 'clearlyu alternate glyphs', 'courier 10 pitch', 'open look glyph', 'bitstream charter', 'song ti', 'open look cursor', 'newspaper', 'clearlyu ligature', 'mincho', 'clearlyu devangari extra', 'clearlyu pua', 'clearlyu', 'clean', 'nil', 'clearlyu arabic', 'clearlyu devanagari', 'gothic', 'clearlyu arabic extra'
'''

# Times label
label1 = ttk.Label(win, text = "Brown-fangsong ti", font = ("fangsong ti",15))
label1.grid(row = 0, column = 0, sticky = 'W')

label12 = ttk.Label(win, text = "Brown-fixed", font = ("fixed",15))
label12.grid(row = 0, column = 1, sticky = 'W')

# Arial label
label2 = ttk.Label(win, text = "Brown-courier", font = ("courier",15))
label2.grid(row = 1, column = 0, sticky = 'W')

label22 = ttk.Label(win, text = "Brown-clearlyu pua", font = ("clearlyu pua",15))
label22.grid(row = 1, column = 1, sticky = 'W')

# Courier label
label3 = ttk.Label(win, text = "Brown-courier", font = ("courier",15))
label3.grid(row = 2, column = 0, sticky = 'W')
# Helvetica label
label4 = ttk.Label(win, text = "Brown-Helvetica", font = ("Helvetica",15))
label4.grid(row = 3, column = 0, sticky = 'W')

win.mainloop()


but the output is similar.



enter image description here



I have tried with all the basic fonts available with tcl code as well as Python. Please look at the difference.



TCL code



#!/usr/bin/wish

font create myFont1 -family {fangsong ti} -size 18 -weight bold
pack [label .labelVar1 -font myFont1 -text "Hello World"]

font create myFont2 -family fixed -size 18 -weight bold
pack [label .labelVar2 -font myFont2 -text "Hello World"]

font create myFont3 -family {clearlyu alternate glyphs} -size 18 -weight bold
pack [label .labelVar3 -font myFont3 -text "Hello World"]

font create myFont4 -family {courier 10 pitch} -size 18 -weight bold
pack [label .labelVar4 -font myFont4 -text "Hello World"]

font create myFont5 -family {open look glyph} -size 18 -weight bold
pack [label .labelVar5 -font myFont5 -text "Hello World"]

font create myFont6 -family {bitstream charter} -size 18 -weight bold
pack [label .labelVar6 -font myFont6 -text "Hello World"]

font create myFont7 -family {song ti} -size 18 -weight bold
pack [label .labelVar7 -font myFont7 -text "Hello World"]

font create myFont8 -family {open look cursor} -size 18 -weight bold
pack [label .labelVar8 -font myFont8 -text "Hello World"]

font create myFont9 -family newspaper -size 18 -weight bold
pack [label .labelVar9 -font myFont9 -text "Hello World"]

font create myFont10 -family {clearlyu ligature} -size 18 -weight bold
pack [label .labelVar10 -font myFont10 -text "Hello World"]

font create myFont11 -family mincho -size 18 -weight bold
pack [label .labelVar11 -font myFont11 -text "Hello World"]

font create myFont12 -family {clearlyu devangari extra} -size 18 -weight bold
pack [label .labelVar12 -font myFont12 -text "Hello World"]

font create myFont13 -family {clearlyu pua} -size 18 -weight bold
pack [label .labelVar13 -font myFont13 -text "Hello World"]

font create myFont14 -family clearlyu -size 18 -weight bold
pack [label .labelVar14 -font myFont14 -text "Hello World"]

font create myFont15 -family clean -size 18 -weight bold
pack [label .labelVar15 -font myFont15 -text "Hello World"]

font create myFont16 -family nil -size 18 -weight bold
pack [label .labelVar16 -font myFont16 -text "Hello World"]

font create myFont17 -family {clearlyu arabic} -size 18 -weight bold
pack [label .labelVar17 -font myFont17 -text "Hello World"]

font create myFont18 -family {clearlyu devanagari} -size 18 -weight bold
pack [label .labelVar18 -font myFont18 -text "Hello World"]

font create myFont19 -family gothic -size 18 -weight bold
pack [label .labelVar19 -font myFont19 -text "Hello World"]

font create myFont20 -family {clearlyu arabic extra} -size 18 -weight bold
pack [label .labelVar20 -font myFont20 -text "Hello World"]

puts [font families]


enter image description here



Python code



from tkinter import *
from tkinter import ttk

win = Tk()
win.title("Fonts not Changing!")
win.geometry("400x400")

fontList = ["{fangsong ti}", "fixed", "{clearlyu alternate glyphs}", "{courier 10 pitch}", "{open look glyph}", "{bitstream charter}", "{song ti}", "{open look cursor}", "newspaper", "{clearlyu ligature}", "mincho", "{clearlyu devangari extra}", "{clearlyu pua}", "clearlyu", "clean", "nil", "{clearlyu arabic}", "{clearlyu devanagari}", "gothic", "{clearlyu arabic extra}"]

label = [ttk.Label(win) for i in range(0,len(fontList))]

for i in range(0,len(fontList)):
label[i].config(text = "Brown-" + fontList[i], font = (fontList[i],18,"bold"))
label[i].grid(row = i, column = 0, sticky = 'W')

win.mainloop()


enter image description here



When these same fonts are ran using Python it's acting weirdly. As you can see how most of the fonts which were looking different using TCL codes are becoming the same font with Python (even though some fonts change).



I also removed tcl/tk and reinstalled (8.6 version) them. Even then it's of no use. Or is there any way that I can add more fonts to the tcl/tk?







fonts python3 tcl tkinter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 15 at 2:06









karel

59k13128149




59k13128149










asked Jan 14 at 17:55









Star RiderStar Rider

11




11













  • Do you have the ttf-mscorefonts-installer Ubuntu package installed? You can check by running apt-cache policy ttf-mscorefonts-installer. This package provides Arial, Times, Courier (as well as others).

    – unutbu
    Jan 14 at 18:17













  • After creating the other fonts, did you run fc-cache -f -v /path/to/fonts/directory to make Ubuntu aware of the fonts?

    – unutbu
    Jan 14 at 18:35











  • I installed ttf-mscorefonts and ran fc-cache -f -v /path/to/fonts/directory but its not adding times new roman or any other fonts into the font families of tk.

    – Star Rider
    Jan 14 at 19:17











  • Are you using Anaconda's Python3? If so, this might be the issue. Related anaconda github issues: #6833 and #776.

    – unutbu
    Jan 14 at 19:40











  • Yes @unutbu I am using Anaconda's python 3. As per the link even though the post had some temporary solutions. It seems that Anaconda wont be solving this issue. Since they suggest using something more modern than tkinter.

    – Star Rider
    Jan 15 at 7:58





















  • Do you have the ttf-mscorefonts-installer Ubuntu package installed? You can check by running apt-cache policy ttf-mscorefonts-installer. This package provides Arial, Times, Courier (as well as others).

    – unutbu
    Jan 14 at 18:17













  • After creating the other fonts, did you run fc-cache -f -v /path/to/fonts/directory to make Ubuntu aware of the fonts?

    – unutbu
    Jan 14 at 18:35











  • I installed ttf-mscorefonts and ran fc-cache -f -v /path/to/fonts/directory but its not adding times new roman or any other fonts into the font families of tk.

    – Star Rider
    Jan 14 at 19:17











  • Are you using Anaconda's Python3? If so, this might be the issue. Related anaconda github issues: #6833 and #776.

    – unutbu
    Jan 14 at 19:40











  • Yes @unutbu I am using Anaconda's python 3. As per the link even though the post had some temporary solutions. It seems that Anaconda wont be solving this issue. Since they suggest using something more modern than tkinter.

    – Star Rider
    Jan 15 at 7:58



















Do you have the ttf-mscorefonts-installer Ubuntu package installed? You can check by running apt-cache policy ttf-mscorefonts-installer. This package provides Arial, Times, Courier (as well as others).

– unutbu
Jan 14 at 18:17







Do you have the ttf-mscorefonts-installer Ubuntu package installed? You can check by running apt-cache policy ttf-mscorefonts-installer. This package provides Arial, Times, Courier (as well as others).

– unutbu
Jan 14 at 18:17















After creating the other fonts, did you run fc-cache -f -v /path/to/fonts/directory to make Ubuntu aware of the fonts?

– unutbu
Jan 14 at 18:35





After creating the other fonts, did you run fc-cache -f -v /path/to/fonts/directory to make Ubuntu aware of the fonts?

– unutbu
Jan 14 at 18:35













I installed ttf-mscorefonts and ran fc-cache -f -v /path/to/fonts/directory but its not adding times new roman or any other fonts into the font families of tk.

– Star Rider
Jan 14 at 19:17





I installed ttf-mscorefonts and ran fc-cache -f -v /path/to/fonts/directory but its not adding times new roman or any other fonts into the font families of tk.

– Star Rider
Jan 14 at 19:17













Are you using Anaconda's Python3? If so, this might be the issue. Related anaconda github issues: #6833 and #776.

– unutbu
Jan 14 at 19:40





Are you using Anaconda's Python3? If so, this might be the issue. Related anaconda github issues: #6833 and #776.

– unutbu
Jan 14 at 19:40













Yes @unutbu I am using Anaconda's python 3. As per the link even though the post had some temporary solutions. It seems that Anaconda wont be solving this issue. Since they suggest using something more modern than tkinter.

– Star Rider
Jan 15 at 7:58







Yes @unutbu I am using Anaconda's python 3. As per the link even though the post had some temporary solutions. It seems that Anaconda wont be solving this issue. Since they suggest using something more modern than tkinter.

– Star Rider
Jan 15 at 7:58












0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1109704%2ftkinter-font-not-changing-on-python-3-6-8-on-ubuntu-18-04%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1109704%2ftkinter-font-not-changing-on-python-3-6-8-on-ubuntu-18-04%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Human spaceflight

Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?

張江高科駅