Set up Python tkTable - python

Being very new to Phyton, I’m trying to use tktable for Python and can’t get it run on my PC.
After searching a lot in the net, without finding any solution, I hope you find the time to help me a bit.
I’m sure this is peanuts for you.
I’m running Python 3.7 on a Windows 8.1. PC.
I’m getting this error:
_tkinter.TclError: invalid command name "table"
What I did so far:
Downloaded tktable and run the setup.py.
Copied the tktable.py to the Python site-packages folder.
Installed ActiveTcl.
Copied the three files tktable.tcl, Tktable.dll and pkgIndex.tcl from ActiveTcl (C:\ActiveTcl\lib\Tktable2.11) to C:........\Python\Python37-32\tcll\Tktable2.11.
According what I have found in the net, this should do it…
But, as I wrote, I keep getting the error I mentioned.
Michael
The content is:
C:\Users\mschuppisser.EAD\AppData\Local\Programs\Python\Python37-32\Lib\;
C:\Users\mschuppisser.EAD\AppData\Local\Programs\Python\Python37-32\DLLs\
Traceback:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\mschuppisser.EAD\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:/Users/mschuppisser.EAD/Data/My Data/Python/Test Applikation/Test Applikation.py", line 267, in Jump_to_UebersichtsFenster3
application = clsUebersichtsFenster3(UebersichtsFenster3)
File "C:/Users/mschuppisser.EAD/Data/My Data/Python/Test Applikation/Test Applikation.py", line 447, in __init__
self.table_grid = tktable.Table(UebersichtsFenster3) # , state='disabled', width=50, titlerows=1, rows=5, cols=4, colwidth=20)
File "C:\Users\mschuppisser.EAD\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tktable.py", line 135, in __init__
tkinter.Widget.__init__(self, master, 'table', kw)
File "C:\Users\mschuppisser.EAD\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 2299, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: invalid command name "table"

Related

Using mysql connector with pyinstaller --onefile causes issue at runtime

I am trying to use pyinstaller to create a .exe for someone else to run. The program uses mysql to ping a sql database and return information from it. When I run the program in PyCharm and with pyinstaller --onedir, everything works fine. However, when I bundle the program with --onefile, I get this error and traceback when running:
Traceback (most recent call last):
File "main.py", line 266, in <module>
File "main.py", line 88, in main
File "main.py", line 108, in grabData
File "sql.py", line 12, in SQLconnect
File "mysql\connector\pooling.py", line 286, in connect
File "mysql\connector\connection_cext.py", line 101, in __init__
File "mysql\connector\abstracts.py", line 1095, in connect
File "mysql\connector\connection_cext.py", line 199, in _open_connection
TypeError: argument 6 must be str, not None
For reference, here is the relevant line in the _open_connection function call in connection_cext.py:
self._cmysql = _mysql_connector.MySQL(
buffered=self._buffered,
raw=self._raw,
charset_name=charset_name,
connection_timeout=(self._connection_timeout or 0),
use_unicode=self._use_unicode,
auth_plugin=self._auth_plugin,
plugin_dir=self._plugin_dir,
)
The __init__ of this file has this code snippet:
self._plugin_dir = os.path.join(
os.path.dirname(os.path.abspath(_mysql_connector.__file__)),
"mysql",
"vendor",
"plugin",
)
I believe this plugin directory is the reason my code is failing, but I do not know how to bypass this or set it so that it references the right file at runtime. I know pyinstaller creates a temp file at runtime, but I don't know how to get the module to use it as the plugin directory.
Any help would be greatly appreciated! I really really wanna keep it in --onefile mode for simplicity for the user, so any solutions that maintain that would be ideal. Thanks!

Problem with adding fonts in python script

