1 |
##### CELSIUS TEMPERATURE WORKAROUND |
2 |
from gi.repository import Pango |
3 |
|
4 |
|
5 |
class CelsiusUnits: |
6 |
|
7 |
@staticmethod |
8 |
def get_units_row(selected): |
9 |
weight = Pango.Weight.NORMAL |
10 |
if selected: |
11 |
weight = Pango.Weight.BOLD |
12 |
return [selected, CelsiusUnits.get_celsius_sign(), "1 K (offset -273.15 K)", weight] |
13 |
|
14 |
@staticmethod |
15 |
def get_celsius_sign(): |
16 |
return "degC" |
17 |
|
18 |
@staticmethod |
19 |
def convert_celsius_to_kelvin(value, instype): |
20 |
if instype.startswith("delta"): |
21 |
return value |
22 |
try: |
23 |
temp = float(value) |
24 |
except ValueError: |
25 |
return value |
26 |
|
27 |
return str(temp + 273.15) |
28 |
|
29 |
@staticmethod |
30 |
def convert_kelvin_to_celsius(value, instype): |
31 |
if instype.startswith("delta"): |
32 |
return value |
33 |
try: |
34 |
temp = float(value) |
35 |
except ValueError: |
36 |
return value |
37 |
|
38 |
return str(temp - 273.15) |
39 |
##### CELSIUS TEMPERATURE WORKAROUND |