我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用gi.repository.GObject.TYPE_INT。
def child_get_property(parent, child, propname): """ Wrapper for child_get_property, which pygobject doesn't properly introspect """ value = GObject.Value() value.init(GObject.TYPE_INT) parent.child_get_property(child, propname, value) return value.get_int()
def __init__(self, parent, app): super().__init__() self.parent = parent self.app = app # pixbuf, name, path, tooltip, size, humansize, # isdir, mtime, human mtime, type, pcs_file self.liststore = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str, str, GObject.TYPE_INT64, str, GObject.TYPE_INT, GObject.TYPE_INT64, str, str, str) self.init_ui()
def __init__(self): Gtk.Window.__init__(self) self.set_title("Dependency Explorer") self.set_default_size(500, 500) self.connect("delete-event", Gtk.main_quit) # Create the data models self.pkg_model = Gtk.ListStore(GObject.TYPE_STRING) self.pkg_model.set_sort_column_id(COL_PKG_NAME, Gtk.SortType.ASCENDING) self.depends_model = Gtk.ListStore(GObject.TYPE_INT, GObject.TYPE_STRING, GObject.TYPE_STRING) self.depends_model.set_sort_column_id(COL_DEP_PACKAGE, Gtk.SortType.ASCENDING) pane = Gtk.HPaned() pane.set_position(250) self.add(pane) # The master list of packages scrolled = Gtk.ScrolledWindow() scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolled.set_shadow_type(Gtk.ShadowType.IN) self.pkg_treeview = Gtk.TreeView(self.pkg_model) self.pkg_treeview.get_selection().connect("changed", self.on_cursor_changed) column = Gtk.TreeViewColumn("Package", Gtk.CellRendererText(), text=COL_PKG_NAME) self.pkg_treeview.append_column(column) pane.add1(scrolled) scrolled.add(self.pkg_treeview) box = Gtk.VBox(homogeneous=True, spacing=4) # Runtime Depends scrolled = Gtk.ScrolledWindow() scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolled.set_shadow_type(Gtk.ShadowType.IN) self.rdep_treeview = PackageDepView(self.depends_model, TYPE_RDEP, "Runtime Depends") self.rdep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE) scrolled.add(self.rdep_treeview) box.add(scrolled) # Build Depends scrolled = Gtk.ScrolledWindow() scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolled.set_shadow_type(Gtk.ShadowType.IN) self.dep_treeview = PackageDepView(self.depends_model, TYPE_DEP, "Build Depends") self.dep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE) scrolled.add(self.dep_treeview) box.add(scrolled) pane.add2(box) # Reverse Depends scrolled = Gtk.ScrolledWindow() scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolled.set_shadow_type(Gtk.ShadowType.IN) self.revdep_treeview = PackageReverseDepView(self.depends_model, "Reverse Depends") self.revdep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PARENT) scrolled.add(self.revdep_treeview) box.add(scrolled) pane.add2(box) self.show_all()