PyEdit Linux File-Association Tips

(Dec-2020) This page briefly describes how to configure file associations to automatically open PyEdit for text-file clicks on Linux, and provides some general advice on using clicked files and improving PyEdit's appearance and usability on this platform. As a bonus, the process outlined here also adds PyEdit to the Linux applications launcher, and generally applies to other Linux programs. Contents here:

Associating PyEdit's Source Code

PyEdit's source-code version is recommended over its executable today, due to Linux font changes (per details in the next section). Because of that, this section focuses on associating the source-code script, but its patterns apply to other contexts.

Normal Steps

To associate the source-code version to open files clicked in the Nautilus (a.k.a. Files) file explorer on Ubuntu Linux:

  1. Download PyEdit's source-code package if needed, by visiting the program's home page or clicking this direct link. Be sure your web browser saves the zipfile in the ~/Downloads folder in your home folder; paths in step #3's file rely on this. If PyEdit's source code has already been installed elsewhere, skip steps #1 and #2 but do #6 later. And if you prefer command lines over browsers, the following have the same effect when pasted into Terminal (curl may work if wget won't):
    cd ~/Downloads
  2. Extract the zipfile downloaded in the prior step to ~/Downloads. For example: right-click in Nautilus (i.e., Files) and pick "Extract Here" to create folder ~/Downloads/PyEdit-source. Also for command-line purists: a simple unzip has the same effect, as does the Python-coded ziptools (if it's downloaded too):
    unzip                      # standard utility 
    ziptools/    # ziptools alternative
  3. Download text file pyedit-source.desktop from this direct link, and save it to ~/Downloads too. Alternatively, you can save this file using the "save" link near the top of this view page. As usual, the following command lines in Terminal download the file too:
    cd ~/Downloads    # iff you're not already there
  4. Copy the text file downloaded in the prior step to its required location by running the following commands in Terminal, replacing the second command's "me" with your user name, and giving your password for sudo when asked:
    cd /usr/share/applications
    sudo cp /home/me/Downloads/pyedit-source.desktop .
    Bonus: copying the .desktop file this way will also add PyEdit to the applications launcher; click it there to open an empty edit window, and right-click it there to add it to your Favorites (taskbar) too.
  5. Associate files with PyEdit by opening Nautilus (Files), right-clicking any text/code file, and then either:
    a) To associate PyEdit permanently with all files of this type:
    Choose "Properties" ⇨ "Open With" ⇨ "PyEdit-source" ⇨ "Set as default" ⇨ close
    b) To open this single file with PyEdit just once:
    Choose "Open With Other Application" ⇨ "View All Applications" ⇨ "PyEdit-source" ⇨ "Select"
    If you ran step #b, the file should now be open in PyEdit. If you ran step #a, all same-type files should now open in PyEdit whenever they are clicked in Nautilus. There's generally no need to restart Linux for any of this to take effect.

Optional Steps

