Scroll to navigation

PYMPRESS(1) pympress PYMPRESS(1)

NAME

pympress - pympress documentation

CONTENTS

What is Pympress?

Pympress is a PDF presentation tool designed for dual-screen setups such as presentations and public talks. Highly configurable, fully-featured, and portable

It comes with many great features (more below):

  • supports embedded gifs (out of the box), videos, and audios (with VLC or Gstreamer integration)
  • text annotations displayed in the presenter window
  • natively supports beamer's notes on second screen, as well as Libreoffice notes pages!

Pympress is a free software, distributed under the terms of the GPL license (version 2 or, at your option, any later version).

Pympress was originally created and maintained by Schnouki <https://github.com/Schnouki>, on his repo <https://github.com/Schnouki/pympress>.

Installing

Ubuntu 20.04 focal or newer, Debian 11 Bullseye or newer (maintained by @mans0954 <https://github.com/mans0954>)

apt-get install pympress libgtk-3-0 libpoppler-glib8 libcairo2 python3-gi python3-gi-cairo gobject-introspection libgirepository-1.0-1 gir1.2-gtk-3.0 gir1.2-poppler-0.18


RPM-based Linux (Fedora, CentOS, Mageia, OpenSuse, RHEL)

You can get pympress from the pympress COPR repo of your system.

With yum or dnf, simply do:

dnf copr enable cimbali/pympress
dnf install python3-pympress


With zypper, fetch the link of the .repo in the table at the bottom of the COPR page and add it as a source.


Arch Linux from AUR (maintained by @Jose1711 <https://github.com/jose1711>)

git clone https://aur.archlinux.org/python-pympress.git
cd python-pympress
makepkg -si


Or using any other tool to manage AUR packages (yay, pacaur, etc.):

yay -S python-pympress


macOS using Homebrew <https://brew.sh/>

brew install pympress


Windows with Chocolatey <https://chocolatey.org/> (maintained by @ComFreek <https://github.com/ComFreek>)

choco install pympress


Or using the Windows Package Manager (winget)

winget install pympress


Or download the latest installer from the latest Github release <https://github.com/Cimbali/pympress/releases/latest>.

If you get an error message along the lines of "MSVCP100.dll is missing", get the Visual C++ 2010 redistributables from Microsoft (x86 (32 bit) <https://www.microsoft.com/en-in/download/details.aspx?id=5555> or x64 (64 bits) <https://www.microsoft.com/en-us/download/details.aspx?id=14632>). Those libraries really should already be installed on your system.

Other systems, directly from PyPI − requires python, gtk+3, poppler, and their python bindings:

python3 -m pip install "pympress"


  • Make sure you have all the dependencies. (These are already included in binary packages or their dependencies.)
  • Using pip, you may want to install with the --user option, or install from github or downloaded sources. See the python documentation on installing <https://docs.python.org/3.7/installing/index.html>.
  • If your python environment lacks the Gobject Introspections module, try
1.
using --system-site-packages for virtual environments <https://docs.python.org/3.7/library/venv.html>,
2.
installing pygobject from pip (pip install pygobject, which requires the correct development/header packages. See the PyPI installation instructions of PyGObject for your system <https://pygobject.readthedocs.io/en/latest/getting_started.html>).



Notes

To support playing embedded videos in the PDFs, your system must have VLC installed (with the same bitness as pympress). VLC is not distributed with pympress, but it is certainly available in your system’s package manager and on their website <https://www.videolan.org/vlc/>.

Usage

Opening a file

Simply start Pympress and it will ask you what file you want to open. You can also start pympress from the command line with a file to open like so: pympress slides.pdf or python3 -m pympress slides.pdf

Functionalities

All functionalities are available from the menus of the window with slide previews. Don't be afraid to experiment with them!

Keyboard shortcuts are also listed in these menus. Some more usual shortcuts are often available, for example Ctrl+L, and F11 also toggle fullscreen, though the main shortcut is just F.

A few of the fancier functionalities are listed here:

Two-screen display: See on your laptop or tablet display the current slide, the next slide, the talk time and wall-clock time, and annotations (either PDF annotations, beamer notes on second slide, or Libreoffice notes pages). The position of the beamer or Libreoffice notes in the slide is detected automatically and can be overridden via a menu option.

If you do not want to use second-slide beamer notes but prefer to have notes on their own pages, you can enable auto-detection of these notes. Use the following snippet that prefixes the page labels with notes: on notes pages:

\addtobeamertemplate{note page}{}{\thispdfpagelabel{notes:\insertframenumber}}


  • Media support: supports playing video, audio, and gif files embedded in (or linked from) the PDF file, with optional start/end times and looping.
  • Highlight mode: Allows one to draw freehand on the slide currently on screen.
  • Go To Slide: To jump to a selected slide without flashing through the whole presentation on the projector, press G or click the "current slide" box. Using J or clicking the slide label will allow you to navigate slide labels instead of page numbers, useful e.g. for multi-page slides from beamer \pause.

    A spin box will appear, and you will be able to navigate through your slides in the presenter window only by scrolling your mouse, with the Home/Up/Down/End keys, with the + and - buttons of the spin box, or simply by typing in the number of the slide. Press Enter to validate going to the new slide or Esc to cancel.

  • Deck Overview: Pressing D will open an overview of your whole slide deck, and any slide can be opened from can simply clicking it.
  • Software pointer: Clicking on the slide (in either window) while holding ctrl down will display a software laser pointer on the slide. Or press L to permanently switch on the laser pointer.
  • Talk time breakdown: The Presentation > Timing Breakdown menu item displays a breakdown of how much time was spent on each slide, with a hierarchical breakdown per chapters/sections/etc. if available in the PDF.
  • Automatic file reloading: If the file is modified, pympress will reload it (and preserve the current slide, current time, etc.)
  • Big button mode: Add big buttons (duh) for touch displays.
  • Swap screens: If Pympress mixed up which screen is the projector and which is not, press S
  • Automatic full screen: pympress will automatically put the content window fullscreen on your non-primay screen when:
  • connecting a second screen,
  • extending your desktop to a second screen that was mirroring your main screen,
  • when starting pympress on a two-screen display. To disable this behaviour, untick “Content fullscreen” under the “Starting configuration” menu.

  • Estimated talk time: Click the Time estimation box and set your planned talk duration. The color will allow you to see at a glance how much time you have left.
  • Adjust screen centering: If your slides' form factor doesn't fit the projectors' and you don't want the slide centered in the window, use the "Screen Center" option in the "Presentation" menu.
  • Resize Current/Next slide: You can drag the bar between both slides on the Presenter window to adjust their relative sizes to your liking.
  • Caching: For efficiency, Pympress caches rendered pages (up to 200 by default). If this is too memory consuming for you, you can change this number in the configuration file.
  • Configurability: Your preferences are saved in a configuration file, and many options are accessible there directly. These include:
  • Customisable key bindings (or shortcuts),
  • Configurable layout of the presenter window, with 1 to 16 next slides preview
  • and many more.

See the configuration file documentation for more details,

  • Editable PDF annotations: Annotations can be added, removed, or changed, and the modified PDF files can be saved
  • Automatic next slide and looping

Command line arguments

  • -h, --help: Shows a list of all command line arguments.
  • -t mm[:ss], --talk-time=mm[:ss]: The estimated (intended) talk time in minutes and optionally seconds.
  • -n position, --notes=position: Set the position of notes on the pdf page (none, left, right, top, or bottom). Overrides the detection from the file.
  • --log=level: Set level of verbosity in log file (DEBUG, INFO, WARNING, ERROR).

Media and autoplay

To enable media playback, you need to have either:

  • Gstreamer installed (enabled by default), with its gtk plugin (libgstgtk) which is sometimes packaged separately (e.g. as gst-plugin-gtk or gstreamer1.0-gtk3), and plugins gstreamer-good/-bad/-ugly based on which codecs you need, or
  • VLC installed (and the python-vlc module), with enabled = on under the [vlc] section of your config file.

On macOS, issues with the gstreamer brew formula may require users to set GST_PLUGIN_SYSTEM_PATH manually. For default homebrew configurations the value should be /opt/homebrew/lib/gstreamer-1.0/. Make sure to set this environmental variable globally, or pympress might not pick it up.

To produce PDFs with media inclusion, the ideal method is to use beamer’s multimedia package, always with \movie:

\documentclass{beamer}
\usepackage{multimedia}
\begin{frame}{Just a mp4 here}

\centering
\movie[width=0.3\textwidth]{\includegraphics[width=0.9\textwidth]{frame1.png}}{movie.mp4}
\movie[width=0.3\textwidth]{}{animation.gif}
\movie[width=0.3\textwidth]{}{ding.ogg} \end{frame}


If you desire autoplay, ensure you have pympress ≥ 1.7.0 and poppler ≥ 21.04, and use the movie15 package as follows:

\documentclass{beamer}
\usepackage{movie15}
\begin{document}
\begin{frame}

\begin{center}
\includemovie[attach=false,autoplay,text={%
\includegraphics{files/mailto.png}%
}]{0.4\linewidth}{0.3\linewidth}{files/random.mpg}
\end{center} \end{frame} \end{document}


Dependencies

Pympress relies on:

  • Cairo <https://www.cairographics.org/> (and python bindings for cairo), the graphics library which is used to pre-render and draw over PDF pages.
  • Gdk, a lower-level graphics library to handle icons.

PyGi, the python bindings for Gtk+3 <https://wiki.gnome.org/Projects/PyGObject>. PyGi is also known as pygobject3, just pygobject or python3-gi.
Introspection bindings for poppler may be shipped separately, ensure you have those as well (typelib-1_0-Poppler-0_18 on OpenSUSE, gir1.2-poppler-0.18 on Ubuntu)


On linux platforms

The dependencies are often installed by default, or easily available through your package or software manager. For example, on ubuntu, you can run the following as root to make sure you have all the prerequisites assuming you use python3:

apt-get install python3 python3-pip libgtk-3-0 libpoppler-glib8 libcairo2 python3-gi python3-cairo python3-gi-cairo gobject-introspection libgirepository-1.0-1 libgirepository1.0-dev gir1.2-gtk-3.0 gir1.2-poppler-0.18


Different distributions might have different package naming conventions, for example the equivalent on OpenSUSE would be:

zypper install python3 python3-pip libgtk-3-0 libpoppler-glib8 libcairo2 python3-gobject python3-gobject-Gdk python3-cairo python3-gobject-cairo typelib-1_0-GdkPixbuf-2_0 typelib-1_0-Gtk-3_0 typelib-1_0-Poppler-0_18


On CentOS/RHEL/Fedora the dependencies would be:

yum install python36 python3-pip gtk3 poppler-glib cairo gdk-pixbuf2 python3-gobject python3-cairo


And on Arch Linux:

pacman -S --needed python python-pip gtk3 poppler cairo gobject-introspection poppler-glib python-gobject gst-plugin-gtk


On macOS

Dependencies can be installed using Homebrew <https://brew.sh/>:

brew install --only-dependencies pympress


On windows

The binary installer for windows comes with pympress and all its dependencies packaged.

Alternately, in order to install from pypi or from source on windows, there are two ways to get the dependencies:

1.
using MSYS2 (replace x86_64 with i686 if you're using a 32 bit machine).

Warning: this can take a substantial amount of disk size as it requires a full software distribution and building platform.

pacman -S --needed mingw-w64-x86_64-gtk3 mingw-w64-x86_64-cairo mingw-w64-x86_64-poppler mingw-w64-x86_64-python3 mingw-w64-x86_64-vlc python3-pip mingw-w64-x86_64-python3-pip mingw-w64-x86_64-python3-gobject mingw-w64-x86_64-python3-cairo


This is also the strategy used to automate builds on appveyor <https://github.com/Cimbali/pympress/tree/master/scripts/build_msi_mingw.sh>.

2.
Using PyGobjectWin32. Be sure to check the supported Python versions (up to 3.4 at the time of writing), they appear in the FEATURES list in the linked page.


Alternately, you can build your Gtk+3 stack from source using MSVC, see the Gnome wiki <https://wiki.gnome.org/Projects/GTK+/Win32/MSVCCompilationOfGTKStack> and this python script that compiles the whole Gtk+3 stack <https://github.com/wingtk/gvsbuild/>. This strategy has not been used successfully yet, due to problems building Poppler with its introspection bidings (i.e. typelib) − see #109 <https://github.com/Cimbali/pympress/issues/109>.

Contributing

Feel free to clone this repo and use it, modify it, redistribute it, etc, under the GPLv2+. A number of contributors <https://github.com/Cimbali/pympress/graphs/contributors> have taken part in the development of pympress and submitted pull requests to improve it.

Be respectful of everyone and keep this community friendly, welcoming, and harrasment-free. Abusive behaviour will not be tolerated, and can be reported by email at me@cimba.li − wrongdoers may be permanently banned.

Pympress has inline sphinx documentation (Google style <http://www.sphinx-doc.org/en/latest/ext/example_google.html>, contains rst syntax), and the docs generated from it are hosted on the github pages of this repo <https://pympress.github.io/>.

Translations

  • Chinese (simplified)
  • Chinese (traditional)
  • Czech
  • Hindi
  • Italian
  • Japanese
  • Polish
  • French
  • German
  • Spanish

We thank the many contributors of translations: Agnieszka, atsuyaw, Cherrywoods, Dongwang, Estel-f, Fabio Pagnotta, Ferdinand Fichtner, Frederik. blome, FriedrichFröbel, GM, He. yifan. xs, Jaroslav Svoboda, Jeertmans, Kristýna, lazycat, Leonvincenterd, LogCreative, Lorenzo. pacchiardi, Luis Sibaja, Marcin Dohnalik, marquitul, Morfit, Mzn, Nico, Ogawa, Paul, Pierre BERTHOU, polaksta, Saulpierotti, Shebangmed, Stanisław Polak, susobaco, Tapia, Tejas, Timo Zhang, Tkoyama010, Toton95, Vojta Netrh, Vulpeculus, and Cimbali.

If you also want to add or contribute to a translation, check pympress’ page on POEditor <https://poeditor.com/join/project/nKfRxeN8pS>. Note that old strings are kept and tagged removed, to give context and keep continuity between translations of succcessive versions. This means removed strings are unused and do not need translating.

Packages

Official releases are made to PyPI <https://pypi.org/> and with github releases <https://github.com/Cimbali/pympress/releases>. The community maintains a number of other packages or recipes to install pympress (see Install section). Any additions welcome.

Configuration file

Pympress has a number of options available from its configuration file.

This file is usually located in:

  • ~/.config/pympress on Linux,
  • %APPDATA%/pympress.ini on Windows,
  • ~/Library/Preferences/pympress on macOS,
  • in the top-level of the pympress install directory for portable installations.

The path to the currently used configuration file can be checked in the Help > About information window.

Shortcuts

The shortcuts are parsed using Gtk.accelerator_parse() <https://lazka.github.io/pgi-docs/#Gtk-3.0/functions.html#Gtk.accelerator_parse>:

The format looks like “<Control>a” or “<Shift><Alt>F1” or “<Release>z” (the last one is for key release).

The parser is fairly liberal and allows lower or upper case, and also abbreviations such as “<Ctl>” and “<Ctrl>”. Key names are parsed using Gdk.keyval_from_name() <https://lazka.github.io/pgi-docs/#Gdk-3.0/functions.html#Gdk.keyval_from_name>. For character keys the name is not the symbol, but the lowercase name, e.g. one would use “<Ctrl>minus” instead of “<Ctrl>-”.



This means that any value in this list of key constants <https://lazka.github.io/pgi-docs/#Gdk-3.0/constants.html#Gdk.KEY_0> is valid (removing the initial Gdk.KEY_ part). You can verify that this value is parsed correctly from the Help > Shortcuts information window.

Layouts

The panes (current slide, next slide, notes, annotations, etc.) can be rearranged arbitrarily by setting the entries of the layout section in the configuration file. Here are a couple examples of layouts, with Cu the current slide, No the notes half of the slide, Nx the next slide:

All-horizontal layout:

+----+----+----+
| Cu | No | Nx |
+----+----+----+


Setting:

notes = {"children": ["current", "notes", "next"], "proportions": [0.33, 0.33, 0.33], "orientation": "horizontal", "resizeable": true}


All-vertical layout:

+----+
| Cu |
+----+
| No |
+----+
| Nx |
+----+


Setting:

notes = {"children": ["current", "notes", "next"], "proportions": [0.33, 0.33, 0.33], "orientation": "vertical", "resizeable": true}


Vertical layout with horizontally divided top pane:

+----+----+
| Cu | No |
+----+----+
|    Nx   |
+---------+


Setting:

notes = {"children": [

{"children": ["current", "notes"], "proportions": [0.5, 0.5], "orientation": "horizontal", "resizeable": true},
"next"
], "proportions": [0.5, 0.5], "orientation": "vertical", "resizeable": true}


Horizontal layout with horizontally divided right pane:

+----+----+
|    | Nx |
+ Cu +----+
|    | No |
+---------+


Setting:

notes = {"children": [

"current",
{"children": ["next", "notes"], "proportions": [0.5, 0.5], "orientation": "vertical", "resizeable": true}
], "proportions": [0.5, 0.5], "orientation": "horizontal", "resizeable": true}



And so on. You can play with the items, their nesting, their order, and the orientation in which a set of widgets appears.

For each entry the widgets (strings that are leaves of "children" nodes in this representation) must be:

  • for notes: "current", "notes", "next"
  • for plain: "current", "next" and "annotations" (the annotations widget is toggled with the A key by default)
  • for highlight: same as plain with "highlight" instead of "current"

A few further remarks:

  • If you set "resizeable" to false, the panes won’t be resizeable dynamically with a handle in the middle
  • "proportions" are normalized, and saved on exit if you resize panes during the execution. If you set them to 4 and 1, the panes will be 4 / (4 + 1) = 20% and 1 / (4 + 1) = 100%, so the ini will contain something like 0.2 and 0.8 after executing pympress.

Themes on Windows

Pympress uses the default Gtk theme of your system, which makes it easy to change on many OSs either globally via your Gtk preferences or per application <https://www.linuxuprising.com/2019/10/how-to-use-different-gtk-3-theme-for.html>. Here’s the way to do it on windows:

1.
Install a theme

There are 2 locations, either install the theme for all your gtk apps, e.g. in C:\Users\%USERNAME%\AppData\Local\themes, or just for pympress, so in %INSTALLDIR%\share\themes (for me that’s C:\Users\%USERNAME%\AppData\Local\Programs\pympress\share\themes)

Basically pick a theme e.g. from this list of dark themes <https://www.gnome-look.org/browse/cat/135/ord/rating/?tag=dark> and make sure to unpack it in the selected directory, it needs at least %THEMENAME%\gtk-3.0\gtk.css and %THEMENAME%\index.theme, where THEMENAME is the name of the theme.

There are 2 pitfalls to be aware of, to properly install a theme:

  • themes that are not self-contained (relying on re-using css from default linux themes that you might not have), and
  • linux links (files under gtk-3.0/ that point to a directory above and that need to be replaced by a directory containing the contents of the target directory that has the same name as the link file).

2.
Set the theme as default

Create a settings.ini file, either under C:\Users\%USERNAME%\AppData\Local\gtk-3.0 (global setting) or %INSTALLDIR%\etc\gtk-3.0 (just pympress) and set the contents:

[Settings]
gtk-theme-name=THEMENAME



In testing this found these 2 stackoverflow questions useful:


Pympress package

This page contains the inline documentation, generated from the code using sphinx.

The code is documented in the source using the Google style <https://google.github.io/styleguide/pyguide.html> for docstrings. Sphinx has gathered a set of examples <http://www.sphinx-doc.org/en/latest/ext/example_google.html> which serves as a better crash course than the full style reference.

Retructured text (rst) can be used inside the comments and docstrings.

Modules

pympress.__main__ -- The entry point of pympress

Entry point of pympress. Parse command line arguments, instantiate the UI, and start the main loop.

Exception handler, to log uncaught exceptions to our log file.

pympress.app -- The Gtk.Application managing the lifetime and CLI

Bases: Application

Class representing the single pympress Gtk application.

list of actions to be passsed to the GUI that were queued before GUI was created

Parse an action name and activate it, with parameter wrapped in a Variant if it is not None.
  • name (str) -- the name of the stateful action
  • parameter -- an object or None to pass as a parameter to the action, wrapped in a GLib.Variant



bool to automatically upgrade log level (DEBUG / INFO at init, then ERROR), False if user set log level

The Config object that holds pympress conferences

Activate: show UI windows.

Build them if they do not exist, otherwise bring to front.


Parse command line options, returned as a VariantDict
estimated talk time, log level, notes positions.
tuple


Handle opening files. In practice we only open once, the last one.
  • files (list of File) -- representing an array of files to open
  • n_files (int) -- the number of files passed.
  • hint (str) -- a hint, such as view, edit, etc. Should always be the empty string.



Perform various cleanups and save preferences.

Common start-up tasks for primary and remote instances.

NB. super(self) causes segfaults, Gtk.Application needs to be used as base.


Parse an action name and return its unwrapped state from the Variant.
name (str) -- the name of the stateful action
the value contained in the action
str, int, bool or float


The UI object that is the interface of pympress



Quit and ignore other arguments e.g. sent by signals.

Parse an action name and set its enabled state to True or False.
  • name (str) -- the name of the stateful action
  • value (bool) -- wheether the action should be enabled or disabled



Parse an action name and set its state wrapped in a Variant.
  • name (str) -- the name of the stateful action
  • value (str, int, bool or float) -- the value to set.



Action that sets the logging level (on the root logger of the active instance)
  • action (Action) -- The action activatd
  • ( (param) -- class:~`GLib.Variant`): The desired level as an int wrapped in a GLib.Variant





pympress.ui -- GUI management

This module contains the whole graphical user interface of pympress, which is made of two separate windows: the Content window, which displays only the current page in full size, and the Presenter window, which displays both the current and the next page, as well as a time counter and a clock.

Both windows are managed by the UI class.

Bases: Builder

Pympress GUI management.

A AccelGroup to store the shortcuts

Scale baseline font size of bottom bar, clipped to 6px..13px. Fonts are then scaled by CSS em indications.

Select how to align the frame on screen.

Class Annotations managing the display of annotations

The Pympress instance

autoplay = None
AutoPlay popup to configure automatic playing

track whether we blank the screen

DrawingArea for the Content window.

AspectFrame for the Content window.

Content window, as a Window instance.

SurfaceCache instance.

Handle the action cancelling the input, if applicable.
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



Switch the position of the nodes in the slide.
the action triggering the call target (Variant): the notes position as a string variant force (bool): Whether to force the notes switch even if it’s already enabled
gaction (Action)
whether the notes position has been toggled
bool


Current choice of mode to toggle notes

Save configuration and exit the main loop.

Callback to clear the cache of zoomed widgets.

Check whether a link was clicked and follow it.

Handles a click on a slide.

  • widget (Widget) -- the widget in which the event occurred
  • event (Event) -- the event that occurred

whether the event was consumed
bool


Remove the current document.

Destroy the shortcuts window once it is hidden.

Determine the arragement of frames in a grid to maximise their size given respective aspect ratios
  • grid_ar (float) -- aspect ratio of grid containing the slides
  • n_frames (int) -- the number of frames



Config to remember preferences

number of page currently displayed in Content window's miniatures

Class Overview displaying a view of all slides

Switch to another page and display it.

This is a kind of event which is supposed to be called only from the Document class.

  • is_preview (bool) -- True if the page change should not update the content
  • unpause (bool) -- True if the page change should unpause the timer, False otherwise
  • autoplay (bool) -- True if the page change is triggered automatically, otherwise cancel auto play




Handle going to the end of the document
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



Handle going to the start of the document
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



Handle going to the previous page.
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



Handle going to the next page.
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



Handle going to the next page in the history of visited pages
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



Handle going to the previous page in the history of visited pages
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



Handle going to the next page with a different label.
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



Handle going to the previous page with a different label.
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



Remove the current document.
uri (str) -- the URI of the document


EstimatedTalkTime to set estimated/remaining talk time

A FileWatcher object to reload modified files

Simple getter.
Truthy when we split slides in content + notes
PdfPage


Handle going to the page passed as argument
  • page (int) -- the page to which to go. Will be clipped to document pages.
  • autoplay (bool) -- whether this page change was triggered automatically



Grid for the next slide(s) in the Presenter window.

ToolButton big button for touch screens, go to scribble on screen

Manage events related to hyperlinks, setting the cursor to a pointer if the hovered region is clickable.
  • widget (Widget) -- the widget in which the event occurred
  • event (Event) -- the event that occurred

whether the event was consumed
bool


int or None, may keep track of the Gtk.Application inhibit request

Software-implemented laser pointer, Pointer

ToolButton big button for touch screens, go toggle the pointer

LayoutEditor popup to configure the layouts of the presenter window

Return the layout made for the selected notes_mode
notes_mode (PdfPage) -- the mode/positioning of notes
a string representing the appropriate layout
str


Set the icon list for both windows.

Replace the current layout
new (str) -- the name of the layout to load, None to use current layout automatically


Initializes the content window.

Initializes the presenter window.

Class Media managing keeping track of and callbacks on media overlays

Display the "About pympress" dialog.

Handles clicks on the "about" menu.


Move window from monitor number from_monitor to monitor to_monitor.

ToolButton big button for touch screens, go to next slide

int the number of next slides currently on display in the “Next slides” pane, initialized to the maximal number

Whether to use notes mode or not

Manage "configure" events for all drawing areas, e.g. resizes.

We tell the local SurfaceCache cache about it, so that it can invalidate its internal cache for the specified widget and pre-render next pages at a correct size.

Warning: Some not-explicitly sent signals contain wrong values! Just don't resize in that case, since these always seem to happen after a correct signal that was sent explicitly.

  • widget (Widget) -- the widget which has been resized
  • event (Event) -- the GTK event, which contains the new dimensions of the widget



Manage "configure" events for both window widgets.
  • widget (Widget) -- the window which has been moved or resized
  • event (Event) -- the GTK event, which contains the new dimensions of the widget



Receive the drag-drops (as text only). If a file is dropped, open it.
  • widget (Widget) -- The widget on which the dragged item was dropped
  • drag_context (DragContext) -- Context object of the dragging
  • x (float) -- position of the drop
  • y (float) -- position of the drop
  • data (SelectionData) -- container for the dropped data
  • info (int) -- info on the target
  • time (int) -- time of the drop



Manage draw events for both windows.

This callback may be called either directly on a page change or as an event handler by GTK. In both cases, it determines which widget needs to be updated, and updates it, using the SurfaceCache if possible.

  • widget (Widget) -- the widget to update
  • cairo_context (Context) -- the Cairo context (or None if called directly)



Handle key strokes at top level, only for when editing needs to bypass action accelerators
  • widget (Widget) -- the widget which has received the key stroke
  • event (Event) -- the GTK event, which contains the key stroke details



Signal handler for current page editing.
  • widget (Widget) -- the editable widget which has received the event.
  • event (Event) -- the GTK event.



Signal handler for gtk.paned events.

This function allows one to delay drawing events when resizing, and to speed up redrawing when moving the middle pane is done (which happens at the end of a mouse resize)

  • widget (Widget) -- the widget in which the event occurred (ignored)
  • evt (Event) -- the event that occurred



Manage scroll events.
  • widget (Widget) -- the widget in which the event occurred (ignored)
  • event (Event) -- the event that occurred

whether the event was consumed
bool


Open a document.
  • gaction (Action) -- the action triggering the call
  • target (Variant) -- the file to open as a string variant



Box for the Presenter window.

DrawingArea for the current slide copy in the Presenter window.

DrawingArea for the current slide in the Presenter window.

DrawingArea for the next slide in the Presenter window.

Frame for the annotations in the Presenter window.

list of AspectFrame for the current slide copy in the Presenter window.

AspectFrame for the current slide in the Presenter window.

list of AspectFrame for the next slide in the Presenter window.

Presenter window, as a Window instance.

PageNumber displaying and setting current page numbers

Map of Paned to the relative position (float between 0 and 1) of its handle

Ask the user which file he means to open.

Dictionary of Widget from the presenter window that can be dynamically rearranged

Callback for the recent document menu.

Gets the URI and requests the document swap.

  • gaction (Action) -- the action triggering the call
  • is_opening (Variant) -- a wrapped boolean indicating whether the menu is opening or closing.



ToolButton big button for touch screens, go to previous slide

number of page currently displayed in Presenter window's miniatures

A Menu to display the recent files to open

Callback to set the number of next frames to preview the the “next slides” panel
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the number of slides as a GVariant



Callback to queue a redraw of the current slides (in both winows).

Handler for Paned's resizing signal.

Used for delayed drawing events of drawing areas inside the panes.

This is very useful on windows where resizing gets sluggish if we try to redraw while resizing.


Tracks return values of GLib.timeout_add to cancel gtk.paned's redraw callbacks

Set the number of next frames to preview the the “next slides” panel
n_frames (int) -- the number of frames


Reload the current document.

Indicates whether we should delay redraws on some drawing areas to fluidify resizing gtk.paned

Remove the current document.

Remove the current document.

Handle ::monitors-changed events
screen (Screen) -- the screen


Class Scribble managing drawing by the user on top of the current slide.

Disable or re-enable the screensaver.
disabled (bool) -- True iff the screensaver should be disabled, otherwise enabled.


If multiple monitors, fullscreen windows on monitors according to config.
  • screen (Screen) -- the screen
  • event_name (str) -- a description of what caused the screen setup event, for debugging



A ShortcutsWindow to show the shortcuts

Whether to display annotations or not

Whether to display big buttons or not

Display the shortcuts window.

Replace the currently open document with a new one.

The new document is possibly and EmptyDocument if doc_uri is None. The state of the ui and cache are updated accordingly.

  • doc_uri (str) -- the URI to the new document
  • page (int) -- the page at which to start the presentation
  • reloading (bool) -- whether we are reloading or detecting stuff from the document



Swap the monitors on which each window is displayed (if there are 2 monitors at least).

Switch the display to show annotations or to hide them.
the action triggering the call target (Variant): the parameter as a variant, or None
gaction (Action)
whether the mode has been toggled.
bool


Toggle the display of big buttons (nice for touch screens).

Switch the blanked mode of the content screen.
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None

whether the notes blanking has been toggled.
bool


Switch the Content window to fullscreen (if in normal mode) or to normal mode (if fullscreen).

Screensaver will be disabled when entering fullscreen mode, and enabled when leaving fullscreen mode.

widget (Widget) -- the widget in which the event occurred
whether some window's full screen status got toggled
bool


Switch the display mode to "Notes mode" or "Normal mode" (without notes).
the action triggering the call target_mode (PdfPage): the mode to which we should switch force (bool): Whether to force the mode switch even if it’s already enabled
gaction (Action)
whether the notes mode has been toggled
bool


TimeCounter clock tracking talk time (elapsed, and remaining)

TimingReport popup to show how much time was spent on which part

Track mouse press and release events.

Handles clicks on the slides.

  • widget (Widget) -- the widget that received the click
  • event (Event) -- the GTK event containing the click position

whether the event was consumed
bool


Track mouse motion events.

Handles mouse motions on the "about" menu.

  • widget (Widget) -- the widget that received the mouse motion
  • event (Event) -- the GTK event containing the mouse position

whether the event was consumed
bool


Prompt the user about what to do with changes in the document: save, discard, or cancel action
reload (bool) -- The unsaved changes is prompted by reloading the file
True iff we need to cancel the current action
bool


Callback to preview the frame alignment, called from the Gtk.SpinButton.
  • widget (SpinButton) -- The button updating the slide alignment in the drawing area widget
  • user_data (str) -- The property being set, either the x or y alignment (resp. xalign and yalign).



Handle the action validating the input, if applicable.
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



Class Zoom managing the zoom level of the current slide.


pympress.document -- document handling

This module contains several classes that are used for managing documents (only PDF documents are supported at the moment, but other formats may be added in the future).

An important point is that this module is completely independent from the GUI: there should not be any GUI-related code here, except for page rendering (and only rendering itself: the preparation of the target surface must be done elsewhere).

Bases: object

This is the main document handling class.

The page numbering starts as 0 and is aware of notes (i.e. number of pages may change to account for note pages). The document page numbers are the same as in Poppler, and also start at 0 but do not depend on notes.

  • builder (pympress.builder.Builder) -- A builder to load callbacks
  • pop_doc (Document) -- Instance of the Poppler document that this class will wrap
  • uri (str) -- URI of the PDF file to open
  • page (int) -- page number to which the file should be opened


bool indicating whether there were modifications to the document

Removes all files that were extracted from the pdf into the filesystem.

Initializes a Document by passing it a Document.
  • builder (pympress.builder.Builder) -- A builder to load callbacks
  • uri (str) -- URI to the PDF file to open
  • page (int) -- page number to which the file should be opened

The initialized document
Document


Current PDF document (Document instance)

list of all the page labels, indexed on document page numbers

Returns full path, extrapolated from a path relative to this document or to the current directory.
filename (Path or str) -- Name of the file or relative path to it
the full path to the file or None if it doesn't exist
Path


Return the last page number for each consecutively distinct page label

In other words, squash together consecutive same labels


Gets the structure of the document from its index.

Recursive, pass the iterator.

index_iter (IndexIter or None) -- the iterator for the child index to explore.
A list of tuples (depth, page number, title)
list


Gives access to the URI, rather than the path, of this document.
the URI to the file currently opened.
str


Switch to another page. Validates the number and returns one in the correct range. Also updates history.
number (int) -- number of the destination page


Get our best guess for the document mode.
  • horizontal (str) -- A string representing the preference for horizontal slides
  • vertical (str) -- A string representing the preference for vertical slides

the notes mode
PdfPage


Return whether that some changes were made (e.g. annotations edited)

Return whether this document has useful labels.
False iff there are no labels or they are just the page numbers
bool


Switch to the page we viewed next.

Our position in the history

Switch to the page we viewed before.

History of pages we have visited, using note-aware page numbers

Switch to the next page with different label.

If we're within a set of pages with the same label we want to go to the last one.


Switch to the previous page with different label.

If we're within a set of pages with the same label we want to go before the first one.


Find a page from its label.
  • label (str) -- the label we are searching for
  • prefix_unique (bool) -- whether a prefix match should be unique, e.g. when the user is still typing

the page
int


Notify the document that some changes were made (e.g. annotations edited)

callback, to be connected to goto_page()

Number of pages in the document

list of (slide's document page number, notes' document page number) tuples, or None if there are no notes

Get the specified page.
number (int) -- number of the page to return
the wanted page, or None if it does not exist
Page


Get the specified page.
number (int) -- number of the page to return
the wanted page, or None if it does not exist
Page


list of slide page labels, indexed on note-aware page numbers

Pages cache (dict of Page). This makes navigation in the document faster by avoiding calls to Poppler when loading a page that has already been loaded.

Get the number of pages in the document.
the number of pages in the document
int


URI
Path to pdf if uri is a file


callback, to be connected to play()

Remember a temporary file to delete later.
filename (Path) -- The path to the file to delete


Save the changes
dest_uri (str or None) -- The URI where to save the file, or None to save in-place


Set whether where the notes pages are relative to normal pages

Valid values are returned by direction() - page number (aka Libreoffice notes mode) - page parity (can not be detected automatically, where every other page contains notes) - page mapping (where labels of notes pages are corresponding slide labels prefixed with “notes:”)

notes_direction (str) -- Where the notes pages are


callback, to be connected to start_editing()

set of Path representing the temporary files which need to be removed

str full path to pdf


Bases: Document

A dummy document, placeholder for when no document is open.

Retrieve a page from the document.
number (int) -- page number to be retrieved
-1 returns the empty page so we can display something.
EmptyPage or None


Retrieve a page from the document.
number (int) -- page number to be retrieved
-1 returns the empty page so we can display something.
EmptyPage or None



Bases: Page

A dummy page, placeholder for when there are no valid pages around.

This page is a non-notes page with an aspect ratio of 1.3 and nothing else inside. Also, it has no "rendering" capability, and is made harmless by overriding its render function.

Informs that rendering is not necessary (avoids checking the type).
False, no rendering
bool


Overriding this purely for safety: make sure we do not accidentally try to render.
  • cr (CairoContext) -- target surface
  • ww (int) -- target width in pixels
  • wh (int) -- target height in pixels
  • dtype (PdfPage) -- the type of document that should be rendered




Bases: object

This class encapsulates one hyperlink of the document.

  • x1 (float) -- first x coordinate of the link rectangle
  • y1 (float) -- first y coordinate of the link rectangle
  • x2 (float) -- second x coordinate of the link rectangle
  • y2 (float) -- second y coordinate of the link rectangle
  • action (function) -- action to perform when the link is clicked


Return a lambda that calls fun(*args, **kwargs), with the current value of args and kwargs.

By creating the lambda in a new scope, we bind the arguments.

  • fun (function) -- The function to be called
  • args (tuple) -- non-keyworded variable-length argument list to pass to fun()
  • kwargs (dict) -- keyworded variable-length argument dict to pass to fun()



function, action to be perform to follow this link

Tell if the input coordinates are on the link rectangle.
  • x (float) -- input x coordinate
  • y (float) -- input y coordinate

True if the input coordinates are within the link rectangle, False otherwise
bool


float, first x coordinate of the link rectangle

float, second x coordinate of the link rectangle

float, first y coordinate of the link rectangle

float, second y coordinate of the link rectangle


Bases: tuple

A class that holds all the properties for media files

Alias for field number 2

Alias for field number 8

Alias for field number 1

Alias for field number 4

Alias for field number 0

Alias for field number 3

Alias for field number 5

Alias for field number 7

Alias for field number 6


Bases: object

Class representing a single page.

It provides several methods used by the GUI for preparing windows for displaying pages, managing hyperlinks, etc.

  • doc (Page) -- the poppler object around the page
  • number (int) -- number of the page to fetch in the document
  • parent (Document) -- the parent Document class


All text annotations

Informs that rendering is necessary (avoids checking the type).
True, do rendering
bool


Get the function to be called when the link is followed.
  • link_type (ActionType) -- The link type
  • action (Action) -- The action to be performed when the link is clicked
  • rect (Rectangle) -- The region of the page where the link is

The function to be called to follow the link
function


Get the list of text annotations on this page.
annotations on this page
list of str


Get the page aspect ratio.
dtype (PdfPage) -- the type of document to consider
page aspect ratio
float


Get the function to be called when the link is followed.
  • link_type (ActionType) -- The type of action to be performed
  • action (Action) -- The atcion to be performed

The function to be called to follow the link
function


Get the Link corresponding to the given position.

Returns None if there is no link at this position.

  • x (float) -- horizontal coordinate
  • y (float) -- vertical coordinate
  • dtype (PdfPage) -- the type of document to consider

the link at the given coordinates if one exists, None otherwise
Link


Get the list of medias this page might want to play.
medias in this page
list


Get the page size.
dtype (PdfPage) -- the type of document to consider
page size
(float, float)


Get the page label.

All the links in the page, as a list of Link instances

All the media in the page, as a list of Media

Add an annotation to this page
  • pos (int) -- The position in the list of annotations in which to insert this annotation
  • rect (Rectangle) -- A rectangle for the position of this annotation
  • value (str) -- The contents of the annotation



Get the page number.

Page handled by this class (instance of Page)

str representing the page label

int, number of the current page (starting from 0)

Instance of Document that contains this page.

float, page height

float, page width

Remove an annotation from this page
pos (int) -- The number of the annotation


Render the page on a Cairo surface.
  • cr (CairoContext) -- target surface
  • ww (int) -- target width in pixels
  • wh (int) -- target height in pixels
  • dtype (PdfPage) -- the type of document that should be rendered



Update an annotation on this page
  • pos (int) -- The number of the annotation
  • value (str) -- The new contents of the annotation




Bases: IntEnum

Represents the part of a PDF page that we want to draw.

Full page + draw another page for notes, which is after the slides

for a notes page, the slide page is BEFORE by half a document
Complementary of AFTER


Bottom half of PDF page

Complementary of ODD

Full PDF page (without notes)

Left half of PDF page

An arbitrary mapping of notes pages to slide pages

No notes on PDF page, only falsy value

Slides on even pages (0-indexed), notes on uneven pages

Right half of PDF page

Reverse the arbitrary mapping MAP

Top half of PDF page

Return the enum value for the other part of the page.

Returns whether the pdf page/notes mode is horizontal or vertical.
a string representing the direction that can be used as the key in the config section
str


Transform visible part of the page coordinates to full page coordinates.

Pass 2 floats to transform coordinates, 4 to transform margins, i.e. the second pair of coordinates is taken from the opposite corner.

  • x (float) -- x coordinate on the screen, on a scale 0..1
  • y (float) -- y coordinate on the screen, on a scale 0..1
  • x2 (float) -- second x coordinate on the screen, from the other side, on a scale 0..1
  • y2 (float) -- second y coordinate on the screen, from the other side, on a scale 0..1



Return the enum value that does only scaling not shifting.

Transform full page coordinates to visible part coordinates.

Pass 2 floats to transform coordinates, 4 to transform margins, i.e. the second pair of coordinates is taken from the opposite corner.

  • x (float) -- x coordinate on the page, on a scale 0..1
  • y (float) -- y coordinate on the page, on a scale 0..1
  • x2 (float) -- second x coordinate on the page, from the other side, on a scale 0..1
  • y2 (float) -- second y coordinate on the page, from the other side, on a scale 0..1




Returns a valid filename extension (recognized by python) for a given mime type.
mime_type (str) -- The mime type for which to find an extension
A file extension used for the given mimetype
str


pympress.ui_builder -- abstract GUI management

This module contains the tools to load the graphical user interface of pympress, building the widgets/objects from XML (glade) files, applying translation "manually" to avoid dealing with all the mess of C/GNU gettext's bad portability.

Bases: Builder

GUI builder, inherits from Builder to read XML descriptions of GUIs and load them.

Signal connector connecting to properties of base_target, or properties of its properties, etc.
  • base_target (Builder) -- The target object, that has functions to be connected to
  • builder. (signals loaded in this) --



Returns the handler from its name, searching in target.

Parse handler names and split on '.' to use recursion.

  • target (object) -- An object that has a method called handler_name
  • handler_name (str) -- The name of the function to be connected to a signal

A function bound to an object
function


List the None-valued attributes of target.
target (dict) -- An object with None-valued attributes


Loads the UI defined in the file named resource_name using the builder.
resource_name (str) -- the basename of the glade file (without extension), identifying the resource to load.


Fill in target with the missing elements introspectively.

This means that all attributes of target that are None now must exist under the same name in the builder.

target (dict) -- An object with None-valued properties whose names correspond to ids of built widgets.


dict mapping Paned names to a tuple of (handler id of the size-allocate signal, remaining number of times we allow this signal to run), and we run the signal 2 * (depth + 1) for each pane. This is because size allocation is done bottom-up but each pane sets a top-down constraint.

Remix the layout below top_widget with the layout configuration given in 'layout' (assumed to be valid!).
  • layout (dict) -- the json-parsed config string, thus a hierarchy of lists/dicts, with strings as leaves
  • top_widget (Container) -- The top-level widget under which we build the hierachyy
  • leaf_widgets (dict) -- the map of valid leaf identifiers (strings) to the corresponding Widget
  • pane_resize_handler (function) -- callback function to be called when the panes are resized

The mapping of the used Paned widgets to their relative handle position (in 0..1).
dict


Resize paned to have its handle at relpos, then disconnect this signal handler.

Called from the Gtk.Widget.signals.size_allocate() signal.

  • paned (Paned) -- Panel whose size has just been allocated, and whose handle needs initial placement.
  • rect (Rectangle) -- The rectangle specifying the size that has just been allocated to paned
  • relpos (float) -- A number between 0. and 1. that specifies the handle position

True


Sets up actions with a given prefix, using the Application as the ActionMap.
  • actions (dict) -- Maps the action names to dictionaries containing their parameters.
  • action_map (ActionMap) -- The object implementing the action map interface to register actions



Callback for signal connection. Implements the BuilderConnectFunc function interface.
  • builder (Builder) -- The builder, unused
  • obj (Object) -- The object (usually a wiget) that has a signal to be connected
  • signal_name (str) -- The name of the signal
  • handler_name (str) -- The name of the function to be connected to the signal
  • connect_object (Object) -- unused
  • flags (ConnectFlags) -- unused
  • user_data (tuple) -- supplementary positional arguments to be passed to the handler




pympress.surfacecache -- pages prerendering and caching

This modules contains stuff needed for caching pages and prerendering them. This is done by the SurfaceCache class, using several dict of ImageSurface for storing rendered pages.

The problem is, neither Gtk+ nor Poppler are particularly threadsafe. Hence the prerendering isn't really done in parallel in another thread, but scheduled on the main thread at idle times using GLib.idle_add().

Bases: object

Pages caching and prerendering made (almost) easy.

  • doc (Document) -- the current document
  • max_pages (int) -- The maximum page number.


Set of active widgets

Add a widget to the list of widgets that have to be managed (for caching and prerendering).

This creates new entries for widget_name in the needed internal data structures, and creates a new thread for prerendering pages for this widget.

  • widget (Widget) -- The widget for which we need to cache
  • wtype (int) -- type of document handled by the widget (see surface_type)
  • prerender_enabled (bool) -- whether this widget is initially in the list of widgets to prerender
  • zoomed (bool) -- whether we will cache a zoomed portion of the widget
  • ignore_max (bool) -- whether we will cache an unlimited number of slides



Remove all cached values for a given widget. Useful for zoomed views.
widget_name (str) -- name of the widget that is resized, None for all widgets.


Remove a widget from the ones to be prerendered.
widget_name (str) -- string used to identify a widget


The current Document.

Lock used to manage conccurent accesses to doc.

Add a widget to the ones to be prerendered.
widget_name (str) -- string used to identify a widget


Fetch a cached, prerendered page for the specified widget.
  • widget_name (str) -- name of the concerned widget
  • page_nb (int) -- number of the page to fetch in the cache

the cached page if available, or None otherwise
ImageSurface


Get the document type of a widget.
widget_name (str) -- string used to identify a widget
type of document handled by the widget (see surface_type)
int


Dictionary of Lock used for managing conccurent accesses to surface_cache and surface_size

maximum number fo pages we keep in cache

Queue a page for prerendering.

The specified page will be prerendered for all the registered widgets.

page_nb (int) -- number of the page to be prerendered


Store a rendered page in the cache.
  • widget_name (str) -- name of the concerned widget
  • page_nb (int) -- number of the page to store in the cache
  • val (ImageSurface) -- content to store in the cache



Rendering function.

This function is meant to be scheduled on the GLib main loop. When run, it will go through the following steps:

  • check if the job's result is not already available in the cache
  • render it in a new ImageSurface if necessary
  • store it in the cache if it was not added there since the beginning of the process and the widget configuration is still valid

  • widget_name (str) -- name of the concerned widget
  • page_nb (int) -- number of the page to store in the cache



Change the size of a registered widget, thus invalidating all the cached pages.
  • widget_name (str) -- name of the widget that is resized
  • width (int) -- new width of the widget
  • height (int) -- new height of the widget



Set the document type of a widget.
  • widget_name (str) -- string used to identify a widget
  • wtype (int) -- type of document handled by the widget (see surface_type)



The actual cache. The dict`s keys are widget names and its values are :class:`~collections.OrderedDict, whose keys are page numbers and values are instances of ImageSurface. In each OrderedDict keys are ordered by Least Recently Used (get or set), when the size is beyond max_pages, pages are popped from the start of the cache.

dict containing functions that return a Surface given a Format, width int and height int, see create_similar_image_surface()

Size of the different managed widgets, as a dict of tuples

its keys are widget names and its values are document types from ui.
Type of document handled by each widget. It is a dict


Replaces the current document for which to cache slides with a new one.

This function also clears the cached pages, since they now belong to an outdated document.

new_doc (Document) -- the new document


Set of widgets for which we ignore the max


pympress.scribble -- Manage user drawings on the current slide

Bases: Builder

UI that allows to draw free-hand on top of the current slide.

  • config (Config) -- A config object containing preferences
  • builder (Builder) -- A builder from which to load widgets
  • notes_mode (bool) -- The current notes mode, i.e. whether we display the notes on second slide


int that is the currently selected element

Properly enable and disable buttons based on scribblings lists.

Actually change the highlight tool elements orientations according to self.tools_orientation

The DrawingArea in the content window

Callback for the scribble clear button, to remove all scribbles.

tuple of (int, str) indicating the current page number and label

Disable the scribbling mode.
whether it was possible to disable (thus if it was not disabled already)
bool


Perform the drawings by user.
  • widget (DrawingArea) -- The widget where to draw the scribbles.
  • cairo_context (Context) -- The canvas on which to render the drawings



Enable the scribbling mode.
whether it was possible to enable (thus if it was not enabled already)
bool


callback, to be connected to get_slide_point()


Handle key events to activate the eraser while the shortcut is held
  • widget (Widget) -- the widget which has received the event.
  • event (Event) -- the GTK event.

whether the event was consumed
bool


callback, to be connected to load_layout()

Loads the preset color of a given number or designed by a given widget, as an event handler.
  • gaction (Action) -- the action triggering the call
  • target (Variant) -- the new preset to load, as a string wrapped in a GLib.Variant

whether the preset was loaded
bool


The position of the mouse on the slide as tuple of float

The next scribble to render (i.e. that is not rendered in cache)

Transfer configure resize to the cache.
  • widget (Widget) -- the widget which has been resized
  • event (Event) -- the GTK event, which contains the new dimensions of the widget



callback, to be connected to on_draw()

Handle drawing the eraser button.
  • widget (Widget) -- the widget to update
  • cairo_context (Context) -- the Cairo context (or None if called directly)



Handle drawing the marker/pencil buttons, with appropriate thickness and color.
  • widget (Widget) -- the widget to update
  • cairo_context (Context) -- the Cairo context (or None if called directly)



Box in the Presenter window, where we insert scribbling.

Called when we change pages, to clear or restore scribbles
  • page_number (int) -- The number of the new page
  • page_label (str) -- The label of the new page



Change whether we exit or stay in highlighting mode on page changes
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the new mode as a string wrapped in a GLib.Variant



bool indicating whether we exit highlighting mode on page change

Transform a string to a Gdk object in a single function call
text (str) -- A string describing a color
A new color object parsed from the string
RGBA


The Action that contains the currently selected pen

Transform a list of points from scribbles to bezier curves
control points of a bezier curves to draw
list


Callback for the scribble undo button, to undo the last scribble.

Commit scribbles to cache so they are faster to draw on the slide

Box containing the presets

int to remember the previously selected element, before holding “eraser”

Callback for the scribble undo button, to undo the last scribble.

callback, to be connected to redraw_current_slide()

dict of scribbles per page

Draw a single scribble, i.e. a bezier curve, on the cairo context
  • cairo_context (Context) -- The canvas on which to render the drawings
  • color (RGBA) -- The color of the scribble
  • width (float) -- The width of the curve
  • points (list) -- The control points of the curve, scaled to the surface.
  • pressures (list) -- The relative line width at each point as float values in 0..1



Clear the cached scribbles.

callback, to be connected to resize_widget()

EventBox for the scribbling in the Content window, captures freehand drawing

A Surface to hold drawn highlights

Button for removing all drawn scribbles


The ColorButton selecting the color of the pen

Box containing the scribble color and width selectors

Whether the current mouse movements are drawing strokes or should be ignored

list of scribbles to be drawn, as tuples of color RGBA, width int, a list of points, and a list of pressure values.

A OffscreenWindow where we render the scribbling interface when it's not shown

HBox that replaces normal panes when scribbling is on, contains buttons and scribble drawing area.

DrawingArea for the scribbles in the Presenter window. Actually redraws the slide.

EventBox for the scribbling in the Presenter window, captures freehand drawing

AspectFrame for the slide in the Presenter's highlight mode

The list containing the radio buttons ModelButton

Button for drawing the last removed scribble

list of undone scribbles to possibly redo

Box containing the scribble buttons

Button for removing the last drawn scribble

int current stroke width of the scribbling tool

The Scale selecting the size of the pen

Whether we are displaying the interface to scribble on screen and the overlays containing said scribbles

Change the mode of clearing and restoring highlights
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the new mode as a string wrapped in a GLib.Variant



Changes the orientation of the highlighting tool box.
  • gaction (Action) -- the action triggering the call
  • target (Variant) -- the new orientation to set, as a string wrapped in a GLib.Variant

whether the preset was loaded
bool


callback, to be connected to start_zooming()

callback, to be connected to stop_zooming()

Starts the mode where one can read on top of the screen.

Args:

whether the event was consumed
bool


list that contains the modifiers which, when held on scribble start, toggle the eraser

list that contains the non-modifier shortcuts which, when held on scribble start, toggle the eraser

str or None that indicates whether a modifier + click or a held shortcut is toggling the eraser

Start/stop drawing scribbles.
  • widget (Widget) -- the widget which has received the event.
  • event (Event) -- the GTK event.

whether the event was consumed
bool


str indicating the current layout of the highlight toolbar

callback, to be connected to track_clicks()

callback, to be connected to track_motions()

Draw the scribble following the mouse's moves.
  • widget (Widget) -- the widget which has received the event.
  • event (Event) -- the GTK event.

whether the event was consumed
bool


Cancel scribbling, if it is enabled.
True if scribbling got cancelled, False if it was already disabled.
bool


Update modifications to the active scribble color and width, on the pen button and config object

Callback for the color chooser button, to set scribbling color.
widget (ColorButton) -- the clicked button to trigger this event, if any


Callback for the width chooser slider, to set scribbling width.
  • widget (Scale) -- The slider control used to select the scribble width
  • event (Event) -- the GTK event triggering this update.
  • value (int) -- the width of the scribbles to be drawn



Button that is clicked to stop zooming, unsensitive when there is no zooming


pympress.pointer -- Manage when and where to draw a software-emulated laser pointer on screen

Bases: object

Manage and draw the software “laser pointer” to point at the slide.

Displays a pointer of chosen color on the current slide (in both windows), either on all the time or only when clicking while ctrl pressed.

  • config (Config) -- A config object containing preferences
  • builder (Builder) -- A builder from which to load widgets


Activate the pointer as given by mode.

Depending on the given mode, shows or hides the laser pointer and the normal mouse pointer.

mode (PointerMode) -- The mode to activate


DrawingArea Slide in the Contents window, used to reliably set cursors.

AspectFrame Frame of the Contents window, used to reliably set cursors.

Callback for a radio item selection as pointer mode (continuous, manual, none).
  • action (Action) -- The action activatd
  • target (Variant) -- The selected mode



Callback for a radio item selection as pointer mode (continuous, manual, none).
  • action (Action) -- The action activatd
  • target (Variant) -- The selected mode



A reference to the UI's Config, to update the pointer preference

Perform the change of pointer using its color name.
name (str) -- Name of the pointer to load


The PointerMode to which we toggle back

DrawingArea Slide in the Presenter window, used to reliably set cursors.

Pixbuf to read XML descriptions of GUIs and load them.

PointerMode indicating the pointer mode

(float, float) of position relative to slide, where the pointer should appear

a dict of the RadioMenuItem selecting the pointer mode

callback, to be connected to redraw_current_slide()

Draw the laser pointer on screen.
  • cairo_context (Context) -- The canvas on which to render the pointer
  • ww (int) -- The widget width
  • wh (int) -- The widget height



callback, to be connected to set_action_state()

bool indicating whether we should show the pointer

Track events defining when the laser is pointing.
  • widget (Widget) -- the widget which has received the event.
  • event (Event) -- the GTK event.

whether the event was consumed
bool


Switches laser off/on in continuous mode on leave/enter slides.

In continuous mode, the laser pointer is switched off when the mouse leaves the slide (otherwise the laser pointer "sticks" to the edge of the slide). It is switched on again when the mouse reenters the slide.

  • widget (Widget) -- the widget which has received the event.
  • event (Event) -- the GTK event.

whether the event was consumed
bool


Move the laser pointer at the mouse location.
  • widget (Widget) -- the widget which has received the event.
  • event (Event) -- the GTK event.

whether the event was consumed
bool



Bases: Enum

Possible values for the pointer.

Pointer switched on continuously

Pointer never switched on

Pointer switched on only manual


pympress.editable_label -- A label that can be swapped out for an editable entry

Bases: object

A label that can switch between simply displaying a value, and allowing user input to edit this value.

Cancel editing the label. Needs to be reimplemented by children classes.

bool tracking whether we are currently editing the label.

EventBox around the label, used to sense clicks

Manage key presses for the editable label. Needs to be reimplemented by children classes.

If we are editing the label, intercept some key presses (to validate or cancel editing or other specific behaviour), otherwise pass the key presses on to the button for normal behaviour.

  • widget (Widget) -- the widget which has received the event.
  • event (Event) -- the GTK event.
  • name (str) -- the name of the key stroke
  • command (str) -- the name of the command in case this function is called by on_key_input

whether the event was consumed
bool


Manage events on the current slide label/entry.

This function triggers replacing the label with an entry when clicked or otherwise toggled.

  • widget (Widget) -- the widget in which the event occurred
  • event (Event or None) -- the event that occurred, None if tf we called from a menu item

whether the event was consumed
bool


Make sure that the editable label is not in entry mode.

If it is an entry, then replace it with the label.


Start the editing of the label if it is disabled.

Disable the editing of the label if it was enabled.

Perform the actual work of starting the editing.

Cancel editing the label, if it is being edited.
True if editing got cancelled, False if the label was not being edited.
bool


Validate the page choice, if the page label is being edited.
True if editing got validated, False if the label was not being edited.
bool


Validate the input to the label. Needs to be reimplemented by children classes.


Bases: EditableLabel

A label that displays the time elapsed since the start of the talk, that can be edited to select talk duration.

The duration of the talk will cause the label to blink and change colour as the elapsed time gets closer to the targeted talk duration.

builder (builder.Builder) -- The builder from which to load widgets.

EventBox associated with the estimated talk time.

Entry used to set the estimated talk time.

Estimated talk time, int in seconds.

Estimated talk time Label for the talk.

Elapsed time Label.

Pass on keystrokes to do_key_press_event().

Make sure that the current page number is displayed in a label and not in an entry.

If it is an entry, then replace it with the label.


Set the talk time.
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- The time in seconds, as an int64 variant



callback, to be connected to stop_editing()

Perform the actual work of starting the editing.

Update estimated talk time from the input.


Bases: EditableLabel

A label that displays "current page / max page", that can be edited to select a page to which to go.

builder (Builder) -- A builder from which to load widgets

Make the UI re-display the pages from before editing the current page.

Get the page number from the spinner and go to that page.

EventBox associated with the slide counter label in the Presenter window.

Entry used to switch to another slide by typing its label.

Allow one to use or ignore labels.
enable (bool) -- Whether to enable labels


callback, to be connected to lookup_label()

callback, to be connected to goto()

HBox containing the slide counter label in the Presenter window.

bool whether to scroll with the pages (True) or with the page numbers (False)

callback, to be connected to label_before()

callback, to be connected to label_after()

Slide counter Label for the current slide.

Slide counter Label for the last slide.

Label separating spin_cur and edit_label

int holding the maximum page number in the document

Implement directions (left/right/home/end) keystrokes.

Otherwise pass on to do_key_press_event().


Scroll event. Pass it on to the spin button if we're currently editing the page number.
  • widget (Widget) -- the widget which has received the event.
  • event (Event) -- the GTK event.

whether the event was consumed
bool


callback, to be connected to do_page_change()

bool holding whether we display or ignore page labels

Make sure that the current page number is displayed in a label and not in an entry.

If it is an entry, then replace it with the label.


Set the max number of pages, both on display and as the range of values for the spinner.
num_pages (int) -- The maximum page number


Callbacks that need to be setup again at every new document
doc (Document) -- The new document that got loaded


SpinButton used to switch to another slide by typing its number.

Perform the actual work of starting the editing.

Update the displayed page numbers.
  • cur_nb (int) -- The current page number, in documentation numbering (range [0..max - 1])
  • label (str) -- The current page label



Get the page number from the spinner and go to that page.


pympress.talk_time -- Manages the clock of elapsed talk time

Bases: object

A double counter, that displays the time elapsed in the talk and a clock.

  • builder (builder.Builder) -- The builder from which to load widgets.
  • ett (int) -- the estimated time for the talk, in seconds.
  • timing_tracker -- (TimingReport): to inform when the slides change
  • autoplay -- (AutoPlay): to adjust the timer display if we’re auto-playing/looping slides


autoplay = None
The AutoPlay, to adjust the timer display if we’re auto-playing/looping slides

Returns the time elapsed in the presentation.
the time since the presentation started in seconds.
int


Time elapsed since the beginning of the presentation, int in seconds

EstimatedTalkTime that handles changing the ett

Clock Label

TimeLabelColorer that handles setting the colors of label_time

Elapsed time Label

Pause the timer if it is not paused, otherwise do nothing.
whether the clock's pause was toggled.
bool


The pause-timer Action

Timer paused status, bool

Reset the timer.

Time at which the counter was started, int in seconds as returned by time()

Switch the timer between paused mode and running (normal) mode.
whether the clock's pause was toggled.
bool


The TimingReport, needs to know when the slides change

Unpause the timer if it is paused, otherwise do nothing.
whether the clock's pause was toggled.
bool


Update the timer and clock labels.
True (to prevent the timer from stopping)
bool



Bases: object

Manage the colors of a label with a set of colors between which to fade, based on how much time remains.

Times are given in seconds (<0 has run out of time). In between timestamps the color will interpolated linearly, outside of the intervals the closest color will be used.

label_time (Gtk.Label) -- the label where the talk time is displayed

list of tuples (int, RGBA), which are the desired colors at the corresponding timestamps. Sorted on the timestamps.

CssProvider affecting the style context of the labels

Forces to reset the default colors on the label.

RGBA The default color of the info labels

The Gtk.Label whose colors need updating

Add class class_name to the time label and return its color.
  • label_time (Gtk.Label) -- the label where the talk time is displayed
  • style_context (StyleContext) -- the CSS context managing the color of the label
  • class_name (str or None) -- The name of the class, if any

The color of the label with class "class_name"
RGBA


Update the color of the time label based on how much time is remaining.
remaining (int) -- Remaining time until estimated talk time is reached, in seconds.



pympress.config -- Configuration

Bases: ConfigParser, object

Manage configuration :Get the configuration from its file and store its back.

Getter for the layout_name layout.

Wrapper for configparser’s getboolean to handle parsing errors when a fallback is given.

getboolean()


Wrapper for configparser’s to handle parsing errors when a fallback is given.

See getfloat()


Wrapper for configparser’s getint to handle parsing errors when a fallback is given.

See getint()


Parse a config value and return the list by splitting the value on commas.

i.e. bar = foo,qux returns the list ['foo', 'qux']

a config value split into a list.
list


dict-tree of presenter layouts for various modes

Parse and validate layouts loaded from config, with fallbacks if needed.

Return the path to the currently used configuration file.
search_legacy_locations (bool) -- whether to look in previously used locations
The path to the config file to use
Path


dict of strings that are the valid representations of widgets from the presenter window that can be dynamically rearranged, mapping to their names

Register actions that impact the config file only.
builder (pympress.builder.Builder) -- a builder to setup the actions


Save the configuration to its file.

dict mapping accelerator keys to actions

dict-tree of presenter layouts that are not configurable

Create or remove a configuration file for portable installs.

The portable install file will be used by default, and deleting it causes the config to fall back to the user profile location.

No need to populate the new config file, this will be done on pympress exit.

  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



Generic function to toggle some boolean startup configuration.
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



Setter for the notes layout.
  • layout_name (str) -- the name of the layout to update
  • widget (Widget) -- the widget that will contain the layout.
  • pane_handle_pos (dict) -- Map of Paned to the relative handle position (float in 0..1)



Update the layout named layout_name. Throws ValueError on invalid layouts.
  • layout_name (str) -- the name of the layout to update
  • layout (dict) -- the hierarchy of dictionaries, lists, and strings representing the layout



Update obsolete config options when pympress updates.

Checks which configuration file location is in use.
True iff we are using the portable (i.e. in install dir) location
bool


Validate layout: check whether the layout of widgets built from the config string is valid.
  • layout (dict) -- the json-parsed config string
  • expected_widgets (set) -- strings with the names of widgets that have to be used in this layout
  • optional_widgets (set) -- strings with the names of widgets that may or may not be used in this layout


Layout must have all self.placeable_widgets (leaves of the tree, as str) and only allowed properties on the nodes of the tree (as dict).

Constraints on the only allowed properties of the nodes are: - resizeable: bool (optional, defaults to no), - orientation: str, either "vertical" or "horizontal" (mandatory) - children: list of size >= 2, containing str`s or `dict`s (mandatory) - proportions: `list of float with sum = 1, length == len(children), representing the relative sizes of all the resizeable items (if and only if resizeable).


Build a tree representing a widget hierarchy, leaves are strings and nodes are dict.

Recursive function. See validate_layout() for more info on the tree structure.

  • widget (Widget) -- the widget where to start
  • pane_handle_pos (dict) -- Map of Paned to the relative handle position (float in 0..1)

A tree of dicts reprensenting the widget hierarchy
dict




pympress.extras -- Manages the display of fancy extras such as annotations, videos and cursors

Bases: Builder

Widget and machinery to setup and play slides automatically, optionally in a loop

The CheckButton to loop

A Dialog to contain the layout edition dialog

The SpinButton for the lower page

The SpinButton for the transition between slides

The SpinButton for the upper page

Return the autoplay info
(first page, stop page, looping, delay i ms)
tuple


callback, to be connected to goto_page()

Return whether an auto-playing

Callback to turn the page to the next slide
it (iterator) -- An iterator that contains the next pages to load. Stop when there are no more pages.
True if he callback needs to be called again, otherwise False
bool


Callback for when a page spin button is modified, maintains a delta of at least 2 pages between first and last page of the intended loop. (No loops needed to loop a single slide.)
  • spin_button (SpinButton) -- The button whose value was changed
  • scroll_direction (ScrollType) -- The speed and amount of change



Pause the looping if it’s running

if the timeout has been paused, int which represents the number of milliseconds until the next page slide

Show the dialog to setup auto-play, and start the autoplay if « apply » is selected
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



Callback for when a document number of pages changes
n_pages (int) -- the number of pages of the loaded document


Source which is the source id of the periodic slide transition, or None if there is no autoplay

Start the auto-playing

Stop the auto-playing

Unpause the looping if it’s paused


Bases: Builder

Widget tracking and displaying hierachically how much time was spent in each page/section of the presentation.

Config to remember preferences

str containing the layout currently edited

Given a path string, look up the appropriate item in both the actual and GtkStore models
path (str) -- A string representing a path in the treemodel
the node and iterator representing the position in the layout and model
dict, TreeIter


Action containing the orientation

A Label to contain the description of the layout


A Dialog to contain the layout edition dialog

Manage events for the layout selector drop-down menu
  • widget (ComboBox) -- the widget which has been modified
  • event (Event) -- the GTK event



A ComboBoxText to select the layout to edit

The TreeModel containing the model of the layouts to view in the treeview

The TreeView displaying the hierarchical layouts

Load the given layout in the treemodel for display and manipulation in the treeview

Action containing the number of next frames

Handle when the next slide count is modified
  • widget (ComboBox) -- the widget which has been modified
  • path (str) -- A string representing the path to the modfied item
  • value (int) -- the new number of next slides



Handler at the end of a drag-and-drop in the treeview

Here we transform the listmodel modified by drag-and-drop back to a valid dict and str hierarchy, and then trigger the loading of the layout again to display the corrected layout.

  • widget (Widget) -- The object which received the signal
  • drag_context (DragContext) -- the drag context
  • reload (bool) -- whether to reload the layout into the treemodel



Handle when the orientation of a box is changed
  • widget (ComboBox) -- the widget which has been modified
  • path (str) -- A string representing the path to the modfied item
  • orient_it (TreeIter) -- the row of the newly selected value in the orientations liststore model



The ListModel containing the possible orientations

Handle when box’ resizeable value is toggled
  • widget (ComboBox) -- the widget which has been modified
  • path (str) -- A string representing the path to the modfied item



Update which is the layout currently used by the UI
layout (str) -- the layout id


Show the popup to edit the layout. Gather info to populate it, and handle apply/cancel at the end.
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



Recursive function to transform the treemodel back into our dict-based representation of the layout
  • iterator (TreeIter) -- the position in the treemodel
  • parent_horizontal (bool) -- whether the parent node is horizontal
  • parent_resieable (bool) -- whether the parent node is resizeable

the list of dict or str representing the widgets at this level
list


callback, to be connected to load_layout()


Bases: Builder

Widget tracking and displaying hierachically how much time was spent in each page/section of the presentation.

bool marking whether next page transition should reset the history of page timings

A dict containing the structure of the current document

bool tracking whether a document is opened

int the time at which the clock was reset

Formats a number of seconds as minutes:seconds.
The formatted time, with 2+ digits for minutes and 2 digits for seconds.
str


A list with the page label of each page of the current document

list of time at which each page was reached

A timer reset. Clear the history as soon as we start changing pages again.

Show the popup with the timing infortmation.
  • doc_structure (dict) -- the structure of the document
  • page_labels (list) -- the page labels for each of the pages



Show the popup with the timing infortmation.
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



A Dialog to contain the timing to show

The TreeView containing the timing data to display in the dialog

Record a transition time between slides.
  • page (int) -- the page number of the current slide
  • time (int) -- the number of seconds elapsed since the beginning of the presentation




pympress.extras -- Manages the display of fancy extras such as annotations, videos and cursors

Bases: object

Widget displaying a PDF’s text annotations.

Add an annotation to the the page’s annotation list
  • gaction (Action) -- the action triggering the call, which identifies which backend
  • param (Variant) -- an optional parameter



The TreeViewColumn where the text is rendered

The CellRendererText defining how text is rendered

The containing ListStore storing the annotations to be displayed

The containing TreeView widget for the annotations

The Entry in which we are currently editing an annotation, or None

Handle the end of editing
cell_renderer (CellRenderer) -- The renderer which received the signal


Handle edit start
  • cell_renderer (CellRenderer) -- The renderer which received the signal
  • widget (CellEditable) -- the Gtk entry editing the annotation entry
  • entry_number (str) -- the string representation of the path identifying the edited cell



Handle successful edit: store the new cell value in the model and the document
  • cell_renderer (CellRenderer) -- The renderer which received the signal
  • entry_number (str) -- the string representation of the path identifying the edited cell
  • new_content (str) -- the new value of the edited cell



Handle a key (press/release) event.

Needed to forward events directly to the Entry, bypassing the global action accelerators.

  • widget (Widget) -- the widget which has received the event.
  • event (Event) -- the GTK event.

whether the event was consumed
bool


Add annotations to be displayed (typically on going to a new slide).
annot_page (Page) -- The page object that contains the annotations



Remove an annotation to the from the page’s annotation list
  • gaction (Action) -- the action triggering the call, which identifies which backend
  • param (Variant) -- an optional parameter




Update the wrap-width of the annotation column to fit its actual width


Try to cancel editing
whether editing was enabled and thus canceled
bool



Bases: object

Class managing cursors statically for displays, so we can select the mouse cursor with a simple string.

Set the cursor named cursor_name'.
  • widget (Widget) -- The widget triggering the cursor change, used to retrieve a Gdk.Window
  • cursor_name (str) -- Name of the cursor to be set




Bases: object

A class that wraps watchdog objects, to trigger callbacks when a file changes.

Callback to be called on file changes, usually connected to reload_document()

A FileSystemEventHandler to get notified when the file changes

A Observer to watch when the file changes

The Path to the file being watched

Remove all files that are being watched.


Watches a new file with a new callback. Removes any precedent watched files.

If the optional watchdog dependency is missing, does nothing.

  • uri (str) -- URI of the file to watch
  • callback (function) -- callback to call with all the further arguments when the file changes




Bases: object

Class managing statically the medias and media player backends, to enable play/pause callbacks.

  • builder (Builder) -- A builder from which to load widgets
  • conf (Config) -- An object containing the preferences


Adjust the relative margins of child widgets for notes mode update.
page_type (PdfPage) -- The part of the page to display


Overlay for the Content window.

Returns a class of type _backend.

Stops playing a media and hides the player. Used as a callback.
  • media_id (int) -- A unique identifier of the media to start playing
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



Stops all playing medias and hides the players. Used before exit.

Overlay for the Presenter window.

Starts playing a media. Used as a callback.
  • media_id (int) -- A unique identifier of the media to start playing
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



Toggles playing and pausing a media. Used as a callback.
  • media_id (int) -- A unique idientifier of the media to start playing
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- the parameter as a variant, or None



Remove current media overlays.

Remove current media overlays.

Remove current media overlays, add new ones if page contains media.
  • current_page (Page) -- The page for which to prepare medias
  • page_type (PdfPage) -- The part of the page to consider



Resize all media overlays that are a child of an overlay.

Set the player of a given media at time t. Used as a callback.
  • media_id (int) -- A unique idientifier of the media to start playing
  • gaction (Action) -- the action triggering the call
  • param (Variant) -- A wrapped float containing the time to which we have to go.



Toggle a backend (if it was loaded correctly)
  • gaction (Action) -- the action triggering the call, which identifies which backend
  • param (Variant) -- an optional parameter



dict containing backends and their mappings to mime type lists for which they are enabled. A default backend is marked by an empty list.


Bases: object

Manage the zoom level (using a cairo matrix), draw area that will be zoomed while it is being selected.

builder (Builder) -- A builder from which to load widgets

callback, to be connected to clear_cache()

Perform the drawings by user.
  • widget (DrawingArea) -- The widget where to draw the scribbles.
  • cairo_context (Context) -- The canvas on which to render the drawings



Returns the Matrix used to perform the zoom for the widget of size ww x wh.
  • ww (float) -- widget width
  • wh (float) -- widget height

the zoom transformation matrix
Matrix


Gets the point on the slide on a scale (0..1, 0..1), from its position in the widget.

Do nothing

Box in the Presenter window, used to reliably set cursors.

callback, to be connected to redraw_current_slide()


callback, to be connected to set_action_enabled()


Setup for the user to select the zooming area.
whether the event was consumed
bool


Cancel the zooming, reset the zoom level to full page.
whether the event was consumed
bool


Start/stop drawing the zoom's target rectangle.
  • widget (Widget) -- the widget which has received the event.
  • event (Event) -- the GTK event.

whether the event was consumed
bool


Draw the zoom's target rectangle.
  • widget (Widget) -- the widget which has received the event.
  • event (Event) -- the GTK event.

whether the event was consumed
bool


Cancel the zoom selection, if it was enabled.
True if the zoom was cancelled, False if a zoom selection was not in progress.
bool



Whether we are displaying the interface to scribble on screen and the overlays containing said scribbles


pympress.deck -- Manage user drawings on the current slide

Bases: Builder

UI that allows to draw free-hand on top of the current slide.

  • config (Config) -- A config object containing preferences
  • builder (Builder) -- A builder from which to load widgets
  • notes_mode (bool) -- The current notes mode, i.e. whether we display the notes on second slide


bool whether we show all pages or remove consecutive identically labeled pages, keeping only the last

The DrawingArea in the content window

SurfaceCache instance.

callback, to be connected to compute_frame_grid()

Build DrawingArea and AspectFrame elements to display later on

The DrawingArea for the first slide

Grid that displays all the slides of the overview

Whether we are displaying the deck overview on screen

A OffscreenWindow where we render the deck interface when it's not shown

Viewport that replaces normal panes when deck is shown

Disable the deck view.
whether it was possible to disable (thus if it was not disabled already)
bool


Enable the deck view.
whether it was possible to enable (thus if it was not enabled already)
bool


callback, to be connected to goto_page()

tuple of rows/columns in the grid

callback, to be connected to load_layout()

int How large (at most) to make rows

A slide has been clicked, go to it
  • widget (Widget) -- the widget which has received the key stroke
  • event (Event) -- the GTK event, which contains the key stroke details



Actually draw the deck slide -- only do this from cache, to limit overhead
  • widget (Widget) -- the widget to update
  • cairo_context (Context) -- the Cairo context (or None if called directly)



Track when each deck in the slide is hovered

Box in the Presenter window, where we insert deck.

Perform in-cache rendering
da (DrawingArea) -- the widget for which we’re rendering


Set the slides configuration and size in the grid

callback, to be connected to resize_widget()

Callbacks that need to be setup again at every new document
doc (Document) -- The new document that got loaded


Starts the mode where one can read on top of the screen.

Args:

whether the event was consumed
bool


Cancel deck, if it is enabled.
True if deck got cancelled, False if it was already disabled.
bool



pympress.util -- various utility functions

Bases: ScreenArea

A specialised ScreenArea representing a monitor, with an descriptive string and a monitor number

Get the info on the monitors
  • display (Display) -- the current screen
  • *windows (tuple of Window) -- windows for which to look up the monitor position

The monitors for each window, followed by the best monitors for presenter and content
tuple of Monitor


An int that identifies the monitor in Display

A str to represent a user-friendly name for the monitor


Bases: Exception

The Exception we raise when there is no way of figuring out the monitor position of windows


Bases: object

Convenience class to represent monitors or windows in terms of the area (position and size) they use on screen

This is similar to Monitor, but necessary as we want to handle “mirrored” monitors as if they were a single monitor, and only use “extended” monitors as target for content window position and/or fullscreening.

Check whether this area contains other
other (ScreenArea) -- The screen area to compare with
True iff the area is contained
bool


Check whether 2 areas cover the exact same space
other (ScreenArea) -- The screen area to compare with
True iff the areas are identical
bool


Compute the intersection of 2 screen areas
other (ScreenArea) -- The screen area to compare with
An area representing the intersection, or None if there is no intersection
ScreenArea or None


Check whether this area intersects other
other (ScreenArea) -- The screen area to compare with
True iff the areas have an intersection
bool


Find the rectangle that intersects least with rect in candidates
candidates (iterable of
`
ScreenArea`s) -- The monitor areas to check for intersection
The best candidate screen area, i.e. that has the smallest intersection
ScreenArea


Find the rectangle that intersects most with rect in candidates
candidates (iterable of
`
ScreenArea`s) -- The monitor areas to check for intersection
The best candidate screen area, i.e. that has the largest intersection
ScreenArea



Close all importlib context managers for resources that we needed over the program lifetime.

Call the right function to open files, based on the platform.
f (path-like) -- path to the file to open


Returns the path to the configuration file containing the defaults.
The path to the portable configuration file.
Path


Get the path for an image from pympress' resources
name (str) -- The name of the icon to load
The path to the icon to load
str


Returns the appropriate path to the log file in the user app dirs.
path to the log file.
Path


Returns the path to the configuration file for a portable install (i.e. in the install root).

May return None if the install root is not a real directory (e.g. in a zip file).

The path to the portable configuration file.
Path or None


Get metadata (version, etc) from pympress' __init__.py or git describe.
metadata properties (version, contributors) mapped to their values
dict


Returns a gettext translation object.

This re-implements gettext’s translation() and find() to allow using a python 3.9 Traversable as localedir

A gettext translation object with the strings for the domain loaded
NullTranslations


Load an UI definition file from pympress' resources
  • name (str) -- The name of the UI to load
  • ext (str) -- The extension of the file

The full path to the glade file
str


Returns the path to the configuration file in the user config directory
path to the user configuration file.
Path


Enable or disable the screensaver.
disabled (bool) -- if True, indicates that the screensaver must be disabled; otherwise it will be enabled


Get the value of a flag from its class, given a value’s name (or nick)

Introspection technique (in particular __flags_values__ dict) inspired from pygtkcompat. This is needed because there is no typelib for libgstplayback.

  • flags_class (a type inheriting from GFlags) -- the flags class to introspect
  • nick (str) -- a name or nick of the flag value that should be returned
  • fallback (int) -- the documented flag value, if lookup fails



List the icons from pympress' resources.
The paths to the icons in the pixmaps directory
list of str


Load the css and in a style provider
style_provider (CssProvider) -- The style provider in which to load CSS
The style provider with CSS loaded
CssProvider


Set to avoid blurriness issues on High-DPI resolutions with scaling.

pympress.media_overlays.base -- base widget to play videos with an unspecified backend

Bases: Builder

Simple Video widget.

All do_X() functions are meant to be called from the main thread, through e.g. idle_add(), for thread-safety in the handling of video backends.

  • container (Overlay) -- The container with the slide, at the top of which we add the movie area
  • page_type (PdfPage) -- the part of the page to display
  • action_map (ActionMap) -- the action map that contains the actions for this media
  • media (Media) -- the object defining the properties of the video such as position etc.


ActionMap containing the actios for this video overlay

autoplay = False
bool that tracks whether we should play automatically

Remove widget from overlays. Needs to be called via idle_add().
True iff this function should be run again (idle_add() convention)
bool


Start playing the media file.

Should run on the main thread to ensure we avoid reentrency problems.

True iff this function should be run again (idle_add() convention)
bool


Toggle pause mode of the media.

Should run on the main thread to ensure we avoid reentrency problems.

True iff this function should be run again (idle_add() convention)
bool


Set the player at time t.

Should run on the main thread to ensure we avoid vlc plugins' reentrency problems.

t (float) -- the timestamp, in s
True iff this function should be run again (idle_add() convention)
bool


Stops playing in the backend player.

bool that tracks whether the playback was paused when the user started dragging the position

bool that tracks whether the user is dragging the position

float giving the end position for playback, if any

Callback to format the current timestamp (in milliseconds) as minutes:seconds.
  • sc (Scale) -- The scale whose position we are formatting
  • prog (float) -- The position of the Scale, i.e. the number of seconds elapsed



Handler to embed the video player in the window, connected to the map signal.

End of the stream reached: restart if looping, otherwise hide overlay

Returns whether the media is currently playing (and not paused).
True iff the media is playing.
bool


Returns whether the media overlay is currently added to the overlays, or hidden.
True iff the overlay is currently displayed.
bool


float representing the last know timestamp at which the progress bar updated

float holding the max time in s

VBox that contains all the elements to be overlayed.

str representing the mime type of the media file

DrawingArea where the media is rendered.

Overlay that is the parent of the VideoOverlay widget.

Callback to toggle play/pausing from clicking on the DrawingArea

Scale that is the progress bar in the controls toolbar - if we have one.

Callback to update the position of the video when the user moved the progress bar.
  • rng (Range) -- The range corresponding to the scale whose position we are formatting
  • sc (Scale) -- The scale whose position we are updating
  • val (float) -- The position of the Scale, which is the number of seconds elapsed in the video



relative_margins = None
tuple containing the left/top/right/bottom space around the drawing area in the visible slide

tuple containing the left/top/right/bottom space around the drawing area in the PDF page

repeat = False
bool that tracks whether we should play after we finished playing

Adjust the position and size of the media overlay.

Bring the widget to the top of the overlays if necessary.

start_pos = 0.0
float giving the initial starting position for playback

ss / m:ss when the max time is known
Format of the video time, defaults to m
ss, changed to m


A HBox containing a toolbar with buttons and progress the progress bar

Recalculate the margins around the media in the event of a page type change.
page_type (PdfPage) -- the part of the page to display


Update the toolbar slider to the current time.
time (float) -- The time in this video in s


Update the toolbar slider size.
max_time (float) -- The maximum time in this video in s



pympress.media_overlays.gif -- widget to play gif images as videos

Bases: VideoOverlay

A simple overlay mimicking the functionality of showing videos, but showing gifs instead.

Advance the gif, queue redrawing if the frame changed, and schedule the next frame.

A PixbufAnimation containing all the frames and their timing for the displayed gif

A PixbufAnimationIter which will provide the timely access to the frames in anim

A tuple of (int, int) indicating the size of the bounding box of the gif

Start playing the media file.

Should run on the main thread to ensure we avoid reentrency problems.

True iff this function should be run again (idle_add() convention)
bool


Toggle pause mode of the media.

Should run on the main thread to ensure we avoid reentrency problems.

True iff this function should be run again (idle_add() convention)
bool


Set the player at time t.

Should run on the main thread to ensure we avoid reentrency problems.

t (int) -- the timestamp, in ms
True iff this function should be run again (idle_add() convention)
bool


Stops playing in the backend player.

Simple resized drawing: get the pixbuf, set the transform, draw the image.

Returns whether the media is currently playing (and not paused).
True iff the media is playing.
bool



Compute the transform to scale (not stretch nor crop) the gif.

Returns the name of this backend.

The Matrix defining the zoom & shift to scale the gif


pympress.media_overlays.gst -- widget to play videos using Gstreamer's Gst

Bases: VideoOverlay

Simple Gstramer widget.

Wraps a simple gstreamer playbin.

Start playing the media file.
True iff this function should be run again (idle_add() convention)
bool


Toggle pause mode of the media.

Should run on the main thread to ensure we avoid reentrency problems.

True iff this function should be run again (idle_add() convention)
bool


Set the player at time time.

Should run on the main thread to ensure we avoid reentrency problems.

time (float) -- the timestamp, in s
True iff this function should be run again (idle_add() convention)
bool


Stops playing in the backend player.

Transmit the change of file duration to the UI to adjust the scroll bar.

Update the current position in the progress bar.
True iff this function should be run again (timeout_add() convention)
bool


Returns whether the media is currently playing (and not paused).
True iff the media is playing.
bool


Mutes or unmutes the player.
value (bool) -- True iff this player should be muted


Set starting position, start scrollbar updates, unhide overlay.

Callback triggered by playbin state changes.
  • bus (Bus) -- the bus that we are connected to
  • msg (Message) -- the "state-changed" message



A Playbin to be play videos

Prepare/check the Gst backend.
the version of Gst used by the backend
str


A Sink to display video content

int number of milliseconds between updates


pympress.media_overlays.vlc -- widget to play videos using VLC

Bases: VideoOverlay

Simple VLC widget.

Its player can be controlled through the 'player' attribute, which is a MediaPlayer instance.

Start playing the media file.

Should run on the main thread to ensure we avoid vlc plugins' reentrency problems.

True iff this function should be run again (idle_add() convention)
bool


Toggle pause mode of the media.

Should run on the main thread to ensure we avoid vlc plugins' reentrency problems.

True iff this function should be run again (idle_add() convention)
bool


Set the player at time time.

Should run on the main thread to ensure we avoid vlc plugins' reentrency problems.

time (float) -- the timestamp, in s
True iff this function should be run again (idle_add() convention)
bool


Stops playing in the backend player.

Handler to embed the VLC player in the window, connected to the map signal.

End of the stream reached: restart if looping, otherwise hide overlay

Overrided because, to implement looping, vlc plugin needs to be told to start on stream end, not to seek


Returns whether the media is currently playing (and not paused).
True iff the media is playing.
bool


Mutes the player.
value (bool) -- True iff this player should be muted


Draw behind/around the video, aka the black bars
  • widget (Widget) -- the widget to update
  • context (Context) -- the Cairo context (or None if called directly)



Prepare/check the VLC backend.
vlc_opts (list) -- the arguments for starting vlc
the version of VLC used by the backend
str


Bring the widget to the top of the overlays if necessary − also force redraw of movie zone

Handle time passing
event (Event) -- The event that triggered the handler



Uses ctypes to call gdk_win32_window_get_handle which is not available in python gobject introspection porting.

Solution from http://stackoverflow.com/a/27236258/1387346

window (Window) -- The window for which we want to get the handle
The handle to the win32 window


AUTHOR

Cimbali

COPYRIGHT

2009-2024, Thomas Jost; 2015-2023 Cimbali

09 April, 2024 1.8.5