本文整理汇总了Python中gi.repository.Gtk.image_new_from_pixbuf方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.image_new_from_pixbuf方法的具体用法?Python Gtk.image_new_from_pixbuf怎么用?Python Gtk.image_new_from_pixbuf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.image_new_from_pixbuf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: confirm_rewrite_brush
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import image_new_from_pixbuf [as 别名]
def confirm_rewrite_brush(window, brushname, existing_preview_pixbuf, imported_preview_data):
dialog = Gtk.Dialog(_("Overwrite brush?"),
window, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT)
cancel = Gtk.Button(stock=Gtk.STOCK_CANCEL)
cancel.show_all()
img_yes = Gtk.Image()
img_yes.set_from_stock(Gtk.STOCK_YES, Gtk.IconSize.BUTTON)
img_no = Gtk.Image()
img_no.set_from_stock(Gtk.STOCK_NO, Gtk.IconSize.BUTTON)
overwrite_this = Gtk.Button(_("Replace"))
overwrite_this.set_image(img_yes)
overwrite_this.show_all()
skip_this = Gtk.Button(_("Rename"))
skip_this.set_image(img_no)
skip_this.show_all()
overwrite_all = Gtk.Button(_("Replace all"))
overwrite_all.show_all()
skip_all = Gtk.Button(_("Rename all"))
skip_all.show_all()
buttons = [(cancel, CANCEL),
(skip_all, DONT_OVERWRITE_ANYTHING),
(overwrite_all, OVERWRITE_ALL),
(skip_this, DONT_OVERWRITE_THIS),
(overwrite_this, OVERWRITE_THIS)]
for button, code in buttons:
dialog.add_action_widget(button, code)
hbox = Gtk.HBox()
vbox_l = Gtk.VBox()
vbox_r = Gtk.VBox()
try:
preview_r = Gtk.image_new_from_pixbuf(existing_preview_pixbuf)
except AttributeError:
preview_r = Gtk.Image.new_from_pixbuf(existing_preview_pixbuf)
label_l = Gtk.Label(label=_("Imported brush"))
label_r = Gtk.Label(label=_("Existing brush"))
question = Gtk.Label(_("<b>A brush named `%s' already exists.</b>\nDo you want to replace it, or should the new brush be renamed?") % brushname)
question.set_use_markup(True)
preview_l = image_new_from_png_data(imported_preview_data)
vbox_l.pack_start(preview_l, True, True, 0)
vbox_l.pack_start(label_l, False, True, 0)
vbox_r.pack_start(preview_r, True, True, 0)
vbox_r.pack_start(label_r, False, True, 0)
hbox.pack_start(vbox_l, False, True, 0)
hbox.pack_start(question, True, True, 0)
hbox.pack_start(vbox_r, False, True, 0)
hbox.show_all()
dialog.vbox.pack_start(hbox, True, True, 0)
answer = dialog.run()
dialog.destroy()
return answer
示例2: terminalshot
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import image_new_from_pixbuf [as 别名]
def terminalshot(self, _widget, terminal):
"""Handle the taking, prompting and saving of a terminalshot"""
# Grab a pixbuf of the terminal
orig_pixbuf = widget_pixbuf(terminal)
savedialog = Gtk.FileChooserDialog(title="Save image",
action=self.dialog_action,
buttons=self.dialog_buttons)
savedialog.set_do_overwrite_confirmation(True)
savedialog.set_local_only(True)
pixbuf = orig_pixbuf.scale_simple(orig_pixbuf.get_width() / 2,
orig_pixbuf.get_height() / 2,
GdkPixbuf.InterpType.BILINEAR)
image = Gtk.image_new_from_pixbuf(pixbuf)
savedialog.set_preview_widget(image)
savedialog.show_all()
response = savedialog.run()
path = None
if response == Gtk.ResponseType.OK:
path = os.path.join(savedialog.get_current_folder(),
savedialog.get_filename())
orig_pixbuf.save(path, 'png')
savedialog.destroy()
示例3: factory
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import image_new_from_pixbuf [as 别名]
def factory(menu_, parent, context):
menu_item = Gtk.ImageMenuItem.new_with_mnemonic(label)
if pix:
menu_item.set_image(Gtk.image_new_from_pixbuf(pix))
if menu_ is self.menu:
menu_item.connect('activate', self.do_bookmark, (key,pos))
else:
menu_item.connect('activate', self.delete_bookmark, (counter,key,pos))
return menu_item
示例4: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import image_new_from_pixbuf [as 别名]
def __init__(self, qty, base, filename, parent, all_effects, vol_adj, mute_adj):
GObject.GObject.__init__(self)
self.base = base
self.session_filename = filename
hbox = Gtk.HBox()
hbox.set_spacing(1)
self.add(hbox)
vbox = Gtk.VBox()
hbox.pack_start(vbox, True, True, 0)
self.effects = []
self.all_effects = all_effects
count = 0
for row in range(qty):
effect = Effect(base + row, self.all_effects, parent)
self.effects.append(effect)
self.all_effects.append(effect)
vbox.pack_start(effect, True, True, 0)
count += 1
level_vbox = Gtk.VBox()
hbox.pack_start(level_vbox, False, padding=3)
vol_image = Gtk.image_new_from_file(FGlobs.pkgdatadir / "volume2.png")
vol = Gtk.VScale(vol_adj)
vol.set_inverted(True)
vol.set_draw_value(False)
set_tip(vol, _('Effects volume.'))
pb = GdkPixbuf.Pixbuf.new_from_file(FGlobs.pkgdatadir / "headroom.png")
mute_image = Gtk.image_new_from_pixbuf(pb)
mute = Gtk.VScale(mute_adj)
mute.set_inverted(True)
mute.set_draw_value(False)
set_tip(mute, _('Player headroom that is applied when an effect is playing.'))
spc = Gtk.VBox()
for widget, expand in zip((vol_image, vol, spc, mute_image, mute),
(False, True, False, False, True)):
level_vbox.pack_start(widget, expand, padding=2)