e, Hi does anyone know, I don't understand how to add my own font for text into some python script for image procesing? I found in code fontlist.txt -> a file that is used as text source. So there I put my .ttf fonts that I downloaded from here: https://www.1001fonts.com/text-fonts.html?page=1&fbclid=IwAR395plHPNmZemLoKmvpedbqRv0z8pUVU66np7LLWzia14GrAKWcZB1H5o4 and then terminal shows me and error :
Traceback (most recent call last):
File "/home/isus/Dokumenti/WET/SynthText-python3/synthgen.py", line 669, in render_text
regions['homography_inv'][ireg])
File "/home/isus/Dokumenti/WET/SynthText-python3/synthgen.py", line 506, in place_text
render_res = self.text_renderer.render_sample(font,collision_mask)
File "/home/isus/Dokumenti/WET/SynthText-python3/text_utils.py", line 414, in render_sample
f_h = self.font_state.get_font_size(font, f_h_px)
File "/home/isus/Dokumenti/WET/SynthText-python3/text_utils.py", line 534, in get_font_size
m = self.font_model[font.name]
KeyError: 'Fabiolo'
Traceback (most recent call last):
File "/home/isus/Dokumenti/WET/SynthText-python3/synthgen.py", line 669, in render_text
regions['homography_inv'][ireg])
File "/home/isus/Dokumenti/WET/SynthText-python3/synthgen.py", line 504, in place_text
font = self.text_renderer.font_state.init_font(font)
File "/home/isus/Dokumenti/WET/SynthText-python3/text_utils.py", line 565, in init_font
font = freetype.Font(fs['font'], size=fs['size'])
OSError: Failed to load font: unknown file format
This 'Fabiolo' is a name of font.
How Failed to load font: unknown file format? I'm using .ttf fonts like they who made a script. Maybe ubuntu supports some certain fonts. I'm using UBUNTU 18.04.
When I use the upper one (fontlist1.txt - mine) there shows an error.
When I use the bottom one (fontlist.txt - originally from script) that works fine everytime.
Here you can see how I add paths and names into fontlist1.txt
I also add the font names like 'Fabiolo', 'Halida Sans', ... into Font Manager but still nothing, shows the same errors.

How do i get rid of' Tkinter.Tcl error- could not recognize data in image file'?

Every time, even though I have the source file, the same error message appears - 'Tcl error...could not recognize data in image file'. The problem also occurs with other images present in my disk drive.
Here is the code:
from tkinter import *
window=Tk()
window.geometry("420x420")
window.title('My first GUI programme')
source='D:\\Desktop\\op.jfif'
icon=PhotoImage(file=source)
window.iconphoto(True, icon)
window.mainloop()
Here goes the error:
PS D:\Documents\pythonProject> & "C:/Program Files (x86)/Python/python.exe" "d:/Documents/pythonProject/Learning python/Practice.py"
Traceback (most recent call last):
File "d:\Documents\pythonProject\Learning python\Practice.py", line 6, in <module>
icon=PhotoImage(file=source)
File "C:\Program Files (x86)\Python\lib\tkinter\__init__.py", line 4064, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "C:\Program Files (x86)\Python\lib\tkinter\__init__.py", line 4009, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize data in image file "D:\Desktop\op.jfif"
I don't know if there is any problem with my code or i need to change any settings. I would be thankful to you if you provide me any assistance.
I managed to do this by changing the file extension and file content of my image file to 'png' which worked in python.
Python Tkinter supports GIF, PGM, PPM, and PNG. So, try changing the extension of the file to one of them
i see your problem
i also have the same problem

idle crashing when I press configure idle

If I go on cmd and write python -m idlelib, that would open IDLE. If I were to then go on configure IDLE, on the cmd, it gives be an error
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\idlelib\editor.py", line 574, in config_dialog
configdialog.ConfigDialog(self.top,'Settings')
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\idlelib\configdialog.py", line 78, in __init__
self.create_widgets()
File "C:\Users\\AppData\Local\Programs\Python\Python38-32\lib\idlelib\configdialog.py", line 113, in create_widgets
self.highpage = HighPage(note)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\idlelib\configdialog.py", line 693, in __init__
self.load_theme_cfg()
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\idlelib\configdialog.py", line 998, in load_theme_cfg
self.paint_theme_sample()
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\idlelib\configdialog.py", line 1279, in paint_theme_sample
self.highlight_sample.tag_config(element, **colors)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 3854, in tag_configure
return self._configure(('tag', 'configure', tagName), cnf, kw)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1627, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: invalid color name "#00224"
I probably have a custom theme with an invalid color, however, how am I supposed to delete it if I can't access it (since it crashes when I do so).
There was a post, Python freezes when configuring IDLE that had I believe the same issue, but all he says as a solution is "manually deleting the faulty theme", which he doesn't explain. Pretty much, I want to access configure IDLE option without it crashing. Once it does crash, the only way I can close it then is by using task manager or restarting my computer.
As solution, you can tell me how to delete a custom theme without using IDLE if that's possible.
If the problem is in a custom theme, then the user configuration file you need to edit is $HOME/.idlerc/config-highlight.cfg. In your case, $HOME, based on the url below, appears to be C:/Users/chess. Just add a digit to make six. You can use the IDLE editor to do so. You should then be able to edit the color properly in the config dialog.
The problem might possibly be a character missing from the defaults file supplied with IDLE:
C:\Users\chess\AppData\Local\Programs\Python\Python38-32\lib\idlelib\config-highlight.def
Thank you for opening IDLE in a console, getting the traceback, and posting all of it. It gave me an idea of how to prevent the crash, so I opened a bug report

