Bom meu projetinho com python e a biblioteca tkinter esse , eu estou tentando fazer um sistema de cadastro mas sou um pouco novo nessa parte de orientação a objetos em python, e acho que esse é a parte que esta me dando erro! Poderiam me dar uma ajuda do que fazer:
from tkinter import *
from functools import partial
import tkinter.messagebox
#-*- coding:UTF-8 -*-
from tkinter import *
import sys
class novo:
## Classe oonde forma a primeira janela com os menus
def __init__(self, janela):
# Inicia como None
janela.title("Sapataria do Seu IVO - Menu Inicial")
self.b1=Button(janela, text='Cadastrar Tenis', command=self.new_janCT)
self.b1.place(x=335, y=245)
self.b2=Button(janela, text='Relatório Geral', command=self.new_janRG)
self.b2.place(x=335, y=285)
self.b3=Button(janela, text='Realizar Venda', command=self.new_janRV)
self.b3.place(x=335, y=325)
self.b4=Button(janela, text='Atualizar preços', command=self.new_janAP)
self.b4.place(x=335, y=365)
self.b5=Button(janela, text='Cadastrar Cores', command=self.new_janCC)
self.b5.place(x=335, y=405)
self.b6=Button(janela, text='Guarda no TXT', command=self.new_janGT)
self.b6.place(x=335, y=445)
self.b7=Button(janela, text='Recupera do TXT', command=self.new_janRT)
self.b7.place(x=335, y=485)
self.b8=Button(janela, text='Sair', command=root.destroy)
self.b8.place(x=335, y=525)
self.l1=Label(janela, text='raiz!')
self.l1.place(x=750, y=560)
screen_width = janela.winfo_screenwidth()
screen_height = janela.winfo_screenheight()
width = 800
height = 600
x = (screen_width/2)-(width/2)
y = (screen_height/2)-(height/2)
self.jan = None
self.caixa=Frame(janela)
self.caixa.grid()
########################################################################################
def new_janCT(self):
def inserindoDados(self, *args):
self.listbox.insert(END, self.inserir.get())
# Verifica se já foi criada
if self.jan is None:
self.jan=Tk()
self.jan.protocol("WM_DELETE_WINDOW", self.fecha_jan)
self.l=Label(self.jan, text='Cadastro de tenis')
self.l.grid()
self.lblistbox = Label(self.jan, text="ESTOQUE DO TIO IVO", bg='lightSteelBlue3', fg='blue').place(x=50, y=60)
self.listbox = Listbox(self.jan, width=60)
self.listbox.insert(0,"Criando listbox = 1")
self.listbox.place(x=100, y=200)
self.lblistbox1 = Label(self.jan, text="Inserindo dados", bg='lightSteelBlue3', fg='blue').place(x=20, y=10)
self.inserir = StringVar()
self.txtlistbox = Entry(self.jan, textvariable=self.inserir, width=47).place(x=120, y=10)
self.btninserir = Button(self.jan, text='INSERIR',height=1, width=10, command=self.inserindoDados).place(x=325, y=30)
self.jan.geometry('800x600')
else:
# Se já foi, basta colocá-la na frente
self.jan.lift()
#########################################################################################
def new_janRG(self):
# Verifica se já foi criada
if self.jan is None:
self.jan=Tk()
self.jan.protocol("WM_DELETE_WINDOW", self.fecha_jan)
self.l=Label(self.jan, text='Relatório Geral')
self.l.grid()
self.jan.geometry('800x600')
else:
# Se já foi, basta colocá-la na frente
self.jan.lift()
#########################################################################################
def new_janRV(self):
# Verifica se já foi criada
if self.jan is None:
self.jan=Tk()
self.jan.protocol("WM_DELETE_WINDOW", self.fecha_jan)
self.l=Label(self.jan, text='Realizar Venda')
self.l.grid()
self.jan.geometry('800x600')
else:
# Se já foi, basta colocá-la na frente
self.jan.lift()
#########################################################################################
def new_janAP(self):
# Verifica se já foi criada
if self.jan is None:
self.jan=Tk()
self.jan.protocol("WM_DELETE_WINDOW", self.fecha_jan)
self.l=Label(self.jan, text='Atualizar preços')
self.l.grid()
self.jan.geometry('800x600')
else:
# Se já foi, basta colocá-la na frente
self.jan.lift()
#########################################################################################
def new_janCC(self):
# Verifica se já foi criada
if self.jan is None:
self.jan=Tk()
self.jan.protocol("WM_DELETE_WINDOW", self.fecha_jan)
self.l=Label(self.jan, text='Cadastrar Cores')
self.l.grid()
self.jan.geometry('800x600')
else:
# Se já foi, basta colocá-la na frente
self.jan.lift()
#########################################################################################
def new_janGT(self):
# Verifica se já foi criada
if self.jan is None:
self.jan=Tk()
self.jan.protocol("WM_DELETE_WINDOW", self.fecha_jan)
self.l=Label(self.jan, text='Guarda no TXT')
self.l.grid()
self.jan.geometry('800x600')
else:
# Se já foi, basta colocá-la na frente
self.jan.lift()
#########################################################################################
def new_janRT(self):
# Verifica se já foi criada
if self.jan is None:
self.jan=Tk()
self.jan.protocol("WM_DELETE_WINDOW", self.fecha_jan)
self.l=Label(self.jan, text='Recupera do TXT')
self.l.grid()
self.jan.geometry('800x600')
else:
# Se já foi, basta colocá-la na frente
self.jan.lift()
#########################################################################################
def new_janSA(self):
#self.janela.destroy()
sys.exit()
l1.text['Para Fechar clique no X vermelho acima! ']
#########################################################################################
def fecha_jan(self):
# Seta de novo em None para recriar quando abrir
self.jan.destroy()
self.jan = None
root=Tk()
novo(root)
root.geometry('800x600')
root.mainloop()
novo()
Erro
Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\ecaet\AppData\Local\Programs\Python\Python37\lib\tkinter__init__.py", line 1705, in call return self.func(*args)
File "G:\python\Tkinter\main.py", line 110, in new_janCT self.btninserir = Button(self.jan, text='INSERIR',height=1, width=10, command=self.inserindoDados).place(x=325, y=30)
AttributeError: 'novo' object has no attribute 'inserindoDados'