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


Python View.set_page方法代码示例

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


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

示例1: UPDF

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

#.........这里部分代码省略.........
        self.scrolledwindow1 = Gtk.ScrolledWindow()
        self.scrolledwindow1.set_size_request(200, 200)
        self.scrolledwindow1.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self.scrolledwindow1.set_shadow_type(Gtk.ShadowType.ETCHED_OUT)
        self.scrolledwindow1.connect("scroll-event", self.scroll)
        panel1.add(self.scrolledwindow1)
        self.viewport0 = Gtk.Viewport()
        self.miniview = PdfView(width=200, height=HEIGHT)
        self.miniview.connect("selected", self.on_page_selected)
        self.miniview.connect("unselected", self.on_page_unselected)
        self.viewport0.add(self.miniview)
        self.scrolledwindow1.add(self.viewport0)
        #
        self.scrolledwindow2 = Gtk.ScrolledWindow()
        self.scrolledwindow2.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self.scrolledwindow2.set_shadow_type(Gtk.ShadowType.ETCHED_OUT)
        panel1.add(self.scrolledwindow2)
        self.viewport = Gtk.Viewport()
        self.viewport.set_shadow_type(Gtk.ShadowType.ETCHED_OUT)
        self.scrolledwindow2.add(self.viewport)
        self.view = View(self.viewport, self)
        self.viewport.add(self.view)
        #

        #
        self.show_all()
        #
        self.set_focus(self.scrolledwindow2)
        self.text = ""
        self.miniview.reset()
        self.entry1.set_text("")
        self.label1.set_text("")
        self.set_tools_sensistive(sensitive=False)
        self.view.set_page(None, None, None, None, None)

    def set_tools_sensistive(self, sensitive=False, all_elements=False):
        for key in self.menus.keys():
            self.menus[key].set_sensitive(sensitive)
        for key in self.buttons.keys():
            self.buttons[key].set_sensitive(sensitive)
        for key in self.tools.keys():
            self.tools[key].set_sensitive(sensitive)
        self.entry1.set_sensitive(sensitive)
        if all_elements == False:
            self.buttons["open"].set_sensitive(True)
            self.menus["open"].set_sensitive(True)
            self.menus["exit"].set_sensitive(True)

    def get_help_menu(self):
        help_menu = Gtk.Menu()
        #
        add2menu(help_menu, text=_("Web..."), conector_event="activate", conector_action=self.on_menu_project_clicked)
        add2menu(
            help_menu,
            text=_("Get help online..."),
            conector_event="activate",
            conector_action=self.on_menu_help_online_clicked,
        )
        add2menu(
            help_menu,
            text=_("Translate this application..."),
            conector_event="activate",
            conector_action=self.on_menu_translations_clicked,
        )
        add2menu(
            help_menu, text=_("Report a bug..."), conector_event="activate", conector_action=self.on_menu_bugs_clicked
开发者ID:hoffmanc,项目名称:uPdf,代码行数:70,代码来源:updf.py

示例2: MainWindow

# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import set_page [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.set_page方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。