本文整理汇总了Python中smart.interfaces.gtk.getPixbuf函数的典型用法代码示例。如果您正苦于以下问题:Python getPixbuf函数的具体用法?Python getPixbuf怎么用?Python getPixbuf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getPixbuf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
gtk.Alignment.__init__(self)
self.__gobject_init__()
self._expandpackage = False
self._changeset = {}
self._scrollwin = gtk.ScrolledWindow()
self._scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
self._scrollwin.set_shadow_type(gtk.SHADOW_IN)
self._scrollwin.show()
self.add(self._scrollwin)
self._treeview = gtk.TreeView()
self._treeview.set_rules_hint(True)
self._treeview.connect("button_press_event", self._buttonPress)
self._treeview.connect("select_cursor_row", self._selectCursor)
self._treeview.connect("cursor_changed", self._cursorChanged)
self._treeview.show()
self._scrollwin.add(self._treeview)
selection = self._treeview.get_selection()
selection.set_mode(gtk.SELECTION_MULTIPLE)
column = gtk.TreeViewColumn(_("Package"))
renderer = PixbufCellRenderer()
renderer.set_property("activate", self._pixbufClicked)
renderer.set_property("xpad", 3)
renderer.set_property("mode", gtk.CELL_RENDERER_MODE_ACTIVATABLE)
column.pack_start(renderer, False)
column.set_cell_data_func(renderer, self._setPixbuf)
renderer = gtk.CellRendererText()
column.pack_start(renderer, True)
column.set_cell_data_func(renderer, self._setName)
self._treeview.append_column(column)
renderer = gtk.CellRendererText()
self._treeview.insert_column_with_data_func(-1, _("Version"), renderer,
self._setVersion)
self._ipixbuf = getPixbuf("package-installed")
self._ilpixbuf = getPixbuf("package-installed-locked")
self._apixbuf = getPixbuf("package-available")
self._alpixbuf = getPixbuf("package-available-locked")
self._npixbuf = getPixbuf("package-new")
self._nlpixbuf = getPixbuf("package-new-locked")
self._fpixbuf = getPixbuf("folder")
self._Ipixbuf = getPixbuf("package-install")
self._Rpixbuf = getPixbuf("package-remove")
self._rpixbuf = getPixbuf("package-reinstall")
示例2: __init__
def __init__(self, parent=None):
self._window = gtk.Window()
self._window.set_icon(getPixbuf("smart"))
self._window.set_title(_("Mirrors"))
self._window.set_modal(True)
self._window.set_transient_for(parent)
self._window.set_position(gtk.WIN_POS_CENTER)
self._window.set_geometry_hints(min_width=600, min_height=400)
def delete(widget, event):
gtk.main_quit()
return True
self._window.connect("delete-event", delete)
vbox = gtk.VBox()
vbox.set_border_width(10)
vbox.set_spacing(10)
vbox.show()
self._window.add(vbox)
sw = gtk.ScrolledWindow()
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
sw.set_shadow_type(gtk.SHADOW_IN)
sw.show()
vbox.add(sw)
self._treemodel = gtk.TreeStore(gobject.TYPE_STRING)
self._treeview = gtk.TreeView(self._treemodel)
self._treeview.set_rules_hint(True)
self._treeview.set_headers_visible(False)
self._treeview.show()
sw.add(self._treeview)
renderer = gtk.CellRendererText()
renderer.set_property("xpad", 3)
renderer.set_property("editable", True)
renderer.connect("edited", self.rowEdited)
self._treeview.insert_column_with_attributes(-1, _("Mirror"), renderer,
text=0)
bbox = gtk.HButtonBox()
bbox.set_spacing(10)
bbox.set_layout(gtk.BUTTONBOX_END)
bbox.show()
vbox.pack_start(bbox, expand=False)
button = gtk.Button(stock="gtk-new")
button.show()
button.connect("clicked", lambda x: self.newMirror())
bbox.pack_start(button)
button = gtk.Button(stock="gtk-delete")
button.show()
button.connect("clicked", lambda x: self.delMirror())
bbox.pack_start(button)
button = gtk.Button(stock="gtk-close")
button.show()
button.connect("clicked", lambda x: gtk.main_quit())
bbox.pack_start(button)
示例3: about
def about(*args):
license = """
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""
gtk.about_dialog_set_url_hook(lambda dialog, url: url_show(url))
aboutdlg = gtk.AboutDialog()
aboutdlg.set_logo(getPixbuf("smart"))
aboutdlg.set_version(VERSION)
aboutdlg.set_name(NAME)
aboutdlg.set_copyright("2008 Canonical, Inc.")
aboutdlg.set_authors(AUTHORS)
aboutdlg.set_license(license)
aboutdlg.run()
aboutdlg.destroy()
return
示例4: __init__
def __init__(self):
gtk.Window.__init__(self)
self.__gobject_init__()
self.set_icon(getPixbuf("smart"))
self.set_title(_("Change Summary"))
self.set_modal(True)
self.set_position(gtk.WIN_POS_CENTER)
self.set_geometry_hints(min_width=600, min_height=400)
def delete(widget, event):
gtk.main_quit()
return True
self.connect("delete-event", delete)
self._vbox = gtk.VBox()
self._vbox.set_border_width(10)
self._vbox.set_spacing(10)
self._vbox.show()
self.add(self._vbox)
self._label = gtk.Label()
self._vbox.pack_start(self._label, expand=False)
self._pv = GtkPackageView()
self._pv.getTreeView().set_headers_visible(False)
self._pv.setExpandPackage(True)
self._pv.show()
self._vbox.pack_start(self._pv)
self._sizelabel = gtk.Label()
self._vbox.pack_start(self._sizelabel, expand=False)
self._confirmbbox = gtk.HButtonBox()
self._confirmbbox.set_spacing(10)
self._confirmbbox.set_layout(gtk.BUTTONBOX_END)
self._vbox.pack_start(self._confirmbbox, expand=False)
self._cancelbutton = gtk.Button(stock="gtk-cancel")
self._cancelbutton.show()
self._cancelbutton.connect("clicked", lambda x: gtk.main_quit())
self._confirmbbox.pack_start(self._cancelbutton)
self._okbutton = gtk.Button(stock="gtk-ok")
self._okbutton.show()
def clicked(x):
self._result = True
gtk.main_quit()
self._okbutton.connect("clicked", clicked)
self._confirmbbox.pack_start(self._okbutton)
self._closebbox = gtk.HButtonBox()
self._closebbox.set_spacing(10)
self._closebbox.set_layout(gtk.BUTTONBOX_END)
self._vbox.pack_start(self._closebbox, expand=False)
self._closebutton = gtk.Button(stock="gtk-close")
self._closebutton.show()
self._closebutton.connect("clicked", lambda x: gtk.main_quit())
self._closebbox.pack_start(self._closebutton)
示例5: __init__
def __init__(self):
self._window = gtk.Window()
self._window.set_icon(getPixbuf("smart"))
self._window.set_title(_("New Flag"))
self._window.set_modal(True)
self._window.set_position(gtk.WIN_POS_CENTER)
#self._window.set_geometry_hints(min_width=600, min_height=400)
def delete(widget, event):
gtk.main_quit()
return True
self._window.connect("delete-event", delete)
vbox = gtk.VBox()
vbox.set_border_width(10)
vbox.set_spacing(10)
vbox.show()
self._window.add(vbox)
table = gtk.Table()
table.set_row_spacings(10)
table.set_col_spacings(10)
table.show()
vbox.pack_start(table)
label = gtk.Label(_("Name:"))
label.set_alignment(1.0, 0.5)
label.show()
table.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
self._flag = gtk.Entry()
self._flag.set_width_chars(20)
self._flag.show()
table.attach(self._flag, 1, 2, 0, 1, gtk.EXPAND|gtk.FILL, gtk.FILL)
sep = gtk.HSeparator()
sep.show()
vbox.pack_start(sep, expand=False)
bbox = gtk.HButtonBox()
bbox.set_spacing(10)
bbox.set_layout(gtk.BUTTONBOX_END)
bbox.show()
vbox.pack_start(bbox, expand=False)
button = gtk.Button(stock="gtk-ok")
button.show()
def clicked(x):
self._result = True
gtk.main_quit()
button.connect("clicked", clicked)
bbox.pack_start(button)
button = gtk.Button(stock="gtk-cancel")
button.show()
button.connect("clicked", lambda x: gtk.main_quit())
bbox.pack_start(button)
示例6: run
def run(self, command=None, argv=None):
self.setCatchExceptions(True)
self._window.set_icon(getPixbuf("smart"))
self._window.show()
self._ctrl.reloadChannels()
self._changeset = ChangeSet(self._ctrl.getCache())
self._pi.setChangeSet(self._changeset)
self._progress.hide()
self.refreshPackages()
gtk.main()
self.setCatchExceptions(False)
示例7: __init__
def __init__(self):
self._fields = {}
self._fieldn = 0
self._tooltips = gtk.Tooltips()
self._window = gtk.Window()
self._window.set_icon(getPixbuf("smart"))
self._window.set_title(_("Edit Channel"))
self._window.set_modal(True)
self._window.set_position(gtk.WIN_POS_CENTER)
#self._window.set_geometry_hints(min_width=600, min_height=400)
def delete(widget, event):
gtk.main_quit()
return True
self._window.connect("delete-event", delete)
vbox = gtk.VBox()
vbox.set_border_width(10)
vbox.set_spacing(10)
vbox.show()
self._window.add(vbox)
self._table = gtk.Table()
self._table.set_row_spacings(10)
self._table.set_col_spacings(10)
self._table.show()
vbox.pack_start(self._table)
sep = gtk.HSeparator()
sep.show()
vbox.pack_start(sep, expand=False)
bbox = gtk.HButtonBox()
bbox.set_spacing(10)
bbox.set_layout(gtk.BUTTONBOX_END)
bbox.show()
vbox.pack_start(bbox, expand=False)
button = gtk.Button(stock="gtk-cancel")
button.show()
button.connect("clicked", lambda x: gtk.main_quit())
bbox.pack_start(button)
button = gtk.Button(stock="gtk-ok")
button.show()
def clicked(x):
self._result = True
gtk.main_quit()
button.connect("clicked", clicked)
bbox.pack_start(button)
示例8: __init__
def __init__(self):
self._window = gtk.Window()
self._window.set_icon(getPixbuf("smart"))
self._window.set_title(_("Status"))
self._window.set_modal(True)
self._window.set_position(gtk.WIN_POS_CENTER)
self._window.set_border_width(20)
self._label = gtk.Label()
self._label.show()
self._window.add(self._label)
self._lastshown = 0
示例9: __init__
def __init__(self):
gtk.Window.__init__(self)
self.__gobject_init__()
self.set_icon(getPixbuf("smart"))
self.set_title(_("Log"))
self.set_geometry_hints(min_width=400, min_height=300)
self.set_modal(True)
self._vbox = gtk.VBox()
self._vbox.set_border_width(10)
self._vbox.set_spacing(10)
self._vbox.show()
self.add(self._vbox)
self._scrollwin = gtk.ScrolledWindow()
self._scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self._scrollwin.set_shadow_type(gtk.SHADOW_IN)
self._scrollwin.show()
self._vbox.add(self._scrollwin)
self._textview = gtk.TextView()
self._textview.set_editable(False)
self._textview.show()
self._scrollwin.add(self._textview)
self._buttonbox = gtk.HButtonBox()
self._buttonbox.set_spacing(10)
self._buttonbox.set_layout(gtk.BUTTONBOX_END)
self._buttonbox.show()
self._vbox.pack_start(self._buttonbox, expand=False, fill=False)
self._clearbutton = gtk.Button(stock="gtk-clear")
self._clearbutton.show()
self._clearbutton.connect("clicked",
lambda x: self._textview.get_buffer()
.set_text(""))
self._buttonbox.pack_start(self._clearbutton)
self._closebutton = gtk.Button(stock="gtk-close")
self._closebutton.show()
self._closebutton.connect("clicked", lambda x: self.hide())
self._buttonbox.pack_start(self._closebutton)
示例10: __init__
def __init__(self, parent=None):
self._window = gtk.Window()
self._window.set_icon(getPixbuf("smart"))
self._window.set_title(_("Package Priority"))
self._window.set_modal(True)
self._window.set_transient_for(parent)
self._window.set_position(gtk.WIN_POS_CENTER)
# self._window.set_geometry_hints(min_width=600, min_height=400)
def delete(widget, event):
gtk.main_quit()
return True
self._window.connect("delete-event", delete)
vbox = gtk.VBox()
vbox.set_border_width(10)
vbox.set_spacing(10)
vbox.show()
self._window.add(vbox)
self._table = gtk.Table()
self._table.set_row_spacings(10)
self._table.set_col_spacings(10)
self._table.show()
vbox.pack_start(self._table)
bbox = gtk.HButtonBox()
bbox.set_spacing(10)
bbox.set_layout(gtk.BUTTONBOX_END)
bbox.show()
vbox.pack_start(bbox, expand=False)
button = gtk.Button(stock="gtk-close")
button.show()
button.connect("clicked", lambda x: gtk.main_quit())
bbox.pack_start(button)
示例11: __init__
def __init__(self, hassub):
Progress.__init__(self)
gtk.Window.__init__(self)
self.__gobject_init__()
self.connect("delete-event", lambda x,y: True)
self._hassub = hassub
self._shorturl = ShortURL(50)
self._ticking = False
self._stopticking = False
self._fetcher = None
if hassub:
self.set_size_request(500, 400)
else:
self.set_size_request(300, 80)
self.set_icon(getPixbuf("smart"))
self.set_title(_("Operation Progress"))
self.set_modal(True)
self.set_position(gtk.WIN_POS_CENTER)
vbox = gtk.VBox()
vbox.set_border_width(10)
vbox.set_spacing(10)
vbox.show()
gtk.Window.add(self, vbox)
self._topic = gtk.Label()
self._topic.set_alignment(0, 0.5)
self._topic.show()
vbox.pack_start(self._topic, expand=False, fill=False)
self._progress = gtk.ProgressBar()
self._progress.set_size_request(-1, 25)
self._progress.show()
vbox.pack_start(self._progress, expand=False, fill=False)
if hassub:
self._scrollwin = gtk.ScrolledWindow()
self._scrollwin.set_policy(gtk.POLICY_AUTOMATIC,
gtk.POLICY_AUTOMATIC)
self._scrollwin.set_shadow_type(gtk.SHADOW_IN)
self._scrollwin.show()
vbox.pack_start(self._scrollwin)
self._treemodel = gtk.ListStore(gobject.TYPE_INT,
gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_STRING)
self._treeview = gtk.TreeView(self._treemodel)
self._treeview.show()
self._scrollwin.add(self._treeview)
renderer = ProgressCellRenderer()
column = gtk.TreeViewColumn(_("Progress"), renderer, percent=0)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(110)
self._treeview.append_column(column)
renderer = gtk.CellRendererText()
renderer.set_fixed_height_from_font(True)
column = gtk.TreeViewColumn(_("Current"), renderer, text=2)
self._currentcolumn = column
self._treeview.append_column(column)
renderer = gtk.CellRendererText()
renderer.set_fixed_height_from_font(True)
column = gtk.TreeViewColumn(_("Total"), renderer, text=3)
self._totalcolumn = column
self._treeview.append_column(column)
renderer = gtk.CellRendererText()
renderer.set_fixed_height_from_font(True)
column = gtk.TreeViewColumn(_("Speed"), renderer, text=4)
self._speedcolumn = column
self._treeview.append_column(column)
renderer = gtk.CellRendererText()
renderer.set_fixed_height_from_font(True)
column = gtk.TreeViewColumn(_("Description"), renderer, text=1)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
self._treeview.append_column(column)
self._subiters = {}
self._subindex = 0
self._lastpath = None
self._bbox = gtk.HButtonBox()
self._bbox.set_spacing(10)
self._bbox.set_layout(gtk.BUTTONBOX_END)
vbox.pack_start(self._bbox, expand=False)
button = gtk.Button(stock="gtk-cancel")
button.show()
button.connect("clicked", self._cancel)
self._bbox.pack_start(button)
示例12: __init__
def __init__(self, parent=None):
gtk.Window.__init__(self)
self.__gobject_init__()
self.set_icon(getPixbuf("smart"))
self.set_title(_("Smart Preferences"))
self.set_position(gtk.WIN_POS_CENTER)
self.set_geometry_hints(min_width=400, min_height=300)
self._vbox = gtk.VBox()
self._vbox.set_border_width(10)
self._vbox.set_spacing(10)
self._vbox.show()
self.add(self._vbox)
self._notebook = gtk.Notebook()
self._notebook.show()
self._vbox.add(self._notebook)
if gtk.pygtk_version < (2,12,0):
self._tooltips = gtk.Tooltips()
sw = gtk.ScrolledWindow()
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
sw.set_border_width(5)
sw.show()
table = gtk.Table()
table.set_row_spacings(2)
table.set_col_spacings(5)
table.set_border_width(5)
table.show()
sw.add_with_viewport(table)
def set_tooltip(widget, text):
if gtk.pygtk_version < (2,12,0):
self._tooltips.set_tip(widget, text)
else:
widget.set_tooltip_text(text)
self._remove_packages = gtk.CheckButton(_("Remove Packages"))
set_tooltip(self._remove_packages,
_("Remove downloaded packages after installation"))
self._remove_packages.set_active(sysconf.get("remove-packages", True))
self._remove_packages.show()
table.attach(self._remove_packages, 0, 1, 0, 0+1,
gtk.FILL, gtk.FILL)
self._commit_stepped = gtk.CheckButton(_("Commit Stepped"))
set_tooltip(self._commit_stepped,
_("Split operations in steps before committing"))
self._commit_stepped.set_active(sysconf.get("commit-stepped", False))
self._commit_stepped.show()
table.attach(self._commit_stepped, 0, 1, 1, 1+1,
gtk.FILL, gtk.FILL)
label = gtk.Label(_("General"))
self._notebook.append_page(sw, label)
self._buttonbox = gtk.HButtonBox()
self._buttonbox.set_spacing(10)
self._buttonbox.set_layout(gtk.BUTTONBOX_END)
self._buttonbox.show()
self._vbox.pack_start(self._buttonbox, expand=False, fill=False)
self._closebutton = gtk.Button(stock="gtk-close")
self._closebutton.show()
self._closebutton.connect("clicked", lambda x: self.close())
self._buttonbox.pack_start(self._closebutton)
示例13: packagePopup
def packagePopup(self, packageview, pkgs, event):
menu = gtk.Menu()
hasinstalled = bool([pkg for pkg in pkgs if pkg.installed
and self._changeset.get(pkg) is not REMOVE])
hasnoninstalled = bool([pkg for pkg in pkgs if not pkg.installed
and self._changeset.get(pkg) is not INSTALL])
image = gtk.Image()
image.set_from_pixbuf(getPixbuf("package-install"))
item = gtk.ImageMenuItem(_("Install"))
item.set_image(image)
item.connect("activate", lambda x: self.actOnPackages(pkgs, INSTALL))
if not hasnoninstalled:
item.set_sensitive(False)
menu.append(item)
image = gtk.Image()
image.set_from_pixbuf(getPixbuf("package-reinstall"))
item = gtk.ImageMenuItem(_("Reinstall"))
item.set_image(image)
item.connect("activate", lambda x: self.actOnPackages(pkgs, REINSTALL))
if not hasinstalled:
item.set_sensitive(False)
menu.append(item)
image = gtk.Image()
image.set_from_pixbuf(getPixbuf("package-remove"))
item = gtk.ImageMenuItem(_("Remove"))
item.set_image(image)
item.connect("activate", lambda x: self.actOnPackages(pkgs, REMOVE))
if not hasinstalled:
item.set_sensitive(False)
menu.append(item)
image = gtk.Image()
if not hasinstalled:
image.set_from_pixbuf(getPixbuf("package-available"))
else:
image.set_from_pixbuf(getPixbuf("package-installed"))
item = gtk.ImageMenuItem(_("Keep"))
item.set_image(image)
item.connect("activate", lambda x: self.actOnPackages(pkgs, KEEP))
if not [pkg for pkg in pkgs if pkg in self._changeset]:
item.set_sensitive(False)
menu.append(item)
image = gtk.Image()
image.set_from_pixbuf(getPixbuf("package-broken"))
item = gtk.ImageMenuItem(_("Fix problems"))
item.set_image(image)
item.connect("activate", lambda x: self.actOnPackages(pkgs, FIX))
if not hasinstalled:
item.set_sensitive(False)
menu.append(item)
inconsistent = False
thislocked = None
alllocked = None
names = pkgconf.getFlagTargets("lock")
if [pkg for pkg in pkgs if pkg in self._changeset]:
inconsistent = True
else:
for pkg in pkgs:
if (names and pkg.name in names and
("=", pkg.version) in names[pkg.name]):
newthislocked = True
newalllocked = len(names[pkg.name]) > 1
else:
newthislocked = False
newalllocked = pkgconf.testFlag("lock", pkg)
if (thislocked is not None and thislocked != newthislocked or
alllocked is not None and alllocked != newalllocked):
inconsistent = True
break
thislocked = newthislocked
alllocked = newalllocked
image = gtk.Image()
if thislocked:
item = gtk.ImageMenuItem(_("Unlock this version"))
if not hasnoninstalled:
image.set_from_pixbuf(getPixbuf("package-installed"))
else:
image.set_from_pixbuf(getPixbuf("package-available"))
def unlock_this(x):
for pkg in pkgs:
pkgconf.clearFlag("lock", pkg.name, "=", pkg.version)
self._pv.queue_draw()
self._pi.setPackage(pkgs[0])
item.connect("activate", unlock_this)
else:
item = gtk.ImageMenuItem(_("Lock this version"))
if not hasnoninstalled:
image.set_from_pixbuf(getPixbuf("package-installed-locked"))
else:
image.set_from_pixbuf(getPixbuf("package-available-locked"))
def lock_this(x):
#.........这里部分代码省略.........
示例14: __init__
def __init__(self, hassub):
Progress.__init__(self)
gtk.Window.__init__(self)
self.connect("delete-event", lambda x,y: True)
# updates from subthreads not showing up [#592503]
self._threadsafe = not glib or glib.glib_version < (2, 24, 0)
self._hassub = hassub
self._shorturl = ShortURL(50)
self._ticking = False
self._stopticking = False
self._fetcher = None
if hassub:
self.set_size_request(500, 100)
self.set_default_size(500, 400)
else:
self.set_size_request(300, 80)
def configure_event(widget, event):
maxlen = widget.allocation.width / 10
self._shorturl = ShortURL(maxlen)
return False
self.connect("configure-event", configure_event)
self.set_icon(getPixbuf("smart"))
self.set_title(_("Operation Progress"))
self.set_modal(True)
self.set_position(gtk.WIN_POS_CENTER)
vbox = gtk.VBox()
vbox.set_border_width(10)
vbox.set_spacing(10)
vbox.show()
gtk.Window.add(self, vbox)
self._topic = gtk.Label()
self._topic.set_alignment(0, 0.5)
self._topic.show()
vbox.pack_start(self._topic, expand=False, fill=False)
self._progressbar = gtk.ProgressBar()
self._progressbar.set_size_request(-1, 25)
self._progressbar.show()
vbox.pack_start(self._progressbar, expand=False, fill=False)
if hassub:
expander = gtk.Expander()
expander.set_expanded(True)
expander.show()
def toggle_window(expander, param_spec):
if expander.get_expanded():
self.resize(500, 400)
else:
self.resize(500, 100)
expander.connect("notify::expanded", toggle_window)
vbox.pack_start(expander)
self._scrollwin = gtk.ScrolledWindow()
self._scrollwin.set_policy(gtk.POLICY_AUTOMATIC,
gtk.POLICY_AUTOMATIC)
self._scrollwin.set_shadow_type(gtk.SHADOW_IN)
self._scrollwin.show()
expander.add(self._scrollwin)
self._treemodel = gtk.ListStore(gobject.TYPE_INT,
gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_STRING)
self._treeview = gtk.TreeView(self._treemodel)
self._treeview.show()
self._scrollwin.add(self._treeview)
if gtk.pygtk_version < (2,6,0):
renderer = ProgressCellRenderer()
column = gtk.TreeViewColumn(_("Progress"), renderer, percent=0)
else:
renderer = gtk.CellRendererProgress()
# don't display the percent label
renderer.set_property("text", "")
column = gtk.TreeViewColumn(_("Progress"), renderer, value=0)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(110)
self._treeview.append_column(column)
renderer = gtk.CellRendererText()
renderer.set_fixed_height_from_font(True)
column = gtk.TreeViewColumn(_("Current"), renderer, text=2)
self._currentcolumn = column
self._treeview.append_column(column)
renderer = gtk.CellRendererText()
renderer.set_fixed_height_from_font(True)
column = gtk.TreeViewColumn(_("Total"), renderer, text=3)
self._totalcolumn = column
self._treeview.append_column(column)
#.........这里部分代码省略.........
示例15: __init__
def __init__(self):
self._window = gtk.Window()
self._window.set_icon(getPixbuf("smart"))
self._window.set_title(_("New Package Priority"))
self._window.set_modal(True)
self._window.set_position(gtk.WIN_POS_CENTER)
#self._window.set_geometry_hints(min_width=600, min_height=400)
def delete(widget, event):
gtk.main_quit()
return True
self._window.connect("delete-event", delete)
vbox = gtk.VBox()
vbox.set_border_width(10)
vbox.set_spacing(10)
vbox.show()
self._window.add(vbox)
table = gtk.Table()
table.set_row_spacings(10)
table.set_col_spacings(10)
table.show()
vbox.pack_start(table)
label = gtk.Label(_("Package Name:"))
label.set_alignment(1.0, 0.5)
label.show()
table.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
self._name = gtk.Entry()
self._name.show()
table.attach(self._name, 1, 2, 0, 1, gtk.EXPAND|gtk.FILL, gtk.FILL)
label = gtk.Label(_("Channel Alias:"))
label.set_alignment(1.0, 0.0)
label.show()
table.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
self._alias = gtk.Entry()
self._alias.set_text("*")
self._alias.show()
table.attach(self._alias, 1, 2, 1, 2, gtk.EXPAND|gtk.FILL, gtk.FILL)
label = gtk.Label(_("Priority:"))
label.set_alignment(1.0, 0.0)
label.show()
table.attach(label, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
self._priority = gtk.SpinButton()
self._priority.set_width_chars(8)
self._priority.set_increments(1, 10)
self._priority.set_numeric(True)
self._priority.set_range(-100000,+100000)
self._priority.show()
align = gtk.Alignment(0.0, 0.5)
align.show()
align.add(self._priority)
table.attach(align, 1, 2, 2, 3, gtk.EXPAND|gtk.FILL, gtk.FILL)
sep = gtk.HSeparator()
sep.show()
vbox.pack_start(sep, expand=False)
bbox = gtk.HButtonBox()
bbox.set_spacing(10)
bbox.set_layout(gtk.BUTTONBOX_END)
bbox.show()
vbox.pack_start(bbox, expand=False)
button = gtk.Button(stock="gtk-cancel")
button.show()
button.connect("clicked", lambda x: gtk.main_quit())
bbox.pack_start(button)
button = gtk.Button(stock="gtk-ok")
button.show()
def clicked(x):
self._result = True
gtk.main_quit()
button.connect("clicked", clicked)
bbox.pack_start(button)