1

Im trying to write a program with tkinter that shows a custom cursor in some context.

In code I did main['cursor'] = "@cursor.cur" and this works as expect when running the script or when running the executable packed with pyinstaller. But when --onefile is checked in pyinstaller, running the executable outputs _tkinter.TclError: bad cursor spec "@cursor.cur", so most likely pyinstaller didn't put the .cur file where tkinter expects it.

So my question is how to include custom tkinter cursor when bundling with pyinstaller --onefile, and also what is the purpose of '@' in main['cursor'] = "@cursor.cur"?

Edit: I've already added ('cursor.cur', '.') in the spec file, how do I use the .cur from _MEIPASS?

goldenotaste
  • 302
  • 2
  • 11
  • 1
    Does this answer your question? [How do I include files with pyinstaller?](https://stackoverflow.com/questions/53587322/how-do-i-include-files-with-pyinstaller) – acw1668 Dec 31 '20 at 02:06
  • Without "@" in the string, it will refer to the system provided cursor with that name. – acw1668 Dec 31 '20 at 02:09
  • @acw1668 sorry I didn't include it in the original post, the .spec already includes the cursor file, but how do I get tkinter to read it? I used the method you linked to include images in the executable, but Im not sure how to apply the same method for cursor since setting the cursor for the window doesn't take a absolute file path right? – goldenotaste Dec 31 '20 at 02:16
  • 1
    You can pass an absolute path, but replace all "\" by "/": i.e. "@/path/to/cursor.cur". – acw1668 Dec 31 '20 at 02:37
  • 1
    Thanks! replacing the slashes fixed it. – goldenotaste Dec 31 '20 at 03:57

0 Answers0