Changed info function to show dialog instead of returning a view.
This commit is contained in:
parent
c4f9f5c399
commit
07ac564668
|
@ -106,31 +106,30 @@ class DatasetInfoFunction(Function):
|
|||
Function.__init__(self, 'data_info', 'Show information')
|
||||
|
||||
def run(self, data):
|
||||
if data:
|
||||
logger.log('notice', 'Generating view for %s.' % data.get_name())
|
||||
return [DatasetInfoView(data)]
|
||||
else:
|
||||
logger.log('notice', 'Not generating view... no data.')
|
||||
if not data:
|
||||
return []
|
||||
|
||||
|
||||
class DatasetInfoView(plots.Plot):
|
||||
def __init__(self, data):
|
||||
plots.Plot.__init__(self, None)
|
||||
|
||||
buf = gtk.TextBuffer()
|
||||
buf_iter = buf.get_start_iter()
|
||||
buf.insert(buf_iter, "Data: %s\n\n" % data.get_name())
|
||||
|
||||
buf.insert(buf_iter, "Dimensions: ")
|
||||
|
||||
dims = []
|
||||
for name in data.get_dim_names():
|
||||
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)
|
||||
area.connect('button_press_event', self.on_button_press)
|
||||
area.set_editable(False)
|
||||
self.add(area)
|
||||
area.show()
|
||||
text = """<span weight="bold">Data:</span> %s
|
||||
|
||||
<span weight="bold">Dimensions:</span> %s""" % (data.get_name(), dim_text)
|
||||
|
||||
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 []
|
||||
|
|
Reference in New Issue