def get_selection(self):
"""get_selection
Creates text appropriate to choices
"""
# get selection from listview
self.choice = self.treeview1.get_selection()
self.choice.set_mode(gtk.SELECTION_SINGLE)
self.model, self.row_reference = self.choice.get_selected()
self.choice = self.liststore.get_value(self.row_reference, 0)
# Create command line
command_ref = "self." + self.choice.replace(' ','_') + "_func"
command = eval(command_ref)
# GUI output
# Make clean textbuffer
self.textbuffer = gtk.TextBuffer(None)
# Create headline style
self.headline = self.textbuffer.create_tag('headline',
weight=700, scale=pango.SCALE_LARGE)
# navigate to start of buffer
place = self.textbuffer.get_start_iter()
# Create pixbuf icon reference
icon = eval("self." + self.choice.replace(' ','_') + "_image")
# Insert icon at top of page
self.textbuffer.insert_pixbuf(place, icon)
# Print appropriate text underneath
text = " " + self.choice + ": \n\n" + commands.getoutput(command)
self.textbuffer.insert_at_cursor(text)
iter0 = self.textbuffer.get_iter_at_line(0)
iter1 = self.textbuffer.get_iter_at_line(1)
self.textbuffer.apply_tag(self.headline,iter0,iter1)
self.textview1.set_buffer(self.textbuffer)
return
评论列表
文章目录