Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is there a simple way to change ttk::combobox arrow image?

458 views
Skip to first unread message

Adrian Davis

unread,
Apr 12, 2012, 7:27:16 AM4/12/12
to
Is there a simple way to change ttk::combobox arrow to use another
image?

if so, is there an example as to how?

Many Thanks,
=Adrian=

tombert

unread,
Apr 12, 2012, 1:29:11 PM4/12/12
to
The only way I know would imply to create a ttk element, change the style and then catch the mouse events - buts thats far from "simple".

Emiliano

unread,
Apr 13, 2012, 3:54:39 PM4/13/12
to
You can create a new Combobox.downarrow element based on an image.
A simple example:

package require Tk
set img [image create photo -data {
R0lGODlhDQAQAPQAAFw1Zl42Z2A6amE6amI7a2I8a2I8bKeHqK6BqbSLsLWLsLuV
t7ufu7yfu72hvL6ivb6ivr+jvsKgvsWlwseow8iqxcmrxs+1zNC2zdO70dS90tW9
0tW+0wAAAAAAAAAAACH5BAEAAB0ALAAAAAANABAAAAVMYCd2QFmOKJltGZCOwMZt
7kvKtH3P9RvzutgmZ4tdiL6NBUkyGTaSjMHkEjgyGcuiwnIIRoWIJUG2eFPhCYJy
fhUkmLbNcPjqRL1RCAA7
}]
ttk::style element create Combobox.downarrow image $img
pack [ttk::combobox .cb1]


See the ttk_image documentation for more details.

Regards
Emiliano

Emiliano

unread,
Apr 13, 2012, 5:01:53 PM4/13/12
to
On 13 abr, 16:54, Emiliano <emilianogavi...@gmail.com> wrote:
> On 12 abr, 08:27, Adrian Davis <adr...@satisoft.com> wrote:
>
> > Is there a simple way to change ttk::combobox arrow to use another
> > image?
>
> > if so, is there an example as to how?
>
> > Many Thanks,
> >    =Adrian=
[snip]

Thinking about it, it's better to define a new style for the modified
comboboxes, and leave the default style untouched.

package require Tk
set img [image create photo -data {
R0lGODlhDQAQAPQAAFw1Zl42Z2A6amE6amI7a2I8a2I8bKeHqK6BqbSLsLWLsLuV
t7ufu7yfu72hvL6ivb6ivr+jvsKgvsWlwseow8iqxcmrxs+1zNC2zdO70dS90tW9
0tW+0wAAAAAAAAAAACH5BAEAAB0ALAAAAAANABAAAAVMYCd2QFmOKJltGZCOwMZt
7kvKtH3P9RvzutgmZ4tdiL6NBUkyGTaSjMHkEjgyGcuiwnIIRoWIJUG2eFPhCYJy
fhUkmLbNcPjqRL1RCAA7}]
ttk::style element create Mystyle.downarrow image $img
ttk::style layout Mystyle.TCombobox {
Combobox.field -sticky nswe -children {
Mystyle.downarrow -side right -sticky ns
Combobox.padding -expand 1 -sticky nswe -children {
Combobox.textarea -sticky nswe
}
}
}
# default style
pack [ttk::combobox .cb1]
# "Mystyle" style
pack [ttk::combobox .cb2 -style Mystyle.TCombobox]

Regards
Emiliano

Adrian Davis

unread,
Apr 16, 2012, 8:17:00 AM4/16/12
to
On Apr 13, 10:01 pm, Emiliano <emilianogavi...@gmail.com> wrote:
>
> Thinking about it, it's better to define a new style for the modified
> comboboxes, and leave the default style untouched.

Emiliano,

That did the trick.

Many Thanks,
=Adrian=
0 new messages