tkinter.TclError: invalid command name "table"

Okay, first of all I don't know what is the actual problem here so I couldn't come up with a more accurate title. Maybe some of you can edit it to make it accurate
The following is the minimalised code to reproduce the problem I'm having.
from traybar import SysTrayIcon
from cal import Calendar
import Tkinter
class Add():
def __init__(self,master):
Calendar(master).pack()
def add(systray):
root = Tkinter.Tk()
Add(root)
root.mainloop()
SysTrayIcon("abc.ico","abc", (('Add',None, add), ) ,default_menu_index=0).start()
The cal and the trabar are these files http://tkinter.unpythonic.net/wiki/TkTableCalendar and https://github.com/Infinidat/infi.systray/blob/develop/src/infi/systray/traybar.py respectively.
If you run this, it will make a icon in the system tray of a windows machine with the options Add and Quit. clicking on the app opens up the calender, no problem. Close the calender and click on the Add again. But this time it doesn't open the calendar and throws the following error
`
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 314, in 'calling callback function'
File "C:\Users\Koushik Naskar\AppData\Roaming\Python\Python27\site-packages\traybar.py", line 79, in WndProc
self._message_dict[msg](hwnd, msg, wparam.value, lparam.value)
File "C:\Users\Koushik Naskar\AppData\Roaming\Python\Python27\site-packages\traybar.py", line 276, in _command
self._execute_menu_option(id)
File "C:\Users\Koushik Naskar\AppData\Roaming\Python\Python27\site-packages\traybar.py", line 283, in _execute_menu_option
menu_action(self)
File "C:\Users\Koushik Naskar\Desktop\So\temp.py", line 11, in add
Add(root)
File "C:\Users\Koushik Naskar\Desktop\So\temp.py", line 7, in __init__
Calendar(master).pack()
File "C:\Users\Koushik Naskar\Desktop\So\cal.py", line 66, in __init__
state='disabled', browsecommand=self._set_selection)
File "C:\Python27\lib\lib-tk\tktable.py", line 118, in __init__
Tkinter.Widget.__init__(self, master, 'table', kw)
File "C:\Python27\lib\lib-tk\Tkinter.py", line 2090, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: invalid command name "table"
`
This problem only appears when I use SysTrayIcon with the Calendar.Instead of Calendar if you use simple Tkinter Button or Label etc. this error doesn't appear. Also I can use the Calendar widget normally (without the SysTrayIcon ) in a usual Tkinter GUI as many times as I want, no error occur there. Now I don't have any clue about whats happenning here and how to fix this. What problem does SysTrayIcon have with Calendar and Why the error doesn't happen the first time I open the GUI? Please help.
TkTableCalendar requies the tktable module, which you have installed in lib-tk (3rd party modules usually go into lib/site-packages) as indicated by this part of the traceback.
File "C:\Python27\lib\lib-tk\tktable.py", line 118, in __init__
Tkinter.Widget.__init__(self, master, 'table', kw)
The tktable module requires that your tcl/tk installation have the tktable extension. That extension defines the 'table' widget. It is not part of the standard tcl/tk that is installed with Python on Windows. Hence
_tkinter.TclError: invalid command name "table"
The tktable source code (probably a mixture of tcl and C) is hosted at SourceForge. This page says that it is part of the ActiveState Batteries Included distribution. I don't know if the free version of AS tcl/tk has all the 'batteries'. And I don't know how to replace the tcl/tk installation you already have with a new one. I personally would use an alternative if possible.

Categories