wx.listctrl.InsertStringItem

22 views
Skip to first unread message

Nathan smith

unread,
May 10, 2019, 3:52:01 PM5/10/19
to wxpytho...@googlegroups.com
Hi there.

I've recently been doing quite a bit of work with
wx.ListCtrl.InsertStringItem in an app.

You can imagine, therefore, my dismay when I discovered that in wx
phoenix, which is that supported by mac, it is not supported any more!

I mean, why not! :(


Anyways, I was wondering if anyone would be able to give me the way to
fix this issue/?

My current code looks something like:

self.listname.InsertStringItem(col, string)


thanks a lot for any assistance.

Thanks

Nate

Scott Talbert

unread,
May 10, 2019, 4:03:31 PM5/10/19
to wxpytho...@googlegroups.com
On Fri, 10 May 2019, Nathan smith wrote:

> Hi there.
>
> I've recently been doing quite a bit of work with
> wx.ListCtrl.InsertStringItem in an app.
>
> You can imagine, therefore, my dismay when I discovered that in wx phoenix,
> which is that supported by mac, it is not supported any more!
>
> I mean, why not! :(
>
>
> Anyways, I was wondering if anyone would be able to give me the way to fix
> this issue/?
>
> My current code looks something like:
>
> self.listname.InsertStringItem(col, string)

I think you should just be able to do:

self.listname.InsertItem(col, string)

Part of what Robin tried to do in Phoenix was eliminate a lot of the
deltas from the C++ API. Because SIP supports overloaded functions, the
Python API now matches the C++ API in this case.

Scott

Nathan smith

unread,
May 10, 2019, 4:24:58 PM5/10/19
to wxpytho...@googlegroups.com
Hi Scott,

thanks for that, that seems to have fixed the traceback, though not my
underlying problem.

Perhaps someone will be able to assist me here.

I have built the following window(code showed after text).

When run on windows, as far as I can see, it runs fine.

When I say runs fine:

I am accessing it with a screen reader, a piece of software which reads
things to blind people from a screen.

When run on windows, it is able to tab through all of the items, and
identify the list is there perfectly fine.


Running the same code on mac, however, doesn't traceback, the only
problem is, voiceover is able to identify everything, accept the list.

I'm not sure if the list is just not showing, if voiceover is being
picky? or what the problem is.

Any help is appreciated.

Code below:

 def searchscreen(self, event):
  self.panel.Hide()
  panel = wx.Panel(self, wx.ID_ANY, style= wx.WANTS_CHARS)
  self.panel2=panel
  vbox = wx.BoxSizer(wx.VERTICAL)
  hbox1 = wx.BoxSizer(wx.HORIZONTAL)
  l1 = wx.StaticText(panel, -1, "Search results.")
  hbox1.Add(l1, 0, wx.EXPAND|wx.ALIGN_LEFT|wx.ALL,5)
  self.results = wx.ListCtrl(panel, -1, style = wx.LC_REPORT)
  self.results.InsertColumn(0, "Results.")
  global items
  for x in range(len(items)):
   self.results.InsertItem(x, items[x].name)
  hbox1.Add(self.results, 1, wx.EXPAND|wx.ALIGN_LEFT|wx.ALL,5)
  l2 = wx.StaticText(panel, -1, "Enter something to search for.")
  hbox1.Add(l2, 0, wx.EXPAND|wx.ALIGN_LEFT|wx.ALL,5)
  self.res = wx.TextCtrl(panel, style=wx.TE_PROCESS_ENTER)
  hbox1.Add(self.res,1,wx.EXPAND|wx.ALIGN_LEFT|wx.ALL,5)
  self.res.Bind(wx.EVT_TEXT_ENTER, self.beginsearch)
  self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.savefeed, self.results)
  self.res.SetFocus()
  browse2 = wx.Button(panel, -1, "Search.")
  browse2.Bind(wx.EVT_BUTTON, self.beginsearch)
  hbox1.Add(browse2,1,wx.EXPAND|wx.ALIGN_LEFT|wx.ALL,5)
  browse2 = wx.Button(panel, -1, "Back")
  browse2.Bind(wx.EVT_BUTTON, self.endsearch)
  hbox1.Add(browse2,1,wx.EXPAND|wx.ALIGN_LEFT|wx.ALL,5)
  vbox.Add(hbox1)
  panel.SetSizer(vbox)
  self.Layout()
  self.Center()
  self.Show();
  self.Fit()


When executing, it focuses, correctly on the text box, but acts as
though there is no search result list there at all.

Even after searching, in which focus gets set to the results list,
nothing seems to occur.

Thanks

Nate

Robin Dunn

unread,
May 10, 2019, 8:41:18 PM5/10/19
to wxPython-users
On Friday, May 10, 2019 at 1:24:58 PM UTC-7, Nathan smith wrote:
Running the same code on mac, however, doesn't traceback, the only
problem is, voiceover is able to identify everything, accept the list.

I'm not sure if the list is just not showing, if voiceover is being
picky? or what the problem is.


On Macs the implementation of the wx.ListCtrl uses a generic widget rather than the native equivalent, and the screen reader software doesn't know anything about the generic widget. If I remember correctly this was done because the API of the native widget was just too different than the wx.ListCtrl API and they couldn't be made to fit together without losing functionality. 

All is not lost however. The wx.dataview.DataViewCtrl is implemented using the native widget on Mac and on GTK, so that would probably work correctly with the screen reader. There is a simpler class derived from it called wx.dataview.DataViewListCtrl that has an API similar to wx.ListCtrl although not quite as capable. The bad news is that wx.dataview.DataViewCtrl is a generic widget on Windows, so you'll need to have two separate implementations of this part of your application in order for the screen reader to work with both.
 

--
Robin
Reply all
Reply to author
Forward
0 new messages