I tried to call a method from within a class like this,
from tkinter import *
class LoginFrame(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
# initialize the login screen UI
def initUI(self):
self.parent.title("Login Screen")
def make_label(parent, caption=NONE, side=TOP, **options):
label = Label(parent, text=caption, **options)
if side is not TOP:
label.pack(side=side)
else:
label.pack()
return label
def main():
top = Tk()
# create a background image
photo_bg = PhotoImage(file="building.gif")
building = make_label(top, image=photo_bg)
top.mainloop()
if __name__ == '__main__':
main()
I got an errorNameError: name 'make_label' is not defined
, how to resolve this. Also I tried to make the code as importable as possible, to run as a module, what's the best way to do that?
many thanks