本文整理汇总了Python中gtk.TreeView方法的典型用法代码示例。如果您正苦于以下问题:Python gtk.TreeView方法的具体用法?Python gtk.TreeView怎么用?Python gtk.TreeView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk
的用法示例。
在下文中一共展示了gtk.TreeView方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TreeView [as 别名]
def __init__(self):
super(ShowLastPackets.PacketList, self).__init__()
self.set_properties(hscrollbar_policy=gtk.POLICY_AUTOMATIC,
vscrollbar_policy=gtk.POLICY_AUTOMATIC)
self.table_model = gtk.ListStore(*([str]*4))
treeview = gtk.TreeView(self.table_model)
treeview.show()
self.add(treeview)
def add_column(descr, colid):
column = gtk.TreeViewColumn(descr, gtk.CellRendererText(), text=colid)
treeview.append_column(column)
add_column("Time", self.COLUMN_TIME)
add_column("Interface", self.COLUMN_INTERFACE)
add_column("Size", self.COLUMN_SIZE)
add_column("Contents", self.COLUMN_CONTENTS)
示例2: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TreeView [as 别名]
def __init__(self):
"""
Initializer
@param self this object
"""
super(ShowLastPackets.PacketList, self).__init__()
self.set_properties(hscrollbar_policy=gtk.POLICY_AUTOMATIC,
vscrollbar_policy=gtk.POLICY_AUTOMATIC)
self.table_model = gtk.ListStore(*([str]*4))
treeview = gtk.TreeView(self.table_model)
treeview.show()
self.add(treeview)
def add_column(descr, colid):
column = gtk.TreeViewColumn(descr, gtk.CellRendererText(), text=colid)
treeview.append_column(column)
add_column("Time", self.COLUMN_TIME)
add_column("Interface", self.COLUMN_INTERFACE)
add_column("Size", self.COLUMN_SIZE)
add_column("Contents", self.COLUMN_CONTENTS)
示例3: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TreeView [as 别名]
def __init__(self, rfunction):
super(FunctionPanel, self).__init__()
self._rfunction = rfunction
formals = self._as_list(rfunction.formals())
formals_value = [x for x in formals.rx(-1)]
formals_name = [x for x in formals.rx(-1).names]
self._table = gtk.ListStore(str, str)
self._treeView = gtk.TreeView(model = self._table)
self._treeView.show()
self._valueColumns = [gtk.TreeViewColumn('parameter'),
gtk.TreeViewColumn('value'),]
self._valueCells = []
for col_i, col in enumerate(self._valueColumns):
self._treeView.append_column(col)
cr = gtk.CellRendererText()
col.pack_start(cr, True)
self._valueCells.append(cr)
col.set_attributes(cr, text=col_i)
for name, value in itertools.izip(formals_name, formals_value):
row = (name, value)
self._table.append(row)
sbox = gtk.HBox(homogeneous=False, spacing=0)
sbox.show()
示例4: viewAction
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TreeView [as 别名]
def viewAction(self, widget, data=None):
# Get the selection in the gtk.TreeView
selection = self._treeView.get_selection()
# Get the selection iter
model, selection_iter = selection.get_selected()
if selection_iter:
packName = self._table.get_value(selection_iter,
self.PACKAGE_I)
vigName = self._table.get_value(selection_iter,
self.ITEM_I)
pdffile = robjects.r.vignette(vigName, package = packName)
pdffile = pdffile.subset("file")[0][0]
pdfviewer = robjects.baseenv["options"]("pdfviewer")[0][0]
pid = os.spawnl(os.P_NOWAIT, pdfviewer, pdffile)
示例5: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TreeView [as 别名]
def __init__(self):
VView.__init__(self)
self.treeview = gtk.TreeView()
self.treeview.connect("row_activated", self.vwActivated)
cols = self.vwGetColumns()
self.vwInitModel(cols, self.__model_class__)
self.add(self.treeview)
self.vwLoad()
示例6: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TreeView [as 别名]
def __init__(self, visualizer, node_index, statistics_collector):
InformationWindow.__init__(self)
self.win = gtk.Dialog(parent=visualizer.window,
flags=gtk.DIALOG_DESTROY_WITH_PARENT|gtk.DIALOG_NO_SEPARATOR,
buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
self.win.connect("response", self._response_cb)
self.win.set_title("Statistics for node %i" % node_index)
self.visualizer = visualizer
self.statistics_collector = statistics_collector
self.node_index = node_index
self.viz_node = visualizer.get_node(node_index)
self.table_model = gtk.ListStore(*([str]*13))
treeview = gtk.TreeView(self.table_model)
treeview.show()
self.win.vbox.add(treeview)
def add_column(descr, colid):
column = gtk.TreeViewColumn(descr, gtk.CellRendererText(), text=colid)
treeview.append_column(column)
add_column("Interface", self.COLUMN_INTERFACE)
add_column("Tx Packets", self.COLUMN_TX_PACKETS)
add_column("Tx Bytes", self.COLUMN_TX_BYTES)
add_column("Tx pkt/1s", self.COLUMN_TX_PACKET_RATE)
add_column("Tx bit/1s", self.COLUMN_TX_BIT_RATE)
add_column("Rx Packets", self.COLUMN_RX_PACKETS)
add_column("Rx Bytes", self.COLUMN_RX_BYTES)
add_column("Rx pkt/1s", self.COLUMN_RX_PACKET_RATE)
add_column("Rx bit/1s", self.COLUMN_RX_BIT_RATE)
self.visualizer.add_information_window(self)
self.win.show()
示例7: build_gui
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TreeView [as 别名]
def build_gui(self):
"""
Build the GUI interface.
"""
vbox = gtk.VBox()
self.top = vbox
button_panel = gtk.Toolbar()
self.button_add = button_panel.insert_stock(gtk.STOCK_ADD, _("Add Mapping"), None, self.add_mapping_clicked, None, -1)
self.button_edit = button_panel.insert_stock(gtk.STOCK_EDIT, _("Edit Mapping"), None, self.edit_mapping_clicked, None, -1)
self.button_del = button_panel.insert_stock(gtk.STOCK_REMOVE, _("Remove Mapping"), None, self.remove_mapping_clicked, None, -1)
vbox.pack_start(button_panel, expand=False, fill=True, padding=5)
self.treestore = gtk.TreeStore(str, str)
self.treeview = gtk.TreeView(self.treestore)
self.treeview.connect("row-activated", self.row_double_clicked)
self.column1 = gtk.TreeViewColumn(_('Surname'))
self.column2 = gtk.TreeViewColumn(_('Group Name'))
self.treeview.append_column(self.column1)
self.treeview.append_column(self.column2)
self.cell1 = gtk.CellRendererText()
self.cell2 = gtk.CellRendererText()
self.column1.pack_start(self.cell1, True)
self.column1.add_attribute(self.cell1, 'text', 0)
self.column2.pack_start(self.cell2, True)
self.column2.add_attribute(self.cell2, 'text', 1)
self.treeview.set_search_column(0)
self.column1.set_sort_column_id(0)
self.column2.set_sort_column_id(1)
vbox.pack_start(self.treeview, expand=True, fill=True)
return vbox
示例8: build_gui
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TreeView [as 别名]
def build_gui(self):
"""
Build the GUI interface.
"""
top = gtk.TreeView()
titles = [(_('Type'), 0, 100),
(_('Name'), 1, 100),
('', 2, 1), #hidden column for the handle
('', 3, 1)] #hidden column for non-localized object type
self.model = ListModel(top, titles, event_func=self.cb_double_click)
return top
示例9: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TreeView [as 别名]
def __init__(self, items=()):
gtk.Dialog.__init__(self)
self.ret = None
self._started = 0
self.connect("destroy", self.quit)
self.connect("delete_event", self.quit)
self.set_geometry_hints(min_width=250, min_height=300)
scrolled_win = gtk.ScrolledWindow()
scrolled_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
scrolled_win.show()
self.vbox.pack_start(scrolled_win)
#self.vbox.show()
button = gtk.Button("Cancel")
button.connect("clicked", self.cancel)
button.set_flags(gtk.CAN_DEFAULT)
self.action_area.pack_start(button)
button.show()
ls = gtk.ListStore(gobject.TYPE_STRING)
for item in items:
iter = ls.append()
ls.set(iter, 0, item)
lister = gtk.TreeView(ls)
selection = lister.get_selection()
selection.set_mode(gtk.SELECTION_BROWSE)
selection.unselect_all()
lister.set_search_column(0)
scrolled_win.add_with_viewport(lister)
column = gtk.TreeViewColumn('Keyword', gtk.CellRendererText(), text=0)
lister.append_column(column)
lister.set_headers_visible(False)
lister.connect("row-activated", self.row_activated)
lister.show()
示例10: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TreeView [as 别名]
def __init__(self, fontfile):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title("%s - pyftinspect" % fontfile)
self.window.connect("delete_event", self._delete_event)
self.window.set_size_request(400, 600)
self.scrolled_window = gtk.ScrolledWindow()
self.window.add(self.scrolled_window)
self.font = ttLib.TTFont(fontfile, lazy=True)
self.treemodel = FontTreeModel(self.font)
self.treeview = gtk.TreeView(self.treemodel)
#self.treeview.set_reorderable(True)
for i in range(2):
col_name = ('Key', 'Value')[i]
col = gtk.TreeViewColumn(col_name)
col.set_sort_column_id(-1)
self.treeview.append_column(col)
cell = gtk.CellRendererText()
col.pack_start(cell, True)
col.add_attribute(cell, 'text', i)
self.treeview.set_search_column(1)
self.scrolled_window.add(self.treeview)
self.window.show_all()
示例11: _init_gui
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TreeView [as 别名]
def _init_gui(self, column_types, rows):
self._rows = gtk.ListStore(*column_types)
for row in rows:
self._rows.append(row)
self._rows_filtered = self._rows.filter_new()
self._tree_view = gtk.TreeView(model=self._rows_filtered)
self._tree_view.set_hover_selection(True)
self._tree_view.set_headers_visible(False)
self._tree_view.set_enable_search(False)
self._tree_view.set_size_request(self._width, self._height)
self._scrolled_window = gtk.ScrolledWindow()
self._scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
self._scrolled_window.set_shadow_type(gtk.SHADOW_ETCHED_IN)
self._scrolled_window.add(self._tree_view)
# HACK: Make sure the height of the tree view can be set properly. Source:
# https://github.com/GNOME/gtk/blob/gtk-2-24/gtk/gtkentrycompletion.c#L472
self._scrolled_window.get_vscrollbar().set_size_request(-1, 0)
# Using `gtk.WINDOW_POPUP` prevents the popup from stealing focus from the
# text entry.
self._popup = gtk.Window(type=gtk.WINDOW_POPUP)
self._popup.set_resizable(False)
self._popup.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_COMBO)
self._popup.add(self._scrolled_window)
self._scrolled_window.show_all()
示例12: loadAction
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import TreeView [as 别名]
def loadAction(self, widget, data=None):
# Get the selection in the gtk.TreeView
selection = self._treeView.get_selection()
# Get the selection iter
model, selection_iter = selection.get_selected()
if selection_iter:
packName = self._table.get_value(selection_iter,
self.PACKAGE_I)
self._console.append('library("%s")\n' %packName)
if sys.platform == 'win32':
tfile = robjects.baseenv["tempfile"]()
tmp = robjects.baseenv["file"](tfile, open="w")
else:
tmp = robjects.baseenv["fifo"]("")
robjects.baseenv["sink"](tmp)
robjects.baseenv["library"](packName)
if sys.platform == 'win32':
robjects.baseenv["close"](tmp)
tmp = robjects.baseenv["file"](tfile, open="r")
out = robjects.baseenv["readLines"](tmp)
for line in out:
self._console.append(str(line)+"\n")
robjects.r.close(tmp)
self._console.append("> ")