4

Below is my example code:

from tkinter import *
from tkinter import ttk

root = Tk()
root.geometry("400x300")

style=ttk.Style()
style.configure("TNotebook", highlightbackground="#848a98") # if I use another option like - background="#848a98" - the style changes, but with - highlightbackground="#848a98" - option the style doesn't change..

MainNotebook = ttk.Notebook(root, style="TNotebook")
MainNotebook.place(x=16, y=16)

Frame1=Frame(MainNotebook, background="#ffffff", width=200, height=150)
Frame1.pack()     
Frame2=Frame(MainNotebook, background="#ffffff", width=200, height=150)
Frame2.pack()

MainNotebook.add(Frame1, text="Tab1")
MainNotebook.add(Frame2, text="Tab2")

root.mainloop()

my goal is change the default border color in "#848a98" but the option highlightbackground="#848a98" doesn't work. am I using the wrong instruction? how can I solve my issue?

enter image description here

Art
  • 2,836
  • 4
  • 17
  • 34
TurboC
  • 777
  • 1
  • 5
  • 19
  • Instead of giving us a small snippet, please provide a [mcve]. It doesn't need to be a whole lot more than what you posted, but it should be complete. – Bryan Oakley Oct 05 '20 at 17:31
  • @ Bryan Oakley: I just changed my example. now it's complete. – TurboC Oct 05 '20 at 19:19
  • @ Bryan Oakley: ciao Bryan, just to be sure, don't you have an idea of how to solve the issue? – TurboC Oct 09 '20 at 09:12
  • 1
    it's mystical, tkinter iIt is the most used component and has the worst documentation. – e-info128 Apr 03 '21 at 02:17
  • @e-info128 Tkinter is a wonderful tool. it is already integrated in Python, simple to use and released with a "flexible" license, but let me say, it is not good for professional works! I studied and worked with it for around one year, and I found many issues. the most important ones are these two: https://stackoverflow.com/questions/65137135/how-can-i-clear-the-ram-memory-from-useless-information-used-by-tkinter-wigets https://stackoverflow.com/questions/66879948/tkinter-bad-resizing-with-panedwindow-widgets – TurboC Apr 03 '21 at 15:49
  • @e-info128 the other ones are lacks. as you can see here, you can't change the notebook border color, because the option to do it, doesn't exist and for the treeview widgets it is the same. to delete the bold style and the focus in a ComboBox widget you have to configure a workaround with many code lines, and so on.. I told you, Tkinter has many annoying issues and when you have to create a complex GUI, they make the job really complicated and frustrating. – TurboC Apr 03 '21 at 15:50
  • @e-info128 it is really limitated and it is useful only if you want to create simple GUIs, for complex ones, my advice is use other Frameworks like PyQt or PySide2. – TurboC Apr 03 '21 at 22:31

1 Answers1

0

I think this should do the work. So, as I read it, you need to change the color of the background for focused and not-focused apps; also, for no borders, set the highlight thickness to 0 (ZERO):

from tkinter import *
root = Tk()
e = Entry(highlightthickness=2)
e.config(highlightbackground = "red", highlightcolor= "red")
e.pack()
root.mainloop()
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Ozbej
  • 1