Prev: C-level command for [file join [file dirname [info script]]
Next: TclOO and defining a "variable" method
From: Georgios Petasis on 24 Mar 2010 14:08 Hi all, Does anybody knows how can I change the background colour of a ttk widget? (In this case the shash of a pane, and the background of a notebook). I have this window: http://www.ellogon.org/~petasis/tcl/TkRibbon/images/Ellogon-Ribbon-System-Logs.png I want to change the background colour at the tab area (beneath Output, Time Log & Error Log), but without loosing the native tabs. I have a rough idea that I need to create a new "style" (is this correct?) but I don't know how to start. Is this feasible? (The wiki seems too slow today, so I cannot search for the time being...) George
From: Georgios Petasis on 24 Mar 2010 14:57 στις 24/3/2010 20:08, O/H Georgios Petasis έγραψε: > Hi all, > > Does anybody knows how can I change the background colour of a ttk > widget? (In this case the shash of a pane, and the background of a > notebook). > > I have this window: > http://www.ellogon.org/~petasis/tcl/TkRibbon/images/Ellogon-Ribbon-System-Logs.png > > > I want to change the background colour at the tab area (beneath Output, > Time Log & Error Log), but without loosing the native tabs. > > I have a rough idea that I need to create a new "style" (is this > correct?) but I don't know how to start. > Is this feasible? > > (The wiki seems too slow today, so I cannot search for the time being...) > > George I tried this: package req Tk ttk::style layout System.notebook { Notebook.client -sticky nswe } ttk::style configure System.notebook -background red ttk::notebook .x for {set i 0} {$i < 10} {incr i} { .x add [frame .x.f$i] -text $i pack [text .x.f$i.t -height 4 -width 60] } pack .x -fill both -expand true A complete failure: I only get half tabs :D George
From: Georgios Petasis on 24 Mar 2010 15:53 στις 24/3/2010 20:08, O/H Georgios Petasis έγραψε: > Hi all, > > Does anybody knows how can I change the background colour of a ttk > widget? (In this case the shash of a pane, and the background of a > notebook). > > I have this window: > http://www.ellogon.org/~petasis/tcl/TkRibbon/images/Ellogon-Ribbon-System-Logs.png > > > I want to change the background colour at the tab area (beneath Output, > Time Log & Error Log), but without loosing the native tabs. > > I have a rough idea that I need to create a new "style" (is this > correct?) but I don't know how to start. > Is this feasible? > > (The wiki seems too slow today, so I cannot search for the time being...) > > George Ok, the following works: ttk::style configure TNotebook -background red But, this changes all notebooks. I tried to create a new layout: ttk::style layout System.Notebook { Notebook.client -sticky nswe } When I use it on a notebook, I get the correct colour, but the tabs do not resize as supposed (and do with the default layout). What is the layout I define missing? George
From: Schelte Bron on 24 Mar 2010 17:14 Georgios Petasis wrote: > Ok, the following works: > > ttk::style configure TNotebook -background red > > But, this changes all notebooks. I tried to create a new layout: > > ttk::style layout System.Notebook { > Notebook.client -sticky nswe > } > > When I use it on a notebook, I get the correct colour, but the > tabs do not resize as supposed (and do with the default layout). > What is the layout I define missing? > It is a misconception to think there even is such a thing as a background color for ttk::widgets. Some themes may use a gradient or a pattern for the background. So at best your strategy will only work with some themes and you should reconsider if this is really what you want to do. If you still decide you want to change the background color of the notebook, you don't have to create a new layout. After all, you are not changing the layout, just the color. So simply use: ttk::style configure System.TNotebook -background red ttk::notebook .nb -style System.TNotebook Schelte.
From: George Petasis on 24 Mar 2010 18:36 στις 24/3/2010 11:14 μμ, O/H Schelte Bron έγραψε: > Georgios Petasis wrote: >> Ok, the following works: >> >> ttk::style configure TNotebook -background red >> >> But, this changes all notebooks. I tried to create a new layout: >> >> ttk::style layout System.Notebook { >> Notebook.client -sticky nswe >> } >> >> When I use it on a notebook, I get the correct colour, but the >> tabs do not resize as supposed (and do with the default layout). >> What is the layout I define missing? >> > It is a misconception to think there even is such a thing as a > background color for ttk::widgets. Some themes may use a gradient or > a pattern for the background. So at best your strategy will only > work with some themes and you should reconsider if this is really > what you want to do. > > If you still decide you want to change the background color of the > notebook, you don't have to create a new layout. After all, you are > not changing the layout, just the color. So simply use: > > ttk::style configure System.TNotebook -background red > ttk::notebook .nb -style System.TNotebook > > > Schelte. > Dear Schelte, Thanls, it works. I had no idea that I can configure a non-existing style... George
|
Next
|
Last
Pages: 1 2 Prev: C-level command for [file join [file dirname [info script]] Next: TclOO and defining a "variable" method |