Python_2  1.0
Public Member Functions | Public Attributes | Private Attributes | List of all members
_08c_clock.clock Class Reference

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...
 

Detailed Description

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'.

Constructor & Destructor Documentation

◆ __init__()

def _08c_clock.clock.__init__ (   self,
  root,
  place = 0,
  sImage = True,
  w = 400,
  h = 400,
  useThread = False,
  debug = False 
)

Constructor.

Parameters
rootTk root window.
placeindex to get city coordinates
sImagewhether to use a background image.
wcanvas width.
hcanvas height.
useThreadwhether the clock should be started or not (if using a separate thread).
debugdebugging state.

Member Function Documentation

◆ decPlace()

def _08c_clock.clock.decPlace (   self,
  event 
)

Decrement the clock place.

Parameters
eventa key pressed event.

References _08c_clock.clock.placeIndex, _08c_clock.clock.places, _08c_clock.clock.resize(), and _08c_clock.clock.setTimeZone().

◆ draw_handle()

def _08c_clock.clock.draw_handle (   self,
  angle,
  len,
  wid = None,
  color = None 
)

Draw a handle.

Parameters
anglehandle angle.
lenhandle length.
widhandle width.
colorhandle 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().

◆ imgSize()

def _08c_clock.clock.imgSize (   self)

Return the canvas size.

References _08c_clock.clock.canvas.

Referenced by _08c_clock.clock.resize().

◆ incPlace()

def _08c_clock.clock.incPlace (   self,
  event 
)

Increment the clock place.

Parameters
eventa key pressed event.

References _08c_clock.clock.placeIndex, _08c_clock.clock.places, _08c_clock.clock.resize(), and _08c_clock.clock.setTimeZone().

◆ paint_arc()

def _08c_clock.clock.paint_arc (   self,
  x,
  y,
  t0,
  t1,
  radius = None,
  color = None,
  border = None 
)

Draws an arc at a given point.

Parameters
x,ygiven point.
t0starting angle for the slice, in degrees, measured from +x direction.
t1ending angle for the slice, in degrees, measured from +x direction.
radiusarc radius.
colorarc color.
borderborder 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().

◆ paint_circle()

def _08c_clock.clock.paint_circle (   self,
  x,
  y,
  radius = None,
  color = None,
  border = None 
)

Draws a circle at a given point.

Parameters
x,ygiven point.
radiuscircle radius.
colorcircle color.
borderborder 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().

◆ paint_hms()

def _08c_clock.clock.paint_hms (   self)

◆ paint_text()

def _08c_clock.clock.paint_text (   self,
  x,
  y,
  txt,
  color = None,
  font = None 
)

Draws a text at a given point.

Parameters
x,ygiven point.
txttext.
colortext color.
fonttext 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().

◆ polar2Cartesian()

def _08c_clock.clock.polar2Cartesian (   self,
  angle,
  radius = 1 
)

Convert a vector from polar to cartesian coordinates.

  • Note that 0° is at three o'clock.
  • For the clock, however, 0° is at twelve o'clock.
Parameters
anglevector angle.
radiusvector length.
Returns
a 2D point.

Referenced by _08c_clock.clock.draw_handle(), and _08c_clock.clock.redraw().

◆ poll()

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().

◆ redraw()

def _08c_clock.clock.redraw (   self)

◆ resize()

def _08c_clock.clock.resize (   self,
  event 
)

◆ setColors()

def _08c_clock.clock.setColors (   self)

Sets the clock colors.

References _08c_clock.clock.showImage.

Referenced by _08c_clock.clock.toggleImage().

◆ setTimeZone()

def _08c_clock.clock.setTimeZone (   self,
  place = 0 
)

Sets the timezone for the clock.

In a unix system, this information can be obtained from:

  • /etc/localtime -> /usr/share/zoneinfo/America/Sao_Paulo
Parameters
placean index into the places list.
See also
https://docs.python.org/3/library/os.path.html

References _08c_clock.clock.places.

Referenced by _08c_clock.clock.decPlace(), and _08c_clock.clock.incPlace().

◆ toggleImage()

def _08c_clock.clock.toggleImage (   self,
  event 
)

