本文整理汇总了Python中view.View.zoom_in方法的典型用法代码示例。如果您正苦于以下问题:Python View.zoom_in方法的具体用法?Python View.zoom_in怎么用?Python View.zoom_in使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类view.View
的用法示例。
在下文中一共展示了View.zoom_in方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UPDF
# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import zoom_in [as 别名]
#.........这里部分代码省略.........
"""
self.pref = Gtk.ImageMenuItem.new_with_label(_('Preferences'))
self.pref.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_PREFERENCES, Gtk.IconSize.MENU))
#self.pref.connect('activate',self.on_preferences_activate)
self.pref.set_always_show_image(True)
self.fileedit.append(self.pref)
"""
#
self.menubar.append(self.filee)
################################################################
filetool = Gtk.Menu.new()
filet = Gtk.MenuItem.new_with_label(_("Tools"))
filet.set_submenu(filetool)
#
self.menus["first"] = Gtk.MenuItem.new_with_label(_("Go to first"))
self.menus["first"].connect("activate", self.on_toolbar_clicked, "goto_first")
filetool.append(self.menus["first"])
#
self.menus["back"] = Gtk.MenuItem.new_with_label(_("Go to back"))
self.menus["back"].connect("activate", self.on_toolbar_clicked, "goto_back")
filetool.append(self.menus["back"])
#
self.menus["forward"] = Gtk.MenuItem.new_with_label(_("Go to forward"))
self.menus["forward"].connect("activate", self.on_toolbar_clicked, "goto_fordward")
filetool.append(self.menus["forward"])
#
self.menus["last"] = Gtk.MenuItem.new_with_label(_("Go to last"))
self.menus["last"].connect("activate", self.on_toolbar_clicked, "goto_last")
filetool.append(self.menus["last"])
#
filetool.append(Gtk.SeparatorMenuItem())
#
self.menus["zoom_in"] = Gtk.MenuItem.new_with_label(_("Zoom in"))
self.menus["zoom_in"].connect("activate", self.on_toolbar_clicked, "zoom_in")
filetool.append(self.menus["zoom_in"])
#
self.menus["zoom_out"] = Gtk.MenuItem.new_with_label(_("Zoom out"))
self.menus["zoom_out"].connect("activate", self.on_toolbar_clicked, "zoom_out")
filetool.append(self.menus["zoom_out"])
#
self.menus["zoom_reset"] = Gtk.MenuItem.new_with_label(_("Reset zoom"))
self.menus["zoom_reset"].connect("activate", self.on_toolbar_clicked, "zoom_reset")
filetool.append(self.menus["zoom_reset"])
#
self.menus["zoom_fit"] = Gtk.MenuItem.new_with_label(_("Fit zoom"))
self.menus["zoom_fit"].connect("activate", self.on_toolbar_clicked, "zoom_fit")
filetool.append(self.menus["zoom_fit"])
#
filetool.append(Gtk.SeparatorMenuItem())
#
self.menus["rotate_pages"] = Gtk.MenuItem.new_with_label(_("Rotate pages"))
self.menus["rotate_pages"].connect("activate", self.on_toolbar_clicked, "rotate_pages")
filetool.append(self.menus["rotate_pages"])
#
filetool.append(Gtk.SeparatorMenuItem())
#
self.menus["insert_pages"] = Gtk.MenuItem.new_with_label(_("Insert pages"))
self.menus["insert_pages"].connect("activate", self.on_toolbar_clicked, "insert_pages")
filetool.append(self.menus["insert_pages"])
#
self.menus["insert_blank_pages"] = Gtk.MenuItem.new_with_label(_("Insert blank pages"))
self.menus["insert_blank_pages"].connect("activate", self.on_toolbar_clicked, "insert_blank_pages")
filetool.append(self.menus["insert_blank_pages"])
#
self.menus["remove_pages"] = Gtk.MenuItem.new_with_label(_("Remove pages"))
示例2: MainWindow
# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import zoom_in [as 别名]
class MainWindow(object):
UI_XML = './ui.xml'
def __init__(self):
self.view = View()
self.builder = gtk.Builder()
self.builder.add_from_file(self.UI_XML)
self.builder.connect_signals(self)
self.wnd = self.builder.get_object('main')
container = self.builder.get_object('container')
container.add(self.view)
self.wnd.connect('delete-event', gtk.main_quit, None)
def show(self):
self.wnd.show_all()
def quit(self, *args):
gtk.main_quit()
def open(self, *args):
dlg = self.builder.get_object('open_dlg')
dlg.parent = self.wnd
if dlg.run() == 1:
uri = dlg.get_uri()
self.load_document(poppler.Document.new_from_file(uri, None))
dlg.hide()
def load_file(self, filename):
self.load_document(poppler.Document.new_from_file('file://' + filename,
None))
def load_document(self, doc):
if not doc:
return
self.doc = doc
self.current_page = 0
self.builder.get_object('next').set_sensitive(doc.get_n_pages() > 1)
self.builder.get_object('prev').set_sensitive(False)
self.view.set_page(self.doc, 0)
def next(self, action):
self.current_page += 1
self.view.set_page(self.doc, self.current_page)
action.set_sensitive(self.doc.get_n_pages() > (self.current_page + 1))
self.builder.get_object('prev').set_sensitive(self.current_page > 0)
def prev(self, action):
self.current_page -= 1
self.view.set_page(self.doc, self.current_page)
action.set_sensitive(self.current_page > 0)
self.builder.get_object('next').set_sensitive(
self.doc.get_n_pages() > (self.current_page + 1))
def zoom_in(self, *args):
self.view.zoom_in()
def zoom_out(self, *args):
self.view.zoom_out()
def zoom_reset(self, *args):
self.view.zoom_reset()
def toggle_snap_to_grid(self, *args):
self.view.snap_to_grid = not self.view.snap_to_grid
def clip(self, *args):
if hasattr(self.view, 'selection_start') and hasattr(self.view, 'selection_end') and self.view.page:
dlg = self.builder.get_object('clip_save_dlg')
dlg.parent = self.wnd
if dlg.run() == 1:
filename = dlg.get_filename()
if not filename.endswith(".pdf"):
filename = filename + '.pdf'
if os.path.exists(filename):
os.remove(filename)
self.clip_pdf_page(self.view.page, self.view.selection_start,
self.view.selection_end, filename)
dlg.hide()
def clip_pdf_page(self, page, start, end, output):
x = min(end[0], start[0])
y = min(end[1], start[1])
width = abs(end[0] - start[0])
height = abs(end[1] - start[1])
surface = cairo.PDFSurface(output, width, height)
ctx = cairo.Context(surface)
ctx.rectangle(0, 0, width, height)
ctx.clip()
ctx.translate(-x, -y)
page.render(ctx)
surface.flush()
surface.finish()