(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:
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.
To associate the source-code version to open files clicked in the Nautilus (a.k.a. Files) file explorer on Ubuntu Linux:
PyEdit-source.zipif needed, by visiting the program's home page or clicking this direct link. Be sure your web browser saves the zipfile in the
~/Downloadsfolder 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 (
curlmay work if
cd ~/Downloads wget https://learning-python.com/pyedit-products/PyEdit-source.zip
~/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
unziphas the same effect, as does the Python-coded ziptools (if it's downloaded too):
unzip PyEdit-source.zip # standard utility ziptools/zip-extract.py PyEdit-source.zip # ziptools alternative
pyedit-source.desktopfrom this direct link, and save it to
~/Downloadstoo. 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 wget https://learning-python.com/pyedit-source.desktop
cd /usr/share/applications sudo cp /home/me/Downloads/pyedit-source.desktop .Bonus: copying the
.desktopfile 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.
The following additional steps and options may or may not apply to your use case:
.desktopfile 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
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 editorThese commands can also be used to view PyEdit's console messages: set the file's
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 presentCaveat: 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.
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.zip ⇒ PyEdit.zip pyedit-source.desktop ⇒ pyedit-exe.desktop PyEdit-source ⇒ PyEdit-exe
The executable version's zipfile and
.desktop file can be fetched directly
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.
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
for a PC-platform sampler, see the screenshots
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.
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
~ can also be called
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):
textConfig.py: make the following two settings, at lines 101 and 148, respectively, to boost the starting font for text content, as well as the font for toolbar buttons (customize as you wish, but both must be large enough to use):
font = ('inconsolata', 12, 'normal') # also mono on Linux: 'courier new' toolbarFont = ('menlo', 12) # now labels (buttons render hugely)
textEditor.py: change the code at line 1175 to the following, to drop glyphs for more room, and pad small toolbar buttons with spaces for usability (the latter renders more clickably, and the former negates some added width):
if RunningOnWindows: # delete 'or RunningOnLinux' ....as is... elif RunningOnLinux: # insert: drop glyphs, pad chars runcode, popup = 'Run', 'Pop' bg, fg, inc, dec, pick, wrap = [' %s ' % char for char in 'bf+-?↲']
For more on using PyEdit in general, see its home page and User Guide.
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.