Tkinter doesn't work with the python plugin

Full code example: https://github.com/argosopentechnologies/snapcraft-tkinter

I’m having trouble getting a Python/Tkinter app to run in a snap container. The python3-tk package isn’t included with python and can’t be installed with pip. When python3-tk is added as a stage-package like this:

parts:
  snapcraft-tkinter:
    plugin: python
    python-version: python3
    source: .
    stage-packages:
      - python3-tk

and you attempt to run a python program that uses tkinter you get this error:

Traceback (most recent call last):
  File "/snap/snapcraft-tkinter/x1/bin/snapcraft-tkinter", line 5, in <module>
    app.main()
  File "/snap/snapcraft-tkinter/x1/lib/python3.6/site-packages/tkinter_demo/app.py", line 7, in main
    window = Tk()
  File "/snap/snapcraft-tkinter/x1/usr/lib/python3.6/tkinter/__init__.py", line 2023, 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: 
    /usr/share/tcltk/tcl8.6 /snap/snapcraft-tkinter/x1/usr/lib/tcl8.6 /snap/snapcraft-tkinter/x1/lib/tcl8.6 /snap/snapcraft-tkinter/x1/usr/library /snap/snapcraft-tkinter/x1/library /snap/snapcraft-tkinter/x1/tcl8.6.8/library /snap/snapcraft-tkinter/tcl8.6.8/library



This probably means that Tcl wasn't installed properly.

This is because the tcl library ends up in the wrong place in the snap. You are able to set the TCL_Library environment variable like this:

apps:
  snapcraft-tkinter: 
    command: bin/snapcraft-tkinter
    environment:
      TCL_LIBRARY: "$SNAP/usr/share/tcltk/tcl8.6"

However the documentation says that using this variable is a “last resort” workaround: https://wiki.tcl-lang.org/page/TCL_LIBRARY . If you add the environment variable then you are able to create a window with tkinter like this:

window = Tk()
window.title("Snapcraft Tkinter Demo")
window.mainloop()

If you try to add any elements to the window like this:

my_scrolledtext = ScrolledText(window, width=10, height=10)
my_scrolledtext.grid(column=0, row=0)

you get “Segmentation fault (core dumped)”. I’m not sure if this is something wrong with the python snapcraft plugin, The way you add python3-tk as a dependency, something with tkinter, or me doing something wrong? Any ideas/workarounds?

Similar forum posts:

  • “_tkinter.TclError: Can’t find a usable init.tcl in the following directories”
  • “Tkinter missing from Python stdlib”
  • “Tkinter missing from Python stdlib”

Thanks for any help!

Edit:
Working example here

Thanks everyone for the help!

The easiest way around this is to use the Layout feature. Specifically, add the following top-level yaml to your snapcraft.yaml:

layout:
  /usr/share/tcltk:
    bind: $SNAP/usr/share/tcltk
1 Like

Thanks for replying, I didn’t know about the layout feature! I tried adding this to my snapcraft.yml:

layout:
  /usr/share/tcltk:
    bind: $SNAP/usr/share/tcltk
  /usr/lib/tcltk:
    bind: $SNAP/usr/lib/tcltk

Trying to run this I get this error:

Traceback (most recent call last):
  File "/snap/snapcraft-tkinter/x1/bin/snapcraft-tkinter", line 5, in <module>
    app.main()
  File "/snap/snapcraft-tkinter/x1/lib/python3.6/site-packages/tkinter_demo/app.py", line 7, in main
    window = Tk()
  File "/snap/snapcraft-tkinter/x1/usr/lib/python3.6/tkinter/__init__.py", line 2023, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display ":0"

If I try to scan the logs of the snap like this:

sudo snappy-debug.security scanlog

then I get this in the logs:

= AppArmor =
Time: Apr 13 15:55:03
Log: apparmor="DENIED" operation="connect" profile="snap.snapcraft-tkinter.snapcraft-tkinter" pid=16050 comm="python3" family="unix" sock_type="stream" protocol=0 requested_mask="send receive connect" denied_mask="send connect" addr=none peer_addr="@/tmp/.X11-unix/X0" peer="unconfined"

If I add this to my snapcraft.yml:

plugs:
  - system-backup
  - log-observe
  - x11

then the snap starts segfaulting and if I run it with gbd like this:

snap run --gdb snapcraft-tkinter

I get this error again:

Traceback (most recent call last):
  File "/snap/snapcraft-tkinter/x1/bin/snapcraft-tkinter", line 5, in <module>
    app.main()
  File "/snap/snapcraft-tkinter/x1/lib/python3.6/site-packages/tkinter_demo/app.py", line 7, in main
    window = Tk()
  File "/snap/snapcraft-tkinter/x1/usr/lib/python3.6/tkinter/__init__.py", line 2023, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display ":0"

and this in the logs:

= AppArmor =
Time: Apr 13 16:01:35
Log: apparmor="DENIED" operation="capable" profile="snap.snapcraft-tkinter.snapcraft-tkinter" pid=17989 comm="python3" capability=2  capname="dac_read_search"
Capability: dac_read_search
Suggestions:
* adjust program to not require 'CAP_DAC_READ_SEARCH' (see 'man 7 capabilities')
* add one of 'system-backup' to 'plugs'
* do nothing if program otherwise works properly

Anyone have any solutions/workarounds?

Just to make sure, have all plugs been connected?

snap connections snapcraft-tkinter
1 Like
>snap connections snapcraft-tkinter
Interface      Plug                             Slot  Notes
log-observe    snapcraft-tkinter:log-observe    -     -
system-backup  snapcraft-tkinter:system-backup  -     -
x11            snapcraft-tkinter:x11            :x11  -

Is the issue that snapcraft-tkinter:system-backup isn’t connected to a slot?

Yes, probably. Many plugs do not auto-connect by default. End-users have to connect them explicitly or you have to request auto-connection for your snap.

Try to connect:

sudo snap connect snapcraft-tkinter:log-observe
sudo snap connect snapcraft-tkinter:system-backup
1 Like

Even after adding these plugs manually it still segfaults just without throwing an error in the logs.

>sudo snappy-debug.security scanlog
Interface      Plug                             Slot            Notes
log-observe    snapcraft-tkinter:log-observe    :log-observe    manual
ssh-keys       snapcraft-tkinter:ssh-keys       :ssh-keys       manual
system-backup  snapcraft-tkinter:system-backup  :system-backup  manual
x11            snapcraft-tkinter:x11            :x11  

and in snapcraft.yml

apps:
  snapcraft-tkinter: 
    command: bin/snapcraft-tkinter
    environment:
      TCL_LIBRARY: "$SNAP/usr/share/tcltk/tcl8.6"
    plugs:
      - system-backup
      - log-observe
      - ssh-keys
      - x11

I understand the AppArmor problem is gone, but you still have this problem:

  File "/snap/snapcraft-tkinter/x1/usr/lib/python3.6/tkinter/__init__.py", line 2023, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display ":0"

Does adding the x11 plug help?~
I was looking at your snapcraft.yaml file on GitHub which hasn’t been updated, sorry.

apps:
  snapcraft-tkinter: 
    command: bin/snapcraft-tkinter
    plugs: [x11]

There are working examples of Tkinter snaps on GitHub (search “snapcraft.yaml Tkinter”). Here is an example:

1 Like

Thanks for getting back to me!

My understanding of the snapcraft.yml you linked is that it is removing the tkinter library instead of installing it using the filesets feature. I’ve been unable to find a working example of a snap using tkinter, and I think it may just be an unresolved bug in tkinter or snapcraft.

I found this bug description which seems to describe the same thing: https://bugs.launchpad.net/snapcraft/+bug/1847321.

Indeed, this specific snap seems to be removing lots of libraries, including usr/lib/python*/tkinter. Yet I was able to find quite a few examples that appear to be working, for example:

What they seem to have in common at first sight:

    stage-packages: [python3-tk,fontconfig-config,fonts-dejavu-extra]
    plugs: [desktop, home, x11, unity7]

I don’t really have prior experience with Python/Tkinter snaps as you have probably understood by now - an I’m sorry about that - yet it may be worth starting from these examples.

This works:
https://github.com/DimitriPapadopoulos/snapcraft-tkinter

Given four of the above links involved me, I’ll chime in. I never did solve my problem regarding typing in a different keyboard layout (e.g. Cyrillic). Besides that, I think it prosakart was working pretty well as a tkinter application. Good luck.

@dimitri I couldn’t get this to work on my computer, when I ran it I got the same segfault.

Thanks for pointing this out, I checked out this application and it seems to be a tkinter application working in a snap. Unfortunately, they didn’t include their snapcraft.yml file so I asked for them to include it here.

I’ve put the snapcraft.yaml file up. See it here:

1 Like

I don’t get a segfault but I noticed the application windows is very small so it might depend on the graphical environment, for example the window manager. Here is what I see on my Ubuntu 20.04 workstation:

$ git clone https://github.com/DimitriPapadopoulos/snapcraft-tkinter.git
[...]
$ 
$ cd snapcraft-tkinter
$ 
$ snap --version
snap    2.44.3+20.04
snapd   2.44.3+20.04
series  16
ubuntu  20.04
kernel  5.4.0-25-generic
$ 
$ snapcraft 
Launching a VM.
error: no changes of type "auto-refresh" found                                  
snap "snapd" has no updates available
Hit http://archive.ubuntu.com/ubuntu bionic InRelease
[...]
Successfully installed Snapcraft-Tkinter-Demo-1.0
/root/stage/usr/bin/python3 setup.py --no-user-cfg install --single-version-externally-managed --user --record install.txt
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: option --single-version-externally-managed not recognized
Cleaning later steps and re-staging snapcraft-tkinter ('build' step changed)
Priming snapcraft-tkinter 
Snapping 'snapcraft-tkinter' /                                                                                       
Snapped snapcraft-tkinter_1.0_amd64.snap
$ 
$ sudo snap install --devmode ./snapcraft-tkinter_1.0_amd64.snap 
snapcraft-tkinter 1.0 installed
$ 
$ /snap/bin/snapcraft-tkinter 
Fontconfig warning: "/etc/fonts/fonts.conf", line 5: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/fonts.conf", line 6: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/fonts.conf", line 6: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/fonts.conf", line 6: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/fonts.conf", line 7: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/fonts.conf", line 7: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/fonts.conf", line 9: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/10-hinting-slight.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/10-hinting-slight.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/10-hinting-slight.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/10-hinting-slight.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/10-hinting-slight.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/10-hinting-slight.conf", line 6: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/10-hinting-slight.conf", line 8: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 6: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 8: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 6: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 8: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/20-unhint-small-vera.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/20-unhint-small-vera.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/20-unhint-small-vera.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/20-unhint-small-vera.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/20-unhint-small-vera.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/20-unhint-small-vera.conf", line 6: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/20-unhint-small-vera.conf", line 8: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/30-metric-aliases.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/30-metric-aliases.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/30-metric-aliases.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/30-metric-aliases.conf", line 6: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 8: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/40-nonlatin.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/40-nonlatin.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/40-nonlatin.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/40-nonlatin.conf", line 6: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 8: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/45-generic.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/45-generic.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/45-generic.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/45-generic.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/45-generic.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/45-generic.conf", line 6: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/45-generic.conf", line 8: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/45-latin.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/45-latin.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/45-latin.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/45-latin.conf", line 6: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 8: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/49-sansserif.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/49-sansserif.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/49-sansserif.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/49-sansserif.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/49-sansserif.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/49-sansserif.conf", line 6: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/49-sansserif.conf", line 8: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/50-user.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/50-user.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/50-user.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/50-user.conf", line 6: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 8: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/51-local.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/51-local.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/51-local.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/51-local.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/51-local.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/51-local.conf", line 6: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/51-local.conf", line 8: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/60-generic.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/60-generic.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/60-generic.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/60-generic.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/60-generic.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/60-generic.conf", line 6: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/60-generic.conf", line 8: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/60-latin.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/60-latin.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/60-latin.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/60-latin.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/60-latin.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/60-latin.conf", line 6: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/60-latin.conf", line 8: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/65-fonts-persian.conf", line 34: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/65-fonts-persian.conf", line 35: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/65-fonts-persian.conf", line 35: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/65-fonts-persian.conf", line 35: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/65-fonts-persian.conf", line 36: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/65-fonts-persian.conf", line 36: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/65-nonlatin.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/65-nonlatin.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/65-nonlatin.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/65-nonlatin.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/65-nonlatin.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/65-nonlatin.conf", line 6: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/65-nonlatin.conf", line 8: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/69-unifont.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/69-unifont.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/69-unifont.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/69-unifont.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/69-unifont.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/69-unifont.conf", line 6: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/70-no-bitmaps.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/70-no-bitmaps.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/70-no-bitmaps.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/70-no-bitmaps.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/70-no-bitmaps.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/70-no-bitmaps.conf", line 6: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/70-no-bitmaps.conf", line 8: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/80-delicious.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/80-delicious.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/80-delicious.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/80-delicious.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/80-delicious.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/80-delicious.conf", line 6: invalid attribute 'version'
Fontconfig warning: "/etc/fonts/conf.d/90-synthetic.conf", line 4: unknown element "its:rules"
Fontconfig warning: "/etc/fonts/conf.d/90-synthetic.conf", line 5: unknown element "its:translateRule"
Fontconfig error: "/etc/fonts/conf.d/90-synthetic.conf", line 5: invalid attribute 'translate'
Fontconfig error: "/etc/fonts/conf.d/90-synthetic.conf", line 5: invalid attribute 'selector'
Fontconfig error: "/etc/fonts/conf.d/90-synthetic.conf", line 6: invalid attribute 'xmlns:its'
Fontconfig error: "/etc/fonts/conf.d/90-synthetic.conf", line 6: invalid attribute 'version'
Fontconfig error: Cannot load config file from /etc/fonts/fonts.conf

Here is the resulting small window:
small_window

After resizing it:
resize

This error:

error: option --single-version-externally-managed not recognized

has been fixed with:
https://github.com/DimitriPapadopoulos/snapcraft-tkinter/commit/66dca18

Note that the tcltk-launch launcher is bundled with the resulting snap:

$ ls /snap/snapcraft-tkinter/current/bin
debian-multiarch-triplet-provider-launch
snapcraft-tkinter
tcltk-launch
$ 

Note sure what tcltk-launch is needed for and whether the steps described here are required:


The demo works for me without these steps.

1 Like

FWIW, it crashed for me due to fontconfig issues. This can be handled easily using the snapraft-desktop-helpers, or the gnome-3-28 / gnome-3-34 extensions, to setup the correct environment. This worked for me:

diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index dfb0e9e..1b279b7 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -19,12 +19,9 @@ apps:
   python-tkinter-skeleton:
     environment:
       LC_ALL: C.UTF-8
-      LIBGL_DRIVERS_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/dri
       PATH: $SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH
-      LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu
-      LD_LIBRARY_PATH: $SNAP/usr/lib:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
-      LD_LIBRARY_PATH: $SNAP_LIBRARY_PATH:$LD_LIBRARY_PATH
       TCL_LIBRARY: $SNAP/usr/share/tcltk/tcl8.6:$TCL_LIBRARY:$TK_LIBRARY
       TK_LIBRARY: $SNAP/usr/share/tcltk/tk8.6:$TK_LIBRARY:$TCL_LIBRARY
     command: bin/skeleton
+    extensions: [gnome-3-34]
     plugs: [home, x11, unity7]

I don’t think gtk/gnome is required in this case, but maybe it’s worth considering a `desktop-common’ extension to enable the common fixups?

1 Like

@dimitri this runs for me thanks!

1 Like