Python Forum
Load external font and does not show font in the window
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Load external font and does not show font in the window
#10
Ah it's success! Dance Thanks!
Code here:
import pyglet
import time

i = 2
time_print="%H:%M %P"

pyglet.font.add_file('/home/pi/.fonts/Digital-7.ttf')
window = pyglet.window.Window()
window.set_fullscreen(True)
label = pyglet.text.Label('',
                    font_name='Digital-7',
                    font_size=400,
                    x=window.width//2, y=window.height//2,
                    anchor_x='center', anchor_y='center')

def update_clock(dt):

    global i
    global time_print
    label.text = time.strftime(time_print)
    if i == 2:
        time_print="%H,%M %P"
        i=1
    elif i == 1:
        time_print="%H:%M %P"
        i = 2
    return


pyglet.clock.schedule_interval(update_clock, 1)

@window.event
def on_draw():
    window.clear()
    label.draw()

pyglet.app.run()
Also I edited the Digital-7.ttf due to keep center and width to stay with : and ; and 1. (; is blank better than the space).

But the pyglet seem more complex than the tkinter. I like tkinter than pyglet more headache for me. I am gonna keep to trying with tkinter because wanted use button and many sizes of fonts each other texts on same the clock screen. Type

Buran or anyone, if you have time, would you find what's wrong with my original coding with the Tkinter as unable to load the font?

My original code does not load the font from the raspberry pi 4B but WORKS on my Python for windows (include exactly copied all modules from raspberry pi to windows)


Thank You So Much a Million!
Reply


Messages In This Thread
RE: Load external font and does not show font in the window - by ATARI_LIVE - Sep-16-2020, 10:30 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python code for alignment and font size 1418 0 431 Jan-14-2024, 03:56 AM
Last Post: 1418
  Is there a way to call and focus any popup window outside of the main window app? Valjean 6 2,291 Oct-02-2023, 04:11 PM
Last Post: deanhystad
  Change font in a list or tuple apffal 4 2,875 Jun-16-2023, 02:55 AM
Last Post: schriftartenio
  can openpyxl read font colors mperemsky 3 1,989 May-09-2023, 11:18 AM
Last Post: MindKeeper
  Comparing two columns with same value but different font format doug2019 1 823 Jan-08-2023, 02:58 PM
Last Post: Larz60+
  PIL Image im.show() no show! Pedroski55 2 1,084 Sep-12-2022, 10:19 PM
Last Post: Pedroski55
  Pyspark Window: perform sum over a window with specific conditions Shena76 0 1,310 Jun-13-2022, 08:59 AM
Last Post: Shena76
  Folium: Conflict with Font Awesome Kit jgomes_eu 0 1,301 Apr-23-2022, 03:18 PM
Last Post: jgomes_eu
  Print text with big font and style tomtom 5 14,795 Mar-03-2022, 01:29 AM
Last Post: tomtom
  PIL Image im.show() no show! Pedroski55 6 5,446 Feb-08-2022, 06:32 AM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

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