TeemoMain TeemoMain - 3 years ago 293
Python Question

"variable" May be undefined or defined from star imports: tkinter

I'm trying to make a simple outline for a gui, and I'm getting the warning
"variable" May be undefined or defined from star imports: tkinter for all of my variables.

Here is my code:

from tkinter import *

class myApp :
def __init__(self, gui,) :
self.root = gui
self.bframe = Frame(self.root) # Create a container Frame at bottom
self.xlabel = Label(self.root, text="Item ID") # Create the Label
self.xentry = Entry(self.root, bd=5) # Create the Entry box
self.xentry.bind('<Return>', self.showStockItem)
self.xentry.focus_set() # Set focus in the Entry box
self.xopen = Button(self.root, text="Show", command=self.showStockItem) # Create the open Button
self.xquit = Button(self.bframe, text="Quit", command=self.quitit) # Create the quit Button

gui = Tk()
app = myApp(gui)

Answer Source

from tkinter import *

In this line, you import everything from tkinter. This is not recommended, so linter will warn you. But if you really want to do this, it's OK, just ignore it.

To be better, you should explicitly import what you need. For example:

from tkinter import Tk, Label, Frame, Entry, Button
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download