class show: def __init__(self): self.window=Tk() self.window.title("Show | All Products") self.window.iconbitmap('shop.ico') self.window.geometry("1365x700+10+10") self.window.maxsize(1365,700) self.window.minsize(1365,700) # self.window.resizable(width=False,height=False) def add_background(self): self.image = Image.open("images/back.jpg") self.image = self.image.resize((1365, 700), Image.ANTIALIAS) self.img = ImageTk.PhotoImage(self.image) self.li = Label(image = self.img, text="TALHA") self.li.image = self.img self.li.pack() self.Menubar() def Menubar(self): self.menubar = Menu() self.menuitems_add = Menu(self.menubar, tearoff=0,bg="blue",fg="white") self.menuitems_add.add_command(label="Add Products", command=self.add_products) # self.menuitems.add_separator() self.menuitems_sales = Menu(self.menubar, tearoff=0,bg="blue",fg="white") self.menuitems_sales.add_command(label="Sale Products", command=self.sales_products) self.menuitems_customer = Menu(self.menubar, tearoff=0, bg="blue", fg="white") self.menuitems_customer.add_command(label="Add Customer", command=self.add_customer) self.menuitems_customer.add_command(label="Show Customer Records", command=self.customer_record) self.menuitems_reports = Menu(self.menubar, tearoff=0, bg="blue", fg="white") self.menuitems_reports.add_command(label="Check Products Quantity", command=self.check_products_quantity) self.menuitems_reports.add_command(label="Check Profit/Loss", command=self.check_profit_loss) self.menuitems_reports.add_command(label="Check Sales Products", command=self.check_products_sales) self.menuitems_reports.add_command(label="Check Sent Amount Details", command=self.check_amount) self.menubar.add_cascade(label="Add Products", menu=self.menuitems_add) self.menubar.add_cascade(label="Sales Products", menu=self.menuitems_sales) self.menubar.add_cascade(label="Customer", menu=self.menuitems_customer) self.menubar.add_cascade(label="Reports", menu=self.menuitems_reports) self.menubar.add_cascade(label="Exit", command=quit) self.window.config(menu=self.menubar) def add_table(self): self.l1=Label(self.window,text="**Products Details**",font="Courier 25 bold",bg="black",fg="white",width=61) self.l1.place(x=82,y=20) self.l1 = Label(self.window, text="Developed by : Muhammad Talha | NTU", font="Courier 10 bold") self.l1.place(x=530, y=610) self.l1 = Label(self.window, text="Enter Product Name:", font="courier 16 bold",bg="blue",fg="white") self.l1.place(x=280, y=90) self.Entry_reg = Entry(self.window, font="courior 14 bold") self.Entry_reg.place(x=550, y=90, height=30) self.b1 = Button(self.window, text="Search", font="Times 13 bold",fg="white",bg="blue",width=10) self.b1.place(x=790, y=90) self.b1.bind('<Button-1>', self.search_product) # for Style Table style = Style() style.configure("mystyle.Treeview", highlightthickness=0, bd=0, font=('courier 12 bold'),rowheight=43) # Modify the font of the body style.configure("mystyle.Treeview.Heading", font=('Times 15 bold'),foreground="black") # Modify the font of the headings # style.layout("mystyle.Treeview", [('mystyle.Treeview.treearea', {'sticky': 'nswe'})]) # Remove the borders # import TreeViewe self.tr=Treeview(self.window,columns=('A','B','C','D','E','F','G','H'),selectmode="extended",style='mystyle.Treeview') # heading key+text self.tr.heading("#0", text="Sr.No") self.tr.column("#0", minwidth=0, width=85, stretch=NO) self.tr.heading("#1",text="Product Name") self.tr.column("#1",minwidth=0,width=160,stretch=NO) self.tr.heading("#2", text="Product Catagory") self.tr.column("#2", minwidth=0, width=200, stretch=NO) self.tr.heading("#3", text="Total Quantity") self.tr.column("#3", minwidth=0, width=175, stretch=NO) self.tr.heading("#4", text="Purchase Price") self.tr.column("#4", minwidth=0, width=175, stretch=NO) self.tr.heading("#5", text="Sales Price") self.tr.column("#5", minwidth=0, width=160, stretch=NO) self.tr.heading("#6", text="Update") self.tr.column("#6", minwidth=0, width=85, stretch=NO) self.tr.heading("#7", text="Delete") self.tr.column("#7", minwidth=0, width=85, stretch=NO) self.tr.heading("#8", text="Sales") self.tr.column("#8", minwidth=0, width=100, stretch=NO) j=1 for i in Database.show_product_details(): self.tr.insert('',index=j,tags=i[0],text=j,values=(i[1],i[2],i[3],i[4],i[5],"UPDATE","DELETE","SALES")) j+=1 self.Entry_reg.bind('<KeyRelease>', self.remove) self.tr.bind('<Double-Button-1>',self.action) self.sb = Scrollbar(self.tr) self.sb.place(x=1205,y=2,height=452,width=22,bordermode=OUTSIDE) self.sb.config(command=self.tr.yview) self.tr.config(yscrollcommand=self.sb.set) self.tr.place(x=85,y=150) self.tr.tag_configure('data', background='black') # to excel file self.b1 = Button(self.window, text="Save to Excel", font="Times 12 bold",bg="blue",fg="white",width=20, ) self.b1.place(x=1122, y=610) self.b1.bind('<Button-1>', self.excel) self.window.mainloop() def action(self,event): fcs=self.tr.focus() col=self.tr.identify_column(event.x) x=self.tr.item(fcs).get('values') text=x[1] data=( text, ) if col=="#7": res=msg.askyesno("Message!","Do you want to delete this product?") if res: d=Database.delete_details(data) if d: msg.showinfo("Deleted","Your product has been deleted successfully!!!") self.window.destroy() x=show() x.add_background() x.add_table() else: self.window.destroy() x=show() x.add_table() elif col=="#6": x=Home.data(self.tr.item(fcs)) x.add_frame() elif col=="#8": x = Sales_Products_Records.data(self.tr.item(fcs)) x.add_frame() def remove(self,event): for row in self.tr.get_children(): self.tr.delete(row) j = 1 for i in Database.show_product_details(): self.tr.insert('', index=j, text=j, values=(i[1], i[2], i[3], i[4], i[5], "UPDATE", "DELETE", "SALES")) j += 1 def search_product(self,event): try: data = (self.Entry_reg.get(),) if self.Entry_reg.get() == "": msg.showwarning("Message ! ", "please insert product name !") else: j = 1 D = Database.search_details(data) if D: for row in self.tr.get_children(): self.tr.delete(row) self.Entry_reg.delete(0, END) for i in D: self.tr.insert('', index=j, text=j, values=(i[1],i[2],i[3],i[4],i[5],"UPDATE","DELETE","SALES")) j += 1 else: msg.showwarning("Message!", "No result Found!") except: msg.showwarning("Error!", "Something went wrong! please contact with developer !!!") def excel(self,event): try: x=Database.show_product_details() p_name=[] p_catagory=[] p_quantity=[] p_purchase_price=[] p_sales_price=[] for i in range(len(x)): z=x.__getitem__(i) p_name.append(z[1]) p_catagory.append(z[2]) p_quantity.append(z[3]) p_purchase_price.append(z[4]) p_sales_price.append(z[5]) products = pd.DataFrame({ "Product Name": p_name, "Product Catagory":p_catagory, "Total Quantity":p_quantity, "Purchase Price":p_purchase_price, "Sales Price":p_sales_price }) with pd.ExcelWriter("Excel Files/All_Products.xlsx") as writer: products.to_excel(writer, sheet_name="All_Products", index=False) msg.showinfo("Message ! ", "Your data has been inserted Susccessfully !") except: msg.showwarning("Message!","Something Went Wrong!please contact with developer!!!") def add_products(self): self.window.destroy() home = Home.data() home.add_background() home.add_frame() def sales_products(self): pass def check_products_quantity(self): self.window.destroy() showP = Check_Products_Quantity.show() showP.add_background() showP.add_table() def check_products_sales(self): self.window.destroy() showP = Check_Sales_Products.show() showP.add_background() showP.add_table() def check_profit_loss(self): self.window.destroy() showP = Check_Profit_Loss_GUI.show() showP.add_background() showP.add_table() def add_customer(self): self.window.destroy() home = Add_Customer.data() home.add_background() home.add_frame() def customer_record(self): self.window.destroy() showP = Customer_Records.show() showP.add_background() showP.add_table() def check_amount(self): self.window.destroy() showP = Check_Amount_Details.show() showP.add_background() showP.add_table()
class GUIDatasetClasificacion(): def __init__(self, root): self.root = root #TODO Esta información se lee desde .cfg con ConfigParser self.ruta_datasets = '' self.ruta_resultados = '' self.rutas_relativas = BooleanVar(root, True) self.usa_sha1 = BooleanVar(root, True) self._tamanyo_muestra = 5 self.clase_al_final = BooleanVar(root, True) self.mostrar_proceso = BooleanVar(root, False) self.lee_configuracion() estilo_bien = Style() estilo_bien.configure('G.TLabel', foreground='green') estilo_mal = Style() estilo_mal.configure('R.TLabel', foreground='red') self.crea_GUI() self.root.title(APP_NAME) # self.root.update() # self.root.minsize(self.root.winfo_width(), self.root.winfo_height()) self.root.minsize(800, 500) # self.lee_configuracion() self.root.protocol('WM_DELETE_WINDOW', self.cerrar_aplicacion) def crea_GUI(self): root = self.root #Menús self.menubar = Menu(root, tearoff=0) m_archivo = Menu(self.menubar, tearoff=0) m_archivo.add_command(label='Abrir', command=self.abrir_dataset, accelerator='Ctrl+O') m_archivo.add_separator() m_archivo.add_command(label='Salir', command=self.cerrar_aplicacion) self.menubar.add_cascade(label='Archivo', menu=m_archivo) m_proyecto = Menu(self.menubar, tearoff=0) m_proyecto.add_command(label='Abrir', command=self.abrir_proyecto, state="disabled") m_proyecto.add_separator() m_proyecto.add_checkbutton(label='Clase al final', onvalue=True, offvalue=False, variable=self.clase_al_final) self.menubar.add_cascade(label='Proyecto', menu=m_proyecto) self.m_configuracion = Menu(self.menubar, tearoff=0) self.m_configuracion.add_command( label='Ruta datasets', command=lambda: self.rutas('datasets')) self.m_configuracion.add_command( label='Ruta resultados', command=lambda: self.rutas('resultados')) self.m_configuracion.add_checkbutton(label='Rutas relativas', onvalue=True, offvalue=False, variable=self.rutas_relativas, command=self.cambia_rutas) self.m_configuracion.add_separator() #TODO Revisar self.v_tamanyo_muestra, no la uso # self.v_tamanyo_muestra = StringVar(root, 'Tamaño muestra ({:,})'.\ # format(self._tamanyo_muestra)) self.m_cfg_tamanyo_muestra = \ self.m_configuracion.add_command(label='Tamaño muestra ({:,})'.\ format(self._tamanyo_muestra), command=lambda: self.tamanyo_muestra(\ self._tamanyo_muestra)) self.m_configuracion.add_separator() self.m_configuracion.add_checkbutton(label='Utiliza sha1', onvalue=True, offvalue=False, variable=self.usa_sha1) self.menubar.add_cascade(label='Configuración', menu=self.m_configuracion) m_ver = Menu(self.menubar, tearoff=0) self.v_tipo_dataset = StringVar(self.root, 'Dataset original') m_ver.add_radiobutton(label='Dataset original', value='Dataset original', variable=self.v_tipo_dataset, command=self.muestra_atributos_y_clase) m_ver.add_radiobutton(label='Dataset sin evidencias incompletas', value='Dataset sin evidencias incompletas', variable=self.v_tipo_dataset, command=self.muestra_atributos_y_clase) m_ver.add_radiobutton(label='Dataset sin atributos constantes', value='Dataset sin atributos constantes', variable=self.v_tipo_dataset, command=self.muestra_atributos_y_clase) m_ver.add_radiobutton(label='Catálogo', value='Catálogo', variable=self.v_tipo_dataset, command=self.muestra_atributos_y_clase) m_ver.add_radiobutton(label='Catálogo Robusto', value='Catálogo Robusto', variable=self.v_tipo_dataset, command=self.muestra_atributos_y_clase) m_ver.add_separator() m_ver.add_checkbutton(label='Log del proceso', onvalue=True, offvalue=False, variable=self.mostrar_proceso, state='disabled') self.menubar.add_cascade(label='Ver', menu=m_ver) root.config(menu=self.menubar) #Dataset de clasificación lf_dataset = LabelFrame(root, text='Dataset de Clasificación') lf_dataset.pack(fill='both', expand=True, padx=5, pady=5) Label(lf_dataset, text='Nombre:').grid(row=0, column=0, sticky='e') self.v_nombre_dataset = StringVar(root, '-------') self.l_nombre_dataset = Label(lf_dataset, textvariable=self.v_nombre_dataset) self.l_nombre_dataset.grid(row=0, column=1, sticky='w') Label(lf_dataset, text='Tamaño:').grid(row=0, column=2, sticky='e') self.v_tamanyo_dataset = StringVar(root, '-------') Label(lf_dataset, textvariable=self.v_tamanyo_dataset).grid(row=0, column=3, sticky='w') Label(lf_dataset, text='Ubicación:').grid(row=1, column=0, sticky='e') self.v_ruta_dataset = StringVar(root, '-------------------------') #TODO Expandir en columnas 1-3, puede ser muy larga Label(lf_dataset, textvariable=self.v_ruta_dataset).grid(row=1, column=1, sticky='w', columnspan=3) #Dataset de clasificación / Muestra lf_dataset_muestra = LabelFrame(lf_dataset, text='Muestra') lf_dataset_muestra.grid(row=2, column=0, sticky='nsew', columnspan=4, padx=5, pady=5) self.sb_v_t_muestra = Scrollbar(lf_dataset_muestra) self.sb_v_t_muestra.grid(row=0, column=1, sticky='sn') self.sb_h_t_muestra = Scrollbar(lf_dataset_muestra, orient='horizontal') self.sb_h_t_muestra.grid(row=1, column=0, sticky='ew') self.t_muestra = Text(lf_dataset_muestra, yscrollcommand=self.sb_v_t_muestra.set, xscrollcommand=self.sb_h_t_muestra.set, bd=0, wrap='none', state='disabled', height=8) self.t_muestra.grid(row=0, column=0, sticky='nswe') self.sb_v_t_muestra.config(command=self.t_muestra.yview) self.sb_h_t_muestra.config(command=self.t_muestra.xview) lf_dataset_muestra.rowconfigure(0, weight=1) lf_dataset_muestra.columnconfigure(0, weight=1) lf_dataset.rowconfigure(2, weight=3) lf_dataset.columnconfigure(1, weight=1) lf_dataset.columnconfigure(3, weight=1) #Dataset de clasificación / Evidencias lf_dataset_evidencias = LabelFrame(lf_dataset, text='Evidencias') lf_dataset_evidencias.grid(row=3, column=0, sticky='nsew', padx=5, pady=5) Label(lf_dataset_evidencias, text='Total:').grid(row=0, column=0, sticky='e') self.v_evidencias_total = StringVar(root, '-------') Label(lf_dataset_evidencias, textvariable=self.v_evidencias_total).\ grid(row=0, column=1, sticky='w') Label(lf_dataset_evidencias, text='Completas:').grid(row=1, column=0, sticky='e') self.v_evidencias_completas = StringVar(root, '-------') Label(lf_dataset_evidencias, textvariable=self.v_evidencias_completas).\ grid(row=1, column=1, sticky='w') Label(lf_dataset_evidencias, text='Únicas:').grid(row=2, column=0, sticky='e') self.v_evidencias_catalogo = StringVar(root, '-------') Label(lf_dataset_evidencias, textvariable=self.v_evidencias_catalogo).\ grid(row=2, column=1, sticky='w') Label(lf_dataset_evidencias, text='Robustas:').grid(row=3, column=0, sticky='e') self.v_evidencias_robustas = StringVar(root, '-------') Label(lf_dataset_evidencias, textvariable=self.v_evidencias_robustas).\ grid(row=3, column=1, sticky='w') #Dataset de clasificación / Atributos lf_dataset_clase_y_atributos = LabelFrame(lf_dataset, text='Clase y atributos') lf_dataset_clase_y_atributos.grid(row=3, column=1, sticky='nsew', columnspan=3, padx=5, pady=5) PROPIEDADES_ATRIBUTOS = ('Nombre', 'count', 'unique', 'top', 'freq', 'mean', 'std', 'min', '25%', '50%', '75%', 'max') self.sb_h_tv_clase = Scrollbar(lf_dataset_clase_y_atributos, orient='horizontal') self.sb_h_tv_clase.grid(row=1, column=0, sticky='ew') self.tv_clase = Treeview(lf_dataset_clase_y_atributos, columns=PROPIEDADES_ATRIBUTOS, height=1, xscrollcommand=self.sb_h_tv_clase.set) self.tv_clase.grid(row=0, column=0, sticky='ew') self.sb_h_tv_clase.config(command=self.tv_clase.xview) self.tv_clase.heading("#0", text="#") self.tv_clase.column("#0", minwidth=30, width=40, stretch=False) self.sb_v_tv_atributos = Scrollbar(lf_dataset_clase_y_atributos) self.sb_v_tv_atributos.grid(row=2, column=1, sticky='sn') self.sb_h_tv_atributos = Scrollbar(lf_dataset_clase_y_atributos, orient='horizontal') self.sb_h_tv_atributos.grid(row=3, column=0, sticky='ew') self.tv_atributos = Treeview(lf_dataset_clase_y_atributos, columns=PROPIEDADES_ATRIBUTOS, yscrollcommand=self.sb_v_tv_atributos.set, xscrollcommand=self.sb_h_tv_atributos.set) self.tv_atributos.grid(row=2, column=0, sticky='nsew') self.tv_atributos.bind('<ButtonRelease-1>', self.selectItem) self.sb_v_tv_atributos.config(command=self.tv_atributos.yview) self.sb_h_tv_atributos.config(command=self.tv_atributos.xview) self.tv_atributos.heading("#0", text="#") self.tv_atributos.column("#0", minwidth=30, width=40, stretch=False) for i in PROPIEDADES_ATRIBUTOS: self.tv_clase.heading(i, text=i) self.tv_clase.column(i, minwidth=50, width=50, stretch=False) self.tv_atributos.heading(i, text=i) self.tv_atributos.column(i, minwidth=50, width=50, stretch=False) lf_dataset_clase_y_atributos.rowconfigure(2, weight=1) lf_dataset_clase_y_atributos.columnconfigure(0, weight=1) lf_dataset.rowconfigure(3, weight=1) def abrir_dataset(self): inicio = time.time() #TODO Las constantes se podrán modificar a través de .cfg nombre = askopenfilename( initialdir=self.ruta_datasets, filetypes=(('Archivos de valores separado por comas', '*.csv'), ('Todos los archivos', '*.*')), title='Selecciona un Dataset de Clasificación') self.root.focus_force() if not nombre: return self.v_nombre_dataset.set( os.path.splitext(os.path.basename(nombre))[0]) #TODO Esto debería hacerlo en otro sitio, no cuando lo elijo con # filedialog, y tener en cuenta self.usa_sha1 if os.path.exists(os.path.dirname(nombre)): self.l_nombre_dataset.configure(style='G.TLabel') else: self.l_nombre_dataset.configure(style='R.TLabel') self.v_tamanyo_dataset.set(tamanyo_legible(os.path.getsize(nombre))) self.v_ruta_dataset.set(os.path.relpath(os.path.dirname(nombre)) \ if self.rutas_relativas.get() else \ os.path.dirname(nombre)) self.limpia_muestra() self.limpia_atributos_y_clase() self.root.update() #TODO Usar hilos o procesos para leer grandes datasets sin problemas # self.progreso = Toplevel(self.root) # self.progreso.title("Leyendo Dataset de Clasificación") # barra = Progressbar(self.progreso, length=200, mode="indeterminate") # barra.pack() # self.q = Queue() # hilo_lectura = Process(target=self.get_dc) # hilo_lectura.start() ## self.dc = self.q.get() ## hilo_lectura.join() # self.root.after(50, self.check_if_running, hilo_lectura, self.progreso) self.dc = DC(self.v_ruta_dataset.get(), self.v_nombre_dataset.get(), self.ruta_resultados, guardar_resultados=False, clase_al_final=self.clase_al_final.get(), mostrar_proceso=self.mostrar_proceso, num_filas_a_leer=None, obtener_catalogo_robusto=False, guardar_datos_proyecto=False, mostrar_uso_ram=False) self.escribe_datos() def escribe_datos(self): self.escribe_muestra() self.v_evidencias_total.set('{:,}'.\ format(self.dc.info_dataset_original.num_evidencias())) self.v_evidencias_completas.set('{:,}'.\ format(self.dc.info_dataset_sin_datos_desconocidos.num_evidencias())) self.v_evidencias_catalogo.set('{:,}'.\ format(self.dc.info_catalogo.num_evidencias())) self.v_evidencias_robustas.set('{:,}'.\ format(self.dc.info_catalogo_robusto.num_evidencias())) self.muestra_atributos_y_clase() self.root.title('{} - {}'.format(APP_NAME, self.v_nombre_dataset.get())) def get_dc(self): #TODO No puedo crear self.dc en un try mientras depure DC # try: self.dc = DC(self.v_ruta_dataset.get(), self.v_nombre_dataset.get(), self.ruta_resultados, guardar_resultados=False, clase_al_final=self.clase_al_final, mostrar_proceso=self.mostrar_proceso, num_filas_a_leer=None, obtener_catalogo_robusto=False, guardar_datos_proyecto=False, mostrar_uso_ram=False) self.q.put(self.dc) # except Exception as e: # self.t_muestra.delete(1.0, 'end') # self.t_muestra.insert('end', e) def check_if_running(self, hilo, ventana): """Check every second if the function is finished.""" if hilo.is_alive(): self.root.after(50, self.check_if_running, hilo, ventana) else: ventana.destroy() self.escribe_datos() def abrir_proyecto(self): inicio = time.time() #TODO Diseñar estrategia para que el usuario sepa si ha de cambiarlo. # Podría bastar con mostrarle los atributos y sus características. # clase_al_final = self._clase_al_final #TODO Las constantes se podrán modificar a través de .cfg nombre = askopenfilename(initialdir=self.ruta_resultados, filetypes=(('Proyectos ACDC', '*.prjACDC'), ('Todos los archivos', '*.*')), title='Selecciona un proyecto ACDC') if nombre is None: return #TODO ¿Mostrar sólo el nombre del dataset original? self.root.title('{} - {}'.format( APP_NAME, os.path.splitext(os.path.basename(nombre))[0])) def rutas(self, r=None): ruta = askdirectory(title='Directorio de {}'.format(r), initialdir=eval('self.ruta_{}'.format(r)), mustexist=True) if ruta != '': if self.rutas_relativas.get(): if r == 'datasets': self.ruta_datasets = os.path.relpath(ruta) else: self.ruta_resultados = os.path.relpath(ruta) else: if r == 'datasets': self.ruta_datasets = ruta else: self.ruta_resultados = ruta def cambia_rutas(self): if self.rutas_relativas.get(): self.ruta_datasets = os.path.relpath(self.ruta_datasets) self.ruta_resultados = os.path.relpath(self.ruta_resultados) else: self.ruta_datasets = os.path.abspath(self.ruta_datasets) self.ruta_resultados = os.path.abspath(self.ruta_resultados) def limpia_atributos_y_clase(self): for i in self.tv_clase.get_children(): self.tv_clase.delete(i) for i in self.tv_atributos.get_children(): self.tv_atributos.delete(i) def limpia_muestra(self): self.t_muestra['state'] = 'normal' self.t_muestra.delete(1.0, 'end') self.t_muestra['state'] = 'disabled' def tamanyo_muestra(self, tamanyo): nuevo_tamanyo = askinteger('Muestra', '¿Cuántas evidencias quieres ver?', parent=self.root, minvalue=1, initialvalue=self._tamanyo_muestra) # minvalue=0, maxvalue=1000) if nuevo_tamanyo: self._tamanyo_muestra = nuevo_tamanyo #TODO Debería averiguar el índice del menú que quiero modificar self.m_configuracion.entryconfigure(4, label='Tamaño muestra ({:,})'.\ format(self._tamanyo_muestra)) self.escribe_muestra() #TODO Tratar excepciones para que no se quede habilitada la escritura def escribe_muestra(self): self.t_muestra['state'] = 'normal' self.t_muestra.delete(1.0, 'end') self.t_muestra.insert('end', '#######################################'\ '########################\n') self.t_muestra.insert('end', ' PRIMERAS {:,} LÍNEAS DEL DATASET DE '\ 'CLASIFICACIÓN ORIGINAL\n'.\ format(self._tamanyo_muestra)) self.t_muestra.insert('end', '#######################################'\ '########################\n') self.t_muestra.insert('end', self.dc.muestra(self._tamanyo_muestra)) self.t_muestra.insert('end', '\n\n') self.t_muestra['state'] = 'disabled' def muestra_atributos_y_clase(self): self.limpia_atributos_y_clase() if self.v_tipo_dataset.get() == 'Dataset original': df = self.dc.info_dataset_original.columnas elif self.v_tipo_dataset.get() == 'Dataset sin evidencias incompletas': df = self.dc.info_dataset_sin_datos_desconocidos.columnas elif self.v_tipo_dataset.get() == 'Dataset sin atributos constantes': df = self.dc.info_dataset_sin_atributos_constantes.columnas elif self.v_tipo_dataset.get() == 'Catálogo': df = self.dc.info_catalogo.columnas elif self.v_tipo_dataset.get() == 'Catálogo Robusto': df = self.dc.info_catalogo_robusto.columnas self.tv_clase["columns"] = list(df.index).insert(0, 'Nombre') self.tv_atributos["columns"] = list(df.index).insert(0, 'Nombre') self.tv_clase.heading('Nombre', text='Nombre') self.tv_atributos.heading('Nombre', text='Nombre') for i in df.index: self.tv_clase.heading(i, text=i) self.tv_clase.column(i, minwidth=50, width=50, stretch=False) self.tv_atributos.heading(i, text=i) self.tv_atributos.column(i, minwidth=50, width=50, stretch=False) for i, atributo in enumerate(df.columns): valores = [valor if not pd.isnull(valor) else '-' for valor \ in df[atributo]] valores.insert(0, atributo) if atributo == self.dc.info_dataset_original.clase: self.tv_clase.insert('', 'end', text=(0), values=valores) else: self.tv_atributos.insert('', 'end', text=(i + 1), values=valores) #TODO Modificar para que muestre información relevante de la celda. def selectItem(self, event): curItem = self.tv_atributos.item(self.tv_atributos.focus()) col = self.tv_atributos.identify_column(event.x) print('curItem = ', curItem) print('col = ', col) if col == '#0': cell_value = curItem['text'] else: cell_value = curItem['values'][int(col[1:]) - 1] print('cell_value = ', cell_value) def lee_configuracion(self): archivo_cfg = ConfigParser() archivo_cfg.optionxform = lambda option: option archivo_cfg.read('app.cfg') self.root.geometry( archivo_cfg.get('Ventana principal', 'Dimensiones y posición')) self.clase_al_final.set( archivo_cfg.get('Proyecto', 'Clase al final', fallback=True)) self.rutas_relativas.set( archivo_cfg.get('Proyecto', 'Rutas relativas', fallback=True)) self.ruta_datasets = archivo_cfg.get('Proyecto', 'Ruta datasets', fallback='../datos/ACDC/') self.ruta_resultados = archivo_cfg.get('Proyecto', 'Ruta resultados', fallback='../datos/catalogos/') def guarda_configuracion(self): archivo_cfg = ConfigParser() archivo_cfg.optionxform = lambda option: option #Dimensiones y posición de la ventana self.root.update() ancho, alto = self.root.winfo_width(), self.root.winfo_height() x, y = self.root.winfo_x(), self.root.winfo_y() archivo_cfg['Ventana principal'] = {\ 'Dimensiones y posición': '{}x{}+{}+{}'.format(ancho, alto, x, y)} archivo_cfg['Proyecto'] = {\ 'Clase al final': self.clase_al_final.get(), 'Ruta datasets': self.ruta_datasets, 'Ruta resultados': self.ruta_resultados, 'Rutas relativas': self.rutas_relativas.get()} with open('app.cfg', 'w') as archivo: archivo_cfg.write(archivo) def cerrar_aplicacion(self): self.guarda_configuracion() self.root.destroy()
class FacultyReturnWindow: def __init__(self): self.win = Tk() self.canvas = Canvas(self.win, width=800, height=420, bg='white') self.canvas.pack(expand=YES, fill=BOTH) # show window in center of the screen width = self.win.winfo_screenwidth() height = self.win.winfo_screenheight() x = int(width / 2 - 800 / 2) y = int(height / 2 - 420 / 2) str1 = "800x420+" + str(x) + "+" + str(y) self.win.geometry(str1) # disable resize window self.win.resizable(False, False) # changing title of the window self.win.title( "| BOOK RETURNING DETAILS | LIBRARY MANAGEMENT SYSTEM |") def add_frame(self): self.frame = Frame(self.win, height=420, width=800) self.frame.place(x=0, y=0) x, y = 0, 0 self.label = Label(self.frame, text="BOOK RETURNING BY FACULTY", fg='black') self.label.config(font=("Poppins", 20, 'underline bold')) self.label.place(x=175, y=30) # use tree view to show details from the table self.tr = Treeview(self.frame, columns=('BOOK_ID', 'FACULTY_ID', 'ISSUE_DATE', 'RETURN_DATE'), selectmode="extended") self.tr.heading('#0', text='BOOK_ID') self.tr.column('#0', minwidth=0, width=100, stretch=NO) self.tr.heading('#1', text='FACULTY_ID') self.tr.column('#1', minwidth=0, width=100, stretch=NO) self.tr.heading('#2', text='ISSUE_DATE') self.tr.column('#2', minwidth=0, width=100, stretch=NO) self.tr.heading('#3', text='RETURN_DATE') self.tr.column('#3', minwidth=0, width=100, stretch=NO) self.tr.heading('#4', text='RETURN') self.tr.column('#4', minwidth=0, width=100, stretch=NO) # self.tr.heading('#5', text='RETURN') # self.tr.column('#5', minwidth=0, width=100, stretch=NO) j = 0 for i in Database.database.FacultyBookLend(): self.tr.insert('', index=j, text=i[0], values=(i[1], i[2], i[3], 'RETURN')) j += 1 # create action on deletion self.tr.bind('<Double-Button-1>', self.bounce) self.tr.place(x=140, y=y + 100) self.win.mainloop() def bounce(self, e): # get the value of deleted row tt = self.tr.focus() # get the column id col = self.tr.identify_column(e.x) # print(col) # print(self.tr.item(tt)) # print(self.tr.item(tt)['text']) # print(self.tr.item(tt)['values'][0]) data = ( str(self.tr.item(tt)['text']), str(self.tr.item(tt)['values'][0]), ) if col == '#4': res = messagebox.askyesno("Message", "Do you want to Return..!") if res: d = Database.database.FacultyReturn(data) if d: messagebox.showinfo( "Message", "Faculty Book Returned successfully..!") self.win.destroy() x = Thirdpage else: self.win.destroy() x = Student.FacultyRet.FacultyReturnWindow() x.add_frame()
class Search: def __init__(self): self.window = Tk() self.window.title( "Search | All Record | National Textile University Faisalabad") self.window.iconbitmap('blood1.ico') can = Canvas(self.window, width=800, height=400, bg="white") can.pack(expand=YES, fill=BOTH) width = self.window.winfo_screenwidth() height = self.window.winfo_screenheight() # print("Width:",width,"\n","Height:",height) x = int(width / 2 - 800 / 2) y = int(height / 2 - 400 / 2) str1 = "980x450+" + str(x) + "+" + str(y) self.window.geometry(str1) self.window.maxsize(980, 450) self.window.minsize(980, 450) def add_fram_search(self): self.frame = Frame(self.window, width=850, height=385, bg="#ef5151") self.frame.place(x=77, y=20) self.l1 = Label(self.frame, text="Enter Reg_N/Blood_G:", font="Times 16 bold") self.l1.place(x=50, y=43) self.Entry_reg = Entry(self.frame, font="courior 14 bold") self.Entry_reg.place(x=280, y=43, height=30) # search-Button self.b1 = Button(self.frame, text="Search-RN", font="Times 12 bold") self.b1.place(x=510, y=40, height=37) self.b1.bind('<Button-1>', self.regno) self.b1 = Button(self.frame, text="Search-BG", font="Times 12 bold") self.b1.place(x=599, y=40, height=37) self.b1.bind('<Button-1>', self.bg) # Back-Buton self.b1 = Button(self.frame, text="Back", font="Times 12 bold") self.b1.place(x=690, y=40, height=37) self.b1.bind('<Button-1>', self.back) # for Styling Table style = Style() style.configure("mystyle.Treeview", highlightthickness=0, bd=0, font=('Calibri 11')) # Modify the font of the body style.configure( "mystyle.Treeview.Heading", font=('Calibri 13 bold')) # Modify the font of the headings style.layout("mystyle.Treeview", [('mystyle.Treeview.treearea', { 'sticky': 'nswe' })]) # Remove the borders # import TreeViewe self.tr = Treeview(self.frame, columns=('A', 'B', 'C', 'D', 'E', 'F'), selectmode="extended", style="mystyle.Treeview") # heading key+text self.tr.heading("#0", text="Sr_No") self.tr.column("#0", minwidth=0, width=100, stretch=NO) self.tr.heading("#1", text="Name") self.tr.column("#1", minwidth=0, width=100, stretch=NO) self.tr.heading("#2", text="Reg_No") self.tr.column("#2", minwidth=0, width=100, stretch=NO) self.tr.heading("#3", text="Blood_Group") self.tr.column("#3", minwidth=0, width=100, stretch=NO) self.tr.heading("#4", text="Phone_No") self.tr.column("#4", minwidth=0, width=100, stretch=NO) self.tr.heading("#5", text="update") self.tr.column("#5", minwidth=0, width=100, stretch=NO) self.tr.heading("#6", text="delete") self.tr.column("#6", minwidth=0, width=100, stretch=NO) self.sb = Scrollbar(self.tr) self.sb.place(x=673, y=2, height=223, width=20, bordermode=OUTSIDE) self.sb.config(command=self.tr.yview) self.tr.config(yscrollcommand=self.sb.set) self.tr.place(x=50, y=100, width=691) # Remove All ROW self.Entry_reg.bind('<KeyRelease>', self.remove) self.tr.bind('<Double-Button-1>', self.action) self.window.mainloop() def regno(self, event): try: data = (self.Entry_reg.get(), ) if self.Entry_reg.get() == "": msg.showwarning("Message!", "insert Reg No!") else: j = 1 D = Database_Insert.search_details(data) if D: self.Entry_reg.delete(0, END) for i in D: self.tr.insert('', index=j, text=j, values=(i[0], i[1], i[2], i[3], "update", "delete")) j += 1 else: msg.showwarning("Message!", "No result Found!") except: msg.showwarning("Error!", "ERORR!") def bg(self, event): try: data = (self.Entry_reg.get(), ) if self.Entry_reg.get() == "": msg.showwarning("Message!", "insert Blood_Group!") else: j = 1 D = Database_Insert.search_details_bg(data) if D: self.Entry_reg.delete(0, END) for i in D: self.tr.insert('', index=j, text=j, values=(i[0], i[1], i[2], i[3], "update", "delete")) j += 1 else: msg.showwarning("Message!", "No result Found!") except: msg.showwarning("Error!", "ERORR!") def remove(self, event): x = self.tr.get_children() if x != '()': for child in x: self.tr.delete(child) def action(self, event): fcs = self.tr.focus() col = self.tr.identify_column(event.x) x = self.tr.item(fcs).get('values') text = x[1] data = (text, ) if col == "#6": res = msg.askyesno("Message!", "Do you want to delete?") if res: d = Database_Insert.delete_details(data) if d: msg.showinfo("Deleted", "Successfully") self.window.destroy() x = Search() x.add_fram_search() else: self.window.destroy() x = Search() x.add_fram_search() elif col == "#5": # self.window.destroy() x = Home.data(self.tr.item(fcs)) x.add_frame() def back(self, event): self.window.destroy() x = Home.data() x.add_frame()
class DeleteWindow: def __init__(self, data=''): self.data = data print(self.data) self.win = Tk() self.canvas = Canvas(self.win, width=800, height=420, bg='white') self.canvas.pack(expand=YES, fill=BOTH) # show window in center of the screen width = self.win.winfo_screenwidth() height = self.win.winfo_screenheight() x = int(width / 2 - 800 / 2) y = int(height / 2 - 420 / 2) str1 = "800x420+" + str(x) + "+" + str(y) self.win.geometry(str1) # disable resize window self.win.resizable(False, False) # changing title of the window self.win.title("| DELETING BOOK DETAILS | LIBRARY MANAGEMENT SYSTEM |") def add_frame(self): self.frame = Frame(self.win, height=420, width=800) self.frame.place(x=0, y=0) x, y = 0, 0 self.label = Label(self.frame, text="DELETING BOOK DETAILS", fg='black') self.label.config(font=("Poppins", 20, 'underline bold')) self.label.place(x=235, y=35) # use tree view to show details from the table self.tr = Treeview(self.frame, columns=('BOOK_ID', 'BOOK_TITLE', 'AUTHOR_NAME', 'PUBLISHED_YEAR', 'PRICE'), selectmode="extended") # heading key + text self.tr.heading('#0', text='BOOK_ID') self.tr.column('#0', minwidth=0, width=100, stretch=NO) self.tr.heading('#1', text='BOOK_TITLE') self.tr.column('#1', minwidth=0, width=100, stretch=NO) self.tr.heading('#2', text='AUTHOR_NAME') self.tr.column('#2', minwidth=0, width=100, stretch=NO) self.tr.heading('#3', text='PUBLISHED_YEAR') self.tr.column('#3', minwidth=0, width=110, stretch=NO) self.tr.heading('#4', text='PRICE') self.tr.column('#4', minwidth=0, width=100, stretch=NO) self.tr.heading('#5', text='DELETE') self.tr.column('#5', minwidth=0, width=100, stretch=NO) # self.tr.heading('#6', text='DELETE') # self.tr.column('#6', minwidth=0, width=100, stretch=NO) j = 0 for i in Database.database.ViewBooks(): self.tr.insert('', index=j, text=i[0], values=(i[1], i[2], i[3], i[4], 'DELETE')) j += 1 # create action on deletion self.tr.bind('<Double-Button-1>', self.actions) self.tr.place(x=100, y=y + 100) self.win.mainloop() def actions(self, e): # get the value of deleted row tt = self.tr.focus() # get the column id col = self.tr.identify_column(e.x) print(col) print(self.tr.item(tt)) data = (self.tr.item(tt).get('text'), ) if col == '#5': res = messagebox.askyesno("Message", "Do you want to delete..!") if res: d = Database.database.Delete(data) if d: messagebox.showinfo( "Message", "Book Details deleted successfully..!") self.win.destroy() x = Thirdpage else: self.win.destroy() x = Student.Delete.DeleteWindow() x.add_frame()
class ShowIncome: def __init__(self): self.win = Tk() canvas = Canvas(self.win, width=800, height=400, bg='white') canvas.pack(expand=YES, fill=BOTH) width = self.win.winfo_screenwidth() height = self.win.winfo_screenheight() x = int(width / 2 - 800 / 2) y = int(height / 2 - 400 / 2) str1 = "800x400+" + str(x) + "+" + str(y) self.win.geometry(str1) self.win.resizable(width=False, height=False) self.win.title("Show Income | Administrator") def add_frame(self): self.frame = Frame(self.win, width=600, height=350) self.frame.place(x=80, y=20) x, y = 70, 20 # use treeview to show the data in forms of table #mention the number of columns self.tr = Treeview(self.frame, columns=('A', 'B', 'C', 'D'), selectmode="extended") # heading key + text self.tr.heading('#0', text='Sr No') self.tr.column('#0', minwidth=0, width=100, stretch=NO) self.tr.heading('#1', text='Source') self.tr.column('#1', minwidth=0, width=100, stretch=NO) self.tr.heading('#2', text='Description') self.tr.column('#2', minwidth=0, width=100, stretch=NO) self.tr.heading('#3', text='Update') self.tr.column('#3', minwidth=0, width=100, stretch=NO) self.tr.heading('#4', text='Delete') self.tr.column('#4', minwidth=0, width=100, stretch=NO) j = 0 for i in db.db.show_income(): self.tr.insert('', index=j, text=i[0], values=(i[1], i[2], 'Update', 'Delete')) j += 1 # create action on selected row self.tr.bind('<Double-Button-1>', self.actions) self.tr.place(x=50, y=y + 50) self.win.mainloop() def actions(self, e): # get the value of selected row tt = self.tr.focus() # get the column id col = self.tr.identify_column(e.x) print(col) print(self.tr.item(tt)) tup = (self.tr.item(tt).get('text'), ) if col == '#4': res = messagebox.askyesno("Message", "Do you want to delete") if res: rs = db.db.delete_income(tup) if rs: messagebox.showinfo("Message", "Data deleted successfully") self.win.destroy() z = ShowIncome() z.add_frame() else: self.win.destroy() z = ShowIncome() z.add_frame()
class main: def __init__(self): self.tk = Tk() height = self.tk.winfo_screenheight() width = self.tk.winfo_screenwidth() y = (height - 650) // 2 x = (width - 650) // 2 self.tk.geometry('650x650+' + str(x) + '+' + str(y)) self.tk.resizable(height=False, width=False) self.tk.title("manage patient") '''self.can=Canvas(self.tk,height="650",width="650") self.can.pack() self.img=PhotoImage(file="./image/img21.gif") self.can.create_image(0,0,image=self.img,anchor=NW)''' self.f = Frame(self.tk, height="100", width="700", bg="#070719") self.f.place(x=0, y=0) self.l = Label(self.f, text="Manage Appointment", fg="powder blue", font=('cooper black', 30), bg="#070719") self.l.place(x=120, y=20) self.f1 = Frame(self.tk, height="650", width="650", bg="#C2DFFF") self.f1.place(x=0, y=100) self.fr = Frame(self.f1, height="10", width="700", bg="#070719") self.fr.place(x=0, y=10) self.fr1 = Frame(self.f1, height="70", width="700", bg="#070719") self.fr1.place(x=0, y=500) self.table = Treeview(self.f1, column=("#0", "#1", "#2", "#3", "#4", "#5")) style = ttk.Style() style.theme_use("alt") ttk.Style().configure("Treeview.heading", font=('', 15)) self.table.heading("#0", text="Sno.") self.table.column("#0", width="40") self.table.heading("#1", text="P_name") self.table.column("#1", width="60") self.table.heading("#2", text="Timing") self.table.column("#2", width="70") self.table.heading("#3", text="Date") self.table.column("#3", width="70") self.table.heading("#4", text="Description") self.table.column("#4", width="70") self.table.heading("#5", text="Edit") self.table.column("#5", width="70") self.table.heading("#6", text="Delete") self.table.column("#6", width="70") self.table.place(x=80, y=140) r = database_queries.database() res = r.view_appoint() print(res) for i in res: self.table.insert('', 'end', text=i[0], value=(i[2], i[3], i[4], i[5], "Edit", "Delete")) self.table.place(x=100, y=150) self.table.bind("<Double Button>", self.fun) self.tk.mainloop() def fun(self, f): #print(e) d1 = self.table.focus() z = (self.table.item(d1)) col1 = self.table.identify_column(f.x) if col1 == "#5": y = editappoint.main(z["text"]) print("edit") elif col1 == "#6": print("delete")
class TreeType(Frame): def __init__(self, parent, item, dialog): Frame.__init__(self, parent) self.parent = parent self.item = item self.numTypeAdded = 0 self.dialogParent = dialog self.listType = item.type self.data = Database() self.drawScreen() self.linkAccelerator() for typeItem in self.listType: self.addTypeIntoTree(typeItem) def linkAccelerator(self): self.bind_all("<Shift-Delete>", self.onDeleteItem) self.bind_all("<Control-N>", self.onAddType) self.bind_all("<Delete>", self.onDeleteType) def drawScreen(self): # self.pack(fill = BOTH, anchor = "w", expand = True) ########## Listing all Bills which has been created ########### layoutList = Frame(self) self.drawTreeOfType(layoutList) layoutList.pack(side=LEFT, fill=BOTH, expand=True) self.menu = Menu(self) self.dialogParent.config(menu=self.menu) self.drawMenu(self.menu) def drawTreeOfType(self, parent): self.pack(fill=BOTH, expand=True) listAttribute = ["Loại hàng", "Số lượng tồn", "Đơn giá"] yScrollTree = Scrollbar(parent, orient=VERTICAL) xScrollTree = Scrollbar(parent, orient=HORIZONTAL) # Create Delete, Add and Edit Button layoutButton = Frame(self) btnAddType = Button(layoutButton, text="+", fg="green", command=self.onAddType) btnDelType = Button(layoutButton, text="-", fg="red", command=self.onDeleteType) btnRefresh = Button(layoutButton, text="Refresh", fg="blue", command=self.dialogParent.onRefresh) btnAddType.pack(side=LEFT) btnDelType.pack(side=LEFT) btnRefresh.pack(side=RIGHT) layoutButton.pack(side=TOP, fill=X, anchor="w") # Create Tree View self.treeType = Treeview(parent, column=listAttribute, yscrollcommand=yScrollTree.set, xscrollcommand=xScrollTree.set) self.treeType.bind(sequence="<Double-Button-1>", func=self.onEditType) self.treeType.heading(column="#0", text="ID") self.treeType.column(column="#0", width=100, minwidth=100) for nameAttr in listAttribute: self.treeType.heading(column=nameAttr, text=nameAttr) self.treeType.column(column=nameAttr, width=100, minwidth=100) #Create Scrollbar for tree view yScrollTree.pack(side=RIGHT, fill=Y) xScrollTree.pack(side=BOTTOM, fill=X) self.treeType.pack(side=TOP, anchor="w", fill=BOTH, expand=True) yScrollTree.config(command=self.treeType.yview) xScrollTree.config(command=self.treeType.xview) def drawMenu(self, parent): # Item Menu itemMenu = Menu(parent) itemMenu.add_command(label="Thêm mặt hàng", command=self.dialogParent.onAddItem, accelerator="Ctrl+N") itemMenu.add_command(label="Xóa mặt hàng", command=self.onDeleteItem, accelerator="Shift+Delete") parent.add_cascade(label="Mặt hàng", menu=itemMenu) # Type Menu typeMenu = Menu(parent) typeMenu.add_command(label="Thêm loại hàng", command=self.onAddType, accelerator="Ctrl+Shift+N") typeMenu.add_command(label="Xóa loại hàng", command=self.onDeleteType, accelerator="Delete") parent.add_cascade(label="Loại hàng", menu=typeMenu) def addTypeIntoTree(self, typeInput): temp = typeInput # if not self.treeType.exists(temp.idParent) : # self.treeType.insert("","end", str(temp.idParent), text = temp.idParent) # self.treeType.item(temp.idParent, open = True) self.treeType.insert("", "end", str(temp.idType), text=temp.idType) self.treeType.set(temp.idType, "Loại hàng", temp.name) self.treeType.set(temp.idType, "Số lượng tồn", temp.amount) self.treeType.set(temp.idType, "Đơn giá", int(temp.unitPrice)) def onEditType(self, event=None): listTemp = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] curItem = self.treeType.item(self.treeType.focus()) col = self.treeType.identify_column(event.x) print(curItem) print(col) if curItem["text"] in listTemp and col != "#0": if col != "#0": messagebox.showinfo( "Thêm loại", "Sửa ID loại tạm này để lưu lại vào Database", parent=self) return cellValue = None if col == "#0": temp = simpledialog.askstring("Đổi ID", "Nhập ID mới", parent=self) if temp != None: if len(temp) > 0: cellValue = curItem["text"] try: if cellValue in listTemp: idTab = self.parent.select() frameChosen = self.parent._nametowidget(idTab) typeItem = TypeItem(curItem["values"][0], 0, 0, temp, frameChosen.item.id) self.data.insertTypeItem(typeItem) frameChosen.treeType.update() print("Sau khi sua:", self.treeType.item(self.treeType.focus())) else: self.data.updateIdOfType(cellValue, temp) except (sqlite3.IntegrityError, TclError): messagebox.showwarning( "Opps !!!!", message="ID bạn nhập đã tồn tại !!!!", parent=self) return if cellValue in listTemp: frameChosen.numTypeAdded -= 1 self.treeType.update() else: messagebox.showwarning("Empty !!!", "ID không thể để trống", parent=self) self.treeType.insert( "", str(self.treeType.index(self.treeType.focus())), temp, text=temp, values=curItem["values"]) self.treeType.delete(self.treeType.focus()) return if col == "#1": temp = simpledialog.askstring("Đổi tên loại hàng", "Nhập tên mới", parent=self) if temp != None: if len(temp) > 0: cellValue = curItem["values"][0] self.data.updateNameOfType(curItem["text"], temp) curItem["values"][0] = temp self.treeType.item(curItem["text"], values=curItem["values"]) self.treeType.update() else: messagebox.showwarning("Empty !!!", "Tên loại hàng không thể để trống", parent=self) return if col == "#2": temp = simpledialog.askinteger("Đổi số lượng tồn", "Nhập số lượng tồn mới: ", parent=self) if temp != None: if temp >= 0: cellValue = curItem["values"][1] self.data.updateAmountOfType(curItem["text"], temp) curItem["values"][1] = temp print(curItem["text"]) self.treeType.item(curItem["text"], values=curItem["values"]) self.treeType.update() else: messagebox.showwarning("Empty !!!", "Số lượng không thể là số âm", parent=self) return if col == "#3": temp = simpledialog.askfloat("Đổi đơn giá", "Nhập đơn giá mới: ", parent=self) if temp != None: if temp >= 0: cellValue = curItem["values"][2] self.data.updateUnitOfType(curItem["text"], temp) curItem["values"][2] = temp print(curItem["text"]) self.treeType.item(curItem["text"], values=curItem["values"]) self.treeType.update() else: messagebox.showwarning("Empty !!!", "Đơn giá không thể là số âm", parent=self) return print("Cell Values = ", cellValue) def onAddType(self, event=None): idTab = self.parent.select() frameChosen = self.parent._nametowidget(idTab) if frameChosen.numTypeAdded > 9: messagebox.showwarning( "Warning", "Bạn chỉ có thể thêm tạm 10 loại \n Hãy Sửa ID để lưu lại những loại tạm trên", parent=self) return typeItem = TypeItem(name=frameChosen.numTypeAdded, amount=0, unitPrice=0, idType="#", idParent=frameChosen.item.id) frameChosen.addTypeIntoTree(typeItem) frameChosen.numTypeAdded += 1 def onDeleteType(self, event=None): idTab = self.parent.select() frameChosen = self.parent._nametowidget(idTab) curItem = frameChosen.treeType.selection() accept = messagebox.askokcancel( "Xóa loại hàng này", "Bạn thật sự muốn xóa!!! Bạn không thể hoàn tác hành động này", parent=self) if accept == True: if len(curItem) == 0: messagebox.showwarning( title="Empty !!!", message="Xin hãy chọn loại hàng bạn muốn xóa", parent=self) return for choose in curItem: treeItem = frameChosen.treeType.item(choose) self.data.deleteType(treeItem["values"][0]) frameChosen.treeType.delete(treeItem["text"]) def onDeleteItem(self, event=None): idTab = self.parent.select() frameChosen = self.parent._nametowidget(idTab) accept = messagebox.askokcancel( "Xóa loại hàng này", "Bạn thật sự muốn xóa!!! Bạn không thể hoàn tác hành động này", parent=self) if accept == True: idTab = self.parent.select() frameChosen = self.parent._nametowidget(idTab) self.data.deleteItem(frameChosen.item.id) self.parent.forget(idTab) self.parent.update() def onDestroy(self, event): # ask = """ # Bạn thực sự muốn đóng ứng dụng # """ # messagebox.askokcancel("Closing!!!",) self.dialogParent.destroy()