The following additional steps and options may or may not apply to your use case:

  1. Path edit: if PyEdit's source is installed elsewhere, change its path in the downloaded .desktop file by running the following commands in Terminal. You can replace "vi" in the second with any editor (e.g., "gedit" or "nano"), and should change the path in both the Exec= and Icon= lines in the file (the former is PyEdit's code, and the latter is its icon):
    cd /usr/share/applications       # iff you're not still there
    sudo vi pyedit-source.desktop    # change "vi" to any editor
    These commands can also be used to view PyEdit's console messages: set the file's Terminal= setting to true.
  2. Rollback: to back out the associations made by step #5a, open Nautilus, right-click any associated file, and chose "Properties" ⇨ "Open With" ⇨ "Reset" (or simply choose a different default). This is effectively an undo for associations made in Nautilus, and will apply to all files of the same type.
  3. Alternatives: as a postscript for command-line fans, you can also create and change file associations in Terminal, by running magic commands and editing magic files such as the following:
    xdg-mime default app.desktop type/sub    # yet another way: see "man xdg-mime"
    /usr/share/applications/defaults.list    # default mime-handlers database
    /usr/share/applications/mimeinfo.cache   # available mimetype handlers
    sudo update-desktop-database             # make mimeinfo.cache from *.desktop
    ~/.config/mimeapps.list                  # added associations: Nautilus, xdg-mime, vi?
    ~/.local/share/applications/*            # per-user overrides, iff present
    Caveat: editing files like these is naturally perilous business, and much of the above tends to vary broadly across Linux distributions and versions. See the web for more details on these options.


This procedure may seem convoluted, but it makes programs like PyEdit much more accessible and useful on Linux. Other PC platforms achieve similar effects with similarly proprietary schemes—for example, dragging apps to the /Applications folder on Mac OS; pinning executables to the taskbar and adding shortcuts in the Start menu's folder on Windows; and making associations and Desktop aliases/shortcuts on both. Linux .desktop files and associations are a variation on a theme, which is based on flexible and easily edited command lines.

Associating PyEdit's Executable

Please note that PyEdit's frozen Linux executable version is not recommended today. The executable generally opens as fast as the source on Linux, but its fonts have grown unusably buggy on Ubuntu as of 2020 due to recent changes in Linux. In short, the executable was built in 2017 with Tk 8.5, but source runs with the latest Tk 8.6 and Linux font support. You can find expanded coverage of the executable breakage at this page. A future PyEdit rebuild may address this, but until one appears, the source-code package works better and is recommended for most Linux users.

If PyEdit's executable is ever repaired, however, you can enable associations with it instead of, or in addition to, its source-code version, by using the same procedure as that for source above, and globally replacing in it all the following's items on the left with their executable-version equivalents on the right:      ⇒
pyedit-source.desktop  ⇒  pyedit-exe.desktop
PyEdit-source          ⇒  PyEdit-exe

The executable version's zipfile and .desktop file can be fetched directly here and here (or indirectly here and here).

Editing Clicked Files on Linux

This section provides general tips for using PyEdit on Linux. It mostly pertains to file-clicks mode on that platform, but also covers cosmetics settings that apply to all Linux usage.

The One-Process-per-Click Model

On Linux, each file opened by PyEdit association clicks runs in its own process, as a main window. This means that:

By contrast, PyEdit's app on Mac OS opens clicked files as multiple popup windows in the same, single process, by catching open-doc events. This cycles colors automatically and detects changes across all clicked files, but also may silently close all windows with the initial and hence main window. Windows' association clicks use one process per file like Linux, but require a pyedit.bat for source; for a PC-platform sampler, see the screenshots here.

If you prefer the Mac OS single-process model, use PyEdit's "Pop" + "Open" toolbar buttons to open files in popups instead of main windows for clicks. This both enables the already-open test and automatically cycles colors, but inherits the potentially surprising mass auto-closes of Mac OS when the main window is closed.

Additional Linux Usage Notes

Logistical note: when running both PyEdit's source-code and executable by file clicks on Linux, its auto-saves folder will appear in your home folder, unless you configure this otherwise. Look for ~/__pyedit-autosaves__/, where ~ can also be called /home/username, and sometimes just Home in file explorers.

Cosmetics note: as shipped, and as rendered by Linux today, PyEdit's Linux font and toolbar presets leave a bit to be desired. For better appearance and usability, the following changes are recommended (and too trivial for formal patch files):

For more on using PyEdit in general, see its home page and User Guide.

Your Linux Mileage May Vary

Disclaimer: the associations procedures described above are known to work on Ubuntu desktop Linux 20.04.1 LTS and its preinstalled Nautilus/Files and Gnome 3.36.3. Given Linux's high degree of variability, morph, and bifurcation, they may or may not apply to other versions, and may or may not have any relevance to other Linux file managers (e.g., Dolphin, Nemo).

Simply put, flux is the norm on Linux (indeed, just three years of Linux changes sufficed to badly break fonts and other functionality in PyEdit's executable), so it's impossible to guarantee applicability outside a specific use case. Please see the web for other solutions where needed.

Also note that this page applies to desktop Linux only. Android is based on Linux and runs PyEdit's source-code version too, but presently requires PyEdit itself to be opened and launched by an IDE app. For details and screenshots, see this doc.

[Home] Books Programs Blog Python Author Training Search Email ©M.Lutz