Posts: 18
Threads: 2
Joined: Jan 2020
Jan-21-2020, 07:41 PM
(This post was last modified: Jan-21-2020, 07:51 PM by buran.)
Hi, I've been trying to make a GUI interface which is updatable and connected to SQLite however I'm receiving the following error:
TypeError: 'Table' object is not callable
It may be a stupid error but I'm below even a novice with this kinda stuff so any help would be greatly appreciated to get the program working again! :)
from msilib.schema import ListBox
from tkinter import *
from matplotlib.pyplot import grid
# Create Window Object
window = Tk()
# Define table contents (each row/column)
l1 = Label(window, text="Name")
l1.grid(row=0, column=0)
l1 = Label(window, text="Monthly Income")
l1.grid(row=1, column=0)
l1 = Label(window, text="Monthly Budget")
l1.grid(row=2, column=0)
l1 = Label(window, text="Monthly Expenses")
l1.grid(row=3, column=0)
# Define Entries
name_text = StringVar()
e1 = Entry(window, textvariable=name_text)
e1.grid(row=0, column=1)
Monthly_Income_text = StringVar()
e2 = Entry(window, textvariable=Monthly_Income_text)
e2.grid(row=0, column=2)
Monthly_Budget = StringVar()
e3 = Entry(window, textvariable=Monthly_Budget)
e3.grid(row=0, column=3)
Monthly_Expenses = StringVar()
e4 = Entry(window, textvariable=Monthly_Expenses)
e4.grid(row=0, column=4)
# Define ListBox
list1 = ListBox(window, height=35, width=35)
list1.grid(row=2, column=0, columnspan=2)
# Attach scrollbar to the list
sb1 = Scrollbar(window)
sb1.grid(row=2, column=2, rowspan=6)
list1.configure(yscrollcommand=sb1.set)
sb1.configure(command=list1.yview)
# Define buttons
b1 = Button(window, text="View All", width=12)
b1 = grid(row=2, column=3)
b1 = Button(window, text="Search Entry", width=12)
b1 = grid(row=3, column=3)
b1 = Button(window, text="Add Entry", width=12)
b1 = grid(row=4, column=3)
b1 = Button(window, text="Update Selected", width=12)
b1 = grid(row=5, column=3)
b1 = Button(window, text="Delete Selected", width=12)
b1 = grid(row=6, column=3)
b1 = Button(window, text="Close", width=12)
b1 = grid(row=7, column=3)
window.mainloop()
Posts: 8,165
Threads: 160
Joined: Sep 2016
Please, post full traceback in error tags
Posts: 18
Threads: 2
Joined: Jan 2020
Here is the full traceback error:
Traceback (most recent call last):
File "C:/Users/name/Desktop/python", line 38, in <module>
list1 = ListBox(window, height=35, width=35)
TypeError: 'Table' object is not callable
This is about all PyCharm shows me, like I said I'm incredibly new to Python and programming in general so if anything else is needed please let me know.
Posts: 8,165
Threads: 160
Joined: Sep 2016
Jan-21-2020, 08:18 PM
(This post was last modified: Jan-21-2020, 08:19 PM by buran.)
I am on linux and cannot check what is in msilib.schema (which is Windows specific). But in any case you don't need to import ListBox from msilib.schema.
You need a tkinter.Listbox widget. So just remove the first import and fix ListBox to Listbox.
Ignore that example is with Capital T - that is python2.
Posts: 18
Threads: 2
Joined: Jan 2020
Umm, so I did what you said and it doesn't show any running errors for the list however the traceback error has just imploded, cause its saying line 261 etc for some things I'm assuming its a plugin error? Also should the tkinter.Listbox widget not be loading into my program as the 'from tkinter import *' should automatically use all installed versions? (I did also install all of the tkinter addons available to PyCharm)
"C:\Users\jumbu\Desktop\CT4021 Introduction to Programming Fundamentals Assignment 001\venv\Scripts\python.exe" "C:/Users/jumbu/Desktop/python/test.py"
Traceback (most recent call last):
File "C:/Users/jumbu/Desktop/python/test.py", line 49, in <module>
b1 = grid(row=2, column=3)
File "C:\Users\jumbu\Desktop\python\venv\lib\site-packages\matplotlib\pyplot.py", line 2601, in grid
return gca().grid(b=b, which=which, axis=axis, **kwargs)
File "C:\Users\jumbu\Desktop\python\venv\lib\site-packages\matplotlib\axes\_base.py", line 2785, in grid
self.xaxis.grid(b, which=which, **kwargs)
File "C:\Users\jumbu\Desktop\python\venv\lib\site-packages\matplotlib\axis.py", line 1477, in grid
**gridkw)
File "C:\Users\jumbu\Desktop\python\venv\lib\site-packages\matplotlib\axis.py", line 874, in set_tick_params
kwtrans = self._translate_tick_kw(kw)
File "C:\Users\jumbu\Desktop\python\venv\lib\site-packages\matplotlib\axis.py", line 941, in _translate_tick_kw
% (key, kwkeys))
ValueError: keyword grid_row is not recognized; valid keywords are ['size', 'width', 'color', 'tickdir', 'pad', 'labelsize', 'labelcolor', 'zorder', 'gridOn', 'tick1On', 'tick2On', 'label1On', 'label2On', 'length', 'direction', 'left', 'bottom', 'right', 'top', 'labelleft', 'labelbottom', 'labelright', 'labeltop', 'labelrotation', 'grid_agg_filter', 'grid_alpha', 'grid_animated', 'grid_antialiased', 'grid_clip_box', 'grid_clip_on', 'grid_clip_path', 'grid_color', 'grid_contains', 'grid_dash_capstyle', 'grid_dash_joinstyle', 'grid_dashes', 'grid_drawstyle', 'grid_figure', 'grid_fillstyle', 'grid_gid', 'grid_in_layout', 'grid_label', 'grid_linestyle', 'grid_linewidth', 'grid_marker', 'grid_markeredgecolor', 'grid_markeredgewidth', 'grid_markerfacecolor', 'grid_markerfacecoloralt', 'grid_markersize', 'grid_markevery', 'grid_path_effects', 'grid_picker', 'grid_pickradius', 'grid_rasterized', 'grid_sketch_params', 'grid_snap', 'grid_solid_capstyle', 'grid_solid_joinstyle', 'grid_transform', 'grid_url', 'grid_visible', 'grid_xdata', 'grid_ydata', 'grid_zorder', 'grid_aa', 'grid_c', 'grid_ds', 'grid_ls', 'grid_lw', 'grid_mec', 'grid_mew', 'grid_mfc', 'grid_mfcalt', 'grid_ms']
Process finished with exit code 1
Posts: 8,165
Threads: 160
Joined: Sep 2016
I didn't pay attention to your third import. remove the from matplotlib.pyplot import grid - that's not needed
you want tkinter grid manager
why do you make these strange imports?
Posts: 8,165
Threads: 160
Joined: Sep 2016
And please use error tags, when post traceback
Posts: 18
Threads: 2
Joined: Jan 2020
Jan-21-2020, 08:49 PM
(This post was last modified: Jan-21-2020, 08:49 PM by Melford.)
Please explain error tags, would you mean Error:
for the forum? Also the weird imports are from PyCharm, I've been using the little light bulb which gives me options such as formatting and different function names etc which is very useful (unfortunately less so with the Listbox vs listbox) and one of the options is 'create import' so it was probably from that, I'll give the tkinter grid manager an install now
Also thanks a lot for the help you've been an incredible help
Ignore the first question, I thought it might've been that code and I just realised theres a button for it... lord have mercy lol
Posts: 8,165
Threads: 160
Joined: Sep 2016
PyCharm IDE suggest code completion, but it doesn't know what you want to do. It's up to you (the programmer) to use the suggestion or not.
Also its better if you not use from tkinter import * , but instead something like import tkinter as tk
then use tk as alias and your code would look like
window = tk.Tk() i.e. you would fuly reference what object you want to use. In this case when you type tk. and PyCharm would suggest more appropriate code completion
Yes, that's error tags
Posts: 18
Threads: 2
Joined: Jan 2020
This'll be the last time I annoy you, following the link you sent me; I've used the same format as the link you've shown however it's saying in the error log 'grid' is not defined. I've checked the Interpreter for the tkinter grid manager addon as well but I can't find anything.
Error: Traceback (most recent call last):
File "C:/Users/jumbu/Desktop/python/test.py", line 49, in <module>
b1 = grid(row=2, column=3)
NameError: name 'grid' is not defined
|