当前位置: 首页>>代码示例>>Python>>正文


Python View.zoom_reset方法代码示例

本文整理汇总了Python中view.View.zoom_reset方法的典型用法代码示例。如果您正苦于以下问题:Python View.zoom_reset方法的具体用法?Python View.zoom_reset怎么用?Python View.zoom_reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在view.View的用法示例。


在下文中一共展示了View.zoom_reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: UPDF

# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import zoom_reset [as 别名]

#.........这里部分代码省略.........
        #
        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"))
        self.menus["remove_pages"].connect("activate", self.on_toolbar_clicked, "remove_pages")
        filetool.append(self.menus["remove_pages"])
        #
        self.menus["extract_pages"] = Gtk.MenuItem.new_with_label(_("Extract pages"))
        self.menus["extract_pages"].connect("activate", self.on_toolbar_clicked, "extract_pages")
        filetool.append(self.menus["extract_pages"])
        #
        self.menubar.append(filet)
开发者ID:hoffmanc,项目名称:uPdf,代码行数:70,代码来源:updf.py

示例2: MainWindow

# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import zoom_reset [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()
开发者ID:mikeandmore,项目名称:pdf-cut,代码行数:100,代码来源:window.py


注:本文中的view.View.zoom_reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。