View Issue Details

IDProjectCategoryView StatusLast Update
0017096ScribusOS-MacOSXpublic2024-01-20 15:54
Reporterale Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Product Version1.7.0.svn 
Summary0017096: include tkinter in the dmg
Descriptionit would be useful to include tkinter in the dmg files.

it's used by script distributed with scribus itself and is the most common way to create a UI in scribus scripts.

since it's included in most software distributed with / for python, i think that it should be documented how to do it.
TagsNo tags attached.
PatchNo

Relationships

has duplicate 0017116 closedcbradney Bug im Kalender Widget 

Activities

cbradney

2023-12-28 15:31

administrator   ~0050707

Ale, I think you experimented with Pyside and Qt for Python? I would much prefer we move to that.

ale

2023-12-28 17:12

manager   ~0050708

i'd love to do so, and i will have a look at it again.

but you will then have to provide pyside6... which is probably harder than tkinter.

personally, i used to hate tk and have now mixed feelings about it:

- it's (almost) everywhere, where python is: that's handy.
- it's trivial to do simple things (but bigger things get hard/ugly rather fast)
- i used to have a real ugly look... it's somehow ok on my computer now.

ale

2023-12-28 19:46

manager   ~0050710

i digged into it:

- debian (and ubuntu) do not have pyside6
- i've installed pyside6 in a venv and started scribus from inside of it.
- In the scripter console, pyside6 is correctly detected:
      import PySide6
      print(PySide6.__version__)
  gives
      6.6.1
- but showing a dialog fails at the import line:
      from PySide6.QtWidgets import QApplication, QWidget
  gives
      ImportError: /home/ale/src/scribus-pyside6/venv/lib/python3.11/site-packages/PySide6/libpyside6.abi3.so.6.6: undefined symbol: _ZN9QMetaType14registerHelperEPKN9QtPrivate18QMetaTypeInterfaceE, version
Qt_6`
- `python3 a_widget.py` correctly shows the empty widget.
- it might be possible to find a way to get it to work but i wonder if it's worth the effort.

somehow, i'd prefer to build a new scripter with solid bases that are somehow the state of the art.

i went back to my pybind11-playground and added a new test folder for pyside6:

https://github.com/aoloe/cpp-pybind11-playground/tree/master/eval-file-pyside6

it does correctly work.

the next step would be to try to update

https://github.com/aoloe/scribus-plugin-scripter-pybind11

to use pyside6. but scrolling through the tickets in that repository, gives me some doubts about how easy it will be to get c++ and python to use the same objects.

the fact that pyside6 is not packaged for debian is not so nice... but there might be ways to get it to work.

and https://github.com/pybind/pybind11/issues/1702 is still not solved... but i want to test it with pyside6... maybe qt did some magic and it does not happen anymore : - )

ale

2023-12-28 20:26

manager   ~0050711

... the issue about importing twice qt into python might be solved with the latest pyside11 and the current pyside6...

cbradney

2023-12-29 18:19

administrator   ~0050714

I'm including the entire python rebuit via https://github.com/gregneagle/relocatable-python .. so maybe Tk is included.. unsure

ale

2023-12-30 16:13

manager   ~0050715

https://docs.python.org/3/library/tkinter.html#module-tkinter

says that "The official Python binary release bundles Tcl/Tk 8.6 threaded. "

i cannot really say if the scripts in the repository you are using are pulling that official binary, but it's possible that it is.

This is the image:

https://www.python.org/ftp/python/3.12.1/

i've managed to unpack it with 7rar and it does not look like it contains much more than pyhton itself (which i could not find) and pip.

cbradney

2023-12-30 21:15

administrator   ~0050717

/Python.framework/Versions/3.11/lib include tcl8.8 and tk8.6 libs

ale

2023-12-31 06:30

manager   ~0050718

and what happens when you run

python -m tkinter

as described in the python documentation linked above?

... i'm asking for a friend...

cbradney

2023-12-31 10:14

administrator   ~0050720

I don't know how to set all the environment variables properly, however I managed to get it to start from within my dmg:

PYTHONPATH=/Volumes/Scribus/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11 python3 -m tkinter

DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning.
And I had a popup GUI based window with a Click Me and Quit button.

ale

2023-12-31 10:56

manager   ~0050721

mmm strange

https://www.python.org/download/mac/tcltk/#tcl-tk-releases

says that tcl/tk should be included.

are you sure that you're using python 3.11 from the Scribus.app folder?

i would launch it as /Volumes/Scribus/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/python3 (if python3 is in the 3.11/ folder)

cbradney

2023-12-31 11:48

administrator   ~0050722

Hmm no, you're right, but calling it directly means it doesn't find the files from the Scribus installation. They are definitely there:
 ls /Volumes/Scribus/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/tcl8.6
auto.tcl encoding http1.0 msgs package.tcl safe.tcl tclIndex word.tcl
clock.tcl history.tcl init.tcl opt0.4 parray.tcl tclAppInit.c tm.tcl

It does not want to find that init.tcl though.

PYTHONPATH=/Volumes/Scribus/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/ PYTHONHOME=/Volumes/Scribus/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/ /Volumes/Scribus/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/bin/python3 -m tkinter
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Volumes/Scribus/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/tkinter/__main__.py", line 7, in <module>
    main()
  File "/Volumes/Scribus/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/tkinter/__init__.py", line 4618, in _test
    root = Tk()
           ^^^^
  File "/Volumes/Scribus/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/tkinter/__init__.py", line 2326, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
    /Library/Frameworks/Python.framework/Versions/3.11/lib/tcl8.6 /Volumes/Scribus/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/Resources/Python.app/Contents/lib/tcl8.6 /Volumes/Scribus/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/Resources/Python.app/lib/tcl8.6 /Volumes/Scribus/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/Resources/Python.app/Contents/library /Volumes/Scribus/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/Resources/Python.app/library /Volumes/Scribus/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/Resources/Python.app/tcl8.6.13/library /Volumes/Scribus/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/Resources/tcl8.6.13/library

cbradney

2023-12-31 13:48

administrator   ~0050723

After fixing some rpaths, i now get this from scripter console:
print(sys.path)
import tkinter
tkinter.TkVersion
-----
['/Applications/Scribus.app/Contents/share/scribus/scripts/', '/Applications/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python311.zip', '/Applications/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11', '/Applications/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/lib-dynload', '/Applications/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages']
8.6


So tkinter is now loading from console. :)


However, running tk based scripts from the Scribus menu still get errors like:

Traceback (most recent call last):
  File "<string>", line 11, in <module>
  File "<string>", line 1577, in <module>
  File "<string>", line 1562, in main_wrapper
  File "<string>", line 1551, in main
  File "<string>", line 1544, in initialisation
  File "<string>", line 1512, in setup_tk
  File "/Applications/Scribus.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/tkinter/__init__.py", line 2326, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
    /Library/Frameworks/Python.framework/Versions/3.11/lib/tcl8.6 /usr/lib/tcl8.6 /lib/tcl8.6 /usr/library /library /tcl8.6.13/library /tcl8.6.13/library



This probably means that Tcl wasn't installed properly.

ale

2023-12-31 15:45

manager   ~0050724

i think that you are on a good path...

... i wonder if it wouldn't be worth to open a ticket on

https://github.com/gregneagle/relocatable-python

and ask there if somebody has a clue about getting tk to work with that relocatable python.

Issue History

Date Modified Username Field Change
2023-12-28 09:17 ale New Issue
2023-12-28 15:31 cbradney Note Added: 0050707
2023-12-28 17:12 ale Note Added: 0050708
2023-12-28 19:46 ale Note Added: 0050710
2023-12-28 20:26 ale Note Added: 0050711
2023-12-29 18:19 cbradney Note Added: 0050714
2023-12-30 16:13 ale Note Added: 0050715
2023-12-30 21:15 cbradney Note Added: 0050717
2023-12-31 06:30 ale Note Added: 0050718
2023-12-31 10:14 cbradney Note Added: 0050720
2023-12-31 10:56 ale Note Added: 0050721
2023-12-31 11:48 cbradney Note Added: 0050722
2023-12-31 13:48 cbradney Note Added: 0050723
2023-12-31 15:45 ale Note Added: 0050724
2024-01-20 15:54 jghali Relationship added has duplicate 0017116