# Using html2 control or webkit to make a (limited) word processor

Hi, list. Long time no post. Glad to see things are still chugging along!

I was hoping to do have a rich text entry widget with certain requirements and was wondering what the options are in 2021 in wxPython. I haven’t upgraded yet my wxPython so I’m still using ‘3.0.2.0 msw (classic)’.

One possibility is wxRichTextCtrl. Last I checked, it didn’t have bitmap bullets nor any built-in way to go back and forth from other rich text interfaces (such as Word, Gmail, etc.). Is that still true? The document about it on wxWidgets seems to not have been updated since about 2007…but then I did find a reference to DrawBitmapBullet in the Phoenix docs, so I thought maybe just the document wasn’t updated but the widget has been?

I was thinking maybe a better way to go would be to use an embedded browser window and showing the text with HTML as a “contenteditable” area.

Given I’ve just retaken wxPython, I’m still using the old version and so just started using the old wx.html2.WebView widget to try to do this. I was able to get some promising things achieved, but am currently stuck on how to get pressing tab to actually make a tab in the text. It seems like I need to write this partly in Javascript, which I a) don’t know and b) it doesn’t return any errors to Python so it’s hard to debug and understand why something isn’t working.

Before I try harder on that, I wanted to ask whether using html2.Webview, or upgrading to the newest wxPython and using WebKit, or embedding CEF (Chromium Embedded Framework) would be a feasible way to do this?

By “feasible” I mean: Is this going to be a major project, akin to rewriting RichTextCtrl itself? I really just want the quickest path to having a WYSIWIG text control, with bullets, formatting, mouse wheel zooming, tab indenting, and easy movement from the control to elsewhere on the desktop (Word, Gmail, etc.). I also want the ability to save all content and formatting and redisplay it. But I don’t need anything heavy duty like all Word can do.

I was also thinking of trying to embed Quill in the wxPython application and view it through an embedded browser, but wasn’t sure if that was possible.

Thanks for any suggestions.

I expect that the first thing you’ll want to try is updating to wxPython 4.1 and then trying out the RichTextEditor there and see it has improved enough for your needs. If so, then that is probably the simplest fix.

If not, then wxPython 4.1 will also get you the newest webkit support and will likely be better for implementing or embedding a javascript based editor than what could be done with wxPython 3.

Thanks, I will try both after upgrading.

I did try upgrading with pip and it is failing for me. I have Python 2.7 still, but I didn’t know if that would be an issue for wxPython 4.1.1 (4.1.0 said it would be the last to include binaries for 2.7 but that the code would likely work anyway for a while).

I used the following command with pip:

pip install -U wxPython

It started and then generated what follows (what should I do?):

Microsoft Windows [Version 6.1.7601]

C:\Users\agent>pip install -U wxPython
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please
upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop s
upport for Python 2.7 in January 2021. More details about Python 2 support in pi
p can be found at Release process - pip documentation v21.1.dev0
hon-2-support pip 21.0 will remove support for this functionality.
Collecting wxPython
Using cached wxPython-4.1.1.tar.gz (66.0 MB)
packages (from wxPython) (4.1.0)
kages (from wxPython) (1.10.0)
ite-packages (from wxPython) (1.16.6)
-packages (from pillow->wxPython) (0.44)
Using legacy ‘setup.py install’ for wxPython, since package ‘wheel’ is not insta
lled.
Installing collected packages: wxPython
Running setup.py install for wxPython … error
ERROR: Command errored out with exit status 1:
command: ‘c:\python27\python.exe’ -u -c ‘import sys, setuptools, tokenize;
sys.argv[0] = ‘"’"‘c:\users\agent\appdata\local\temp\pip-install-oijdz8\w
xpython\setup.py’"’"’; file=’"’"‘c:\users\agent\appdata\local\temp\pi
p-install-oijdz8\wxpython\setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, op
(compile(code, file, ‘"’"‘exec’"’"’))’ install --record ‘c:\users\agent\appd
ata\local\temp\pip-record-cthc3d\install-record.txt’ --single-version-externally
cwd: c:\users\agent\appdata\local\temp\pip-install-oijdz8\wxpython
Complete output (33 lines):
running install
running build
WARNING: Building this way assumes that all generated files have been
generated already. If that is not the case then use build.py directly
to generate the source and perform the build stage. You can use
–skip-build with the bdist_* or install commands to avoid this
message and the wxWidgets and Phoenix build steps in the future.

"c:\python27\python.exe" -u build.py build
Will build using: "c:\python27\python.exe"
2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)]
Python's architecture is 32bit
cfg.VERSION: 4.1.1

Running command: build
Running command: build_wx
Command '"c:\python27\python.exe" -c "import setuptools, distutils.msvc9comp


iler as msvc; mc = msvc.MSVCCompiler(); mc.initialize(); print(mc.cc)"’ failed w
ith exit code 1.
Traceback (most recent call last):
File “”, line 1, in
File “c:\python27\lib\distutils\msvc9compiler.py”, line 383, in initialize

    vc_env = query_vcvarsall(VERSION, plat_spec)
File "c:\python27\lib\site-packages\setuptools\msvc.py", line 147, in msvc


9_query_vcvarsall
return EnvironmentInfo(arch, ver).return_env()
File “c:\python27\lib\site-packages\setuptools\msvc.py”, line 1227, in ret
urn_env
[self.VCIncludes,
File “c:\python27\lib\site-packages\setuptools\msvc.py”, line 876, in VCIn
cludes
return [os.path.join(self.si.VCInstallDir, ‘Include’),
File “c:\python27\lib\site-packages\setuptools\msvc.py”, line 555, in VCIn
stallDir
raise distutils.errors.DistutilsPlatformError(msg)
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 9.0 is require
d. Get it from http://aka.ms/vcpython27
Finished command: build_wx (0.553s)
Finished command: build (0.553s)
Command ‘“c:\python27\python.exe” -u build.py build’ failed with exit code 1
.
----------------------------------------
ERROR: Command errored out with exit status 1: ‘c:\python27\python.exe’ -u -c ‘i
mport sys, setuptools, tokenize; sys.argv[0] = ‘"’"‘c:\users\agent\appdata\l
ocal\temp\pip-install-oijdz8\wxpython\setup.py’"’"’; file=’"’"‘c:\users
\agent\appdata\local\temp\pip-install-oijdz8\wxpython\setup.py’"’"’;f=get
pip install wxPython==4.1.0