Python Forum
[Tkinter] How to Print a list = ['a','b','c'], using tkinter along with a custom font?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] How to Print a list = ['a','b','c'], using tkinter along with a custom font?
#1
Smash

I'm trying to print out a list using tkinter and a custom font with the font family that is named Voynich. I have made several lists named Vglyphs that use the random module and I would like to display the output in the voynich text font. If you loaded this piece of code into your python idle as you can see it prints the text. I would really like to see the Vglyphs = list print the output of the Voynich font yet I'm new to python and I'm slugging through this as it is. Thanks for any help :)

from tkinter import *
from tkinter.font import Font

root = Tk()

my_font = Font(family="Voynich", size=16)
label = Label(root, text="I would like this t to print, that is set to Vglyphs", font=my_font).pack()
root.geometry("300x300+120+120")
root.mainloop()

  


import random
while True:
	e = int(input("Enter a number 1 through 12 to make a Voynich Vord: "))
	
	Vglyphs1 = ['y','e','9']
	Vglyphs2 = ['o','a','8','1','3']
	Vglyphs3 = ['1','8','3','4']
	Vglyphs4 = ['o','c','a','8']
	

	
	
	
	
	
	if e == 3 :

		
			
		t  = random.choices(Vglyphs3,weights=[6,8,2,2])
		
			
		print(*t , end="" )
		
		pass
	if e == 3:
		t = random.choices(Vglyphs4,weights=[13,10,8,8])
		
		
			
		print(*t   , end="" )
		root.mainloop()
		pass
	if e == 3:
		t = random.choices(Vglyphs1,weights=[3,4,11])
		
			
		print(*t   , end="" )
		print("\n")
		continue
			
	if e == 2: 
		t = random.choices(Vglyphs2,weights=[13,8,8,6,2],)
		
		
		print(*t , end="" )
		pass
		
		
	if e == 2:
		t = random.choices(Vglyphs1,weights=[7,6,4])
		
		
		print(*t  , end="")
		print("\n")
		continue
	elif e < 3:
		
		print(*t  , end="")
		break
Reply
#2
this code is messed up
first reformat it so it can be read:
import tkinter as tk
from tkinter.font import Font
import random


root = Tk()
 
my_font = Font(family="Voynich", size=10)
label = Label(root, text="I would like this t to print, that is set to Vglyphs", font=my_font).pack()
root.geometry("1200x1200+120+120")
root.mainloop()
 
while True:
    e = int(input("Enter a number 1 through 12 to make a Voynich Vord: "))
     
    Vglyphs1 = ['y','e','9']
    Vglyphs2 = ['o','a','8','1','3']
    Vglyphs3 = ['1','8','3','4']
    Vglyphs4 = ['o','c','a','8']

    if e == 3 :
        t  = random.choices(Vglyphs3,weights=[6,8,2,2])
        print(*t , end="" )
    if e == 3:
        t = random.choices(Vglyphs4,weights=[13,10,8,8])
        print(*t   , end="" )
        root.mainloop()
        pass
    if e == 3:
        t = random.choices(Vglyphs1,weights=[3,4,11])
        print(*t   , end="" )
        print("\n")
        continue
    if e == 2: 
        t = random.choices(Vglyphs2,weights=[13,8,8,6,2],)
        print(*t , end="" )
        pass
    if e == 2:
        t = random.choices(Vglyphs1,weights=[7,6,4])
        print(*t  , end="")
        print("\n")
        continue
    elif e < 3:
        print(*t  , end="")
        break
now the if e == 3: only needs to be there once, the others are redundant
same with if e == 2:

clean up the code, and try again
Reply
#3
Thanks Larz60+ that code was redundant. I really would like to see if tkinter or pyglet is able to print the a list for the Vglyphs so I can see the font in Voynich displayed.

import random
while True:
	e = int(input("Enter a number 1 through 12 to make a Voynich Vord: "))

	Vglyphs1 = ['y','e','9']
	Vglyphs2 = ['o','a','8','1','3']
	Vglyphs3 = ['1','8','3','4']
	Vglyphs4 = ['o','c','a','8']
	

	if e == 3 :
		t  = random.choices(Vglyphs3,weights=[6,8,2,2])
		print(*t , end="" )
		pass
		
		t = random.choices(Vglyphs4,weights=[13,10,8,8])
		print(*t   , end="" )
		pass
		
		t = random.choices(Vglyphs1,weights=[3,4,11])
		print(*t   , end="" )
		print("\n")
		continue

	if e == 2: 
		t = random.choices(Vglyphs2,weights=[13,8,8,6,2],)
		print(*t , end="" )
		pass
		
		t = random.choices(Vglyphs1,weights=[7,6,4])
		print(*t  , end="")
		print("\n")
		continue
	
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Trouble changing Font within tkinter frame title AnotherSam 1 4,011 Sep-30-2021, 05:57 PM
Last Post: menator01
  [Tkinter] Redirecting all print statements from all functions inside a class to Tkinter Anan 1 2,603 Apr-24-2021, 08:57 AM
Last Post: ndc85430
  Tkinter menu font size -method to change tonycat 2 7,707 Oct-11-2020, 02:43 AM
Last Post: tonycat
  TKINTER - Change font color for night or day Ayckinn 2 3,822 May-24-2020, 09:25 PM
Last Post: Ayckinn
  [Tkinter] Tkinter custom widget styling and creating custom theme karolp 6 4,747 May-06-2020, 06:11 PM
Last Post: karolp
  [Tkinter] Tkinter Font Color notsolowki 11 62,549 Mar-28-2018, 03:53 AM
Last Post: notsolowki
  tkinter filedialog and pickle - custom icon question. kim07133 0 2,727 Jan-08-2018, 12:10 PM
Last Post: kim07133
  [Tkinter] import numbers into a list and print (gui python) kostasalgo 5 5,373 Aug-09-2017, 08:21 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020