![]() |
Python_2
1.0
|
Class for drawing a simple analog clock. More...
Public Member Functions | |
def | __init__ (self, root, place=0, sImage=True, w=400, h=400, useThread=False, debug=False) |
Constructor. More... | |
def | setTimeZone (self, place=0) |
Sets the timezone for the clock. More... | |
def | polar2Cartesian (self, angle, radius=1) |
Convert a vector from polar to cartesian coordinates. More... | |
def | imgSize (self) |
Return the canvas size. More... | |
def | resize (self, event) |
Called when the window changes, by means of a user input. More... | |
def | setColors (self) |
Sets the clock colors. More... | |
def | toggleImage (self, event) |
Toggles the displaying of a background image, when the 'i' key is pressed. More... | |
def | redraw (self) |
Redraws the whole clock. More... | |
def | incPlace (self, event) |
Increment the clock place. More... | |
def | decPlace (self, event) |
Decrement the clock place. More... | |
def | draw_handle (self, angle, len, wid=None, color=None) |
Draw a handle. More... | |
def | paint_hms (self) |
Draws the three handles. More... | |
def | paint_text (self, x, y, txt, color=None, font=None) |
Draws a text at a given point. More... | |
def | paint_circle (self, x, y, radius=None, color=None, border=None) |
Draws a circle at a given point. More... | |
def | paint_arc (self, x, y, t0, t1, radius=None, color=None, border=None) |
Draws an arc at a given point. More... | |
def | poll (self) |
Animates the clock, by redrawing the handles, after a certain time interval. More... | |
Public Attributes | |
world | |
Default window. More... | |
viewport | |
Default viewport. More... | |
imgPath | |
Image logo path. More... | |
bezelPath | |
showImage | |
Whether to use the logo image. More... | |
debug | |
Debugging state. More... | |
circlesize | |
Default circle radius. More... | |
root | |
tkinter root More... | |
pad | |
Viewport margin (pad) More... | |
hwidth | |
Handle width. More... | |
lwidth | |
Circle and arc border width. More... | |
fiveMin | |
Five minutes or an hour is thirty degrees. More... | |
oneMin | |
One minute is six degrees. More... | |
fluImg | |
Logo image. More... | |
bezelImg | |
deltahours | |
UTC offset. More... | |
delta | |
A time difference of deltahours. More... | |
canvas | |
Canvas for drawing. More... | |
T | |
Window to Viewport mapping. More... | |
font | |
Text font. More... | |
fontSmall | |
Text font small. More... | |
roman | |
Roman numerals. More... | |
decimal | |
Decimal numerals. More... | |
places | |
List of available places for the clock. More... | |
placeIndex | |
Current clock place index. More... | |
longitude | |
Current latitude and longitude. More... | |
timezone | |
Clock time zone. More... | |
local | |
Clock region and city. More... | |
arc | |
Day light arc. More... | |
flu | |
Resized PIL logo image. More... | |
bezel | |
Resized PIL logo image. More... | |
bgcolor | |
Default background color. More... | |
timecolor | |
Default handle color. More... | |
circlecolor | |
Default circle fill color. More... | |
bordercolor | |
Default circle outline color. More... | |
pincolor | |
Handle origin color. More... | |
Private Attributes | |
_ALL | |
Handles' tag. More... | |
Class for drawing a simple analog clock.
The background image may be changed by pressing key 'i'. The image path is hardcoded. It should be available in directory 'images'.
def _08c_clock.clock.__init__ | ( | self, | |
root, | |||
place = 0 , |
|||
sImage = True , |
|||
w = 400 , |
|||
h = 400 , |
|||
useThread = False , |
|||
debug = False |
|||
) |
Constructor.
root | Tk root window. |
place | index to get city coordinates |
sImage | whether to use a background image. |
w | canvas width. |
h | canvas height. |
useThread | whether the clock should be started or not (if using a separate thread). |
debug | debugging state. |
def _08c_clock.clock.decPlace | ( | self, | |
event | |||
) |
Decrement the clock place.
event | a key pressed event. |
References _08c_clock.clock.placeIndex, _08c_clock.clock.places, _08c_clock.clock.resize(), and _08c_clock.clock.setTimeZone().
def _08c_clock.clock.draw_handle | ( | self, | |
angle, | |||
len, | |||
wid = None , |
|||
color = None |
|||
) |
Draw a handle.
angle | handle angle. |
len | handle length. |
wid | handle width. |
color | handle color. |
References _08c_clock.clock._ALL, _08c_clock.clock.canvas, _08c_clock.clock.polar2Cartesian(), _08c_clock.clock.T, and _08c_clock.clock.timecolor.
Referenced by _08c_clock.clock.paint_hms().
def _08c_clock.clock.imgSize | ( | self | ) |
Return the canvas size.
References _08c_clock.clock.canvas.
Referenced by _08c_clock.clock.resize().
def _08c_clock.clock.incPlace | ( | self, | |
event | |||
) |
Increment the clock place.
event | a key pressed event. |
References _08c_clock.clock.placeIndex, _08c_clock.clock.places, _08c_clock.clock.resize(), and _08c_clock.clock.setTimeZone().
def _08c_clock.clock.paint_arc | ( | self, | |
x, | |||
y, | |||
t0, | |||
t1, | |||
radius = None , |
|||
color = None , |
|||
border = None |
|||
) |
Draws an arc at a given point.
x,y | given point. |
t0 | starting angle for the slice, in degrees, measured from +x direction. |
t1 | ending angle for the slice, in degrees, measured from +x direction. |
radius | arc radius. |
color | arc color. |
border | border color. |
References _08c_clock.clock.bordercolor, _08c_clock.clock.canvas, _08c_clock.clock.circlecolor, _08c_clock.clock.circlesize, _08c_clock.clock.lwidth, and _08c_clock.clock.T.
Referenced by _08c_clock.clock.redraw().
def _08c_clock.clock.paint_circle | ( | self, | |
x, | |||
y, | |||
radius = None , |
|||
color = None , |
|||
border = None |
|||
) |
Draws a circle at a given point.
x,y | given point. |
radius | circle radius. |
color | circle color. |
border | border color. |
References _08c_clock.clock.bordercolor, _08c_clock.clock.canvas, _08c_clock.clock.circlecolor, _08c_clock.clock.circlesize, _08c_clock.clock.lwidth, and _08c_clock.clock.T.
Referenced by _08c_clock.clock.redraw().
def _08c_clock.clock.paint_hms | ( | self | ) |
Draws the three handles.
References _08c_clock.clock._ALL, _08c_clock.clock.canvas, _08c_clock.clock.circlecolor, _08c_clock.clock.delta, _08c_clock.clock.draw_handle(), _08c_clock.clock.fiveMin, _08c_clock.clock.hwidth, _08c_clock.clock.oneMin, _08a_pack_circles.Timer.root, _08c_clock.clock.root, and _04e_boxplot_demo.title.
Referenced by _08c_clock.clock.poll(), and _08c_clock.clock.redraw().
def _08c_clock.clock.paint_text | ( | self, | |
x, | |||
y, | |||
txt, | |||
color = None , |
|||
font = None |
|||
) |
Draws a text at a given point.
x,y | given point. |
txt | text. |
color | text color. |
font | text font. |
References _08c_clock.clock.canvas, _08c_clock.clock.circlecolor, _08c_clock.clock.font, and _08c_clock.clock.T.
Referenced by _08c_clock.clock.redraw().
def _08c_clock.clock.polar2Cartesian | ( | self, | |
angle, | |||
radius = 1 |
|||
) |
Convert a vector from polar to cartesian coordinates.
angle | vector angle. |
radius | vector length. |
Referenced by _08c_clock.clock.draw_handle(), and _08c_clock.clock.redraw().
def _08c_clock.clock.poll | ( | self | ) |
Animates the clock, by redrawing the handles, after a certain time interval.
References _08c_clock.clock.paint_hms(), _08c_clock.clock.poll(), _08a_pack_circles.Timer.root, and _08c_clock.clock.root.
Referenced by _08c_clock.clock.poll().
def _08c_clock.clock.redraw | ( | self | ) |
Redraws the whole clock.
References _08c_clock.clock.arc, _08c_clock.clock.bordercolor, _08c_clock.clock.circlecolor, _08c_clock.clock.decimal, _08c_clock.clock.delta, _08c_clock.clock.deltahours, _08c_clock.clock.fiveMin, _08c_clock.clock.fontSmall, _08c_clock.clock.local, _08c_clock.clock.paint_arc(), _08c_clock.clock.paint_circle(), _08c_clock.clock.paint_hms(), _08c_clock.clock.paint_text(), _08c_clock.clock.pincolor, _08c_clock.clock.polar2Cartesian(), _08c_clock.clock.roman, _08c_clock.clock.showImage, and _08c_clock.clock.timecolor.
def _08c_clock.clock.resize | ( | self, | |
event | |||
) |
Called when the window changes, by means of a user input.
event | a "<Configure>" event. |
References _08c_clock.clock.canvas, _08c_clock.clock.fluImg, _08c_clock.clock.hwidth, _08c_clock.clock.imgSize(), _08c_clock.clock.lwidth, _08c_clock.clock.pad, _08c_clock.clock.showImage, _08c_clock.clock.T, _08c_clock.clock.viewport, and _08c_clock.clock.world.
Referenced by _08c_clock.clock.decPlace(), _08c_clock.clock.incPlace(), and _08c_clock.clock.toggleImage().
def _08c_clock.clock.setColors | ( | self | ) |
Sets the clock colors.
References _08c_clock.clock.showImage.
Referenced by _08c_clock.clock.toggleImage().
def _08c_clock.clock.setTimeZone | ( | self, | |
place = 0 |
|||
) |
Sets the timezone for the clock.
In a unix system, this information can be obtained from:
place | an index into the places list. |
References _08c_clock.clock.places.
Referenced by _08c_clock.clock.decPlace(), and _08c_clock.clock.incPlace().
def _08c_clock.clock.toggleImage | ( | self, | |
event | |||
) |
Toggles the displaying of a background image, when the 'i' key is pressed.
event | a key pressed event. |
References _08c_clock.clock.imgPath, _08c_clock.clock.resize(), _08c_clock.clock.setColors(), and _08c_clock.clock.showImage.
|
private |
Handles' tag.
Referenced by _08c_clock.clock.draw_handle(), and _08c_clock.clock.paint_hms().
_08c_clock.clock.arc |
Day light arc.
Referenced by _08c_clock.clock.redraw().
_08c_clock.clock.bezel |
Resized PIL logo image.
_08c_clock.clock.bezelImg |
_08c_clock.clock.bezelPath |
_08c_clock.clock.bgcolor |
Default background color.
_08c_clock.clock.bordercolor |
Default circle outline color.
Referenced by _08c_clock.clock.paint_arc(), _08c_clock.clock.paint_circle(), and _08c_clock.clock.redraw().
_08c_clock.clock.canvas |
Canvas for drawing.
Referenced by _08c_clock.clock.draw_handle(), _08c_clock.clock.imgSize(), _08c_clock.clock.paint_arc(), _08c_clock.clock.paint_circle(), _08c_clock.clock.paint_hms(), _08c_clock.clock.paint_text(), and _08c_clock.clock.resize().
_08c_clock.clock.circlecolor |
Default circle fill color.
Referenced by _08c_clock.clock.paint_arc(), _08c_clock.clock.paint_circle(), _08c_clock.clock.paint_hms(), _08c_clock.clock.paint_text(), and _08c_clock.clock.redraw().
_08c_clock.clock.circlesize |
Default circle radius.
Referenced by _08c_clock.clock.paint_arc(), and _08c_clock.clock.paint_circle().
_08c_clock.clock.debug |
Debugging state.
Referenced by digitalClock.makeThread.__del__(), and digitalClock.makeThread.run().
_08c_clock.clock.decimal |
Decimal numerals.
Referenced by _08c_clock.clock.redraw().
_08c_clock.clock.delta |
A time difference of deltahours.
Referenced by _08c_clock.clock.paint_hms(), and _08c_clock.clock.redraw().
_08c_clock.clock.deltahours |
UTC offset.
Referenced by _08c_clock.clock.redraw().
_08c_clock.clock.fiveMin |
Five minutes or an hour is thirty degrees.
Referenced by _08c_clock.clock.paint_hms(), and _08c_clock.clock.redraw().
_08c_clock.clock.flu |
Resized PIL logo image.
_08c_clock.clock.fluImg |
Logo image.
Referenced by _08c_clock.clock.resize().
_08c_clock.clock.font |
Text font.
Referenced by _08c_clock.clock.paint_text().
_08c_clock.clock.fontSmall |
Text font small.
Referenced by _08c_clock.clock.redraw().
_08c_clock.clock.hwidth |
Handle width.
Referenced by _08c_clock.clock.paint_hms(), and _08c_clock.clock.resize().
_08c_clock.clock.imgPath |
Image logo path.
Referenced by _08c_clock.clock.toggleImage().
_08c_clock.clock.local |
Clock region and city.
Referenced by _08c_clock.clock.redraw().
_08c_clock.clock.longitude |
Current latitude and longitude.
_08c_clock.clock.lwidth |
Circle and arc border width.
Referenced by _08c_clock.clock.paint_arc(), _08c_clock.clock.paint_circle(), and _08c_clock.clock.resize().
_08c_clock.clock.oneMin |
One minute is six degrees.
Referenced by _08c_clock.clock.paint_hms().
_08c_clock.clock.pad |
Viewport margin (pad)
Referenced by _08c_clock.clock.resize().
_08c_clock.clock.pincolor |
Handle origin color.
Referenced by _08c_clock.clock.redraw().
_08c_clock.clock.placeIndex |
Current clock place index.
Referenced by _08c_clock.clock.decPlace(), and _08c_clock.clock.incPlace().
_08c_clock.clock.places |
List of available places for the clock.
Referenced by _08c_clock.clock.decPlace(), _08c_clock.clock.incPlace(), and _08c_clock.clock.setTimeZone().
_08c_clock.clock.roman |
Roman numerals.
Referenced by _08c_clock.clock.redraw().
_08c_clock.clock.root |
tkinter root
Referenced by _08c_clock.clock.paint_hms(), and _08c_clock.clock.poll().
_08c_clock.clock.showImage |
Whether to use the logo image.
Referenced by _08c_clock.clock.redraw(), _08c_clock.clock.resize(), _08c_clock.clock.setColors(), and _08c_clock.clock.toggleImage().
_08c_clock.clock.T |
Window to Viewport mapping.
Referenced by mapper2.mapper2.__windowToViewport(), _08c_clock.clock.draw_handle(), _08c_clock.clock.paint_arc(), _08c_clock.clock.paint_circle(), _08c_clock.clock.paint_text(), _08c_clock.clock.resize(), and mapper2.mapper2.windowVecToViewport().
_08c_clock.clock.timecolor |
Default handle color.
Referenced by _08c_clock.clock.draw_handle(), and _08c_clock.clock.redraw().
_08c_clock.clock.timezone |
Clock time zone.
_08c_clock.clock.viewport |
Default viewport.
Referenced by _08c_clock.clock.resize().
_08c_clock.clock.world |
Default window.
Referenced by _08c_clock.clock.resize().