How to use the pympress.ui.UI function in pympress

To help you get started, we’ve selected a few pympress examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Cimbali / pympress / pympress / __main__.py View on Github external
'; Poppler', document.Poppler.get_version(), document.Poppler.get_backend().value_nick,
            '; Cairo', ui.cairo.cairo_version_string(), ', pycairo', ui.cairo.version,
            '; Media:', extras.Media.backend_version()
        ]))

    try:
        opts, args = getopt.getopt(argv, "hn:t:", ["help", "notes=", "talk-time=", "log="])
    except getopt.GetoptError:
        usage()
        sys.exit(2)

    ett, log_level, notes_pos = parse_opts(opts)
    logger.setLevel(log_level)

    # Create windows
    gui = ui.UI()

    # pass command line args
    if ett: gui.est_time.set_time(ett)

    gui.swap_document(os.path.abspath(args[0])) if args else gui.pick_file()

    if notes_pos is not None:
        gui.change_notes_pos(notes_pos, force_change = True)

    gui.run()
github Cimbali / pympress / pympress / page_number.py View on Github external
"""
        if not self.editing_cur or event.type != Gdk.EventType.KEY_PRESS:
            return False

        name = Gdk.keyval_name(event.keyval).lower().replace('kp_', '')

        if name == 'return' or name == 'enter':
            try:
                page_nb = int(self.spin_cur.get_buffer().get_text()) - 1
            except:
                page_nb = int(self.spin_cur.get_value()) - 1
            self.doc.goto(page_nb)
            self.restore_current_label()

        elif name == 'escape':
            GLib.idle_add(ui.UI.notify_page_change, False)
            self.restore_current_label()

        elif name == 'home':
            self.spin_cur.set_value(1)
        elif name == 'end':
            self.spin_cur.set_value(self.doc.pages_number())
        elif name == 'left':
            self.spin_cur.set_value(self.spin_cur.get_value() - 1)
        elif name == 'right':
            self.spin_cur.set_value(self.spin_cur.get_value() + 1)
        else:
            return Gtk.SpinButton.do_key_press_event(self.spin_cur, event)

        return True
github Cimbali / pympress / pympress / ui.py View on Github external
def __init__(self):
        super(UI, self).__init__()
        self.blanked = self.config.getboolean('content', 'start_blanked')

        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(),
            util.load_style_provider(Gtk.CssProvider()),
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
        )

        self.show_annotations = self.config.getboolean('presenter', 'show_annotations')

        # Surface cache
        self.cache = surfacecache.SurfaceCache(self.doc, self.config.getint('cache', 'maxpages'))

        # Make and populate windows
        self.load_ui('presenter')
        self.load_ui('content')
github Cimbali / pympress / pympress / page_number.py View on Github external
if name is None:
                name = Gdk.keyval_name(event.keyval)
            if name.upper() != 'G':
                return False

        elif event.type == Gdk.EventType.BUTTON_PRESS:
            # If we clicked on the Event Box then don't toggle, just enable.
            if widget is not self.eb_cur or self.editing_cur:
                return False
        else:
            return False

        # Perform the state toggle

        if not self.editing_cur:
            ui.UI.stop_editing_time()

            # Replace label with entry
            self.hb_cur.remove(self.label_cur)
            self.spin_cur.show()
            self.hb_cur.add(self.spin_cur)
            self.hb_cur.reorder_child(self.spin_cur, 0)
            self.spin_cur.grab_focus()
            self.editing_cur = True

            self.spin_cur.set_value(int(self.label_cur.get_text()))
            self.spin_cur.select_region(0, -1)

        else:
            self.restore_current_label()

        return True