Python Forum
looking for a GUI digital clock
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
looking for a GUI digital clock
#1
i am looking for a GUI LED-style digital clock program. the digits need to automatically fill the window i need to have a setting to set hours+minutes mode (4 digits) or hours+minutes+seconds mode (6 digits). nice features would include color setting for digits and background, different fonts, transparency for the window. and this needs to be written in Python and work on at least Ubuntu Linux. working on other systems would be great. i would prefer that at least work in Python3 but if it work on both Python3 and Python2 that would be nice.

the xclock program that come with Xwindows in Linux/Unix systems uses a text mode in the window when digital mode is chosen. this is not very useful.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
see PyQt5 example

https://github.com/baoboa/pyqt5/blob/mas...alclock.py

[Image: dclock.png]

or

from Tkinter import *
import time
root = Tk()
time1 = ''
clock = Label(root, font=('times', 20, 'bold'), bg='lightgray')
clock.pack(fill=BOTH, expand=1)
def tick():
    global time1
    time2 = time.strftime('%H:%M:%S')
    if time2 != time1:
        time1 = time2
        clock.config(text=time2)
    clock.after(200, tick)
tick()
root.mainloop(  )
Reply
#3
wxPython example:
[Image: KowOBoH.png]
#!/usr/bin/env python

import time

import wx
import wx.lib.gizmos as gizmos  # Formerly wx.gizmos in Classic

#----------------------------------------------------------------------

class TestPanel(wx.Panel):
    def __init__(self, parent, log):
        wx.Panel.__init__(self, parent, -1)
        self.log = log

        led = gizmos.LEDNumberCtrl(self, -1, (25,25), (280, 50))
        led.SetValue("012.34")

        led = gizmos.LEDNumberCtrl(self, -1, (25,100), (280, 50))
        led.SetValue("56789")
        led.SetAlignment(gizmos.LED_ALIGN_RIGHT)
        led.SetDrawFaded(False)
        led.SetForegroundColour('yellow')

        led = gizmos.LEDNumberCtrl(self, -1, (25,175), (280, 50),
                              gizmos.LED_ALIGN_CENTER)# | gizmos.LED_DRAW_FADED)
        led.SetForegroundColour('black')
        led.SetBackgroundColour('white')

        self.clock = led
        self.OnTimer(None)

        self.timer = wx.Timer(self)
        self.timer.Start(1000)
        self.Bind(wx.EVT_TIMER, self.OnTimer)


    def OnTimer(self, evt):
        t = time.localtime(time.time())
        st = time.strftime("%H:%M:%S", t)
        self.clock.SetValue(st)


    def ShutdownDemo(self):
        self.timer.Stop()
        del self.timer


#----------------------------------------------------------------------

def runTest(frame, nb, log):
    win = TestPanel(nb, log)
    return win

#----------------------------------------------------------------------

overview = """\
<html>
<body>
<font size=-1>The following was gleaned as best I could from the wxWindows
source, which was a bit reluctant to reveal its secrets. My appologies if
I missed anything - jmg</font>
<p>
<code><b>LEDNumberCtrl</b>( parent, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=LED_ALIGN_LEFT | LED_DRAW_FADED)</code>

<p>This is a control that simulates an LED clock display. It only accepts
numeric input.

<p><b>Styles</b>

<p><dl>
<dt><b>LED_ALIGN_LEFT</b>
<dd>Align to the left.

<dt><b>LED_ALIGN_RIGHT</b>
<dd>Align to the right.

<dt><b>LED_ALIGN_CENTER</b>
<dd>Center on display.

<dt><b>LED_DRAW_FADED</b>
<dd>Not implemented.

</dl>

<p><b>Methods</b> (and best guesses at what they do)

<p><dl>
<dt><b>GetAlignment()</b>
<dd>Returns the alignment attribute for the control.

<dt><b>GetDrawFaded()</b>
<dd>Returns the DrawFaded attribute for the control.

<dt><b>GetValue()</b>
<dd>Returns the current value of the control.

<dt><b>SetAlignment(alignment)</b>
<dd>Set the alignment attribute for the control.

<dt><b>SetDrawFaded(value)</b>
<dd>Set the DrawFaded attribute for the control.

<dt><b>SetValue(number)</b>
<dd>Set the value for the control. Only numeric values are accepted.

</dl>

<p>Additionally, several methods of wx.Window are available as well.

</body>
</html>
"""



if __name__ == '__main__':
    import sys,os
    import run
    run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
Reply
#4
@Axel_Erfurt the digits stay small as i enlarge the window. i want the digits to fill the window. and i had to switch to python2 to make it run

@Standard_user pip could not find module wx. Ubuntu's apt-get could not find it, either.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#5
(Oct-09-2018, 12:17 AM)Skaperen Wrote: @Axel_Erfurt the digits stay small as i enlarge the window. i want the digits to fill the window. and i had to switch to python2 to make it run

change

from Tkinter import *
to
from tkinter import * 
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  command line progam wanted: clock Skaperen 2 2,696 Apr-18-2018, 06:54 AM
Last Post: Gribouillis
  my cheap chinese clock Skaperen 0 2,734 Nov-05-2017, 08:20 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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