distributedproofreaders / guiguts-py Goto Github PK
View Code? Open in Web Editor NEWGuiguts rewrite using Python/tkinter
License: GNU General Public License v2.0
Guiguts rewrite using Python/tkinter
License: GNU General Public License v2.0
In logging_init
,
sys.stdout.reconfigure(encoding="utf-8")
sys.stderr.reconfigure(encoding="utf-8")
In GG1 Tools menu
Start a new file, type in some text, Save As filename.
Look in Recent Files, and your new filename isn't there.
In GG1 Tools menu
On Windows (at least)...
Closing with "File->Quit/Exit" does.
Closing the file with File->Close does.
Opening a new file does.
But just destroying the window via the Window manager does not.
Python's base regex engine (in the re
module) is "similar" to Perl PCRE but not exactly compatible. This leaves us with a choice to make, and some research to do, to inform the choice: should we make GG2 backward-compatible with PP'er workflows? Many PP'ers have carefully honed regexes used in their workflows. An argument could be made that the best choice is to make GG2 perfectly compatible with those workflows. But that must be counterbalanced against the amount of effort required to accomplish the backward compatibility, and ongoing maint, etc.
References / projects to review:
At a cursory glance, the python-pcre option seems "best" in terms of least disruptive to users, but I have no opinion yet about the future maintainability about any of these options. I will look at this, though of course I would welcome any opinions or input from anyone who has time to read / think about this.
If you just start up a gg2 instance and start typing, this problem doesn't appear to exist, but currently (confirmed at least on Mac and Windows), when a new document is first opened in gg2 (i.e. a new project's text CTF), the cursor is visible, but not active. This means that
To make the window active, you need to click in the GG window, or, on a Mac, cmd-tab away from and back into the python instance that is running (@windymilla, can you describe the Windows method?).
In Tools menu in GG1
May be worth checking in forums - some of the tool's options in GG1 are dangerous and maybe not used
If Auto Img is trying to load an image but can't find it, it pops a directory selection dialog. If the users cancels this, it just pops again.
One solution would be turn off Auto Img if user cancels dir selection.
Another would be not to pop the dir selection at all if because of Auto Img, but that would require the user to manually select the folder.
In GG1 Tools menu
For developers to have confidence contributing to this repo it should have a license. Which license is up to @windymilla as the primary author and as the only other contributor thus far I hereby retroactively accept whatever open-source license he uses.
I am not a lawyer, nor do I play one on TV or the internet, but if we intend to lift code from GG1 we are probably incentivized to make GG2 use the same license. That said, if we intend to bundle other code in a GG2 distribution that code will need to be using a compatible license. If we merely use other code (for instance, if we use ebookmaker
as a python dependency but we do not bundle the ebookmaker
code with GG2) we do not need to have compatible licenses as we are not redistributing the code. I think. To reiterate: I am not a lawyer.
Possibly-useful information:
ppvimage.pl
- unknown, we should reach out to RogerBase on Spell Query - not Aspell-based Spell Check
After #37
Advanced features (could be postponed to future issue):
\C...\E
in GG1 executes Perl code)See if it's possible to run sphinx and detect docstring errors using Github actions
See python-app.yml
I'm not sure I grok this in its completeness, so I'll describe what happens for me as far as I've been able to test it (macOS, and no idea whether Windows has the same issue).
I discovered it when I was tangling with the cursor-not-active issue.
With a clean instance of gg2, open a text file. Try to figure out how to get the cursor moving and load images, and decide that maybe reloading the file will fix it. Img:
is not set (i.e. still has a hyphen instead of a number). The test file I was using had 27 pages.
When I reloaded the test file, the Img
number went to 27. When clicking into the text, the cursor moves. An image can be loaded, but it's the last image. The img
in the status bar remained at 27. Even if I opened a text file that had more pages, it appears to be stuck there for that document for that session.
Default text widget bindings: https://tcl.tk/man/tcl8.6/TkCmd/text.htm#M192
So it can be installed via pip
In GG1 tools menu are checks for:
Could be tackled one at a time or all three
In GG1 Tools menu
In GG1 Search menu
In GG1 Search menu
Accessible by right-clicking "Img:nnn" in status bar in GG1
Could maybe use to implement split screen editing, with two different portions of the text visible.
Similar to GG1
Suggestion: don't bind to F1/F2/F3 as they are in GG1
Accessible by right-clicking "Lbl:nnn" in status bar in GG1
Generic widgets (formerly dialogs) code needs to know about maintext in order to bind keystrokes.
Mainwindow code needs to use generic widgets, e.g. for MessageLogDialog.
Consider putting widgets into mainwindow, or splitting things up in mainwindow, or storing key widgets in a separate low-level module, or something else :(
A relatively recent addition to perl GG, the ruler is a nice-to-have feature, though not critical. Users should be able to turn it on or off.
Algorithm should match GG1 pretty closely as it's been tailored for our needs.
GG2 is currently being developed against python 3.10 per the README.md
and it is currently supported for security releases. ๐. However, binaries aren't available for the most recent 3.10 release on Windows. python 3.12 is the most recent supported version -- see the python version status.
We should consider updating the minimum version to 3.12 so we're developing against the latest version. Windows and macOS (via Homebrew) have ready access to python 3.12.
The biggest downside and thing to consider is for Linux users. Some very common, supported platforms include older versions:
Getting newer versions installed on those platforms is doable but often not trivial. We should consult with some of our GG1 Linux users and get their thoughts on python version and either proceed with this work or WONTFIX this issue and punt it to the future.
I don't see us targeting new python features that would preclude users from running on older versions, but for support purposes by having a target version we test and validate against is useful -- and that may be sticking with 3.10.
Currently, if a user opens a "Save as ..." or "Open ..." dialog, gets distracted and when they return don't notice that the dialog is already open, an try to open a new one, a new one opens quite nicely! It works properly, in that once the input is done, and the action takes place, all of the open dialogs are closed, but it's probably still not a good idea to have multiple windows open at the same time. Screenshot:
This is on macOS Monterey, 12.7.2.
Line numbers are very useful in a text editor. Users should be able to turn them on and off.
https://docs.python.org/3/library/tkinter.ttk.html#module-tkinter.ttk
Also "Modern Tkinter" book downloaded
Possibly include some/all of options available in GG1:
Case / regex / reverse / whole word
Try to mimic behavior of more modern editor(s) - consider things like if text is selected before beginning search
Something that bothers me in Guiguts is the use of Windows-style keymaps even when run on Macs. Probably 99% of the difference between the platforms would be swapping Ctrl
for Cmd
. In other words, like this example:
Function | Windows | Linux | Mac |
---|---|---|---|
Find | Ctrl-F |
Ctrl-F |
Cmd-F |
Save | Ctrl-S |
Ctrl-S |
Cmd-S |
In most Mac apps, you can use Emacs-style movement keys in text areas / text input boxes. Many Mac users are accustomed to doing so. In the current incarnation of guiguts-py, this works (because no other maps are overriding it, yet). If Cmd
bindings are used for the application commands / menus, then this should continue to work and it would be an improvement over the prior generation (for Mac users, at least).
Even for users who don't use these keys, using Cmd
bindings would be more in line with the other apps on the system and it would be much more natural on the platform.
When I use Guiguts, I often hit one of these keys out of habit and trigger a command unintentionally.
For those not familar, Emacs-style mappings possibly relevant to this issue are below. I didn't check which of these overlap with Guiguts - at least several of them do, they may not all overlap.
Ctrl-F
Ctrl-B
move cursor right (forward) or left (backward)Ctrl-P
Ctrl-N
move cursor to previous / next line (up, down)Ctrl-A
Ctrl-E
move cursor to beginning / end of current lineCtrl-D
Ctrl-H
delete character to right / left of cursorCtrl-K
delete from cursor to end of lineCtrl-O
split line into two lines, at current cursor positionCtrl-T
transpose characters on either side of cursorCtrl-V
page downIn GG1 Search menu
Submenu of Tools in GG1
Some checks in GG1's WF tool are probably not used since duplicates of other checks, e.g. comma followed by upper case.
Some are not to do with word list, e.g. Character Counts
Unicode>FF probably no longer required
Dashes, hyphens, italic/bold/etc, Mixed case, accents, ligatures, regexp are probably useful - maybe others like 1st Harmonic
This is really a note to self to investigate something not quite working.
Note to self: Probably something in the repeat timer is changing a pref, which causes a save of GGprefs.json.
May be related to Recent files
Current options are Open and Quit. Close should close the current document without quitting the application (prompting for save if there are changes since the last save) and open a new blank document, or leave it with no window, but allow the user to open a new document.
Image viewer is very rudimentary, allowing pan/zoom by mouse only (drag, Control+mouse wheel, maybe scroll gestures on mousepads)
Also hasn't been tested on different platforms.
At minimum it needs
Also consider what zoom/position to use when new image is loaded, which could be different size/aspect ratio.
Also what to do if floating window is resized.
Consider pyinstaller et al and see what works on a Mac with its digital signing, etc.
Currently, the directory that contains the page images must be in the same location as the text file. It's useful to be able to leave the images where they are, and point to where the directory is, instead of having to move them. Not critical, but nice to have.
Choose a default font (for each platform Win/Mac/Linux):
I would also propose bundling DP Sans Mono for easy use, if possible. I'm not sure how to install custom fonts on every platform, but on macOS I think adding font files to $HOME/Library/Fonts/
is sufficient.
"Linux" is actually a bunch of different platforms, really... I'll leave it for someone else to figure out what default fonts are available on any of them, since I have no clue about it...
As in GG1's edit menu:
Indicates (hopefully) that user has manually edited JSON file badly, and needs to fix it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.