Desktop Writing App: Python/C++ and Spellchecking
-
I've been working on a writeing app (designed for novel writing) for the past couple of years. It's a hobby project, so development is slow, but it is now nearly feature-complete.
I wrote the app with Qt5 and Python 3 (PyQt5). I mainly landed on Python because it was a lot faster to develop the features and test them, and it is easier to deploy cross-platform.
However, lately I've started to question the choice of Python. While it is fast enough for most of the features I use, I've run into a couple of bottlenecks and challenges. One challenge is the ability to properly multi-thread across Python/C++. The main bottleneck has been adding a decent spell checker to the central QTextEdit widget. Most examples out there inject the spell checking code into the QSyntaxHighlighter, and I've done the same. This is unfortunately extremely slow for large documents as the overloaded function lives on the Python side.
My question is two-fold.
How tricky is cross-platform deployment (I work mainly on Linux) for C++ vs. Python? I would use CMake for a C++ implementation as it's what I'm most familiar with. I would develop from a Linux-first perspective, so is MinGW the way to go on Windows?
If I do stay with Python (there would be a lot of code to convert to C++) I would appreciate some input on how to solve spell checking efficiently in QTextEdit, if anyone's got any examples or experience with this. I have spent a lot of time searching across the web, and not come across anything better than what I have so far: QSyntaxHighlighter + libEnchant via pyEnchant.
Edit: [VRonin] removed links
-
I've been working on a writeing app (designed for novel writing) for the past couple of years. It's a hobby project, so development is slow, but it is now nearly feature-complete.
I wrote the app with Qt5 and Python 3 (PyQt5). I mainly landed on Python because it was a lot faster to develop the features and test them, and it is easier to deploy cross-platform.
However, lately I've started to question the choice of Python. While it is fast enough for most of the features I use, I've run into a couple of bottlenecks and challenges. One challenge is the ability to properly multi-thread across Python/C++. The main bottleneck has been adding a decent spell checker to the central QTextEdit widget. Most examples out there inject the spell checking code into the QSyntaxHighlighter, and I've done the same. This is unfortunately extremely slow for large documents as the overloaded function lives on the Python side.
My question is two-fold.
How tricky is cross-platform deployment (I work mainly on Linux) for C++ vs. Python? I would use CMake for a C++ implementation as it's what I'm most familiar with. I would develop from a Linux-first perspective, so is MinGW the way to go on Windows?
If I do stay with Python (there would be a lot of code to convert to C++) I would appreciate some input on how to solve spell checking efficiently in QTextEdit, if anyone's got any examples or experience with this. I have spent a lot of time searching across the web, and not come across anything better than what I have so far: QSyntaxHighlighter + libEnchant via pyEnchant.
Edit: [VRonin] removed links
wrote on 8 May 2020, 08:10 last edited by JonB 5 Aug 2020, 08:12@CarsonGrey
I have little experience of your issues, but it doesn't stop me trying to offer you some thoughts: fools rush in where angels fear to tread ;-)-
Deploying for a Qt program is usually done via
linux/mac/windeployqt
, so that in theory should address the cross-platform installation. -
You still have to compile for each target, but I believe that can be done with cross-compilers from Linux (you'd have to check that for Windows). Yes, MinGW is the compiler to use if you're on Windows (as opposed to MSVC, for simplicity/compatibility).
-
You can write parts of your code in C++ and call from Python, if that helps on the "slow" parts. Perhaps you are already doing that for your "Enchant" stuff, I don't know. This does presumably exacerbate your compilation/distribution issue.
-
I assume you are/could be doing the checking stuff in a thread separate from the GUI. I don't know what this issues are about threading when using Python/PyQt5. You could join & post into the dedicated PyQt5 "forum", see https://riverbankcomputing.com/mailman/listinfo/pyqt . Answers there are often just aimed at PyQt specific questions and can be a bit brief, but the posters are very knowledgeable about all things PyQt/Qt/Python and hopefully may offer you guidance.
Hope these observations might be of some help!
-
1/2