Python Tkinter Notebook widget Python Tkinter Notebook widget tkinter tkinter

Python Tkinter Notebook widget


Label reference: compound

Controls how to combine text and image in the label. By default, if an image or bitmap is given, it is drawn instead of the text. If this option is set to CENTER, the text is drawn on top of the image. If this option is set to one of BOTTOM, LEFT, RIGHT, or TOP, the image is drawn besides the text (use BOTTOM to draw the image under the text, etc.). Default is NONE.

tab1 = note.add_tab(text = "Tab One",image=scheduledimage, compound=TOP)

ttk.Notebook sample:

from Tkinter import *from ttk import *root = Tk()scheduledimage=PhotoImage(...)note = Notebook(root)tab1 = Frame(note)tab2 = Frame(note)tab3 = Frame(note)Button(tab1, text='Exit', command=root.destroy).pack(padx=100, pady=100)note.add(tab1, text = "Tab One",image=scheduledimage, compound=TOP)note.add(tab2, text = "Tab Two")note.add(tab3, text = "Tab Three")note.pack()root.mainloop()exit()


Instead of above code :

from Tkinter import *from ttk import *root = Tk()scheduledimage=PhotoImage(...)note = Notebook(root)tab1 = Frame(note)tab2 = Frame(note)tab3 = Frame(note)Button(tab1, text='Exit', command=root.destroy).pack(padx=100, pady=100)note.add(tab1, text = "Tab One",image=scheduledimage, compound=TOP)note.add(tab2, text = "Tab Two")note.add(tab3, text = "Tab Three")note.pack()root.mainloop()exit()

try this one, it will work :-)

from tkinter import *from tkinter import ttkroot = Tk()scheduledimage=PhotoImage("...")note = ttk.Notebook(root)tab1 = ttk.Frame(note)tab2 = ttk.Frame(note)tab3 = ttk.Frame(note)Button(tab1, text='Exit', command=root.destroy).pack(padx=100, pady=100)note.add(tab1, text = "Tab One",image=scheduledimage, compound=TOP)note.add(tab2, text = "Tab Two")note.add(tab3, text = "Tab Three")note.pack()root.mainloop()