Inside tkinter notebook, ttk widget not responding
Asked Answered
M

0

0

In my application I have a main frame. Then make a login frame inside the main frame.

Then make a notebook frame inside the login Frame.

But inside the notebook frame, ttk combobox, butoon are not showing as per ttk style.

It show as the default comboBox, default button.

Here the code

from tkinter import *
from tkinter import ttk
from tkinter.messagebox import askyesno

root = Tk()

root.geometry("500x500+10+10")

main_frame = Frame(root)
# main_frame.pack(side=LEFT, padx=5, pady=5)
# main_frame.pack_propagate(False)
main_frame.configure(width=2000, height=1400)
main_frame.pack(expand=True, fill=BOTH)


login_frame1 = Frame(main_frame)
login_frame1.configure(width=2000, height=1400)
login_frame1.pack(expand=True, fill=BOTH)


COLOR_GREEN = "#996666"
COLOR_select = "#b3cccc"

# style for notebook tab
style = ttk.Style()
style.theme_create("yummy", parent="alt", settings={ 
"TNotebook": {"configure": {"tabmargins": [2, 5, 2, 0] } },
"TNotebook.Tab": {
"configure": {"padding": [5, 1], "background": COLOR_GREEN, "font" : ('times', '11', 'bold')},
"map":       {"background": [("selected", COLOR_select)],
"expand": [("selected", [1, 1, 1, 0])] } } } )

style.configure("yummy", focuscolor=style.configure(".")["background"])
style.theme_use("yummy")


# global notebook
notebook = ttk.Notebook(login_frame1)
notebook.pack(expand=True, fill=BOTH)

frame_color = 'white'
input_color = '#c7d1d1'

label_font = ('calibri',12, 'bold')
input_font = ('times',12)


tab1 = Frame(notebook, bg=frame_color)
tab2 = Frame(notebook, bg=frame_color)
tab1.pack(expand=True, fill= BOTH)

# Add tab1 frame into notebook
notebook.add(tab1, text='Table 1')
notebook.add(tab2, text='Table 2')
notebook.select(tab1) 

txt = 'Table View'
lbl = Label(tab1, text=txt, font=('Gloss And Bloom',20,'bold'),  fg='red', bg='white')
lbl.place(x=80, y=5, relwidth=1, height=45)

combo = ttk.Combobox(tab1)
combo.place(x=10, y=15)

btn = ttk.Button(tab1, text='Click me', width=20)
btn.place(x=10, y=50)




root.mainloop()
Michalmichalak answered 15/5, 2023 at 11:7 Comment(4)
It this is what you want? ibb.co/cN2xLD4Ylem
The code seems to work fine for me. Also, your question is unclear. The title says widgets don't respond, but in the body you seem to be asking about colors.Phillip
@toyotaSupra No. Look at the code, here I'm using ttk.Combobox . But in the output it look like default Combobox, not ttk.Combobox.Michalmichalak
What do you mean default combobox? I'm using ttk.combobox and ttk.Button, etc. Please edit your question..Ylem

© 2022 - 2024 — McMap. All rights reserved.