Jul-14-2017, 07:14 PM
(Jul-14-2017, 03:32 PM)Rishav Wrote: Why label of volume class is overwriting the label of area class in both tabs what's the solution to that help please
from tkinter import * from tkinter import ttk class App(Frame): def __init__(self,*args,**kwargs): Frame.__init__(self,*args,**kwargs) self.notebook = ttk.Notebook() self.add_tab() self.notebook.grid(row=0) def add_tab(self): tab = Area(self.notebook) tab2 = Volume(self.notebook) self.notebook.add(tab,text="Tag") self.notebook.add(tab2,text="Tag2") class Area(Frame): def __init__(self,name,*args,**kwargs): Frame.__init__(self,*args,**kwargs) self.label = Label(text="Hi This is Tab1") self.label.grid(row=1,column=0,padx=10,pady=10) self.name = name class Volume(Frame): def __init__(self,name,*args,**kwargs): Frame.__init__(self,*args,**kwargs) self.label = Label(text="Hi This is Tab2") self.label.grid(row=1,column=0,padx=10,pady=10) self.name = name my_app = App()
I think it has something to do with where you are placing each label as it seems you are telling them to be in the same place on screen and Area is in the same place as volume. Two things to try are to alter the row of one of the labels and the other is to use Area.lift after assigning tab2
I think one of these might help to see what is happening.
As I have said in another thread I haven't been using classes so I could be entirely wrong.