Analog Clock using wxPython

bumsfeld 0 Tallied Votes 720 Views Share

The wxPython GUI tool makes it very simple to create nice looking analog clock. The analog clock component was put into simple dialog frame and can be moved about the screen.

# create nice Analog Clock using wxPython
# tested with Python24 and wxPython26  by  HAB

import wx
from wx.lib.analogclock import *

class MyFrame(wx.Dialog):
    """use simple dialog box as frame"""
    def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, -4, title, size=(300,320))
        self.SetBackgroundColour("blue")

        clock = AnalogClockWindow(self)
        clock.SetBackgroundColour("yellow")
        
        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(clock, 1, wx.EXPAND|wx.ALIGN_CENTER|wx.ALL|wx.SHAPED, 10)

        self.SetAutoLayout(True)
        self.SetSizer(box)
        self.Layout()
        
        self.ShowModal()
        self.Destroy()


app = wx.PySimpleApp()
frame = MyFrame(None, -1, "wx Analog Clock")
# show the frame
frame.Show(True)
# start the event loop
app.MainLoop()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.