Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Changed info function to show dialog instead of returning a view.

This commit is contained in:
Truls Alexander Tangstad 2006-04-21 14:12:18 +00:00
parent c4f9f5c399
commit 07ac564668
1 changed files with 15 additions and 16 deletions

View File

@ -106,31 +106,30 @@ class DatasetInfoFunction(Function):
Function.__init__(self, 'data_info', 'Show information') Function.__init__(self, 'data_info', 'Show information')
def run(self, data): def run(self, data):
if data: if not data:
logger.log('notice', 'Generating view for %s.' % data.get_name())
return [DatasetInfoView(data)]
else:
logger.log('notice', 'Not generating view... no data.')
return [] return []
class DatasetInfoView(plots.Plot):
def __init__(self, data):
plots.Plot.__init__(self, None)
buf = gtk.TextBuffer() buf = gtk.TextBuffer()
buf_iter = buf.get_start_iter() buf_iter = buf.get_start_iter()
buf.insert(buf_iter, "Data: %s\n\n" % data.get_name()) buf.insert(buf_iter, "Data: %s\n\n" % data.get_name())
buf.insert(buf_iter, "Dimensions: ") buf.insert(buf_iter, "Dimensions: ")
dims = [] dims = []
for name in data.get_dim_names(): for name in data.get_dim_names():
dims.append((name, data.dims[data._dim_num[name]])) dims.append((name, data.dims[data._dim_num[name]]))
buf.insert(buf_iter, ", ".join(["%s (%d)" % dim for dim in dims])) dim_text = ", ".join(["%s (%d)" % dim for dim in dims])
area = gtk.TextView(buf) text = """<span weight="bold">Data:</span> %s
area.connect('button_press_event', self.on_button_press)
area.set_editable(False) <span weight="bold">Dimensions:</span> %s""" % (data.get_name(), dim_text)
self.add(area)
area.show() d = gtk.MessageDialog(flags=(gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT),
buttons=gtk.BUTTONS_OK)
d.set_markup(text)
d.set_default_response(gtk.BUTTONS_OK)
d.run()
d.destroy()
return []