Python Forum
[WxPython] [SOLVED] [listbox] Read-only?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[WxPython] [SOLVED] [listbox] Read-only?
#1
Question 
Hello,

Neither Google nor the archives here helped.

Can a listbox be made read-only, so that the user cannot change the selections I made through code?

Cheers,

--
Edit

#Not good: User can't scroll :-/
self.lb1.Disable()
--
Edit: Work-around

def __init__(self, *args, **kwargs):  
	...
	self.lb1 = wx.ListBox(panel, style=wx.LB_MULTIPLE)
	sizer.Add(self.lb1,1, wx.ALL | wx.EXPAND ,5)
	self.lb1.Bind(wx.EVT_LEFT_DOWN, self.on_input_intercept)
	self.lb1.Bind(wx.EVT_KEY_DOWN, self.on_input_intercept)
	...
	
def on_input_intercept(self, event):
	# Do NOT call event.Skip(). The event dies here, ignoring the user's action.
	return
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question [WxPython] [SOLVED] [listbox] Edit items? Winfried 4 132 Sep-23-2026, 03:48 PM
Last Post: deanhystad
Information [WxPython] [SOLVED] Let user search read-only text control? Winfried 3 1,313 Jun-24-2025, 02:04 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020