Oct-09-2020, 04:39 AM
I am redesigning my horse race handicapping program based on everyone's advice concerning classes and Modules. So I will post my beginning effort and explain my confusion.
$ python new.py
Traceback (most recent call last):
File "new.py", line 14, in <module>
import main_w.py
File "C:\guis\main_w.py", line 58, in <module>
file_menu.add_command(label="Initialize Setup Files", command=setup_command)
NameError: name 'setup_command' is not defined
from tkinter import * from tkinter import ttk import time from tkinter import messagebox from glob import glob import os import shutil import csv import array as arr import sqlite3 import pandas as pd import numpy as np import re import main_w.py #________________________________________________________________ main_w.py() root.mainloop()The above works and brings up the gui. But there are things missing in the gui. Such as the following code.
# DEFINE MENU my_menu = Menu(root) root.config(menu=my_menu) #CREATE MENU ITEMS file_menu = Menu(my_menu) my_menu.add_cascade(label="Configure Program", menu=file_menu) file_menu.add_command(label="Initialize Setup Files", command=setup_command) file_menu.add_separator() file_menu.add_command(label="Change File directory Path", command=change_path) file_menu.add_separator() file_menu.add_command(label="Build Race Analyst", command=build_factors) #file_menu.add_command(label="Build Race Analyst", command=build_analyst) file_menu.add_command(label="Delete Race Analyst", command=delete_analyst) file_menu.add_separator() file_menu.add_command(label="Close Handifast", command=close_handifast)When I add this code to the main_w.py() and then try and run it i get the following error, which I understand. But it puts me back in my original position of too much code all in one place I guess you'd say. How do I fix the problem?
$ python new.py
Traceback (most recent call last):
File "new.py", line 14, in <module>
import main_w.py
File "C:\guis\main_w.py", line 58, in <module>
file_menu.add_command(label="Initialize Setup Files", command=setup_command)
NameError: name 'setup_command' is not defined