Rfswarm tkinter.tclerror

Hi all,

I’m attempting to get a POC together and am fighting getting rfswarm up and running

when running rfswarm command I seeing the following:-

Robot Framework Swarm: Manager
Version 1.5.0
Configuration File: PATH/venv/lib/python3.10/site-packages/rfswarm_manager/RFSwarmManager.ini
Traceback (most recent call last):
File “PATH/venv/bin/rfswarm”, line 5, in
from rfswarm_manager.rfswarm import RFSwarm
File “PATH/venv/lib/python3.10/site-packages/rfswarm_manager/rfswarm.py”, line 10696, in
core = RFSwarmCore()
File “PATH/venv/lib/python3.10/site-packages/rfswarm_manager/rfswarm.py”, line 2741, in init
base.gui = RFSwarmGUI()
File “PATH/venv/lib/python3.10/site-packages/rfswarm_manager/rfswarm.py”, line 4799, in init
self.set_app_icon()
File “PATH/venv/lib/python3.10/site-packages/rfswarm_manager/rfswarm.py”, line 4838, in set_app_icon
self.icon = tk.PhotoImage(file=icon_file)
File “PATH/.pyenv/versions/3.10.14/lib/python3.10/tkinter/init.py”, line 4103, in init
Image.init(self, ‘photo’, name, cnf, master, **kw)
File “PATH/.pyenv/versions/3.10.14/lib/python3.10/tkinter/init.py”, line 4048, in init
self.tk.call((‘image’, ‘create’, imgtype, name,) + options)
_tkinter.TclError: couldn’t recognize data in image file “PATH/venv/lib/python3.10/site-packages/rfswarm_manager/icons/rfswarm-manager-128.gif”

I’ve attempted uninstalling, reinstalling rfswarm-manager and icons
Resizing, reformating the image, and editing in the rfswarm.py file
I’m running it on a mac (latest)

Anyone else ran into this and could suggest anything,
Cheers
Stu

@damies13 ^ looks like a bug either in your code or in packaging ? There’s no gif files shipped at least with the wheel:

drwxr-xr-x@ 6 rasjani  staff    192 May 23 13:21 ..
-rw-r--r--@ 1 rasjani  staff  10594 May 23 13:21 rfswarm-manager-128.png
drwxr-xr-x@ 7 rasjani  staff    224 May 23 13:21 .
-rw-r--r--@ 1 rasjani  staff  67646 May 23 13:21 rfswarm-manager-128.ico
-rw-r--r--@ 1 rasjani  staff  96395 May 23 13:21 rfswarm-manager-1024.png
-rw-r--r--@ 1 rasjani  staff   6763 May 23 13:21 rfswarm-logo-128.png
-rw-r--r--@ 1 rasjani  staff  67646 May 23 13:21 rfswarm-logo-128.ico

No sorry that was me trying to circumvent the issue, it is png by default

So its a bit unclear what is the actual issue then ? Just getting rfswarm-manager up and running ?

Yes, this is happening when I run rfswarm command

If the error is from your modified code - it would make sense to have the actual traceback from unmodified code ?

However, i did google the error message and there was some references that Tk in some scenarios might not support png ..

Okay, the error is from a clean and happens when it is not altered. Omit the non png image change from above.
That was ab attempt to fit in with it not handling pngs.

There is also conflicting reports that it does and doesn’t support pngs. Hence the change away from png in the initial submission.

The error occurs on a clean install on a Mac.
Trying to run the rfswarm command
To start the gui

Have followed the readme installation instructions regarding manager and agent.

AFAIK Tk might not support PNG on all platforms - at least not directly. I’ve seen some workarounds where PIL has been used to load the png - so i’d still bug @damies13 but i would still attach the real, unmodified stacktrace..

As a side-note that does not seem to relate to the OP’s question, rfswarm-manager doesn’t start on my mac at all, execution gets stuck and there’s a stacktrace on the console:

(venv) rasjani@Janis-MacBook-Pro ~/src/work/client/e2e-testing (aktia-debug)$ rfswarm-manager
Matplotlib is building the font cache; this may take a moment.
/Users/rasjani/src/work/client/e2e-testing/venv/lib/python3.13/site-packages/matplotlib/font_manager.py:1024: EncodingWarning: 'encoding' argument not specified
  with cbook._lock_path(filename), open(filename, 'w') as fh:
Robot Framework Swarm: Manager
	Version 1.5.0
	Configuration File:  /Users/rasjani/src/work/client/e2e-testing/venv/lib/python3.13/site-packages/rfswarm_manager/RFSwarmManager.ini
