I am new to coding and I am creating things with Python that will allow me to explore the limitations of the programme and the packages and set me up to create more serious and useful programmes later. I have read loads of articles and the wiki guidance for fontTools but I cannot find the specific answer I am looking for and I imagine that what I am about to ask is impossible but I will go ahead anyway.
So yesterday's project was the make a Star Wars themed alarm clock with the Tkinter package which was simple enough and then I realised I could make multiple windows with Tkinter so I programmed a way for the first window to show "A long time ago in a galaxy far far away..." and then for a second window to show Star Wars and play the theme after a button was clicked:
import tkinter as tk
from tkinter import *
import threading
import winsound
from fontTools.ttLib import TTFont
font = TTFont("C:/Users/lugz2/PycharmProjects/StarWarsGUIChanger/Starjedi.ttf")
window = Tk()
window.config(bg="black")
starwars = tk.Label(
text="A long time ago in a galaxy far far away...",
fg="lightBlue",
bg="black",
height=800,
width=400,
font=(None, 20)
)
window.title("Star Wars")
window.geometry("800x400")
starwars.pack()
def play():
winsound.PlaySound("swtheme.wav", winsound.SND_ALIAS)
def printtext():
threadsound.start()
print("STAR WARS")
window2 = Tk()
window2.config(bg="black")
starwarsnew = tk.Label(
window2,
text="STAR WARS",
fg="yellow",
bg="black",
height=800,
width=400,
font=(font, 80)
)
window2.title("STAR WARS")
window2.geometry("800x400")
starwarsnew.pack()
threadsound = threading.Thread(target=play)
button = Button(window, text="PLAY", fg="lightBlue", bg="black", width=10, command=printtext).place(x=350, y=300)
starwars.mainloop()
In the code above, you can see I added the "Starjedi.ttf" using fontTools which I wanted to then import into Tkinter to use for the "Star Wars" text in "window2" - I have tried LOADS of ways but nothing seems to work! I wondered if anyone could give me a heads up on whether it is possible and if so, how can I do that?