conversion to new python3
This commit is contained in:
+19
-17
@@ -56,16 +56,17 @@ matplotlib.rcParams[ "interactive" ] = "False"
|
||||
matplotlib.rcParams[ "text.usetex" ] = "False"
|
||||
matplotlib.rcParams[ "axes.formatter.limits" ] = "-3,3"
|
||||
|
||||
#from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
|
||||
from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas
|
||||
from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
|
||||
#from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas
|
||||
|
||||
max_points_to_display = 0
|
||||
|
||||
import matplotlib.axes
|
||||
import matplotlib.figure
|
||||
#for printing issues
|
||||
if hasattr( gtk, "PrintOperation" ):
|
||||
import matplotlib.backends.backend_cairo
|
||||
#if hasattr( gtk, "PrintOperation" ):
|
||||
# import matplotlib.backends.backend_cairo
|
||||
|
||||
print('backend:', matplotlib.get_backend()) # must print GTK3Agg
|
||||
# import our own stuff
|
||||
from damaris.gui import ExperimentWriter, ExperimentHandling
|
||||
@@ -288,12 +289,13 @@ class DamarisGUI:
|
||||
self.toolbar_pause_button = self.xml_gui.get_object( "toolbar_pause_button" )
|
||||
|
||||
# print button
|
||||
self.toolbar_print_button = self.xml_gui.get_object( "toolbar_print_button" )
|
||||
if not hasattr( gtk, "PrintOperation" ):
|
||||
self.toolbar_print_button.set_sensitive( False )
|
||||
print("Printing is not supported by GTK+ version in use")
|
||||
else:
|
||||
self.toolbar_print_button.set_sensitive( True )
|
||||
# disabled 2026-02-24
|
||||
#self.toolbar_print_button = self.xml_gui.get_object( "toolbar_print_button" )
|
||||
#if not hasattr( gtk, "PrintOperation" ):
|
||||
# self.toolbar_print_button.set_sensitive( False )
|
||||
# print("Printing is not supported by GTK+ version in use")
|
||||
#else:
|
||||
# self.toolbar_print_button.set_sensitive( True )
|
||||
|
||||
# prepare for edit state
|
||||
self.toolbar_run_button.set_sensitive( True )
|
||||
@@ -541,7 +543,7 @@ class DamarisGUI:
|
||||
for r in still_running:
|
||||
r.quit_flag.set( )
|
||||
print("waiting for threads stoping...", end=' ')
|
||||
still_running = [x for x in [ self.si.exp_handling, self.si.res_handling, self.si.back_driver ] if x is not None and x.isAlive( )]
|
||||
still_running = [x for x in [ self.si.exp_handling, self.si.res_handling, self.si.back_driver ] if x is not None and x.is_alive()]
|
||||
for t in still_running:
|
||||
t.join( )
|
||||
print("done")
|
||||
@@ -624,7 +626,7 @@ class DamarisGUI:
|
||||
r_text = None
|
||||
b_text = None
|
||||
if self.si.exp_handling is not None:
|
||||
if not self.si.exp_handling.isAlive( ):
|
||||
if not self.si.exp_handling.is_alive():
|
||||
self.si.exp_handling.join( )
|
||||
if self.si.exp_handling.raised_exception:
|
||||
print("experiment script failed at line %d (function %s): %s" % (self.si.exp_handling.location[ 0 ],
|
||||
@@ -642,7 +644,7 @@ class DamarisGUI:
|
||||
e_text += experimenttimetext
|
||||
|
||||
if self.si.res_handling is not None:
|
||||
if not self.si.res_handling.isAlive( ):
|
||||
if not self.si.res_handling.is_alive():
|
||||
self.si.res_handling.join( )
|
||||
if self.si.res_handling.raised_exception:
|
||||
print("result script failed at line %d (function %s): %s" % (self.si.res_handling.location[ 0 ],
|
||||
@@ -657,7 +659,7 @@ class DamarisGUI:
|
||||
r_text = "Result Script Running (%d)" % r
|
||||
|
||||
if self.si.back_driver is not None:
|
||||
if not self.si.back_driver.isAlive( ):
|
||||
if not self.si.back_driver.is_alive():
|
||||
if self.si.back_driver.raised_exception:
|
||||
b_text = "Backend Failed"
|
||||
else:
|
||||
@@ -671,7 +673,7 @@ class DamarisGUI:
|
||||
b_text += backendtimetext
|
||||
|
||||
if self.dump_thread is not None:
|
||||
if self.dump_thread.isAlive( ):
|
||||
if self.dump_thread.is_alive():
|
||||
sys.stdout.write( "." )
|
||||
self.dump_dots += 1
|
||||
if self.dump_dots > 80:
|
||||
@@ -713,7 +715,7 @@ class DamarisGUI:
|
||||
return True
|
||||
else:
|
||||
if self.save_thread is not None:
|
||||
if self.save_thread.isAlive( ):
|
||||
if self.save_thread.is_alive():
|
||||
sys.stdout.write( "." )
|
||||
self.dump_dots += 1
|
||||
if self.dump_dots > 80:
|
||||
@@ -1086,7 +1088,7 @@ class DamarisGUI:
|
||||
|
||||
if requested_doc in self.doc_urls and self.doc_urls[ requested_doc ] is not None:
|
||||
if self.doc_browser is not None:
|
||||
if not self.doc_browser.isAlive( ):
|
||||
if not self.doc_browser.is_alive():
|
||||
self.doc_browser.join( )
|
||||
if self.doc_browser.my_webbrowser is not None:
|
||||
print("new browser tab")
|
||||
|
||||
@@ -104,7 +104,7 @@ class ResultReader:
|
||||
self.result_job_number = None
|
||||
# Job Date is set in __read_file()
|
||||
self.__filetype = None
|
||||
for elem in xml.etree.cElementTree.ElementTree(file=in_file).getiterator():
|
||||
for elem in xml.etree.cElementTree.ElementTree(file=in_file).iter():
|
||||
if elem.tag == 'result':
|
||||
self.result_job_number = int(elem.get("job"))
|
||||
pass
|
||||
@@ -114,7 +114,7 @@ class ResultReader:
|
||||
self.result_description = {}
|
||||
self.in_description_section=True
|
||||
self.in_description_data=()
|
||||
for an_item in elem.getchildren():
|
||||
for an_item in elem.iter():
|
||||
self.in_description_data = (an_item.get("key"), an_item.get("type"), an_item.text)
|
||||
# make item contents to dictionary item:
|
||||
k,t,v=self.in_description_data
|
||||
@@ -173,7 +173,7 @@ class ResultReader:
|
||||
self.adc_result_trailing_chars = "".join(elem.text.splitlines())
|
||||
tmp_string = base64.standard_b64decode(self.adc_result_trailing_chars)
|
||||
self.adc_result_trailing_chars = None
|
||||
tmp = numpy.fromstring(tmp_string,dtype='Int16')
|
||||
tmp = numpy.fromstring(tmp_string,dtype='int16')
|
||||
tmp_string = None
|
||||
self.adc_result_parts.append(tmp)
|
||||
tmp = None
|
||||
@@ -213,13 +213,13 @@ class ResultReader:
|
||||
self.adc_result_sample_counter>0:
|
||||
# fill the ADC_Result with collected data
|
||||
# x data
|
||||
self.result.x=numpy.arange(self.adc_result_sample_counter, dtype="Float64")/\
|
||||
self.result.x=numpy.arange(self.adc_result_sample_counter, dtype="float64")/\
|
||||
self.result.get_sampling_rate()
|
||||
self.result.y = []
|
||||
nChannels = self.result.get_nChannels()
|
||||
# initialise the y arrays
|
||||
for i in range(nChannels):
|
||||
self.result.y.append(numpy.empty(self.adc_result_sample_counter, dtype='Int16'))
|
||||
self.result.y.append(numpy.empty(self.adc_result_sample_counter, dtype='int16'))
|
||||
# remove from result stack
|
||||
tmp_index = 0
|
||||
while self.adc_result_parts:
|
||||
@@ -293,12 +293,12 @@ class ResultReader:
|
||||
self.__filetype == ResultReader.ADCDATA_TYPE and \
|
||||
self.adc_result_sample_counter>0:
|
||||
# fill the ADC_Result with collected data
|
||||
self.result.x=numpy.arange(self.adc_result_sample_counter, dtype="Float64")/\
|
||||
self.result.x=numpy.arange(self.adc_result_sample_counter, dtype="float64")/\
|
||||
self.result.get_sampling_rate()
|
||||
self.result.y=[]
|
||||
self.result.index=[]
|
||||
for i in range(2):
|
||||
self.result.y.append(numpy.empty((self.adc_result_sample_counter,), dtype="Int16"))
|
||||
self.result.y.append(numpy.empty((self.adc_result_sample_counter,), dtype="int16"))
|
||||
tmp_sample_counter=0
|
||||
while self.adc_result_parts:
|
||||
tmp_part=self.adc_result_parts.pop(0)
|
||||
@@ -468,10 +468,10 @@ class ResultReader:
|
||||
tmp=None
|
||||
if self.adc_data_encoding=="a":
|
||||
values=list(map(int,self.adc_result_trailing_chars.split()))
|
||||
tmp=numpy.array(values, dtype="Int16")
|
||||
tmp=numpy.array(values, dtype="int16")
|
||||
elif self.adc_data_encoding=="b":
|
||||
tmp_string=base64.standard_b64decode(self.adc_result_trailing_chars)
|
||||
tmp=numpy.fromstring(tmp_string, dtype="Int16")
|
||||
tmp=numpy.fromstring(tmp_string, dtype="int16")
|
||||
del tmp_string
|
||||
else:
|
||||
print("unknown ADC data format")
|
||||
|
||||
+3
-1
@@ -644,6 +644,7 @@ Public License instead of this License.
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<!--
|
||||
<child>
|
||||
<object class="GtkToolButton" id="toolbar_print_button">
|
||||
<property name="visible">True</property>
|
||||
@@ -653,7 +654,8 @@ Public License instead of this License.
|
||||
<packing>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</child>
|
||||
-->
|
||||
<child>
|
||||
<object class="GtkSeparatorToolItem" id="toolbutton2">
|
||||
<property name="visible">True</property>
|
||||
|
||||
Reference in New Issue
Block a user