Casey Bralla via plug on 23 Jan 2024 15:21:01 -0800


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] Raspbian S*cks!


Wow!  I'm a longtime Raspberry Pi user and fan, but my recent experience
makes me wonder what the heck is up with those guys over in Jolly Ol'
England.

I've got several old Pi Model A's lying around, and a bunch of old Dell
flat monitors.  So I thought, why not make nice Digital Clocks out of
them?  Can't be too hard.  I wrote the enclosed python-tkinter script to
show the time and date in a clean display.

I downloaded the latest Raspbian and put it on a (full-sized!) SD card. 
Then the fun started...

Lots of problems.

  -  System wouldn't even finish booting.  The initial setup program
appears on Screen 8, so the install hangs.  I was able to eventually
google enough to find that I could Alt-F8 to get to the initial setup
screen.

  -  Kicking the system into graphics mode meant it would never return
to text mode, even if X was killed.

  -  Simple things like setting static IP didn't work.  I've done this
dozens of times on stock Debian systems, but sometimes
/etc/network/interfaces was simply ignored.  Was it NetManager? Never
did find out.

  -  The python tkinter script wouldn't run.  No error messages; it
just didn't run.  Except it did kick the system into graphics mode, from
which it would not exit back to text without a hard reboot.


I tried lots of troubleshooting things.  I've got 10+ years experience
with Debian, but I was stumped.  Tried several Model A's, and even a
Model 3B+, but still had issues.  Tried bookworm (Debian 12) as well as
Bullseye (Debian 11), but got similar problems.  Threw away an SD card
and tried several others.  No go.

Finally, I tried loading it on an old Odroid C2 loaded with Ubuntu 20.04
(the most recent system available), and it "Just Worked!".

Something is seriously wrong with Raspbian on the Pi, or I've turned
into a flippin' idiot in my retirement.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# DigitalClock.py
#
#
#  Display an nice looking digital clock for general use
#   Can be used as a dedicated clock on old Monitors with Raspberry Pi
#
#


Version = "1.22"
Author  = "J R Casey Bralla"
Program = "DigitalClock.py"



# Import some standard python modules
import os               # misc operating system calls.
import sys              # More misc operating system calls
import datetime         # Time & Date functions
import tkinter          # Screen manipulation and information
from tkinter import ttk # TK-Intger themed widgets



# Get the command line arguments
CommandLineArguments = sys.argv[1:]
# print ( CommandLineArguments )

# CommandLineArgument = ""

if len( CommandLineArguments ) > 0:
    #
    # show help
    #
    #
    print ( )
    print ( "Program"  + Program )
    print ( )
    print ( "Version " + Version )
    print ( "     by " + Author )
    print ( )
    print ( "Nice Digital Clock for general display" )
    print ( )
    print ( 'Usage: "' + Program + ' --help or -h for help"' )
    print ( )
    print ( )
    print ( )
    sys.exit(0)
    #








# Set some Variables
#
#
CompositeVideo  = "No"  # Composite Video cannot determine the max widow size properly



Screen_Color    = "Black"   # Background color for the screen
Time_Color      = "White"   # Font Color for Time
DayOfWeek_Color = "Yellow"  # Font Color for Day of Week
LongDate_Color  = "Yellow"  # Font Color for Long Date
ISODate_Color   = "Yellow"  # Font Color for ISO Date





### Create the Window ###
### Create the Window ###
### Create the Window ###
#
#
#
MainWindow = tkinter.Tk()
MainWindow.title(      "NerdWorld Digital Clock" )
MainWindow.configure(  bg="black" )
MainWindow.attributes( '-topmost', True )   # Always on top


# Window dimensions are the maximum window size
if CompositeVideo == "Yes":
    #
    WindowWidth  = 720
    WindowHeight = 480
    #
else:
    #
    WindowWidth  = MainWindow.winfo_screenwidth()
    WindowHeight = MainWindow.winfo_screenheight()
    #
#

MainWindow.geometry(   str(WindowWidth) + "x" + str(WindowHeight) )