Traceback (most recent call last):
  File "/Users/rasjani/src/work/client/e2e-testing/venv/bin/rfswarm-manager", line 5, in <module>
    from rfswarm_manager.rfswarm import RFSwarm
  File "/Users/rasjani/src/work/client/e2e-testing/venv/lib/python3.13/site-packages/rfswarm_manager/rfswarm.py", line 10696, in <module>
    core = RFSwarmCore()
  File "/Users/rasjani/src/work/client/e2e-testing/venv/lib/python3.13/site-packages/rfswarm_manager/rfswarm.py", line 2743, in __init__
    self.BuildCore()
    ~~~~~~~~~~~~~~^^
  File "/Users/rasjani/src/work/client/e2e-testing/venv/lib/python3.13/site-packages/rfswarm_manager/rfswarm.py", line 2758, in BuildCore
    self.BuildCorePlan()
    ~~~~~~~~~~~~~~~~~~^^
  File "/Users/rasjani/src/work/client/e2e-testing/venv/lib/python3.13/site-packages/rfswarm_manager/rfswarm.py", line 3314, in BuildCorePlan
    base.addScriptRow()
    ~~~~~~~~~~~~~~~~~^^
  File "/Users/rasjani/src/work/client/e2e-testing/venv/lib/python3.13/site-packages/rfswarm_manager/rfswarm.py", line 2036, in addScriptRow
    base.gui.addScriptRow()
    ~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/rasjani/src/work/client/e2e-testing/venv/lib/python3.13/site-packages/rfswarm_manager/rfswarm.py", line 7886, in addScriptRow
    base.scriptlist[row]["TestVar"].trace("w", self.sr_test_validate)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/tkinter/__init__.py", line 506, in trace_variable
    self._tk.call("trace", "variable", self._name, mode, cbname)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: bad option "variable": must be add, info, or remove

EDIT: above error is because of homebrew that ships with incompatible tk – [ Bug] TclError with PySimpleGUI, Python 3.13 and tcl-tk 9.0.0_1 · Issue #6822 · PySimpleGUI/PySimpleGUI · GitHub

1 Like

Hi Stuart,

As @rasjani said, this looks like a bug related to the installation of tkinter on a Mac. The rfswarm manager should support the rfswarm png icon provided by default on mac OS with python3.10 in use, so this error is probably due to environmental differences, so it’s hard to reproduce it for me.

Can you run python3 -m tkinter to get the tkinter version? Perhaps there are problems with the version that you are currently using.
Have you tried creating a completely new venv with only rfswarm manager installed? Maybe there are some conflicts with other installations.

For a quick workaround, I suggest changing line: 4838 (self.icon = tk.PhotoImage(file=icon_file)) in the rfswarm.py file to:

		image = Image.open(icon_file)
		self.icon = ImageTk.PhotoImage(image)

If you haven’t tried this yet.
Don’t forget to add the import:

from PIL import Image, ImageTk

Finally, as @rasjani suggests, it is a good idea to use the PIL module instead of tkinter to load the rfswarm icon. So you can create an issue on the rfswarm github page for this bug, we would appreciate it.
I will read more about your problem and maybe I can somehow reproduce it or suggest something else.

2 Likes

Hi rasjani,

Yes you are right, your tkinter version no longer supports this deprecated function format:

base.scriptlist[row][‘TestVar’].trace(‘w’, self.sr_test_validate)

A newer version of this line should look something like this:

base.scriptlist[row][‘TestVar’].trace_add(‘write’, self.sr_test_validate)

This syntax no longer works in Tcl/Tk 8.7 and later, so I assume you are using this version or newer, can you verify this for me using the python3 -m tkinter command and send me the information? I would appreciate it.
So the solution to this problem is to update some of the code to the new formats, great find!

Unfortunately a quick workaround at the moment i think is to downgrade tkinter to version 8.6 or older. Or try changing line: 7897 to the new format I wrote earlier. Let me know if that worked for you :slight_smile:

FFS deleted by accident .. message said:

Quick fix would be to switch from homebrew python binary to official release – as the issue is that homebrew ships with newer tkinter than official releases (i think) ..

BUT i was only referring to the trace vs trace_add issue ..

I still feel that using png as default image format might not work on all tkinter installations ..

1 Like

Hey all back in the world of funtioning internet, just saw this thread while waiting for my last flight home, will have a better read and review when i get home later today

3 Likes

Hi Stuart @StuartD,

Ok now I’m back in the world of functioning internet, I’ve had a decent sleep, a coffee, and read this thread on a decent monitor (in stead of skimming it on a phone screen between flights) I can now try to understand the issue.

First and most importantly, are you able to get RFSwarm running on your environment? was it one of the workarounds above that helped?

