removed print button, cleanup last Gtk3 porting issues
Build Debian Packages / build (bookworm, debian12) (push) Successful in 7m47s
Build Debian Packages / build (bullseye, debian11) (push) Successful in 6m55s
Build Debian Packages / build (trixie, debian13) (push) Successful in 8m58s

This commit is contained in:
2026-03-17 09:00:05 +01:00
parent 05b9f1305c
commit f5811b8ee1
4 changed files with 49 additions and 301 deletions
-1
View File
@@ -76,7 +76,6 @@ class Drawable:
"Sets a channel to a certain plot-style" "Sets a channel to a certain plot-style"
if channel in self.styles: if channel in self.styles:
print("Drawable Warning: Style key \"%s\" will be overwritten with \"%s\"" % (str(channel), str(value))) print("Drawable Warning: Style key \"%s\" will be overwritten with \"%s\"" % (str(channel), str(value)))
self.styles[channel] = str(value) self.styles[channel] = str(value)
+49 -272
View File
@@ -25,8 +25,6 @@ gi.require_version('GtkSource', '3.0')
from gi.repository import GObject as gobject from gi.repository import GObject as gobject
import sqlite3,uuid import sqlite3,uuid
#gobject.threads_init( )
from gi.repository import Gtk as gtk from gi.repository import Gtk as gtk
gtk_version_missmatch = gtk.check_version( 3, 0, 0 ) gtk_version_missmatch = gtk.check_version( 3, 0, 0 )
@@ -35,10 +33,6 @@ if gtk_version_missmatch:
from gi.repository import Gdk as gdk from gi.repository import Gdk as gdk
#gdk.threads_init( )
#import gtk.glade
from gi.repository import GtkSource as gtksourceview2 from gi.repository import GtkSource as gtksourceview2
gobject.type_register(gtksourceview2.View) gobject.type_register(gtksourceview2.View)
@@ -62,9 +56,6 @@ max_points_to_display = 0
import matplotlib.axes import matplotlib.axes
import matplotlib.figure import matplotlib.figure
#for printing issues
if hasattr( gtk, "PrintOperation" ):
import matplotlib.backends.backend_cairo
# import our own stuff # import our own stuff
from damaris.gui import ExperimentWriter, ExperimentHandling from damaris.gui import ExperimentWriter, ExperimentHandling
@@ -219,8 +210,7 @@ class DamarisGUI:
self.statusbar_init( ) self.statusbar_init( )
#connect event handlers #connect event handlers
eventhandlers = {"on_toolbar_print_button_clicked": self.print_button_switch, eventhandlers = {"on_toolbar_run_button_clicked": self.start_experiment,
"on_toolbar_run_button_clicked": self.start_experiment,
"on_toolbar_pause_button_toggled": self.pause_experiment, "on_toolbar_pause_button_toggled": self.pause_experiment,
"on_toolbar_stop_button_clicked": self.stop_experiment, "on_toolbar_stop_button_clicked": self.stop_experiment,
"on_doc_menu_activate": self.show_doc_menu, "on_doc_menu_activate": self.show_doc_menu,
@@ -242,7 +232,6 @@ class DamarisGUI:
"on_config_load_button_clicked": self.config.load_config_handler, "on_config_load_button_clicked": self.config.load_config_handler,
"on_backend_executable_browse_button_clicked": self.config.browse_backend_executable_dialog, "on_backend_executable_browse_button_clicked": self.config.browse_backend_executable_dialog,
"on_fontbutton_font_set": self.config.set_script_font_handler, "on_fontbutton_font_set": self.config.set_script_font_handler,
"on_printer_setup_button_clicked": self.config.printer_setup_handler,
"on_display_autoscaling_checkbutton_toggled": self.monitor.display_autoscaling_toggled, "on_display_autoscaling_checkbutton_toggled": self.monitor.display_autoscaling_toggled,
"on_display_statistics_checkbutton_toggled": self.monitor.display_statistics_toggled, "on_display_statistics_checkbutton_toggled": self.monitor.display_statistics_toggled,
"on_display_x_scaling_combobox_changed": self.monitor.display_scaling_changed, "on_display_x_scaling_combobox_changed": self.monitor.display_scaling_changed,
@@ -336,7 +325,7 @@ class DamarisGUI:
question = gtk.MessageDialog(parent=self.xml_gui.get_object( "main_window"), question = gtk.MessageDialog(parent=self.xml_gui.get_object( "main_window"),
type=gtk.MessageType.WARNING, type=gtk.MessageType.WARNING,
flags=gtk.DialogFlags.MODAL, flags=gtk.DialogFlags.MODAL,
buttons=(gtk.STOCK_CANCEL, gtk.ResponseType.CANCEL, gtk.STOCK_NO, gtk.ResponseType.NO, gtk.STOCK_YES, gtk.ResponseType.YES)) buttons=("_Cancel", gtk.ResponseType.CANCEL, "_No", gtk.ResponseType.NO, "_Yes", gtk.ResponseType.YES))
question.set_markup("The Experiment Script has been changed. Save changes?") question.set_markup("The Experiment Script has been changed. Save changes?")
response = question.run() response = question.run()
@@ -357,7 +346,7 @@ class DamarisGUI:
question = gtk.MessageDialog(parent=self.xml_gui.get_object( "main_window"), question = gtk.MessageDialog(parent=self.xml_gui.get_object( "main_window"),
type=gtk.MessageType.WARNING, type=gtk.MessageType.WARNING,
flags=gtk.DialogFlags.MODAL, flags=gtk.DialogFlags.MODAL,
buttons=(gtk.STOCK_CANCEL, gtk.ResponseType.CANCEL, gtk.STOCK_NO, gtk.ResponseType.NO, gtk.STOCK_YES, gtk.ResponseType.YES)) buttons=("_Cancel", gtk.ResponseType.CANCEL, "_No", gtk.ResponseType.NO, "_Yes", gtk.ResponseType.YES))
question.set_markup("The Result Script has been changed. Save changes?") question.set_markup("The Result Script has been changed. Save changes?")
response = question.run() response = question.run()
@@ -387,7 +376,7 @@ class DamarisGUI:
question = gtk.MessageDialog(parent=self.xml_gui.get_object( "main_window"), question = gtk.MessageDialog(parent=self.xml_gui.get_object( "main_window"),
type=gtk.MessageType.ERROR, type=gtk.MessageType.ERROR,
flags=gtk.DialogFlags.MODAL, flags=gtk.DialogFlags.MODAL,
buttons=(gtk.STOCK_OK, gtk.ResponseType.OK)) buttons=("_Understood!", gtk.ResponseType.OK))
question.set_markup("Experiment still running, can not close DAMARIS!") question.set_markup("Experiment still running, can not close DAMARIS!")
response = question.run() response = question.run()
@@ -822,7 +811,7 @@ class DamarisGUI:
last_backup -= 1 last_backup -= 1
os.rename( self.dump_filename, dump_filename_pattern % 0 ) os.rename( self.dump_filename, dump_filename_pattern % 0 )
if cummulated_size > (1 << 30): if cummulated_size > (1 << 30):
print("Warning: the cummulated backups size of '%s' is %d MByte" % (self.dump_filename, print("Warning: the cumulated backups size of '%s' is %d MByte" % (self.dump_filename,
cummulated_size / (1 << 20))) cummulated_size / (1 << 20)))
# init is finnished now # init is finnished now
@@ -990,53 +979,6 @@ class DamarisGUI:
r.quit_flag.set( ) r.quit_flag.set( )
self.state = DamarisGUI.Stop_State self.state = DamarisGUI.Stop_State
def print_button_switch( self, widget ):
"""
decides what to print... and prints, layout is done by responsible class
"""
if not hasattr( gtk, "PrintOperation" ):
return
# copied and modified from pygtk-2.10.1/examples/pygtk-demo/demos/print_editor.py
print_ = gtk.PrintOperation( )
# will come from config
settings = None
if settings is not None:
print_.set_print_settings( settings )
page_setup = None
if page_setup is not None:
print_.set_default_page_setup( page_setup )
#print_.set_property("allow_async",True)
current_page = self.main_notebook.get_current_page( )
print_data = { }
if current_page in [ 0, 1 ]:
print_.connect( "begin_print", self.sw.begin_print, print_data )
print_.connect( "draw_page", self.sw.draw_page, print_data )
elif current_page == 2:
print_.connect( "begin_print", self.monitor.begin_print, print_data )
print_.connect( "draw_page", self.monitor.draw_page, print_data )
else:
return
try:
res = print_.run( gtk.PRINT_OPERATION_ACTION_PRINT_DIALOG, self.main_window )
except gobject.GError as ex:
error_dialog = gtk.MessageDialog( self.main_window,
gtk.DIALOG_DESTROY_WITH_PARENT,
gtk._MESSAGE_ERROR,
gtk.BUTTONS_CLOSE,
("Error printing file:\n%s" % str( ex )) )
error_dialog.connect( "response", gtk.Widget.destroy )
error_dialog.show( )
else:
if res == gtk.PRINT_OPERATION_RESULT_APPLY:
settings = print_.get_print_settings( )
def documentation_init( self ): def documentation_init( self ):
self.doc_urls = { self.doc_urls = {
@@ -1526,7 +1468,6 @@ get_job_id get_description set_description get_xdata get_ydata set_xdate set_yda
""" """
helpful tab and return key functions helpful tab and return key functions
""" """
#print "keypress", event.state, event.keyval
if event.state & gdk.ModifierType.CONTROL_MASK != 0: if event.state & gdk.ModifierType.CONTROL_MASK != 0:
if event.keyval == gdk.keyval_from_name( "s" ): if event.keyval == gdk.keyval_from_name( "s" ):
# save buffer # save buffer
@@ -1631,10 +1572,11 @@ get_job_id get_description set_description get_xdata get_ydata set_xdate set_yda
question = gtk.MessageDialog(parent=self.xml_gui.get_object( "main_window"), question = gtk.MessageDialog(parent=self.xml_gui.get_object( "main_window"),
type=gtk.MessageType.WARNING, type=gtk.MessageType.WARNING,
flags=gtk.DialogFlags.MODAL, flags=gtk.DialogFlags.MODAL,
buttons=gtk.BUTTONS_NONE) buttons=("_Yes", gtk.ResponseType.YES,
question.add_button(gtk.STOCK_CANCEL, gtk.ResponseType.CANCEL) "_No", gtk.ResponseType.NO,
question.add_button(gtk.STOCK_NO, gtk.ResponseType.NO) "_Cancel", gtk.ResponseType.CANCEL))
question.add_button(gtk.STOCK_YES, gtk.ResponseType.YES)
question.set_markup("The file has been changed. Save changes?") question.set_markup("The file has been changed. Save changes?")
response = question.run() response = question.run()
@@ -1653,7 +1595,7 @@ get_job_id get_description set_description get_xdata get_ydata set_xdate set_yda
script_filename = os.path.abspath( file_name ) script_filename = os.path.abspath( file_name )
if not os.access( script_filename, os.R_OK ): if not os.access( script_filename, os.R_OK ):
outer_space.show_error_dialog( "File I/O Error", "Cannot read from file %s" % script_filename ) self.outer_space.show_error_dialog( "File I/O Error", "Cannot read from file %s" % script_filename )
return True return True
script_string = script_widget.load_file_as_unicode( script_filename ) script_string = script_widget.load_file_as_unicode( script_filename )
@@ -1672,8 +1614,8 @@ get_job_id get_description set_description get_xdata get_ydata set_xdate set_yda
dialog = gtk.FileChooserDialog( title=open_dialog_title, dialog = gtk.FileChooserDialog( title=open_dialog_title,
parent=parent_window, parent=parent_window,
action=gtk.FileChooserAction.OPEN, action=gtk.FileChooserAction.OPEN,
buttons=(gtk.STOCK_OPEN, gtk.ResponseType.OK, gtk.STOCK_CANCEL, gtk.ResponseType.CANCEL) buttons=("_Open", gtk.ResponseType.OK, "_Cancel", gtk.ResponseType.CANCEL)
) )
dialog.set_default_response( gtk.ResponseType.OK ) dialog.set_default_response( gtk.ResponseType.OK )
dialog.set_select_multiple( False ) dialog.set_select_multiple( False )
# Event-Handler for responce-signal (when one of the button is pressed) # Event-Handler for responce-signal (when one of the button is pressed)
@@ -1740,7 +1682,7 @@ get_job_id get_description set_description get_xdata get_ydata set_xdate set_yda
question = gtk.MessageDialog(parent=script_widget.xml_gui.get_object( "main_window"), question = gtk.MessageDialog(parent=script_widget.xml_gui.get_object( "main_window"),
type=gtk.MessageType.WARNING, type=gtk.MessageType.WARNING,
flags=gtk.DialogFlags.MODAL, flags=gtk.DialogFlags.MODAL,
buttons=(gtk.STOCK_YES, gtk.ResponseType.YES, gtk.STOCK_NO, gtk.ResponseType.NO)) buttons=("_Yes", gtk.ResponseType.YES, "_No", gtk.ResponseType.NO))
question.set_markup("The file already exists. Do you want to overwrite the existing file and delete its contents?") question.set_markup("The file already exists. Do you want to overwrite the existing file and delete its contents?")
response = question.run() response = question.run()
@@ -1772,8 +1714,7 @@ get_job_id get_description set_description get_xdata get_ydata set_xdate set_yda
dialog = gtk.FileChooserDialog( title=dialog_title, dialog = gtk.FileChooserDialog( title=dialog_title,
parent=parent_window, parent=parent_window,
action=gtk.FileChooserAction.SAVE, action=gtk.FileChooserAction.SAVE,
buttons=( buttons=("_Save", gtk.ResponseType.OK, "_Cancel", gtk.ResponseType.CANCEL) )
gtk.STOCK_SAVE, gtk.ResponseType.OK, gtk.STOCK_CANCEL, gtk.ResponseType.CANCEL) )
dialog.set_default_response( gtk.ResponseType.OK ) dialog.set_default_response( gtk.ResponseType.OK )
dialog.set_select_multiple( False ) dialog.set_select_multiple( False )
@@ -1897,7 +1838,7 @@ get_job_id get_description set_description get_xdata get_ydata set_xdate set_yda
dialog = gtk.Dialog(title="Search", parent=self.xml_gui.get_object("main_window"), flags=0, dialog = gtk.Dialog(title="Search", parent=self.xml_gui.get_object("main_window"), flags=0,
buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE, "Find last", -1, "Find next", 1)) buttons=("_Close", gtk.ResponseType.CLOSE, "Find last", -1, "Find next", 1))
cont = dialog.get_content_area() cont = dialog.get_content_area()
markedstring = "" markedstring = ""
@@ -1933,7 +1874,7 @@ get_job_id get_description set_description get_xdata get_ydata set_xdate set_yda
dialog.connect("response", response, self, textbox) dialog.connect("response", response, self, textbox)
dialog.set_resizable(False) dialog.set_resizable(False)
dialog.show_all() dialog.show()
if startit is not None and endit is not None: if startit is not None and endit is not None:
if current_page == 0: if current_page == 0:
@@ -1956,7 +1897,7 @@ get_job_id get_description set_description get_xdata get_ydata set_xdate set_yda
question = gtk.MessageDialog(parent=self.xml_gui.get_object( "main_window"), question = gtk.MessageDialog(parent=self.xml_gui.get_object( "main_window"),
type=gtk.MessageType.WARNING, type=gtk.MessageType.WARNING,
flags=gtk.DialogFlags.MODAL, flags=gtk.DialogFlags.MODAL,
buttons=(gtk.STOCK_YES, gtk.ResponseType.YES, gtk.STOCK_NO, gtk.ResponseType.NO, gtk.STOCK_CANCEL, gtk.ResponseType.CANCEL)) buttons=("_Yes", gtk.ResponseType.YES, "_No", gtk.ResponseType.NO, "_Cancel", gtk.ResponseType.CANCEL))
question.set_markup("The file has been changed. Save changes?") question.set_markup("The file has been changed. Save changes?")
response = question.run() response = question.run()
@@ -1974,7 +1915,7 @@ get_job_id get_description set_description get_xdata get_ydata set_xdate set_yda
question = gtk.MessageDialog(parent=self.xml_gui.get_object( "main_window"), question = gtk.MessageDialog(parent=self.xml_gui.get_object( "main_window"),
type=gtk.MessageType.WARNING, type=gtk.MessageType.WARNING,
flags=gtk.DialogFlags.MODAL, flags=gtk.DialogFlags.MODAL,
buttons=(gtk.STOCK_YES, gtk.ResponseType.YES, gtk.STOCK_NO, gtk.ResponseType.NO, gtk.STOCK_CANCEL, gtk.ResponseType.CANCEL)) buttons=("_Yes", gtk.ResponseType.YES, "_No", gtk.ResponseType.NO, "_Cancel", gtk.ResponseType.CANCEL))
question.set_markup("The file has been changed. Save changes?") question.set_markup("The file has been changed. Save changes?")
response = question.run() response = question.run()
@@ -1989,83 +1930,6 @@ get_job_id get_description set_description get_xdata get_ydata set_xdate set_yda
self.res_script_filename = None self.res_script_filename = None
self.set_toolbuttons_status( ) self.set_toolbuttons_status( )
def begin_print( self, operation, context, print_data ):
"""
layout of all pages
"""
# copied and modified from pygtk-2.10.1/examples/pygtk-demo/demos/print_editor.py
# Determining the tab which is currently open
current_page = self.main_notebook.get_current_page( )
script = ""
# get script text
if current_page == 0:
script = self.get_scripts( )[ 0 ]
elif current_page == 1:
script = self.get_scripts( )[ 1 ]
width = context.get_width( )
height = context.get_height( )
layout = context.create_pango_layout( )
layout.set_font_description( pango.FontDescription( "Monospace 12" ) )
layout.set_width( int( width * pango.SCALE ) )
layout.set_text( script )
num_lines = layout.get_line_count( )
page_breaks = [ ]
page_height = 0
for line in range( num_lines ):
layout_line = layout.get_line( line )
ink_rect, logical_rect = layout_line.get_extents( )
lx, ly, lwidth, lheight = logical_rect
line_height = lheight / 1024.0
if page_height + line_height > height:
page_breaks.append( line )
page_height = 0
page_height += line_height
operation.set_n_pages( len( page_breaks ) + 1 )
print_data[ "page_breaks" ] = page_breaks
print_data[ "layout" ] = layout
def draw_page( self, operation, context, page_nr, print_data ):
"""
render a single page
"""
# copied and modified from pygtk-2.10.1/examples/pygtk-demo/demos/print_editor.py
assert isinstance( print_data[ "page_breaks" ], list )
if page_nr == 0:
start = 0
else:
start = print_data[ "page_breaks" ][ page_nr - 1 ]
try:
end = print_data[ "page_breaks" ][ page_nr ]
except IndexError:
end = print_data[ "layout" ].get_line_count( )
cr = context.get_cairo_context( )
cr.set_source_rgb( 0, 0, 0 )
i = 0
start_pos = 0
iter = print_data[ "layout" ].get_iter( )
while 1:
if i >= start:
line = iter.get_line( )
_, logical_rect = iter.get_line_extents( )
lx, ly, lwidth, lheight = logical_rect
baseline = iter.get_baseline( )
if i == start:
start_pos = ly / 1024.0;
cr.move_to( lx / 1024.0, baseline / 1024.0 - start_pos )
cr.show_layout_line( line )
i += 1
if not (i < end and iter.next_line( )):
break
class ConfigTab: class ConfigTab:
""" """
@@ -2100,9 +1964,6 @@ class ConfigTab:
self.config_data_pool_comprate = self.xml_gui.get_object( "CompRatio" ) self.config_data_pool_comprate = self.xml_gui.get_object( "CompRatio" )
self.config_info_textview = self.xml_gui.get_object( "info_textview" ) self.config_info_textview = self.xml_gui.get_object( "info_textview" )
self.config_script_font_button = self.xml_gui.get_object( "script_fontbutton" ) self.config_script_font_button = self.xml_gui.get_object( "script_fontbutton" )
self.config_printer_setup_button = self.xml_gui.get_object( "printer_setup_button" )
if not hasattr( gtk, "print_run_page_setup_dialog" ):
self.config_printer_setup_button.set_sensitive( False )
# insert version informations # insert version informations
components_text = """ components_text = """
@@ -2112,8 +1973,7 @@ glib version %(glib)s
python version %(python)s python version %(python)s
matplotlib version %(matplotlib)s, %(matplotlib_backend)s matplotlib version %(matplotlib)s, %(matplotlib_backend)s
numpy version %(numpy)s numpy version %(numpy)s
pytables version %(pytables)s, using %(pytables_libs)s pytables version %(pytables)s, using: %(pytables_libs)s
pygtk version %(pygtk)s
pygobject version %(pygobject)s pygobject version %(pygobject)s
""" """
if hasattr( gobject, "glib_version" ): if hasattr( gobject, "glib_version" ):
@@ -2135,15 +1995,14 @@ pygobject version %(pygobject)s
components_versions = { components_versions = {
"os": platform.platform( ), "os": platform.platform( ),
"gtk": gtk._version, "gtk": "{}.{}.{}".format(gtk.MAJOR_VERSION, gtk.MINOR_VERSION, gtk.MICRO_VERSION),
"glib": glib_version, "glib": glib_version,
"python": sys.version, "python": sys.version,
"matplotlib": matplotlib.__version__, "matplotlib": matplotlib.__version__,
"matplotlib_backend": FigureCanvas.__name__[ 12: ], "matplotlib_backend": FigureCanvas.__name__[ 12: ],
"numpy": numpy_version, "numpy": numpy_version,
"pytables": tables.get_pytables_version( ), "pytables": tables.__version__,
"pytables_libs": "", "pytables_libs": "",
"pygtk": gtk._version,
"pygobject": pygobject_version "pygobject": pygobject_version
} }
@@ -2151,14 +2010,14 @@ pygobject version %(pygobject)s
# find compression extensions for combo box and write version numbers # find compression extensions for combo box and write version numbers
# list is taken from ValueError output of tables.which_lib_version("") # list is taken from ValueError output of tables.which_lib_version("")
model = self.config_data_pool_complib.get_model( ) model = self.config_data_pool_complib.get_model( )
for libname in ('hdf5', 'zlib', 'lzo', 'ucl', 'bzip2'): for libname in ('hdf5', 'zlib', 'lzo', 'blosc'):
version_info = None version_info = None
try: try:
version_info = tables.which_lib_version( libname ) version_info = tables.which_lib_version( libname )
except ValueError: except ValueError:
continue continue
if version_info: if version_info:
components_versions[ "pytables_libs" ] += "\n %s: %s" % (libname, str( version_info )) components_versions[ "pytables_libs" ] += "\n * %s: %s" % (libname, str( version_info[1] ))
if libname != "hdf5": if libname != "hdf5":
# a compression library, add it to combo box # a compression library, add it to combo box
if isinstance( model, gtk.ListStore ): if isinstance( model, gtk.ListStore ):
@@ -2272,22 +2131,6 @@ pygobject version %(pygobject)s
if data_handling_textview: if data_handling_textview:
data_handling_textview.modify_font( pango.FontDescription( font ) ) data_handling_textview.modify_font( pango.FontDescription( font ) )
def printer_setup_handler( self, widget ):
"""
changes to printer setup
"""
if not (hasattr( gtk, "PrintSettings" ) and hasattr( gtk, "print_run_page_setup_dialog" )):
return
if not hasattr( self, "printer_setup" ):
self.printer_setup = gtk.PrintSettings( )
if not hasattr( self, "page_setup" ):
self.page_setup = None
self.page_setup = gtk.print_run_page_setup_dialog( self.xml_gui.get_object( "main_window" ),
self.page_setup, self.printer_setup )
def browse_backend_executable_dialog( self, widget ): def browse_backend_executable_dialog( self, widget ):
""" """
do the open file dialog do the open file dialog
@@ -2302,14 +2145,13 @@ pygobject version %(pygobject)s
script_widget.config_backend_executable_entry.set_text( file_name ) script_widget.config_backend_executable_entry.set_text( file_name )
return True return True
parent_window = self.xml_gui.get_object( "main_window" ) parent_window = self.xml_gui.get_object( "main_window" )
dialog = gtk.FileChooserDialog( title=backend_filename_dialog_title, dialog = gtk.FileChooserDialog( title=backend_filename_dialog_title,
parent=parent_window, parent=parent_window,
action=gtk.FileChooserAction.OPEN, action=gtk.FileChooserAction.OPEN,
buttons=(gtk.STOCK_OPEN, buttons=("_Open",
gtk.ResponseType.OK, gtk.ResponseType.OK,
gtk.STOCK_CANCEL, "_Cancel",
gtk.ResponseType.CANCEL) ) gtk.ResponseType.CANCEL) )
dialog.set_default_response( gtk.ResponseType.OK ) dialog.set_default_response( gtk.ResponseType.OK )
dialog.set_select_multiple( False ) dialog.set_select_multiple( False )
@@ -2859,7 +2701,7 @@ class MonitorWidgets:
question = gtk.MessageDialog(parent=parentfordialog, question = gtk.MessageDialog(parent=parentfordialog,
type=gtk.MessageType.WARNING, type=gtk.MessageType.WARNING,
flags=gtk.DialogFlags.MODAL, flags=gtk.DialogFlags.MODAL,
buttons=(gtk.STOCK_YES, gtk.ResponseType.YES, gtk.STOCK_NO, gtk.ResponseType.NO)) buttons=("_Yes", gtk.ResponseType.YES, "_No", gtk.ResponseType.NO))
question.set_markup("The file already exists. Do you want to overwrite the existing file and delete its contents?") question.set_markup("The file already exists. Do you want to overwrite the existing file and delete its contents?")
response = question.run() response = question.run()
@@ -2883,8 +2725,7 @@ class MonitorWidgets:
dialog = gtk.FileChooserDialog( title=dialog_title, dialog = gtk.FileChooserDialog( title=dialog_title,
parent=self.main_window, parent=self.main_window,
action=gtk.FileChooserAction.SAVE, action=gtk.FileChooserAction.SAVE,
buttons=( buttons=("_Save", gtk.ResponseType.OK, "_Cancel", gtk.ResponseType.CANCEL) )
gtk.STOCK_SAVE, gtk.ResponseType.OK, gtk.STOCK_CANCEL, gtk.ResponseType.CANCEL) )
dialog.set_default_response( gtk.ResponseType.OK ) dialog.set_default_response( gtk.ResponseType.OK )
dialog.set_current_name( data_to_save[ 0 ] ) dialog.set_current_name( data_to_save[ 0 ] )
@@ -2956,13 +2797,10 @@ class MonitorWidgets:
self.measurementresultgraph = None self.measurementresultgraph = None
elif self.measurementresultgraph is not None: elif self.measurementresultgraph is not None:
# clear errorbars # clear errorbars
#self.matplot_axes.lines.remove( self.measurementresultgraph[ 0 ] )
self.measurementresultgraph[0].remove() self.measurementresultgraph[0].remove()
for line in self.measurementresultgraph[ 1 ]: for line in self.measurementresultgraph[ 1 ]:
#self.matplot_axes.lines.remove( l )
line.remove() line.remove()
for line in self.measurementresultgraph[ 2 ]: for line in self.measurementresultgraph[ 2 ]:
#self.matplot_axes.collections.remove( l )
line.remove() line.remove()
self.measurementresultgraph = None self.measurementresultgraph = None
self.matplot_axes.clear( ) self.matplot_axes.clear( )
@@ -2971,7 +2809,6 @@ class MonitorWidgets:
self.graphen = [ ] self.graphen = [ ]
elif self.graphen: elif self.graphen:
for line in self.graphen: for line in self.graphen:
#self.matplot_axes.lines.remove( line )
line.remove() line.remove()
self.graphen = [ ] self.graphen = [ ]
self.matplot_axes.clear( ) self.matplot_axes.clear( )
@@ -3121,26 +2958,27 @@ class MonitorWidgets:
else: else:
self.matplot_axes.set_ylabel( "" ) self.matplot_axes.set_ylabel( "" )
# Any variables to be set? # Any variables to be drawn on plot
# if False: if True:
# if isinstance(in_result, Accumulation): descriptions = None
# descriptions = in_result.common_descriptions if isinstance(in_result, Accumulation):
# elif isinstance(in_result, ADC_Result): descriptions = in_result.common_descriptions
# descriptions = in_result.description elif isinstance(in_result, ADC_Result):
# else: pass descriptions = in_result.description
# actual_config = self.config.get() else:
# if (descriptions is not None) : #--markusro pass
# print actual_config['pretty_descriptions'] #actual_config = self.config.get()
# pass if (descriptions is not None):
# description_string = "" #print(actual_config['pretty_descriptions'])
# for key in descriptions.keys(): description_string = ""
# description_string += "%s = %s\n" % (key,descriptions[key]) for key in descriptions.keys():
# self.matplot_axes.text(0.7,0.95, description_string[:-1], description_string += "%s = %s\n" % (key,descriptions[key])
# size=8, self.matplot_axes.text(0.8,0.95, description_string[:-1],
# transform=self.matplot_axes.transAxes, size=10,
# va='top', transform=self.matplot_axes.transAxes,
# backgroundcolor='white') va='top',
# backgroundcolor='white')
# Draw it! # Draw it!
self.matplot_canvas.draw_idle( ) self.matplot_canvas.draw_idle( )
del in_result del in_result
@@ -3258,67 +3096,6 @@ class MonitorWidgets:
return return
self.update_display( ) self.update_display( )
def begin_print( self, operation, context, print_data ):
"""
layout of one page with matplotlib graph
"""
operation.set_n_pages( 1 )
def draw_page( self, operation, context, page_nr, print_data ):
"""
render a single page
"""
# copied and modified from pygtk-2.10.1/examples/pygtk-demo/demos/print_editor.py
if page_nr != 0:
return
# check page dimensions
# all lengths in inch: name *_in
page_setup = context.get_page_setup( )
dpi = context.get_dpi_x( )
if dpi != context.get_dpi_y( ):
print("draw_page: dpi_x!=dpi_y, I am not prepared for that")
freewidth_in = float( context.get_width( ) ) / dpi
freeheight_in = float( context.get_height( ) ) / dpi
fc = self.matplot_canvas.switch_backends( matplotlib.backends.backend_cairo.FigureCanvasCairo )
fc.figure.dpi.set( dpi )
orig_w_in, orig_h_in = fc.figure.get_size_inches( )
orig_f_color = fc.figure.get_facecolor( )
orig_e_color = fc.figure.get_edgecolor( )
# scale to maximum
fc.figure.set_facecolor( "w" )
fc.figure.set_edgecolor( "w" )
# maximum scale with constant aspect
scale = min( freewidth_in / orig_w_in, freeheight_in / orig_h_in )
fc.figure.set_size_inches( orig_w_in * scale, orig_h_in * scale )
width_in_points, height_in_points = orig_w_in * dpi * scale, orig_h_in * dpi * scale
renderer = matplotlib.backends.backend_cairo.RendererCairo( fc.figure.dpi )
renderer.width = width_in_points
renderer.height = height_in_points
# centered picture
renderer.matrix_flipy = cairo.Matrix( yy=-1, xx=1,
y0=page_setup.get_top_margin( gtk.UNIT_POINTS ) + (
height_in_points + freeheight_in * dpi) / 2.0,
x0=page_setup.get_left_margin( gtk.UNIT_POINTS ) + (
freewidth_in * dpi - width_in_points) / 2.0 )
renderer.set_ctx_from_surface( context.get_cairo_context( ).get_target( ) )
# unfortunateley there is need for extra treatment of text
renderer.ctx.translate(
page_setup.get_left_margin( gtk.UNIT_POINTS ) + (freewidth_in * dpi - width_in_points) / 2.0,
page_setup.get_top_margin( gtk.UNIT_POINTS ) - height_in_points / 2.0 + freeheight_in * dpi / 2.0 )
renderer.ctx.save( ) # important! there will be no effect of previous statement without save
fc.figure.draw( renderer )
# restore the figure's settings
fc.figure.set_size_inches( orig_w_in, orig_h_in )
fc.figure.set_facecolor( orig_f_color )
fc.figure.set_edgecolor( orig_e_color )
class ScriptInterface: class ScriptInterface:
""" """
-15
View File
@@ -1389,21 +1389,6 @@ ppm</property>
</child> </child>
<child> <child>
<widget class="GtkHBox" id="hbox23"> <widget class="GtkHBox" id="hbox23">
<property name="visible">True</property>
<child>
<widget class="GtkButton" id="printer_setup_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Printer Setup</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_printer_setup_button_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
-13
View File
@@ -1868,19 +1868,6 @@ Public License instead of this License.
<child> <child>
<object class="GtkHBox" id="hbox23"> <object class="GtkHBox" id="hbox23">
<property name="visible">True</property> <property name="visible">True</property>
<child>
<object class="GtkButton" id="printer_setup_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Printer Setup</property>
<property name="use_underline">True</property>
<signal handler="on_printer_setup_button_clicked" name="clicked"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>