I'm working with tkinter at the moment, ive needed to call a method onto an object that has a Tk() class. im trying to call the method not in the Tk() class, but from the class ive already created, which the tkinter object is in already.
Ive tried to call .Format() onto l_label, but i think it is trying to find an attribute or method within the Label class from tkinter, because it returns: AttributeError: 'Label' object has no attribute 'Format'
Any thoughts?
from tkinter import *
from tkinter import messagebox
from tkinter import filedialog
thing = Tk()
class App():
def __init__(self, master, _title, back='white'):
self.master = master
self._title = _title
self.back = back
self.master.title(self._title)
self.master.configure(background=back)
def label(self, _text, back='white', w=1, h=1):
self.back = back
self.w = w
self.h = h
self._text = _text
l_label = Label(self.master, text=self._text, bg=self.back, width=self.w, height=self.h)
return l_label
def Format(self, l_label, Row=1, Column=1):
self.Row = Row
self.Column = Column
l_label.grid(row=Row, column=Column)
app = App(thing, 'hello world')
label = app.label('this is a text boc', 'white').Format()
thing.mainloop()