/[ascend]/branches/adrian/pygtk/celsiusunits.py
ViewVC logotype

Contents of /branches/adrian/pygtk/celsiusunits.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3043 - (show annotations) (download) (as text)
Wed Aug 5 12:43:22 2015 UTC (6 years, 10 months ago) by adrian
File MIME type: text/x-python
File size: 813 byte(s)
Added celsius temperatures to study dialog
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

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22