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

How to configure Tkinter Listbox to disable state keeping selected item highlighted

61 views
Skip to first unread message

Sarbjit singh

unread,
Jul 17, 2012, 9:55:21 AM7/17/12
to


I am having a problem configuring a listbox widget such that the selection remains highlighted even while it is set (programmatically) to the DISABLED state. Below code shows the problem:

from Tkinter import *
master = Tk()
listbox = Listbox(master)
listbox.pack()
listbox.insert(END, "Text1")
listbox.insert(END, "Text2")
listbox.insert(END, "Text3")
listbox.selection_set(first=0, last=None)
listbox.configure(exportselection=False)
listbox.configure(state=DISABLED)

Now when I change state to NORMAL, selected item is being highlighted. Is there a way I could disable widget (i.e. No response on mouse clicks) but keep the selected object remain highlighted?

Intent: I want to utilise this widget on wizard App that I am creating. I would like this widget to indicate the current page / wizard number which the user selected. Is there any other widget I could use instead of it? (Labels possibly?)

Rick Johnson

unread,
Jul 18, 2012, 7:47:55 PM7/18/12
to
On Tuesday, July 17, 2012 8:55:21 AM UTC-5, Sarbjit singh wrote:
> I am having a problem configuring a listbox widget such that the selection remains highlighted even while it is set (programmatically) to the DISABLED state. Below code shows the problem:
>
> from Tkinter import *
> master = Tk()
> listbox = Listbox(master)
> listbox.pack()
> listbox.insert(END, "Text1")
> listbox.insert(END, "Text2")
> listbox.insert(END, "Text3")
> listbox.selection_set(first=0, last=None)
> listbox.configure(exportselection=False)
> listbox.configure(state=DISABLED)
>
> Now when I change state to NORMAL, selected item is being highlighted. Is there a way I could disable widget (i.e. No response on mouse clicks) but keep the selected object remain highlighted?
>
> Intent: I want to utilise this widget on wizard App that I am creating. I would like this widget to indicate the current page / wizard number which the user selected. Is there any other widget I could use instead of it? (Labels possibly?)



On Tuesday, July 17, 2012 8:55:21 AM UTC-5, Sarbjit singh wrote:
> I am having a problem configuring a listbox widget such that the selection remains highlighted even while it is set (programmatically) to the DISABLED state. Below code shows the problem:
>
> from Tkinter import *
> master = Tk()
> listbox = Listbox(master)
> listbox.pack()
> listbox.insert(END, "Text1")
> listbox.insert(END, "Text2")
> listbox.insert(END, "Text3")
> listbox.selection_set(first=0, last=None)
> listbox.configure(exportselection=False)
> listbox.configure(state=DISABLED)
>
> Now when I change state to NORMAL, selected item is being highlighted. Is there a way I could disable widget (i.e. No response on mouse clicks) but keep the selected object remain highlighted?
>
> Intent: I want to utilise this widget on wizard App that I am creating. I would like this widget to indicate the current page / wizard number which the user selected. Is there any other widget I could use instead of it? (Labels possibly?)

What's wrong with a page number displayed on a label? Why must you insist on displaying every page number in a Listbox? That seems like a waste of resources to me. You could even say: "Showing page I of N".
0 new messages