AttributeError: ‘App’ object has no attribute ‘tk’
# -*- coding: utf-8 -*-
from Tkinter import *
import ttk
class Test_Dialog(Toplevel):
def __init__(self, parent):
Toplevel.__init__(self, parent)
self.parent = parent
self.transient(self.parent)
frame = Frame(self)
lab = ttk.Label(frame, justify="left", anchor="n",
text="Мой техт")
lab.grid(row=0, column=0, padx=10, pady=5, sticky=E)
frame.grid(row=0, column=0, sticky=NSEW)
class App(object):
def __init__(self):
self.tool = ttk.Frame()
self.tool.pack(anchor = NW)
self.btn = ttk.Button(self.tool, text= u"Добавить", command=self._add_record)
self.btn.pack(side = LEFT)
def _add_record(self, event=None):
win = Test_Dialog(self)
if __name__ == "__main__":
root = Tk()
app = App()
root.mainloop()