Toggles the displaying of a background image, when the 'i' key is pressed.

Parameters
eventa key pressed event.

References _08c_clock.clock.imgPath, _08c_clock.clock.resize(), _08c_clock.clock.setColors(), and _08c_clock.clock.showImage.

Member Data Documentation

◆ _ALL

_08c_clock.clock._ALL
private

◆ arc

_08c_clock.clock.arc

Day light arc.

Referenced by _08c_clock.clock.redraw().

◆ bezel

_08c_clock.clock.bezel

Resized PIL logo image.

◆ bezelImg

_08c_clock.clock.bezelImg

◆ bezelPath

_08c_clock.clock.bezelPath

◆ bgcolor

_08c_clock.clock.bgcolor

Default background color.

◆ bordercolor

_08c_clock.clock.bordercolor

◆ canvas

_08c_clock.clock.canvas

◆ circlecolor

_08c_clock.clock.circlecolor

◆ circlesize

_08c_clock.clock.circlesize

Default circle radius.

Referenced by _08c_clock.clock.paint_arc(), and _08c_clock.clock.paint_circle().

◆ debug

_08c_clock.clock.debug

◆ decimal

_08c_clock.clock.decimal

Decimal numerals.

Referenced by _08c_clock.clock.redraw().

◆ delta

_08c_clock.clock.delta

A time difference of deltahours.

Referenced by _08c_clock.clock.paint_hms(), and _08c_clock.clock.redraw().

◆ deltahours

_08c_clock.clock.deltahours

UTC offset.

Referenced by _08c_clock.clock.redraw().

◆ fiveMin

_08c_clock.clock.fiveMin

Five minutes or an hour is thirty degrees.

Referenced by _08c_clock.clock.paint_hms(), and _08c_clock.clock.redraw().

◆ flu

_08c_clock.clock.flu

Resized PIL logo image.

◆ fluImg

_08c_clock.clock.fluImg

Logo image.

Referenced by _08c_clock.clock.resize().

◆ font

_08c_clock.clock.font

Text font.

Referenced by _08c_clock.clock.paint_text().

◆ fontSmall

_08c_clock.clock.fontSmall

Text font small.

Referenced by _08c_clock.clock.redraw().

◆ hwidth

_08c_clock.clock.hwidth

Handle width.

Referenced by _08c_clock.clock.paint_hms(), and _08c_clock.clock.resize().

◆ imgPath

_08c_clock.clock.imgPath

Image logo path.

Referenced by _08c_clock.clock.toggleImage().

◆ local

_08c_clock.clock.local

Clock region and city.

Referenced by _08c_clock.clock.redraw().

◆ longitude

_08c_clock.clock.longitude

Current latitude and longitude.

◆ lwidth

_08c_clock.clock.lwidth

◆ oneMin

_08c_clock.clock.oneMin

One minute is six degrees.

Referenced by _08c_clock.clock.paint_hms().

◆ pad

_08c_clock.clock.pad

Viewport margin (pad)

Referenced by _08c_clock.clock.resize().

◆ pincolor

_08c_clock.clock.pincolor

Handle origin color.

Referenced by _08c_clock.clock.redraw().

◆ placeIndex

_08c_clock.clock.placeIndex

Current clock place index.

Referenced by _08c_clock.clock.decPlace(), and _08c_clock.clock.incPlace().

◆ places

_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().

◆ roman

_08c_clock.clock.roman

Roman numerals.

Referenced by _08c_clock.clock.redraw().

◆ root

_08c_clock.clock.root

tkinter root

Referenced by _08c_clock.clock.paint_hms(), and _08c_clock.clock.poll().

◆ showImage

_08c_clock.clock.showImage

◆ T

_08c_clock.clock.T

◆ timecolor

_08c_clock.clock.timecolor

Default handle color.

Referenced by _08c_clock.clock.draw_handle(), and _08c_clock.clock.redraw().

◆ timezone

_08c_clock.clock.timezone

Clock time zone.

◆ viewport

_08c_clock.clock.viewport

Default viewport.

Referenced by _08c_clock.clock.resize().

◆ world

_08c_clock.clock.world

Default window.

Referenced by _08c_clock.clock.resize().


The documentation for this class was generated from the following file: