Commit 01bfd701dd8cd1c32297b615cc1b004b2578a502
1 parent
44da1d6d
Exists in
master
Added docstrings
Showing
1 changed file
with
6 additions
and
0 deletions
Show diff stats
telemetry/code/monitor/graph_plotter_rewrite.py
| ... | ... | @@ -9,6 +9,7 @@ from colours import * |
| 9 | 9 | |
| 10 | 10 | class Plot: |
| 11 | 11 | def __init__(self, title="Unknown", size=(640, 480)): |
| 12 | + """Setup a the details of a plot, and create a corresponding window""" | |
| 12 | 13 | self.title = title |
| 13 | 14 | self.size = size |
| 14 | 15 | self.font = 'Arkhip' |
| ... | ... | @@ -18,17 +19,21 @@ class Plot: |
| 18 | 19 | self.window.on_draw = self.draw |
| 19 | 20 | |
| 20 | 21 | def resize(self, width, height): |
| 22 | + """Handle a pyglet resize event, then give control back to the event loop""" | |
| 21 | 23 | self.size = (width, height) |
| 22 | 24 | super(pyglet.window.Window, self.window).on_resize(width, height) |
| 23 | 25 | |
| 24 | 26 | def draw(self): |
| 27 | + """Draw all the components of the graph""" | |
| 25 | 28 | self.drawBackground() |
| 26 | 29 | self.drawHeading() |
| 27 | 30 | |
| 28 | 31 | def drawBackground(self): |
| 32 | + """Draw the graph background, currently a plain colour""" | |
| 29 | 33 | pyglet.image.SolidColorImagePattern(WHITE).create_image(self.size[0], self.size[1]).blit(0, 0) |
| 30 | 34 | |
| 31 | 35 | def drawHeading(self): |
| 36 | + """Draw a title for the graph (duplicated in the window titlebar, if present""" | |
| 32 | 37 | heading = pyglet.text.Label(self.title, color=BLACK, |
| 33 | 38 | font_name=self.font, font_size=self.size[0]/50, x=self.size[0]/2, y=self.size[1], |
| 34 | 39 | anchor_x='center', anchor_y='top') |
| ... | ... | @@ -38,6 +43,7 @@ plots = [] |
| 38 | 43 | plots.append(Plot("This is a test plot")) |
| 39 | 44 | |
| 40 | 45 | def pollSerial(foo): |
| 46 | + """Dummy, will check serial port for incoming data""" | |
| 41 | 47 | # Note, foo seems to be a float |
| 42 | 48 | pass |
| 43 | 49 | ... | ... |