README-development 4.27 KB
Newer Older
1 2
README for developers

4 5
The Frescobaldi LilyPond sheet music editor is written in Python and uses
Qt4 for its user interface, via the PyQt4 bindings.

7 8 9
All code and application data is in the frescobaldi_app/ directory. The
frescobaldi script just imports frescobaldi_app.main.  You can simply run
./frescobaldi from the commandline after unpacking Frescobaldi.

11 12 13
You can also install the 'frescobaldi_app' package in the system- or user-wide
python directories and the frescobaldi script in your PATH.  The distutils-based
installation procedure can do this.

15 16 17 18
'frescobaldi_app' is not a real package: on startup, the absolute
'frescobaldi_app' directory is added to sys.path and its own __path__ is cleared
so all modules and packages inside frescobaldi_app are available as toplevel
modules and packages.
19 20

21 22
Running Frescobaldi in an interactive shell

24 25 26
To test features or to experiment, you can run Frescobaldi in an interactive
Python shell. It is recommended to open a shell (e.g. by simply running python
without arguments, or by using Dreampie or IPython) and then enter:

import frescobaldi_app.main

30 31
This ensures the application starts up and uses the correct SIP api (2) for
QString and QVariant.

33 34
Currently Python 2.6 and 2.7 are supported, but the code should be designed such
that Frescobaldi works as well with Python 3.
35 36

37 38
How Frescobaldi is organized

40 41 42 43
There can be one or more mainwindow.MainWindow instances and one or more
document.Document instances (when the last Document is closed, another one is
always constructed). The app module keeps references to those and contains the
Signals emitted when something changes.

45 46 47 48
Many parts inside Frescobaldi need to store or cache additional information or
add features to Documents, MainWindows etc. Instead of clobbering those basic
classes with an ever-growing number of unrelated groups of methods, a different
approach is chosen: the plugin module.

50 51
This keeps all classes small and only have methods that direcly apply to
themselves and not to other parts of Frescobaldi.

53 54 55
So e.g. the resultfiles, highlighter or documentinfo modules contain classes
for objects that coexist with a Document, and providing their own relevant
methods, while keeping a weak reference to the Document.

57 58 59
Exchange of messages is done as much as possible using signals (PyQt4 signals
or from the signals module), so adding new features changes as less existing
code as possible.
60 61

Some important modules:

64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
main:           Entry point
info:           Information about the application, such as the version
toplevel:       Adds the path of frescobaldi_app to sys.path, clears __path__
                so all modules inside frescobaldi_app can be imported as
                toplevel modules and packages
app:            Central hub with global signals, also keeping references to
                mainwindow and document instances
mainwindow:     MainWindow (QMainWindow)
document:       Document (QTextDocument)
view:           View (QPlainTextEdit)
menu:           Here the menubar is constructed (by importing all the relevant
                modules and adding the actions they define)
plugin:         A simple way to extend objects without them knowing it
ly:             LilyPond and the LY file format, tokenizer for LY and related
metainfo:       Stores (optionally) meta information about the document, such
                as last cursor position, whether to enable auto indent, etc
panels:         Both the base class for dock widgets and the manager of them
symbols:        Provides icons of LilyPond-generated SVG files that draw
                themselves in the default text color.
83 84

85 86
Some completely generic modules (don't have anything to do with Frescobaldi or

88 89 90 91 92 93 94 95
qpopplerview:   PDF viewer widget using the popplerqt4 binding to Poppler-Qt4
signals:        An alternative to Qt signals that allows for connections to have
                priorities, and objects don't have to be Qt objects
slexer:         A Stateful Lexer, used to build regular expression-based parsers
hyphenator:     Hyphenate text using hyphenation dictionaries
cursortools:    Some useful functions manipulating QTextCursor instances
portmidi:       Access the PortMidi library in different ways
midifile:       Load and play MIDI files
96 97