Почему я получаю _ tkinter.tclerror:? [закрыто]Python

Программы на Python
Ответить
Anonymous
 Почему я получаю _ tkinter.tclerror:? [закрыто]

Сообщение Anonymous »

Программа Tkinter работала отлично, но при каждом ее запуске внезапно начинала показывать следующую ошибку.
Отображение программы Tkinter
Traceback (most recent call last):
File "c:\Users\allen\OneDrive\Desktop\Office_App - Copy\form_main.py", line 169, in
form = formMain()
^^^^^^^^^^
File "c:\Users\allen\OneDrive\Desktop\Office_App - Copy\form_main.py", line 9, in __init__
self.build_control()
File "c:\Users\allen\OneDrive\Desktop\Office_App - Copy\form_main.py", line 100, in build_control
self.tree.heading(column = id, text = id, anchor = "e")
File "C:\Users\allen\AppData\Local\Programs\Python\Python311\Lib\tkinter\ttk.py", line 1274, in heading
return _val_or_dict(self.tk, kw, self._w, 'heading', column)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\allen\AppData\Local\Programs\Python\Python311\Lib\tkinter\ttk.py", line 281, in _val_or_dict
res = tk.call(*(args + options))
^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: wrong # args: should be ".!treeview heading column -option value...".”`

#The Code
def _init_(self):

self.data_manager = data_layer.DataLayer()

self.build_control()

self.refresh_tree()

self.form_main.mainloop()
def refresh_tree(self):

self.tree.delete(\*self.tree.get_children())

for record in self.data_manager.get_data():

self.tree.insert("", tk.END, values=record)
def delete_click(self):

self.delete_record()

self.refresh_tree()
def edit_click(self):

print("edit")

self.refresh_tree()
def save_click(self):

self.save_record()

self.refresh_tree()

def get_data_from_controls(self):

return [self.entry_name.get(),

self.entry_psn.get(),

self.entry_lga.get(),

self.entry_designation.get(),

self.entry_gl.get(),

self.radio_gender.get(),

self.entry_dob.get(),
self.entry_date_of_first_app.get(),

self.entry_date_of_pre_app.get(),

self.entry_qualification.get(),

self.entry_remarks.get()\]
def save_record(self):
self.data_manager.add_record(self.get_data_from_controls())
def delete_record(self):

selection = self.tree.focus()

if not selection:

messagebox.showerror(message="No Record Selected. Please Select and try again")

return

row_index = self.tree.index(selection)
self.data_manager.delete_record(row_index+1)
def theme_selected(self, event):
self.style.theme_use(self.combo_theme.get())
def update_controls(self, parent):

for child in self.walk_widgets(parent):

if isinstance(child,(tk.Frame, ttk.Treeview)):

child.grid_configure(padx=15, pady=15, sticky="w")

else:

child.grid_configure(padx=5, pady=5, sticky="w")
def walk_widgets(self, parent):

widget =[]

for child in parent.winfo_children():

widget.append(child)
widget.extend(self.walk_widgets(child))

return widget

def build_control(self):

self.form_main = tb.Window(themename="superhero")

self.style = tb.Style()

self.form_main.title("Adamawa State Bureau of Statistics Staff Manager")

#CREATE CONTROLS
frame_top_left = tk.Frame(self.form_main)

button_edit = tk.Button(frame_top_left, text="Edit", width=10, command=self.edit_click)

button_delete = tk.Button(frame_top_left, text="Delete", width=10, command=self.delete_click)

#THEMES
themes = ["cosmo","flatly","sandstone","pulse","united","journal","darkly","superhero"]

frame_top_right = tk.Frame(self.form_main)

self.combo_theme = ttk.Combobox(frame_top_right, values=themes)

self.combo_theme.set(self.style.theme.name)

self.combo_theme.bind("",self.theme_selected)

#column_ids = ["Full Name","PSN", "LGA","Designation","GL","Gender","DOB","Date of 1st App","Date of Pre App","Qualification"]

form = formMain()


Подробнее здесь: https://stackoverflow.com/questions/798 ... r-tclerror
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»