#
TimeSize        = int( WindowWidth * (72/96) /  8 )
DayOfWeekSize   = int( WindowWidth * (72/96) / 13 )
LongDateSize    = int( WindowWidth * (72/96) / 12 )
ISODateSize     = int( WindowWidth * (72/96) / 20 )
#





### Function which acts as the main loop that updats the Time & Date ###
### Function which acts as the main loop that updats the Time & Date ###
### Function which acts as the main loop that updats the Time & Date ###
#
#
#
def UpdateClockDisplay():
    #
    #
    ### Get the Time and Date and format it ###
    #
    TimeNow     = datetime.datetime.now()
    #
    Time        = TimeNow.strftime( "%-I:%M:%S %p" )
    DayOfWeek   = TimeNow.strftime( "%A"           )
    LongDate    = TimeNow.strftime( "%B %-d, %Y"   )
    ISODate     = TimeNow.strftime( "%Y-%m-%d"     )
    #
    #
    # Set the font sizes based on the window size
    #
    TimeSize        = 24        # Font Size for Time
    DayOfWeekSize   = 18        # Font Size for Day of Week
    LongDateSize    = 18        # Font Size for Long Date
    ISODateSize     = 12        # Font Size for ISO Date
    #
    if CompositeVideo != "Yes":        # Use the maximum if no window manager
        #
        WindowWidth = MainWindow.winfo_width()          # Variable based on window size
        #
    else:
        #
        WindowWidth = 720          # Fixed width for composite video
        #
    #
    # print (WindowWidth)  #
    #
    TimeSize        = int( WindowWidth * (72/96) /  8 )
    DayOfWeekSize   = int( WindowWidth * (72/96) / 13 )
    LongDateSize    = int( WindowWidth * (72/96) / 12 )
    ISODateSize     = int( WindowWidth * (72/96) / 20 )
    #
    #
    #
    #
    ### Display the Time ###
    ### Display the Time ###
    ### Display the Time ###
    #
    TimeLabel.config(       text=Time,      font=("Helvetica", TimeSize)      )
    DayOfWeekLabel.config(  text=DayOfWeek, font=("Helvetica", DayOfWeekSize) )
    LongDateLabel.config(   text=LongDate,  font=("Helvetica", LongDateSize)  )
    ISODateLabel.config(    text=ISODate,   font=("Helvetica", ISODateSize)   )
    BlankLabel.config(      text=" "                                          )
    #
    #
    # Force an update after waiting milliseconds
    #
    TimeLabel.after(250, UpdateClockDisplay)    # Updates every quarter second.  (No more than .25 seconds error)
    #
    #
    #






### Define the labels ###
### Define the labels ###
### Define the labels ###
#
#
#
TimeLabel = ttk.Label(
    MainWindow,
    text="*",
    foreground=Time_Color,
    background="black"
    )
#
DayOfWeekLabel = ttk.Label(
    MainWindow,
    text="*",
    foreground=DayOfWeek_Color,
    background="black"
    )
#
LongDateLabel = ttk.Label(
    MainWindow,
    text="*",
    foreground=LongDate_Color,
    background="black"
    )
#
ISODateLabel = ttk.Label(
    MainWindow,
    text="*",
    foreground=ISODate_Color,
    background="black"
    )
#
BlankLabel = ttk.Label(
    MainWindow,
    text="*",
    font=("Helvetica", 10),
    foreground="white",
    background="black"
    )








### Pack the labels onto the window
#
#
TimeLabel.pack(     side=tkinter.TOP,            expand=True  )
DayOfWeekLabel.pack(side=tkinter.TOP, ipady = 5, expand=False )
LongDateLabel.pack( side=tkinter.TOP, ipady = 5, expand=False )
ISODateLabel.pack(  side=tkinter.TOP, ipady = 5, expand=False )
BlankLabel.pack(    side=tkinter.TOP, ipady = 5, expand=True  )
#
#
#



### Run the function to update the labels ###
#
#
UpdateClockDisplay()





### Obligatory TKInter routine to keep window open

MainWindow.mainloop()




___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug