Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Turn on, tune up, rock out." -- Billy Gibbons


devel / comp.lang.python / tkinter ttk.Treeview: changing background colour of single item when selected

SubjectAuthor
* tkinter ttk.Treeview: changing background colour of single itemJohn O'Hagan
+- Re: tkinter ttk.Treeview: changing background colour of single itemstefalem
+- Re: tkinter ttk.Treeview: changing background colour of single itemstefalem
`* Re: tkinter ttk.Treeview: changing background colour of single itemstefalem
 +- Re: tkinter ttk.Treeview: changing background colour of single itemstefalem
 +* Re: tkinter ttk.Treeview: changing background colour of single itemJohn O'Hagan
 |`- Re: tkinter ttk.Treeview: changing background colour of single itemstefalem
 +- Re: tkinter ttk.Treeview: changing background colour of single itemThomas Passin
 `- Re: tkinter ttk.Treeview: changing background colour of single itemJohn O'Hagan

1
tkinter ttk.Treeview: changing background colour of single item when selected

<mailman.1759.1675507388.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21564&group=comp.lang.python#21564

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: resea...@johnohagan.com (John O'Hagan)
Newsgroups: comp.lang.python
Subject: tkinter ttk.Treeview: changing background colour of single item
when selected
Date: Sat, 04 Feb 2023 21:42:46 +1100
Lines: 47
Sender: "John O'Hagan" <johnmohagan@gmail.com>
Message-ID: <mailman.1759.1675507388.20444.python-list@python.org>
References: <4dd9c35651eb62c95808e42ce66f0ab1bfdab7c2.camel@johnohagan.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de FTRvJHt/yyUykpCs9ZhrMgfuonD34aQJvQkOTCPksz8A==
Return-Path: <johnmohagan@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=QAdC5D0r;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.039
X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'def': 0.04; 'containing':
0.05; 'issue.': 0.05; 'subject:single': 0.07; 'subject:when':
0.07; 'tkinter': 0.07; 'anymore.': 0.09; 'tags': 0.09; 'import':
0.15; 'displays': 0.16; 'flashing.': 0.16; 'item,': 0.16;
'items,': 0.16; 'structure.': 0.16; 'styles,': 0.16;
'subject:item': 0.16; 'subject:tkinter': 0.16; 'tk()': 0.16;
'to:addr:python-list': 0.20; "i've": 0.22; 'code': 0.23;
'configure': 0.26; 'else': 0.27; 'background': 0.28;
'received:209.85.210': 0.29; 'it,': 0.29; 'error': 0.29; 'header
:User-Agent:1': 0.30; 'received:192.168.1': 0.32; 'but': 0.32;
"i'm": 0.33; 'there': 0.33; 'particular': 0.33; '0);': 0.33;
'rgb(0,': 0.33; 'received:google.com': 0.34; 'item': 0.35;
'auto;': 0.36; 'display': 0.36; 'change': 0.36; "skip:' 10": 0.37;
'using': 0.37; 'received:209.85': 0.37; 'received:192.168': 0.37;
'way': 0.38; 'thanks': 0.38; 'received:209': 0.39; 'two': 0.39;
'list': 0.39; 'want': 0.40; 'font-family:': 0.60; 'widows:': 0.62;
'none;': 0.62; 'font-weight:': 0.62; '0px;': 0.63; 'skip:b 20':
0.63; 'skip:b 10': 0.63; 'orphans:': 0.64; 'text-indent:': 0.64;
'normal;': 0.66; 'skip:t 20': 0.66; 'skip:n 30': 0.67; 'items':
0.68; 'below': 0.69; 'backgrounds': 0.84; 'color.': 0.84; 'flash':
0.84; 'received:192.168.1.109': 0.84; 'sender:addr:gmail.com':
0.84; 'subject: \n ': 0.84; '400;': 0.89; 'none;">': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:user-agent:date:to:from:subject:message-id:sender:from
:to:cc:subject:date:message-id:reply-to;
bh=04OcYFdX68BNSxpihP8r8D/y2an2SjbF60aYfWyTvu4=;
b=QAdC5D0ryL/FMxWRetVFudDxyzSYPJrcKqpPxuCTWLDyoLujlVOtcTgZUUzhnGH9js
mdZ1Pr2QleSjOqKl82sLS9G2CFqGXEk3KxB7o7nnsjd+SXUVeMSsISHIDqq+1q2N1R9h
rlIaYACp9VdiolYhGIwVMrNg/tbov2GqxO/u7cwsx0xBz4ndYypXuCZgvrsAfocBTEvV
RKgNND/UoMsdh9H/8gJqS8ekY/pOSwiGNV4yOlYOXhWuy4ONsbUoJwmglMRyr7KSZlyI
1X/ajTnGyJcgI40cn0sHTvg0xEEXWxZUy/rwfI3wvMzr8h4JYLc+BwifM+ct7tYoFhRD
7hWA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=mime-version:user-agent:date:to:from:subject:message-id:sender
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=04OcYFdX68BNSxpihP8r8D/y2an2SjbF60aYfWyTvu4=;
b=nBlm7UuwJkxIR0RRzOjNq+GZLsFFGKfk3teFBlAj99lfcv5O9NmmqUQMxQfbnkkWM1
8Nrbcpv+RbB1/rSzN/wakNg/5GSObf33GfjeoCn4M9slqjuPFhdEMVHh8KUBCPzmDuC3
tHATV0oHPA/Iox963GAOLWde0dOHS6VfED7znkNKHJvl++7hZieSlrxB617UB/SfctkV
PnARuRQudQ+kvX257K5PbRZAPKMPJRTMbajES1sApoXUuy21x7Jnkgguvjv0HXo6vgkN
JBYDIR9D0Ei08+RPW0AsoEhd4LBTpD4145rGfXZy6Gese1bp3oNTxz7IMS9L026iMdpS
Phlw==
X-Gm-Message-State: AO0yUKXW3xUw5UX4t+5YjPXERrXSOYQgWMX8DRVNweckfWgZ6AnBtT5R
FOhrzo7PY3hd8xvvFPH+E1m4O3WvNRk=
X-Google-Smtp-Source: AK7set/6fnliu2lbYjIJmmhJWT5keJRrFSl1YXfb9zRWkq+0/0zGtmUEtls3RCa+iDYIQscz4PsjDQ==
X-Received: by 2002:a05:6a00:3002:b0:593:b169:ae51 with SMTP id
ay2-20020a056a00300200b00593b169ae51mr11325847pfb.32.1675507384716;
Sat, 04 Feb 2023 02:43:04 -0800 (PST)
User-Agent: Evolution 3.46.3-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <4dd9c35651eb62c95808e42ce66f0ab1bfdab7c2.camel@johnohagan.com>
 by: John O'Hagan - Sat, 4 Feb 2023 10:42 UTC

Hi list

I'm using a ttk Treeview to display a hierarchical data structure. When
an error condition arises in a node, I want the corresponding item in
the Treeview to flash its background color. 

Using a tag to flash the item background works, except when the item is
selected, when the tag has no effect. I want the item to keep flashing
even when selected.

The code below is a minimal example of the issue. It displays a
Treeview containing two items with the first one flashing. If you
select it, you don't see the flashing anymore.

from tkinter import *
from tkinter.ttk import *

root = Tk()
t = Treeview(root)

t.insert('', 0, iid='item1', text='item1')
t.insert('', 1, text='item2')
t.tag_configure('flashtag', background='red')
t.pack()

def flash():
tags = t.item('item1', 'tags')
t.item('item1', tags='' if tags else 'flashtag')
t.after(500, flash)

flash()
mainloop()

Other than tags, the only other way I've found to dynamically change
Treeview backgrounds is using styles, in particular Style.map to
configure the background of a selected item, but they apply to all
items in the Treeview and would flash all selected items, not just the
one I want to keep flashing.

Is there another way to do what I want?

Thanks

--

John

Re: tkinter ttk.Treeview: changing background colour of single item when selected

<c47c9186-42b7-4931-bf75-d7d6812baf1cn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21598&group=comp.lang.python#21598

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a05:6214:1a53:b0:56b:f123:f58a with SMTP id fi19-20020a0562141a5300b0056bf123f58amr346943qvb.80.1675707591107;
Mon, 06 Feb 2023 10:19:51 -0800 (PST)
X-Received: by 2002:a05:622a:1048:b0:3b6:2dcb:f7c0 with SMTP id
f8-20020a05622a104800b003b62dcbf7c0mr27377qte.215.1675707590923; Mon, 06 Feb
2023 10:19:50 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Mon, 6 Feb 2023 10:19:50 -0800 (PST)
In-Reply-To: <mailman.1759.1675507388.20444.python-list@python.org>
Injection-Info: google-groups.googlegroups.com; posting-host=109.113.161.216; posting-account=dCOPzgoAAAC2ct1LtEHnlN9qaHJL-e3h
NNTP-Posting-Host: 109.113.161.216
References: <4dd9c35651eb62c95808e42ce66f0ab1bfdab7c2.camel@johnohagan.com> <mailman.1759.1675507388.20444.python-list@python.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c47c9186-42b7-4931-bf75-d7d6812baf1cn@googlegroups.com>
Subject: Re: tkinter ttk.Treeview: changing background colour of single item
when selected
From: stefale...@gmail.com (stefalem)
Injection-Date: Mon, 06 Feb 2023 18:19:51 +0000
Content-Type: text/plain; charset="UTF-8"
 by: stefalem - Mon, 6 Feb 2023 18:19 UTC

Il giorno sabato 4 febbraio 2023 alle 11:43:29 UTC+1 John O'Hagan ha scritto:
....

> Is there another way to do what I want?

from tkinter import *
from tkinter.ttk import *

root = Tk()
t = Treeview(root)

t.insert('', 0, iid='item1', text='item1')
t.insert('', 1, text='item2')
t.tag_configure('flashtag', background='red')
t.pack()

def flash():
tags = t.item('item1', 'tags')
t.item('item1', tags='' if tags else 'flashtag')
t.after(500, flash)
itemselected = t.selection()
for x in itemselected:
if (x == 'item1'):
t.selection_remove(t.get_children())

flash()

> Thanks
>
> --
>
> John

Re: tkinter ttk.Treeview: changing background colour of single item when selected

<6e36768d-de8b-4068-8dfe-d10a278afa87n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21599&group=comp.lang.python#21599

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a05:622a:214:b0:3b6:3a22:812c with SMTP id b20-20020a05622a021400b003b63a22812cmr45168qtx.96.1675707759684;
Mon, 06 Feb 2023 10:22:39 -0800 (PST)
X-Received: by 2002:ac8:5e51:0:b0:3a8:179f:b1ba with SMTP id
i17-20020ac85e51000000b003a8179fb1bamr41675qtx.47.1675707759515; Mon, 06 Feb
2023 10:22:39 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Mon, 6 Feb 2023 10:22:39 -0800 (PST)
In-Reply-To: <mailman.1759.1675507388.20444.python-list@python.org>
Injection-Info: google-groups.googlegroups.com; posting-host=109.113.161.216; posting-account=dCOPzgoAAAC2ct1LtEHnlN9qaHJL-e3h
NNTP-Posting-Host: 109.113.161.216
References: <4dd9c35651eb62c95808e42ce66f0ab1bfdab7c2.camel@johnohagan.com> <mailman.1759.1675507388.20444.python-list@python.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6e36768d-de8b-4068-8dfe-d10a278afa87n@googlegroups.com>
Subject: Re: tkinter ttk.Treeview: changing background colour of single item
when selected
From: stefale...@gmail.com (stefalem)
Injection-Date: Mon, 06 Feb 2023 18:22:39 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1764
 by: stefalem - Mon, 6 Feb 2023 18:22 UTC

> Is there another way to do what I want?

Try this:

from tkinter import *
from tkinter.ttk import *

root = Tk()
t = Treeview(root)

t.insert('', 0, iid='item1', text='item1')
t.insert('', 1, text='item2')
t.tag_configure('flashtag', background='red')
t.pack()

def flash():
tags = t.item('item1', 'tags')
t.item('item1', tags='' if tags else 'flashtag')
t.after(500, flash)
itemselected = t.selection()
for x in itemselected:
if (x == 'item1'):
t.selection_remove(t.get_children())

flash()

Re: tkinter ttk.Treeview: changing background colour of single item when selected

<2865ec14-cc88-4c3b-a641-788c08f9f851n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21600&group=comp.lang.python#21600

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a05:622a:1819:b0:3a5:7c31:2e3e with SMTP id t25-20020a05622a181900b003a57c312e3emr33536qtc.111.1675707996114;
Mon, 06 Feb 2023 10:26:36 -0800 (PST)
X-Received: by 2002:a05:622a:1a13:b0:3b9:f97b:3241 with SMTP id
f19-20020a05622a1a1300b003b9f97b3241mr28934qtb.262.1675707995899; Mon, 06 Feb
2023 10:26:35 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Mon, 6 Feb 2023 10:26:35 -0800 (PST)
In-Reply-To: <mailman.1759.1675507388.20444.python-list@python.org>
Injection-Info: google-groups.googlegroups.com; posting-host=109.113.161.216; posting-account=dCOPzgoAAAC2ct1LtEHnlN9qaHJL-e3h
NNTP-Posting-Host: 109.113.161.216
References: <4dd9c35651eb62c95808e42ce66f0ab1bfdab7c2.camel@johnohagan.com> <mailman.1759.1675507388.20444.python-list@python.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2865ec14-cc88-4c3b-a641-788c08f9f851n@googlegroups.com>
Subject: Re: tkinter ttk.Treeview: changing background colour of single item
when selected
From: stefale...@gmail.com (stefalem)
Injection-Date: Mon, 06 Feb 2023 18:26:36 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1782
 by: stefalem - Mon, 6 Feb 2023 18:26 UTC

> Is there another way to do what I want?

try this:

from tkinter import *
from tkinter.ttk import *

root = Tk()
t = Treeview(root)

t.insert('', 0, iid='item1', text='item1')
t.insert('', 1, text='item2')
t.tag_configure('flashtag', background='red')
t.pack()

def flash():
tags = t.item('item1', 'tags')
t.item('item1', tags='' if tags else 'flashtag')
t.after(500, flash)
itemselected = t.selection()
for x in itemselected:
if (x == 'item1'):
t.selection_remove(t.get_children())

flash()
mainloop()

Re: tkinter ttk.Treeview: changing background colour of single item when selected

<trrqjs$374de$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21605&group=comp.lang.python#21605

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: stefale...@gmail.com (stefalem)
Newsgroups: comp.lang.python
Subject: Re: tkinter ttk.Treeview: changing background colour of single item
when selected
Date: Mon, 6 Feb 2023 22:14:36 +0100
Organization: A noiseless patient Spider
Lines: 2
Message-ID: <trrqjs$374de$1@dont-email.me>
References: <4dd9c35651eb62c95808e42ce66f0ab1bfdab7c2.camel@johnohagan.com>
<mailman.1759.1675507388.20444.python-list@python.org>
<2865ec14-cc88-4c3b-a641-788c08f9f851n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 6 Feb 2023 21:14:37 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="944372d2e5f68fccf342f3ca4b22b729";
logging-data="3379630"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+WtxHtl2XDke/RftWH0bIP"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.6.0
Cancel-Lock: sha1:kZmZY5ZKa1HPD+Z/tdv8Agkw4Kw=
Content-Language: en-US
In-Reply-To: <2865ec14-cc88-4c3b-a641-788c08f9f851n@googlegroups.com>
 by: stefalem - Mon, 6 Feb 2023 21:14 UTC

I apologize for the 3 messages sent, I could not access the usual news
server and with Google Groups I messed up :)

Re: tkinter ttk.Treeview: changing background colour of single item when selected

<mailman.1808.1676200246.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21665&group=comp.lang.python#21665

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: resea...@johnohagan.com (John O'Hagan)
Newsgroups: comp.lang.python
Subject: Re: tkinter ttk.Treeview: changing background colour of single item
when selected
Date: Sun, 12 Feb 2023 22:10:20 +1100
Lines: 41
Sender: "John O'Hagan" <johnmohagan@gmail.com>
Message-ID: <mailman.1808.1676200246.20444.python-list@python.org>
References: <4dd9c35651eb62c95808e42ce66f0ab1bfdab7c2.camel@johnohagan.com>
<mailman.1759.1675507388.20444.python-list@python.org>
<2865ec14-cc88-4c3b-a641-788c08f9f851n@googlegroups.com>
<fddb7bca4e3bd55d44abdef40fc7f3cbffb7ecc4.camel@johnohagan.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de mCkVyCO3lZXAZe+iCnCD/QzqexlDOihmRedvzM2oKKmA==
Return-Path: <johnmohagan@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=aM1WFjlu;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.062
X-Spam-Evidence: '*H*': 0.88; '*S*': 0.00; 'def': 0.04; '2023': 0.07;
'subject:single': 0.07; 'subject:when': 0.07; 'tkinter': 0.07;
'items.': 0.09; 'tags': 0.09; 'import': 0.15; 'colour': 0.16;
'item,': 0.16; 'subject:item': 0.16; 'subject:tkinter': 0.16;
'tk()': 0.16; '\xc2\xa0for': 0.16; 'wrote:': 0.16; 'to:addr
:python-list': 0.20; 'goal': 0.23; 'seems': 0.26; "isn't": 0.27;
'else': 0.27; 'header:User-Agent:1': 0.30; 'received:209.85.214':
0.32; 'received:192.168.1': 0.32; "i'm": 0.33; 'there': 0.33;
'0);': 0.33; 'rgb(0,': 0.33; 'able': 0.34; 'header:In-Reply-To:1':
0.34; 'received:google.com': 0.34; 'item': 0.35; 'auto;': 0.36;
'mon,': 0.36; 'change': 0.36; 'received:209.85': 0.37;
'received:192.168': 0.37; 'way': 0.38; '8bit%:14': 0.38; 'thanks':
0.38; 'received:209': 0.39; 'quite': 0.39; 'necessary': 0.39;
'font-family:': 0.60; 'skip:\xc2 10': 0.62; 'widows:': 0.62;
'none;': 0.62; 'font-weight:': 0.62; '0px;': 0.63; 'skip:b 10':
0.63; 'orphans:': 0.64; 'your': 0.64; 'text-indent:': 0.64;
'normal;': 0.66; 'skip:t 20': 0.66; 'skip:t 30': 0.67; 'that,':
0.67; 'alle': 0.69; 'received:192.168.1.109': 0.84;
'sender:addr:gmail.com': 0.84; 'subject: \n ': 0.84; '400;': 0.89;
'none;">': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:user-agent:references:in-reply-to:date:to:from:subject
:message-id:sender:from:to:cc:subject:date:message-id:reply-to;
bh=Uz7H8oF+3JCt5C4p8xxZwoaEh3Yn5FIi4Bm2La2V7hI=;
b=aM1WFjluMy53kfnZ7f4fIA/9q4u0aWrmtgr8dy4BZ4s8j+I9oRu4iUbCXHbDlTFQPC
EZ4kIaPTbxJVJfLWX7MPsj5Wml2UFXtjrsIbaNeP1dlEDNjTfHycEb3alVgjK3F9YaeI
sZboQUVVQsVXLVb66O57PHWc/bISiwsXRGgJH+v6CWn1R/DvO4b5trFK9VjTSp09quXi
tOD22Ez2rkdgybMJkMNp6f8El5T37tmXos+c3jlnkWQM0HM0yrTF1igVJ8r3PJyfcs/4
3+pYdNWfqxhgSpWy1dcB8cueA07Yo2P9x7KDDeTET5MKuIKntz1PbVYJHXLr925aDGXY
KI6w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=mime-version:user-agent:references:in-reply-to:date:to:from:subject
:message-id:sender:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to;
bh=Uz7H8oF+3JCt5C4p8xxZwoaEh3Yn5FIi4Bm2La2V7hI=;
b=wZrcognPy/kPK3e/frLeQ8Yw4W5BR+c41hbisKKI6sMl1NklNMeV0d+ZKZ7M/WRPMw
LFPMHcWCryqzh5ITsywQDFtaSfZReQXMuQXoQ8BkJC/0xAPHoqxaTLu1KXDY9np6/rVY
E0nKC2X5Ggkhwyh8FMiB8hbhQPFlVg8EN5hq6e8Gn97P/6UTBXXf3kfer1VxpWITYW46
5FGkF5H0djXxOUKmGjaKwehBWB4uGBgC/A3uZiYh4M7xtXSfuJ79i6wA1U8O/MA9fsJE
hYTAWxUdIiOmLSk9Fr8V103ydCJW8nFakelqfbukTj6chdFXWDE5rftUY/w9zBbTYl/7
BLZA==
X-Gm-Message-State: AO0yUKVtjebgSNEGj+//UfacdN24wCwc/zJ1rRBnLvxhH7s0ls5MY0X6
3/dTRWyv2q2eKjZzkXrguE587xedv68=
X-Google-Smtp-Source: AK7set+yCmFmj0y/jWdDubOLrSKesm23q0n9nxbzPe8OJ10tLV5RBRsw5lxYZC61DOlD+zXdJKNw5g==
X-Received: by 2002:a17:902:f1ca:b0:199:196a:ed0b with SMTP id
e10-20020a170902f1ca00b00199196aed0bmr8653529plc.22.1676200242892;
Sun, 12 Feb 2023 03:10:42 -0800 (PST)
In-Reply-To: <2865ec14-cc88-4c3b-a641-788c08f9f851n@googlegroups.com>
User-Agent: Evolution 3.46.3-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <fddb7bca4e3bd55d44abdef40fc7f3cbffb7ecc4.camel@johnohagan.com>
X-Mailman-Original-References: <4dd9c35651eb62c95808e42ce66f0ab1bfdab7c2.camel@johnohagan.com>
<mailman.1759.1675507388.20444.python-list@python.org>
<2865ec14-cc88-4c3b-a641-788c08f9f851n@googlegroups.com>
 by: John O'Hagan - Sun, 12 Feb 2023 11:10 UTC

On Mon, 2023-02-06 at 10:19 -0800, stefalem wrote:
> Il giorno sabato 4 febbraio 2023 alle 11:43:29 UTC+1 John O'Hagan ha
> scritto:
> ...
>
> > Is there another way to do what I want? 
>
> from tkinter import *
> from tkinter.ttk import *
>
> root = Tk()
> t = Treeview(root)
>
> t.insert('', 0, iid='item1', text='item1')
> t.insert('', 1, text='item2')
> t.tag_configure('flashtag', background='red')
> t.pack()
>   
> def flash():
>  tags = t.item('item1', 'tags')
>  t.item('item1', tags='' if tags else 'flashtag')
>  t.after(500, flash)
>  itemselected = t.selection()
>  for x in itemselected:
>   if (x == 'item1'):
>    t.selection_remove(t.get_children())
>
> flash()

Thank you for your reply. Unfortunately that's not quite what I'm
after, because it unselects the flashing item.

My goal was to be able to change the colour of an individual item
regardless of whether it is selected or not. To do that, it is
necessary to be able to change the colour of an individual selected
item, without changing the selection or changing the colour of other
selected items. It seems this isn't possible.

Thanks

John

Re: tkinter ttk.Treeview: changing background colour of single item when selected

<tsain0$1onrl$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21666&group=comp.lang.python#21666

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: stefale...@gmail.com.invalid (stefalem)
Newsgroups: comp.lang.python
Subject: Re: tkinter ttk.Treeview: changing background colour of single item
when selected
Date: Sun, 12 Feb 2023 12:31:44 +0100
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <tsain0$1onrl$1@dont-email.me>
References: <4dd9c35651eb62c95808e42ce66f0ab1bfdab7c2.camel@johnohagan.com>
<mailman.1759.1675507388.20444.python-list@python.org>
<2865ec14-cc88-4c3b-a641-788c08f9f851n@googlegroups.com>
<fddb7bca4e3bd55d44abdef40fc7f3cbffb7ecc4.camel@johnohagan.com>
<mailman.1808.1676200246.20444.python-list@python.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 12 Feb 2023 11:31:44 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="f2ac3402bc03d2391e09e3c057277b1b";
logging-data="1859445"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX198cRJfBWGsRzQaTBt5vfHb"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.6.0
Cancel-Lock: sha1:zN29O3oe3klLgmIv3A5YTPc45FE=
In-Reply-To: <mailman.1808.1676200246.20444.python-list@python.org>
Content-Language: en-US
 by: stefalem - Sun, 12 Feb 2023 11:31 UTC

Il 12/02/23 12:10, John O'Hagan ha scritto:

> My goal was to be able to change the colour of an individual item
> regardless of whether it is selected or not. To do that, it is
> necessary to be able to change the colour of an individual selected
> item, without changing the selection or changing the colour of other
> selected items. It seems this isn't possible.

ok sorry. As another alternative I had thought of this:

from tkinter import *
from tkinter.ttk import *

root = Tk()
t = Treeview(root)

t.insert('', 0, iid='item1', text='item1')
t.insert('', 1, text='item2')
t.tag_configure('flashtag', background='red')
t.pack()
style = Style()
styleDefault = (style.map("Treeview"))

def flash():
tags = t.item('item1', 'tags')
t.item('item1', tags='' if tags else 'flashtag')
t.after(500, flash)
itemselected = t.selection()
for x in itemselected:
if (x == 'item1'):
style.configure('Treeview', selectbackground='red')
style.map('Treeview', background=[('disabled', 'white')],
foreground=[('disabled', 'red')])
else:
style.map('Treeview', background=[('selected',
styleDefault['background'][1][1])],
foreground=[('selected',
styleDefault['background'][0][1])])
flash()
mainloop()

Maybe it can be useful for other situations.

Bye bye

Re: tkinter ttk.Treeview: changing background colour of single item when selected

<mailman.1809.1676210355.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21667&group=comp.lang.python#21667

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!lilly.ping.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: lis...@tompassin.net (Thomas Passin)
Newsgroups: comp.lang.python
Subject: Re: tkinter ttk.Treeview: changing background colour of single item
when selected
Date: Sun, 12 Feb 2023 08:59:03 -0500
Lines: 68
Message-ID: <mailman.1809.1676210355.20444.python-list@python.org>
References: <4dd9c35651eb62c95808e42ce66f0ab1bfdab7c2.camel@johnohagan.com>
<mailman.1759.1675507388.20444.python-list@python.org>
<2865ec14-cc88-4c3b-a641-788c08f9f851n@googlegroups.com>
<fddb7bca4e3bd55d44abdef40fc7f3cbffb7ecc4.camel@johnohagan.com>
<3a4a97b7-dd85-6d64-4a20-dc65270b60d3@tompassin.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de HshFy3ctHOQjbW2J/7yhZAloT3b5GGB6vZJxmJaQZw9g==
Return-Path: <list1@tompassin.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=tompassin.net header.i=@tompassin.net header.b=Z1ZnUQav;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'def': 0.04; '2023': 0.07;
'e.g.': 0.07; 'else.': 0.07; 'subject:single': 0.07;
'subject:when': 0.07; 'tkinter': 0.07; 'items.': 0.09; 'objects,':
0.09; 'tags': 0.09; 'import': 0.15; 'applies': 0.16; 'be,': 0.16;
'colour': 0.16; 'events:': 0.16; 'item,': 0.16; 'received:10.0.0':
0.16; 'received:64.90': 0.16; 'received:64.90.62': 0.16;
'received:64.90.62.162': 0.16; 'received:dreamhost.com': 0.16;
'subject:item': 0.16; 'subject:tkinter': 0.16; 'tk()': 0.16;
'want,': 0.16; '\xc2\xa0for': 0.16; 'wrote:': 0.16; 'to:addr
:python-list': 0.20; 'goal': 0.23; 'skip:p 30': 0.23; 'seems':
0.26; 'object': 0.26; "isn't": 0.27; 'leave': 0.27; 'else': 0.27;
'old': 0.27; '>>>': 0.28; 'background': 0.28; 'header:User-
Agent:1': 0.30; 'am,': 0.31; 'effect': 0.31; 'think': 0.32;
'objects': 0.32; 'received:10.0': 0.32;
'received:mailchannels.net': 0.32;
'received:relay.mailchannels.net': 0.32; 'but': 0.32; "i'm": 0.33;
'there': 0.33; 'able': 0.34; 'header:In-Reply-To:1': 0.34; 'item':
0.35; 'mon,': 0.36; 'possibly': 0.36; 'change': 0.36; "skip:' 10":
0.37; 'way': 0.38; '8bit%:14': 0.38; 'changes': 0.39; 'quite':
0.39; 'necessary': 0.39; 'skip:o 10': 0.61; 'color': 0.62;
'skip:\xc2 10': 0.62; 'skip:b 10': 0.63; 'becomes': 0.64; 'your':
0.64; 'skip:t 20': 0.66; 'worked': 0.67; 'skip:t 30': 0.67;
'header:Received:6': 0.67; 'received:64': 0.67; 'that,': 0.67;
'exactly': 0.68; 'alle': 0.69; 'depending': 0.70; 'desktop': 0.70;
'restore': 0.76; 'theme': 0.76; '6:10': 0.84; 'itself.': 0.84;
'mouse': 0.84; 'subject: \n ': 0.84
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1676210345; a=rsa-sha256;
cv=none;
b=VA6OLQc6otFoFtM7raiqrDiOJcU5Um/Ilyqjsz35cVNnfFKJj/1NXwIMefwvQyAm/aoMGx
Wz99uMVblmy9JO+4bXoqzX9pmsozdwFsUccFlkI1weRhrVLrFWmrB+JhmfgsbxiptYBab6
8pme9k0Ik91rkI+el2dQ4WHw+hIXSMsFka7NSYM1wZUiCrO6JUg+yQQ/mClb5ijDQSJjii
+0kW8vQD5h5Yc4Gql8WHFdEPrj3P2ghAoUDfQtjGpbB2fL2iv4fIX7Gv5IdpE6iYdEWKgD
qmTsgH7FypR10QNk/1YCJAiU3oBjEKFRh1MXlN9vTvFLoGEKChtXa86ECYAwcA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=mailchannels.net; s=arc-2022; t=1676210345;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:dkim-signature;
bh=yCOfTqkDdDDmvGtqmNRiwADIamiAkWfBf1wgO6cD5ak=;
b=EMRDk8xuJF4KT975swEYGT6/YexB6fHIxbPDk030tLooawOR3iK306k25jreaIi32e647Q
DL4/gIdCl4YG5LLU9/9sCbxRUQlHdmnbVH6ALvjhWvD44IdaarsD+Mx/HHHgmgwsnE5euQ
NEcqjimjcRH5//ZuyFfHs4dWephugBbxGQyTp8hIMLkPGZ00iCZDLCTfn2Y6JTe/Jb83Na
pZEO7meQF+GvWTqRQSVUyLjegpve6vHZEwPvhtFY68DN6iD3u2M/TlcYzqc0nnqJyvmwc8
Mx8YxdTe11hMQulzefwwbI598gwRUOy/TbHYdN1iUW2N/xZpn1xCcO24Nusjpw==
ARC-Authentication-Results: i=1; rspamd-b9c55767f-wsb4l;
auth=pass smtp.auth=dreamhost smtp.mailfrom=list1@tompassin.net
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|tpassin@tompassin.net
X-MailChannels-Auth-Id: dreamhost
X-Belong-Fumbling: 33718de42a6770f1_1676210345615_3889942818
X-MC-Loop-Signature: 1676210345615:734765463
X-MC-Ingress-Time: 1676210345615
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net;
s=dreamhost; t=1676210345;
bh=yCOfTqkDdDDmvGtqmNRiwADIamiAkWfBf1wgO6cD5ak=;
h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding;
b=Z1ZnUQav5KCkZ2RPqemFXbw8Nn236KNgc9J/lXtj9AJhPHMQdChHwW4/535dy5X6Z
Q5h1g/kla/XgDolsXw6hn/AbC6qff5i5PLbJVphX1TajmSpIScmY1F8mdLaIE8UsSS
T3HeIwb6LtASu8ff6hOmKqYGYxtIzjM4ye4PmIsXLQqX8btcztFhdCvNJlUHuN224C
LzMZXI4JHQl9S6bvANmonxcBmaFdLmpA0mojwsbms5myI41J0bKrAWPHhEgBXAO8VT
L+UK5stb7J6AllIBcmcMvWpyR+i9aD3h8HwwlGkIYfZqdIx1upw4locV6bt5wGCNa/
Z6XecsMulh76A==
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.7.2
Content-Language: en-US
In-Reply-To: <fddb7bca4e3bd55d44abdef40fc7f3cbffb7ecc4.camel@johnohagan.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <3a4a97b7-dd85-6d64-4a20-dc65270b60d3@tompassin.net>
X-Mailman-Original-References: <4dd9c35651eb62c95808e42ce66f0ab1bfdab7c2.camel@johnohagan.com>
<mailman.1759.1675507388.20444.python-list@python.org>
<2865ec14-cc88-4c3b-a641-788c08f9f851n@googlegroups.com>
<fddb7bca4e3bd55d44abdef40fc7f3cbffb7ecc4.camel@johnohagan.com>
 by: Thomas Passin - Sun, 12 Feb 2023 13:59 UTC

On 2/12/2023 6:10 AM, John O'Hagan wrote:
> On Mon, 2023-02-06 at 10:19 -0800, stefalem wrote:
>> Il giorno sabato 4 febbraio 2023 alle 11:43:29 UTC+1 John O'Hagan ha
>> scritto:
>> ...
>>
>>> Is there another way to do what I want?
>>
>> from tkinter import *
>> from tkinter.ttk import *
>>
>> root = Tk()
>> t = Treeview(root)
>>
>> t.insert('', 0, iid='item1', text='item1')
>> t.insert('', 1, text='item2')
>> t.tag_configure('flashtag', background='red')
>> t.pack()
>>
>> def flash():
>>  tags = t.item('item1', 'tags')
>>  t.item('item1', tags='' if tags else 'flashtag')
>>  t.after(500, flash)
>>  itemselected = t.selection()
>>  for x in itemselected:
>>   if (x == 'item1'):
>>    t.selection_remove(t.get_children())
>>
>> flash()
>
> Thank you for your reply. Unfortunately that's not quite what I'm
> after, because it unselects the flashing item.
>
> My goal was to be able to change the colour of an individual item
> regardless of whether it is selected or not. To do that, it is
> necessary to be able to change the colour of an individual selected
> item, without changing the selection or changing the colour of other
> selected items. It seems this isn't possible.

I haven't worked with ttk objects or Treeviews, but judging from old
style objects, I think you have to re-apply your color and flashing when
the item becomes selected and possibly again when it becomes unselected.

Depending on exactly what effect you want, you may also need to apply
color and flashing when the mouse moves over the item and again when it
leaves. When I make changes in e.g. color, I like to save the previous
value(s) in the object itself. That way I can easily restore say a
background color without having to work out what it used to be, which
may be some color that Tk applies based on the desktop theme and who
know what else.

Here's an example (simplified) for changing color on mouse hover and
leave events:

BG_KEY = 'bg' if platform.lower().startswith('win') \
else 'activebackground' # Different for Linux!

def on_enter(event):
w = event.widget
w.old_bg = w.cget('bg')
w[BG_KEY] = BUTTON_HOVER # Color you have chosen

def on_leave(event):
w = event.widget
_bg = w.old_bg
w[BG_KEY] = _bg

Re: tkinter ttk.Treeview: changing background colour of single item when selected

<mailman.1812.1676266951.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21673&group=comp.lang.python#21673

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: resea...@johnohagan.com (John O'Hagan)
Newsgroups: comp.lang.python
Subject: Re: tkinter ttk.Treeview: changing background colour of single item
when selected
Date: Mon, 13 Feb 2023 16:42:03 +1100
Lines: 85
Sender: "John O'Hagan" <johnmohagan@gmail.com>
Message-ID: <mailman.1812.1676266951.20444.python-list@python.org>
References: <4dd9c35651eb62c95808e42ce66f0ab1bfdab7c2.camel@johnohagan.com>
<mailman.1759.1675507388.20444.python-list@python.org>
<2865ec14-cc88-4c3b-a641-788c08f9f851n@googlegroups.com>
<fddb7bca4e3bd55d44abdef40fc7f3cbffb7ecc4.camel@johnohagan.com>
<3a4a97b7-dd85-6d64-4a20-dc65270b60d3@tompassin.net>
<be86357e7a5f0cfbdd159363eba61cbd1fecd401.camel@johnohagan.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de Ig2quxaJuxDhgMoI0lIeygT6yUl8ax5eZ6THCAAAwxRA==
Return-Path: <johnmohagan@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=nSE7PBsE;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'looks': 0.02; 'def': 0.04;
'issue.': 0.05; 'e.g.': 0.07; 'else.': 0.07; 'subject:single':
0.07; 'subject:when': 0.07; 'sun,': 0.07; 'tkinter': 0.07;
'items.': 0.09; 'look,': 0.09; 'objects,': 0.09; 'tags': 0.09;
'unlike': 0.09; 'widgets': 0.09; 'applies': 0.16; 'be,': 0.16;
'classic': 0.16; 'colour': 0.16; 'colours': 0.16; 'events:': 0.16;
'item,': 0.16; 'stuck': 0.16; 'subject:item': 0.16;
'subject:tkinter': 0.16; 'want,': 0.16; 'widgets,': 0.16;
'widgets.': 0.16; 'wrote:': 0.16; 'to:addr:python-list': 0.20;
'option': 0.20; 'goal': 0.23; 'skip:p 30': 0.23; 'idea': 0.24;
'(and': 0.25; 'seems': 0.26; 'object': 0.26; "isn't": 0.27;
'leave': 0.27; 'else': 0.27; 'old': 0.27; 'done': 0.28;
'background': 0.28; 'settings': 0.28; 'header:User-Agent:1': 0.30;
'whole': 0.30; 'am,': 0.31; 'approach': 0.31; 'effect': 0.31;
'think': 0.32; 'do.': 0.32; 'nature': 0.32; 'objects': 0.32;
'received:192.168.1': 0.32; 'but': 0.32; "i'm": 0.33; 'able':
0.34; "didn't": 0.34; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'item': 0.35; 'request': 0.35;
'possibly': 0.36; 'change': 0.36; "skip:' 10": 0.37; 'really':
0.37; 'using': 0.37; "it's": 0.37; 'received:209.85': 0.37;
'received:192.168': 0.37; 'way': 0.38; 'could': 0.38; 'put': 0.38;
'8bit%:14': 0.38; 'thanks': 0.38; 'received:209': 0.39; 'changes':
0.39; 'necessary': 0.39; 'hand': 0.40; 'want': 0.40; 'try': 0.40;
'skip:o 10': 0.61; "there's": 0.61; 'color': 0.62; 'skip:\xc2 10':
0.62; 'forward': 0.62; 'great': 0.63; 'skip:b 10': 0.63;
'becomes': 0.64; 'your': 0.64; 'look': 0.65; 'worked': 0.67;
'that,': 0.67; 'exactly': 0.68; 'items': 0.68; 'depending': 0.70;
'desktop': 0.70; '8bit%:100': 0.76; 'restore': 0.76; 'theme':
0.76; '6:10': 0.84; 'itself.': 0.84; 'mouse': 0.84;
'received:192.168.1.109': 0.84; 'say,': 0.84;
'sender:addr:gmail.com': 0.84; 'styles': 0.84; 'subject: \n ':
0.84; '\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0': 0.84; 'interest.': 0.93
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:user-agent:references:in-reply-to:date:to:from:subject
:message-id:sender:from:to:cc:subject:date:message-id:reply-to;
bh=D8KH524zgGqiZtXOVnT1sy4NAqnpSneTeB45UNj4Ga4=;
b=nSE7PBsEeQp6dfmf4nTJVSeQG3cZorjlBs3n7ICBUx+eew2qIuGN7d+p96x0YyKY2P
jVguyPDpmLHdGjZ4yzQUPYzRGO6KBE4ePjfX2mWcaaKIXXBPDI9e8CQzWrB5AAmVHiUa
Dv1Shz7YvMyesHV9NNkJzpIZ9LW01ZVt1Tt1lVQwegMtaZ1vt2sTF4I3M+az+n0cBAWR
pE0HA5w9+z/pQkY8XY3g0q0l8Y+ff5KJtdbMpBqv6V/zQgm3jTactsk/0gvr95ONO5ml
zWAsKVbkXHzvl/w5rQFbxwb5baPZBPaERrDzWW/+zQanoUO/Xj2K8sZRRNGfBTgDKZ5x
75Wg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=mime-version:user-agent:references:in-reply-to:date:to:from:subject
:message-id:sender:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to;
bh=D8KH524zgGqiZtXOVnT1sy4NAqnpSneTeB45UNj4Ga4=;
b=ZcmrCG+YmXpxn12u9eWBqqrYuvruJLsp0tn4+/4EjdAFvN8PKXZCOYbxzobzlNdHeR
rZk/p2q1KxNlUbVRp5kN8rzl3b6HH4ECuqQjR5J484Fb6BN5LQ+H3EYXUwwIVXtey9Cg
Q4cK3LnPHQnHgk/G0MDoy7YlQJmI0eYimw3p3Zh3dQ2tnGerO2pQJ58hyY7KQk+I25ev
ZzC5xc66Ak0ZELkHTBfUBgejP2FbuMJUuVNqi0FAfMTLeAokbq/MPu3DTZB3VnIxh/1N
wQFv5N6lkVQduAMnRgCFSxUql25tu/LwxUx9BkRyTTTZCWJ9A34UcbasNe8ji9bLv7e8
NbWg==
X-Gm-Message-State: AO0yUKUCWRJBmCgdnojZO3SDnsSjZehyEoXvMFdiBiqqU4/uyEUrnv7e
ecoBy1wr+LZB6t+jAY1DEmwxMlcSyeo=
X-Google-Smtp-Source: AK7set96B9RpU94rl0BknhSnu0gJOxe5z3hTuLDIBCXv5eoB+EhV0Q1pKOXpBgsy7hSr6GwVhEJEww==
X-Received: by 2002:a05:6a20:6914:b0:c3:3ea7:e324 with SMTP id
q20-20020a056a20691400b000c33ea7e324mr17969960pzj.34.1676266948190;
Sun, 12 Feb 2023 21:42:28 -0800 (PST)
In-Reply-To: <3a4a97b7-dd85-6d64-4a20-dc65270b60d3@tompassin.net>
User-Agent: Evolution 3.46.3-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <be86357e7a5f0cfbdd159363eba61cbd1fecd401.camel@johnohagan.com>
X-Mailman-Original-References: <4dd9c35651eb62c95808e42ce66f0ab1bfdab7c2.camel@johnohagan.com>
<mailman.1759.1675507388.20444.python-list@python.org>
<2865ec14-cc88-4c3b-a641-788c08f9f851n@googlegroups.com>
<fddb7bca4e3bd55d44abdef40fc7f3cbffb7ecc4.camel@johnohagan.com>
<3a4a97b7-dd85-6d64-4a20-dc65270b60d3@tompassin.net>
 by: John O'Hagan - Mon, 13 Feb 2023 05:42 UTC

On Sun, 2023-02-12 at 08:59 -0500, Thomas Passin wrote:

[...]

> On 2/12/2023 6:10 AM, John O'Hagan wrote:

[...]

> >
> > My goal was to be able to change the colour of an individual item
> > regardless of whether it is selected or not. To do that, it is
> > necessary to be able to change the colour of an individual selected
> > item, without changing the selection or changing the colour of
> > other
> > selected items. It seems this isn't possible.
>
> I haven't worked with ttk objects or Treeviews, but judging from old
> style objects, I think you have to re-apply your color and flashing
> when
> the item becomes selected and possibly again when it becomes
> unselected.
>
> Depending on exactly what effect you want, you may also need to apply
> color and flashing when the mouse moves over the item and again when
> it
> leaves.  When I make changes in e.g. color, I like to save the
> previous
> value(s) in the object itself.  That way I can easily restore say a
> background color without having to work out what it used to be, which
> may be some color that Tk applies based on the desktop theme and who
> know what else.
>
> Here's an example (simplified) for changing color on mouse hover and
> leave events:
>
> BG_KEY = 'bg' if platform.lower().startswith('win') \
>           else 'activebackground'  # Different for Linux!
>
> def on_enter(event):
>      w = event.widget
>      w.old_bg = w.cget('bg')
>      w[BG_KEY] = BUTTON_HOVER  # Color you have chosen
>
> def on_leave(event):
>      w = event.widget
>      _bg = w.old_bg
>      w[BG_KEY] = _bg
>
>

Thank you again for your reply, Thomas. I didn't know tkinter
configuration keys have different names on different platforms, that
seems unneccesary! I also like the idea of storing the original
settings on the object itself.

However, because of the nature of ttk widgets, I think I'm stuck with
my original issue. Unlike classic tkinter widgets, a lot of the ttk
configuration options are not available on individual widgets, but must
be done through styles or tags. On Treeviews (and possibly other ttk
widgets), the colours for selected items can only be set using
style.map (AFAIK).  The colours for individual items can (only?) be set
using tags, but this is evidently overridden when the item is
selected by the selection colour dictated by the style. Treeview tags
do not have a 'selectbackground' option like many tkinter widgets do.
(Fonts _can_ be set this way, so I could flash, say, the font size, but
that's ugly!)

As as aside, IMO ttk looks great (and Treeview is really useful) but
this approach to configuration is a double-edged sword. On one hand
it's super-easy to change the whole look, but on the other, it can be
overly restrictive if you want to control the look of individual
widgets. 

I might try to put forward a feature request to add a
'selectbackground' option to ttk tags to see if there's any interest.

Thanks

--

John

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor