Skip to content

Commit c9668bd

Browse files
Merge branch 'master' into master
2 parents cdd34a2 + ef464f1 commit c9668bd

21 files changed

Lines changed: 939 additions & 72 deletions

docs/canvas_widgets.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ These widgets provide visual feedback to the user using the canvas.
1111
.. autoclass:: canvas.RotaryScale
1212
:members:
1313

14+
``Gauge``
15+
---------
16+
17+
.. image:: img/gauges.png
18+
19+
.. autoclass:: canvas.Gauge
20+
:members:
21+
1422
``Graph``
1523
---------
1624

docs/img/gauges.png

7.75 KB
Loading

docs/img/multi-slot-frame.png

829 Bytes
Loading

docs/img/seven-segment-display.png

1.03 KB
Loading

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Welcome to tk_tools's documentation!
1313
Widget Groups <widget_groups.rst>
1414
Canvas Widgets <canvas_widgets.rst>
1515
Smart Widgets <smart_widgets.rst>
16+
Tool Tips <tooltips.rst>
1617

1718
Introduction
1819
------------

docs/tooltips.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Tool Tips
2+
==============
3+
4+
``ToolTip``
5+
-----------
6+
7+
.. autoclass:: tooltips.ToolTip
8+
:members:

docs/widget_groups.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,20 @@ The screenshot consists of three individual examples of ``KeyValueEntry`` widget
4444

4545
.. autoclass:: groups.Calendar
4646
:members:
47+
48+
``MultiSlotFrame``
49+
------------------
50+
51+
.. image:: img/multi-slot-frame.png
52+
53+
.. autoclass:: groups.MultiSlotFrame
54+
:members:
55+
56+
``SevenSegment``
57+
----------------
58+
59+
.. image:: img/seven-segment-display.png
60+
61+
.. autoclass:: groups.SevenSegment
62+
63+
.. autoclass:: groups.SevenSegmentDisplay

examples/gauge.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import tkinter as tk
2+
import tk_tools
3+
4+
5+
root = tk.Tk()
6+
7+
max_speed = 20000
8+
speed_gauge = tk_tools.Gauge(root,
9+
max_value=max_speed,
10+
label='speed', unit='m/h')
11+
speed_gauge.grid(row=0, column=0, sticky='news')
12+
13+
14+
tach_gauge = tk_tools.Gauge(root,
15+
max_value=8000,
16+
label='tach', unit='RPM',
17+
divisions=10)
18+
tach_gauge.grid(row=1, column=0, sticky='news')
19+
20+
strange_gauge = tk_tools.Gauge(root,
21+
max_value=30000,
22+
label='strange', unit='blah',
23+
divisions=3)
24+
strange_gauge.grid(row=2, column=0, sticky='news')
25+
26+
count = 0
27+
up = True
28+
29+
30+
def update_gauge():
31+
global count, up
32+
33+
increment = 30
34+
35+
if up:
36+
count += increment
37+
if count > max_speed:
38+
up = False
39+
else:
40+
count -= increment
41+
42+
if count <= 0.0:
43+
up = True
44+
45+
speed_gauge.set_value(count)
46+
tach_gauge.set_value(count)
47+
strange_gauge.set_value(count)
48+
49+
root.after(50, update_gauge)
50+
51+
52+
root.after(100, update_gauge)
53+
54+
root.mainloop()

examples/multislotframe.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import tkinter as tk
2+
import tk_tools
3+
4+
root = tk.Tk()
5+
6+
msf = tk_tools.MultiSlotFrame(root)
7+
msf.grid(row=0, column=0, sticky='news')
8+
9+
count = 0
10+
11+
12+
def add_element():
13+
global count
14+
msf.add(count)
15+
count += 1
16+
17+
18+
def show_elements():
19+
print(msf.get())
20+
21+
22+
tk.Button(root, text='add element', command=add_element)\
23+
.grid(row=1, column=0, sticky='news')
24+
25+
tk.Button(root, text='retrieve elements', command=show_elements)\
26+
.grid(row=2, column=0, sticky='news')
27+
28+
root.mainloop()

examples/seven_segment.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import tkinter as tk
2+
import tk_tools
3+
from decimal import Decimal
4+
5+
6+
root = tk.Tk()
7+
8+
max_speed = 20.0
9+
10+
ss_float = tk_tools.SevenSegmentDigits(root, digits=5)
11+
ss_float.grid(row=0, column=1, sticky='news')
12+
13+
ss_int = tk_tools.SevenSegmentDigits(root, digits=3, background='black', digit_color='red')
14+
ss_int.grid(row=1, column=1, sticky='news')
15+
16+
count = 0
17+
up = True
18+
19+
20+
def update_gauge():
21+
global count, up
22+
23+
if up:
24+
count += 0.1
25+
if count > max_speed:
26+
up = False
27+
else:
28+
count -= 0.1
29+
30+
if count < -1.0:
31+
up = True
32+
33+
decimal_count_float = str(Decimal(count).quantize(Decimal('0.10')))
34+
decimal_count_int = str(Decimal(count).quantize(Decimal('1')))
35+
36+
ss_float.set_value(decimal_count_float)
37+
ss_int.set_value(decimal_count_int)
38+
39+
root.after(100, update_gauge)
40+
41+
42+
root.after(100, update_gauge)
43+
44+
root.mainloop()

0 commit comments

Comments
 (0)