Bug 157624 - Add tkinter to LibreOffice's Python Interpreter
Summary: Add tkinter to LibreOffice's Python Interpreter
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: framework (show other bugs)
Version:
(earliest affected)
7.6.1.2 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL: https://forum.openoffice.org/en/forum...
Whiteboard:
Keywords: needsDevAdvice
Depends on:
Blocks: Macro-Python
  Show dependency treegraph
 
Reported: 2023-10-05 21:29 UTC by tomekluke
Modified: 2024-02-10 16:47 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tomekluke 2023-10-05 21:29:27 UTC
Description:
tkinter works beautifully under LibreOffice. It can be used in Linux without any problem (Linux LibreOffice uses system Python interpreter if LibreOffice is installed using packaging system like deb/rpm). But on Windows, Mac and LibreOffice installed in Linux using e.g. flatpak, LibreOffice has its own Python interpreter packaged. This interpreter is missing tkinter. Other Python packages can be added using pip but not tkinter. If tkinter is not a part of a Python interpreter, there is no way to add it later.

Steps to Reproduce:
1. there is no way to add tkinter to LibreOffice Python interpreter

Actual Results:
tkinter works nicely but can not be added

Expected Results:
tkinter should be the default part of the packaged Python interpreter


Reproducible: Always


User Profile Reset: No

Additional Info:
It is very sad that there are very limited possibilities regarding GUI frameworks in Python in LibreOffice. Only UNO dialogs really work. Under Linux, tkinter works without problems but it can not be used on Windows/Mac/Linux with LO installed using flatpak.
Also PyQT and PySide actually work very nicely! But after closing a PyQT window, LibreOffice always crashes (new versions of LO. In older versions of LO, PyQT/PySide just worked).
Many other GUI frameworks do not work under LibreOffice (I tested Dear PyGUI, Toga, PySimpleGUI, wxPython, Kivy, Pywebview). It is interesting that many of them actually work but only after closing a window, the whole LibreOffice freezes or crashes or the window can not be closed (destroy method does not work).
So, there are really no options, just UNO dialog windows and forms which are unknown to almost all Pythonists.
Comment 1 Roman Kuznetsov 2023-10-09 19:36:36 UTC
I think it's an enhancement, but not a bug

Would be interesting to know why LO's python has no tkinter from the box...

Andreas, Alain, maybe you have some opinion here?
Comment 2 Roman Kuznetsov 2023-10-14 07:40:28 UTC
Taichi, may be you have some opinion here (I asked because you added bz2 module to our internal Python)
Comment 3 Alain Romedenne 2023-10-27 14:31:23 UTC
It is definitely an enhancement request, instead of a bug.

tkinter is not natively linked to UNO API, whereas the Basic dialog editor is. Python editors are not - easily - linked to LibreOffice either.

I foresee a limited community of coders that may be interested in such enhancements.

Workaround for : 
- LibreOffice embedded Python path can be added to native Python path in order to benefit from UNO API if need be.
- Native Python path can be prepended to LibreOffice Python path to benefit from tkinter.

However such setups may hardly benefit to standard - that is non-scripters -  users unless some automated startup would accompany tkinter-dependant apps inside LibreOffice.
Comment 4 tomekluke 2023-10-27 15:09:12 UTC
Hi, I am just a member of the "limited comunity of coders". Actually, I think that the whole Python scripting in LO is something that is only used by a limited community of coders.

But whenever I see anyone coding in Python in LO and they need to add any GUI, they look for tkinter. And no wonder, because it is super easy to use and is a part of every standard Python installation (but not in LO). Here someone was asking this in 2010: https://forum.openoffice.org/en/forum/viewtopic.php?t=31426

Here is an issue from 2004 already mentioning this:
https://bz.apache.org/ooo/show_bug.cgi?id=30349

Not having tkinter could deterr some Python devs because it is not so easy to create a UNO dialog with listeners etc. comparing to tkinter which is immediately known to Pythonists.