Second, to help us reproduce your issue, how were you running the RFSwarm Manager? e.g.:

  • Did you install the optional desktop icons and click the icon from your desktop environment?
  • did you just run rfswarm from a command line window? did you pass any optional arguments to the manager?
  • did you launch it some other way?

Also can you confirm:

  • which tkinter version you have (python3 -m tkinter) ?
  • which OS you are running on?

Hopefully we can get this resolved for you quickly,

Dave.

Hi @ArekKuczynski and @rasjani,

Firstly thanks both of you for trying to help while I was away :+1:

From the Python Doc’s:

PhotoImage for images in PGM, PPM, GIF and PNG formats. The latter is supported starting with Tk 8.6.

So as this code is using PhotoImage, I believe a png file should be supported unless it’s a really old version of tk (tk 8.6.0 was released in 2012, and tk 8.6.16 December 2024). If it’s not going to be supported going forward we’ll defiantly need to raise an issue and prepare for this.

I’m not sure if this is a bug or not yet, but this is also not new code from the 1.5 release, this code was part of the 1.4 release so while I am not ruling out it being a bug I’d be surprised it hadn’t shown earlier of it was, since it’s happening on loading of the application’s main ui screen.

Dave.

1 Like

@damies13 and @ArekKuczynski
Sorry just back from holiday, will get the info today for you, thankyou

1 Like

Yeah, the reports about png not being supported where pretty old but there was some recent’ish posts on SO about this so i thought it might be “distribution” issue. For example, i do use homebrew for convenience and it ships with tk thats not even used by official python.

Also, thats why i asked the OP for original stacktrace to clear out what is really going on …

1 Like

@damies13 @ArekKuczynski

So running python3 -m tkinter only returns me this message

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.

Mac OS version Sequoia V15.5

I had also installed the icons.
When I attempt to run it from command line, no additional parameters, I get the original message.
When I attempt via the icons, it appears to acknowledge it’s been clicked but nothing else happens.

I am using homebrew

After suggested code changes
I’ve attempted Arek’s workaround (changing line 4838) and that managed to open a pop up box (nothing loaded in the box).
So pop up opens RFSwarm v1.5.0 - untitled
Scroll bars present but nothing within the GUI, I do have the Mac controls for the GUI, so can select play, stop open new graph.

I still see this pesky message when running rfswarm after editing line 4838, but it does look like a step forward.

Robot Framework Swarm: Manager
Version 1.5.0
Configuration File: /PATH/venv/lib/python3.10/site-packages/rfswarm_manager/RFSwarmManager.ini
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.

Have also made the change for this line (I have it as line 7887)
# base.scriptlist[row][“TestVar”].trace(“w”, self.sr_test_validate)
base.scriptlist[row][“TestVar”].trace_add(“write”, self.sr_test_validate)

Still seeing the same as above with the line 4838 change.

I am now able to get the empty GUI to open with the icons as well as the command line

So just went and installed this on my personal windows machine and all good.
Can now also confirm that on the Mac it isn’t loading any of the parts of the GUI such as the dropdowns etc. but definitely a step forward.

Hi Stuart,

Thanks for confirming the progress. RFSwarm’s UI is dependant on Tk so I’m guessing from these messages that MacOS 15.5 is disabling Tk by default.

Rather than changing the code of RFSwarm, can you try just changing the TK_SILENCE_DEPRECATION=1 as the message suggests? and see if that enables Tk, by running python3 -m tkinter again after changing that setting?

I just checked my Mac it’s also 15.5, and I don’t get these messages, but it’s an old Intel Mac (circa 2018) and has been through many upgrades, so may not have had the deprecation settings applied? It is also using the default python that ships with MacOS, not any homebrew python. As it’s the only Mac I have to test this stuff on, I wanted to keep it stock MacOS as possible.

I also checked the Github runners that are used to test RFSwarm on MacOS, I run with “macos-latest” but that is apparently still 14.7.6, but those are arm. (RFSwarm is pure python so ARM/Intel should make no difference)

My Mac with OS 15.5 seems to be running Tkinter 8.6 and Python 3.9.10, so perhaps the older Tkinter 8.6 is what’s conflicting with the newer python you installed with homebrew. I have seen something similar before, though not as severe where newer python versions installed with homebrew had comparability issues with the default Tk version on MacOS. I just don’t remember how I solved it as it was many years ago.

If changing TK_SILENCE_DEPRECATION=1 doesn’t fix the issue maybe you need to install a newer version of Tk that works with the homebrew’s python.

Did a quick search and found this that seems to indicate that for Python 3 versions homebrew’s python doesn’t include tkinter, but you can use homebrew to install it. I’m not sure what the correct way to do that is, because there different answers including:

  • brew install python-tk
  • brew install tcl-tk followed by brew install python --with-tcl-tk

Hopefully that link helps?

Dave.