1 |
from gi.repository import Gtk, Gdk |
from gi.repository import Gtk, Gdk |
2 |
from gi.repository import Pango |
from gi.repository import Pango |
3 |
import ascpy |
import ascpy |
4 |
|
from celsiusunits import CelsiusUnits |
5 |
|
from preferences import Preferences |
6 |
|
|
7 |
from varentry import * |
from varentry import * |
8 |
from studyreporter import * |
from studyreporter import * |
96 |
_arr = {self.lowerb: self.instance.getRealValue() |
_arr = {self.lowerb: self.instance.getRealValue() |
97 |
,self.upperb: self.instance.getUpperBound() # this upper bound is probably stoopid |
,self.upperb: self.instance.getUpperBound() # this upper bound is probably stoopid |
98 |
} |
} |
99 |
|
|
100 |
|
##### CELSIUS TEMPERATURE WORKAROUND |
101 |
|
if self.instance.getType().isRefinedReal() and str(self.instance.getType().getDimensions()) == 'TMP': |
102 |
|
units = Preferences().getPreferredUnitsOrigin(str(self.instance.getType().getName())) |
103 |
|
if units == CelsiusUnits.get_celsius_sign(): |
104 |
|
self.convert = True |
105 |
|
##### CELSIUS TEMPERATURE WORKAROUND |
106 |
|
|
107 |
for _k,_v in _arr.iteritems(): |
for _k,_v in _arr.iteritems(): |
108 |
_t = str(_v / _conversion)+" "+_u |
_t = str(_v / _conversion)+" "+_u |
109 |
|
##### CELSIUS TEMPERATURE WORKAROUND |
110 |
|
if self.convert: |
111 |
|
_t = CelsiusUnits.convert_kelvin_to_celsius(_v, str(self.instance.getType())) + " " + CelsiusUnits.get_celsius_sign() |
112 |
|
##### CELSIUS TEMPERATURE WORKAROUND |
113 |
_k.set_text(_t) |
_k.set_text(_t) |
114 |
|
|
115 |
self.browser.builder.connect_signals(self) |
self.browser.builder.connect_signals(self) |
308 |
entry.set_property("secondary-icon-stock", 'gtk-dialog-error') |
entry.set_property("secondary-icon-stock", 'gtk-dialog-error') |
309 |
else: |
else: |
310 |
entry.set_property("secondary-icon-stock", 'gtk-yes') |
entry.set_property("secondary-icon-stock", 'gtk-yes') |
311 |
entry.set_property("secondary-icon-tooltip-text", "") |
|
312 |
entry.set_property("secondary-icon-tooltip-text", msg) |
# causes gtk-critical errors |
313 |
|
# entry.set_property("secondary-icon-tooltip-text", "") |
314 |
|
# entry.set_property("secondary-icon-tooltip-text", msg) |
315 |
|
|
316 |
def taint_dist(self, good=0, msg=None): |
def taint_dist(self, good=0, msg=None): |
317 |
""" |
""" |
330 |
""" |
""" |
331 |
Parse an input box and enforce dimensional agreement with self.instance. |
Parse an input box and enforce dimensional agreement with self.instance. |
332 |
""" |
""" |
333 |
|
newtext = entry.get_text() |
334 |
|
##### CELSIUS TEMPERATURE WORKAROUND |
335 |
|
if self.convert: |
336 |
|
if len(newtext) > 0 and (len(newtext.split(" ")) == 1 or newtext.split(" ")[1] == CelsiusUnits.get_celsius_sign()): |
337 |
|
newtext = CelsiusUnits.convert_celsius_to_kelvin(newtext.split(" ")[0], str(self.instance.getType())) |
338 |
|
##### CELSIUS TEMPERATURE WORKAROUND |
339 |
# FIXME Add missing units if they have not been entered. |
# FIXME Add missing units if they have not been entered. |
340 |
i = RealAtomEntry(self.instance, entry.get_text()) |
i = RealAtomEntry(self.instance, newtext) |
341 |
_msg = None |
_msg = None |
342 |
try: |
try: |
343 |
i.checkEntry() |
i.checkEntry() |
397 |
# FIXME move following code to the StudyReporter class? |
# FIXME move following code to the StudyReporter class? |
398 |
i = 0 |
i = 0 |
399 |
_val = _start |
_val = _start |
400 |
while i<=_nsteps and reporter.guiinterrupt == False: |
while i <= _nsteps and reporter.guiinterrupt is False: |
401 |
# run a method, if requested |
# run a method, if requested |
402 |
if self.method: |
if self.method: |
403 |
try: |
try: |
404 |
_b.sim.run(method) |
_b.sim.run(self.method) |
405 |
except RuntimeError,e: |
except RuntimeError,e: |
406 |
_b.reporter.reportError(str(e)) |
_b.reporter.reportError(str(e)) |
407 |
|
|