What am I doing wrong here, please?
My understanding was that from <module> import *
means “please give me access everything in that module that I’m meant to have access to”
Am I wrong?
The reason for my question is this code that I’ve written, as a small tester for learning.
#!/usr/bin/python3
from tkinter import *
from tkinter.ttk import *
# -------------For the 'About' function----------------#
from tkinter import messagebox
#?? Why do I need this, when I've got the import * above??##
def about():
messagebox.showinfo('About','This is only a test.')
#------------------------------------------------------#
#---------------For the File dialog Box----------------#
from tkinter import filedialog
#?? Why do I need this, when I've got the import * above??##
def openfile():
filename = filedialog.askopenfilename()
print(filename)
#------------------------------------------------------#
#-----------------------Mainloop-----------------------#
root = Tk()
root.title('My First Application')
root.geometry('1200x600')
root.resizable(False, False)
# Creating Menubar
menubar = Menu(root)
# Adding File Menu
file = Menu(menubar, tearoff = 0)
menubar.add_cascade(label = 'File', menu = file)
# Add items to the File Menu
file.add_command(label = 'New File', command = None)
file.add_command(label = 'Open...', command = openfile)
file.add_command(label = 'Close', command = None)
file.add_command(label = 'Save', command = None)
file.add_command(label = 'Exit', command = root.destroy)
help = Menu(menubar, tearoff = 0)
menubar.add_cascade(label = 'Help', menu = help)
help.add_command(label = 'About', command = about)
# Display Menu
root.config(menu = menubar)
# Run the app
root.mainloop()
You’ll notice that, as comments, I’ve asked the question: Why do I need this, when I’ve got the import *
above. I’ve had to insert the line of code above said comments, for the app to work, but I can’t see why, given the code at lines 3 & 4.
I’ve been as proactive on this as I can, that is to say, I’ve not simply hit a wall and then posted right away; I’ve been searching for an answer to this for the past 6 hours, so I’ve concluded that there has to be a fundamental gap in my knowledge, which means I don’t know what to search for.