Source Code Documentation

note.py: Yet another note taking app

class note.App(persistence=<note.Persistence object>)

Main class that runs the app.

Parameters:

model (AppModel) – Model of the application.

onclose()

Saves the current note and closes the app.

run()

Runs the app.

class note.FilterableListbox(master, model, icons)

Widget to display a filterable list of notes.

Parameters:
  • master (tk.Widget) – Control owning this widget.

  • model (NoteCollection) – Note collection that is displayed by the list.

  • icons (Icons) – Icon collection that is used to render some buttons.

onselect(event)

Callback when a note is selected. Used internally only.

Parameters:

event (tk.Event) – Event triggered the callback.

update()

Updates the displayed list of notes.

class note.Icons(master, font_size)

Namespace for icons.

Note that master is actually not used, but it makes sure a tkinter interstance was created when Icons are instanciated.

Parameters:
  • master (tk.Widget) – tkinter container.

  • font_size (int) – Font size of default icons.

class note.Note(parent, persistence, name, isvalid=True)

Contains all business logic of a note.

Parameters:
  • parent (NoteCollection) – Note collection that owns the note.

  • persistence (Persistence) – Persitence Provider of the note.

  • name (str) – Name of the note.

  • isvalid – Optional flag to mark the note valid (Default: True).

base_path()

Returns the directory of the note.

Returns:

Base path of the note.

Return type:

str

contents(value=None)

Reads or writes the contents of a note.

Parameters:

value (str | None) – Optional new contents of the note (Default: None).

Returns:

Contents of the note.

Return type:

str

css()

Returns the CSS for the note. All notes share the same CSS yet, but this may change in future.

Returns:

Style sheet of the note.

Return type:

str

delete()

Deletes the note and all related files.

matches(note_filter, tags)

“Returns True, when the notes name or content matches the filter.

Parameters:
  • note_filter (str) – Filter to check the note against.

  • tags (str[]) – Tags to check the note against.

Returns:

True, if the note matches the filter.

Return type:

bool

name(value=None)

Reads or sets the name of a note.

Parameters:

value (str | None) – Optional new name of the note (Default: None).

Returns:

Name of the note.

Return type:

str

screenshot()

Takes a screenshot and returns the filename.

Returns:

Filename of the screenshot on success, None otherwise.

Return type:

str | None

tags(value=None)

Reads or writes tags of a note.

Parameters:

value (str[] | None) – Optional new list of tags (Default: None).

Returns:

Tags of the note

Return type:

str[]

class note.NoteCollection(persistence)

Business logic of a collection of notes.

Parameters:

persistence (Persistence) – Persistence provider of the notes.

add_new()

Adds a new note to the collection.

note_changed()

Is called by notes only to inform about changes.

query(note_filter, tags)

Returns an ordered list of all notes that matches the filter.

Parameters:
  • note_filter (str) – filter to match the notes

  • tags (str[]) – tags to match the notes

Returns:

Ordered list toall notes that matches the filter.

Return type:

list[Note]

select(note_name)

Selects a note.

Parameters:

note_name (str) – Name of the note to select.

selected_note()

Returns the currently selected note.

Returns:

Currently selected note.

Return type:

Note

tags()

Returns a list of all tags.

class note.NoteFrame(master, model, icons)

Widget to view and edit a single note.

Parameters:
  • master (tk.Widget) – Container owning the note frame.

  • model (NoteCollection) – Note collection providing the contents of the note frame.

  • icons (Icons) – Icon collection used to render some frame buttons.

browse_attachments()

Opens a note’s attachments in file explorer.

change_tab(_)

Changes from view to edit tab or vice versa. Bound to Control-e.

delete()

Asks, if the current note should be deleted and deletes it.

enable(value=True)

Enables or disables all activatable sub-widgets.

Parameters:

value (bool) – True to enable the control (Default: True).

Opens a link in the default web-browser.

Paran url:

Url to open.

save()

Saves the name and contents of a note.

screenshot()

Takes a screenshot and insert it to the current note’s contents.

tab_changed(_)

Saves the contents of the currently selected note, when switched from edit to view mode (tab).

update()

Update the selected note (e.g. a new note is selected).

class note.Persistence(config_file='.notepy.yml')

Persistence handling.

All file operations are handled by the Persistence class.

css()

Returns the CSS of the webview.

Returns:

Returns the style sheet of the webview.

Return type:

str

font_size()

Returns the font size of the application.

Returns:

Font size of the application.

Return type:

int

geometry(geometry=None)

Returns and optionally sets the geometry of the application window.

Parameters:

geometry (str | None) – Optional geometry of application window (Default: None).

Returns:

Configured geometry of the application window.

Return type:

str

list_notes()

Returns a list of all notes.

Returns:

List of all notes.

Return type:

list[str]

list_tags()

Returns a list of all tag.

note_path(name)

Return the directory of a given note.

Parameters:

name (str) – Name of the note.

Returns:

Path of directory that conatins the nore.

Return type:

str

read_note(name)

Returns the contents of a note.

Non-existing notes will be created.

Parameters:

name (str) – Name of the note.

Returns:

Contents of the note.

Return type:

str

read_tags(name)

Reads all tags associated with a note.

Parameters:

name (str) – Name of the note.

Returns:

List of tags.

Return type:

str[]

remove_note(name)

Removes a note (including all related files).

Parameters:

name (str) – Name of the note.

rename_note(oldname, newname)

Renames a note in the filesystem.

Parameters:
  • oldname (str) – Old name of the note.

  • newname (str) – New name of the note.

screenshot(name)

Takes a screenshot and returns it’s filename.

Parameters:

name (str) – Name of the note the screenshot is assigned to.

Returns:

Filename of the screenshot.

Return type:

str

theme()

Return the theme of the application.

Returns:

Theme of the application.

Return type:

str

write_note(name, text)

Writes the contents of a note to note file.

Parameters:
  • name (str) – Name of the note.

  • text (str) – Contents of the note.

write_tags(name, tags)

Writes all tags associated with a note.

Parameters:
  • name (str) – Name of the note.

  • tags (str[]) – Name of the note.

class note.TabControl(master)

Replacement for ttk.Notepad

ttk.Notepad crashed on Windows in combination with tkinterweb and tk.Text (see https://github.com/Andereoo/TkinterWeb/issues/19).

Parameters:

master (tk.Widget) – Control owning the TabControl.

add(widget, name)

Adds a tab.

Parameters:
  • widget (tk.Widget) – Widget containing the contents of the tab.

  • name (str) – Name of the tab.

index(widget)

Returns the index of a widget.

Parameters:

widget (tk.Widget) – Widget to find.

Returns:

Index of the widget or -1 if widget is not contained.

Return type:

int

select(index=None)

Selects a tab and returns the selected widget.

Parameters:

index (int | None) – Optional index of the tab to select (Default: None)

Returns:

Selected widget.

Return type:

tk.Widget

class note.TagButton(parent, text, command)

Sticky button used to enable and disable tag filter

get_tag()

Returns the name of the tag.

is_active()

Returns true if the tag filter is active.

note.float_layout_apply(frame)

Applys the float layout to a frame widget.

Parameters:

frame (tk.Widget) – frame widget

note.float_layout_update(event)

Updates the layout of a widget. This function is called internally by frame layout.

Parameters:
  • event – resize event

  • type – tk.Event

note.main()

Entry point.

note.quote(value)

Quotes special characters that are not allowed in file names.

Special characters are URL encoded.

note.shim_waitstatus_to_exitcode(status)

Transforms waitstatus to exitcode without Python 3.9 features (see https://bugs.python.org/issue40094 for details)

Parameters:

status (int) – status code as returned by os.system

Returns:

exit code

Return type:

int