I made a
wx.dataview.DataViewListCtrl widget, I added 8 columns to it, and I want to add data to those columns, I cannot figure out how to do that, what is VariantVector type? I can’t find any information about it online no examples nothing, can’t find about UIntPtr either. What do I need to put in those parameters to add data. I basically want to insert data into the columns based on what audio file the user chooses from DirCtrl or FileBrowser, and then I use mutagen to get tags and info about that audio, and I want to insert say filename in one column, genre in another, length in another and so on. I can provide any information screenshots, code snippets if needed.
I made a
Did you have a look at the demo
Do you mean this?
If not could you please share the link to the file please.
The demo contains small samples for most of the widgets in wxPython which demonstrate the widget and sometimes a few options. The code for each sample is also editable in the demo so you can experiment with it.
It seems that more and more users miss the demo.
May I suggest to add the demo to the standard distribution? Is there a way to ask the user after installation whether he/she wants to run the demo?
Maybe, it would be possible to add links or hints to the documentation page as well.
I would suggest to drop the ‘dependency’ on numpy instead. This is using much more resources than the demo.
I’ve been thinking about this today too. Let’s continue the discussion in the wxPython Dev category.
Yes, I cannot find any link to the demo, I have been searching whole day so I can find some demo examples to look at. I did find example for C++ version not for python but.
I saw the demo for
DVC_ListCtrl.py, looks like they are using a list of lists as a 2d matrix for rows and columns. I tried something, my app did open but with a error message box, and when I clicked OK, it closed the app.
Code I tried
Sdata = [["one", "two", "three", "four", "five", "six", "seven", "eight"], ["one", "two", "three", "four", "five", "six", "seven", "eight"], ["one", "two", "three", "four", "five", "six", "seven", "eight"], ["one", "two", "three", "four", "five", "six", "seven", "eight"], ["one", "two", "three", "four", "five", "six", "seven", "eight"], ["one", "two", "three", "four", "five", "six", "seven", "eight"], ["one", "two", "three", "four", "five", "six", "seven", "eight"]] for item in Sdata: SampleListView.AppendItem(item) print("Column: " + str(SampleListView.GetColumn(1))) print("Column count: " + str(SampleListView.GetColumnCount())) print("Item count: " + str(SampleListView.GetItemCount())) print("Selected Items count: " + str(SampleListView.GetSelectedItemsCount())) print("Selected row: " + str(SampleListView.GetSelectedRow()))
And the error I get is
❯ python main.py 03:36:55: Warning: Mismatch between the program and library build versions detected. The library used 3.0 (wchar_t,compiler with C++ ABI 1013,wx containers,compatible with 2.8), and wxPython used 3.0 (wchar_t,compiler with C++ ABI 1014,wx containers,compatible with 2.8). Default path before: / Default path after: /home Column: <wx._dataview.DataViewColumn object at 0x7f1f8eb96310> Column count: 8 Item count: 7 Selected Items count: 0 Selected row: -1 Traceback (most recent call last): File "main.py", line 13, in <module> frame.Show() wx._core.wxAssertionError: C++ assertion "Assert failure" failed at ./src/common/variant.cpp(684) in GetBool(): Could not convert to a bool
The mismatch warning is telling you that wxPython was built with one version of wxWidgets, but the wxWidgets found at runtime has a different version with a different ABI.
The assert failure is telling you that the DVLC is unable to convert a data item type (string) to the expected type for the column (bool). Take a closer look at how you defined your columns.
Thank you, I forgot I have my first column as a
ToggleColumn, I changed all to
False, now it works.
Ok, I’m able to add data to each column the way I wanted to, but I get some error box pop up everytime I add a item, saying
Wrong type, required: arrstring but: string. I’m not sure what this means, what is
How are your columns created? Is one of them expecting a sequence of strings? “arrstring” is the internal variant type name for the C++
P.S. It’s always a good idea to share at least part of the code that relates to the problem. (Duplicating the problem in a small runnable application is even better.) That would save the helpers from needing to ask questions like the above.
Reading your reply I figured it out, I had a value inside the list as another list, I’m calling that by index now, so it fixed that. Sorry I’ll be sure to share code snippet next time.
What event to catch to see if toggle column is activated in
wxDataViewListCtrl? Is it
Also is there a way to change toggle column default check box to a image like a star?
May I suggest that you look at the documentation and the demo?
E.g. from the docs,
EVT_DATAVIEW_ITEM_VALUE_CHANGED is a promising candidate.
If things don’t work, ask here and include a runnable code sample.
P.S.: For exploring, it’s a good practise to add handlers for all the events which will just print that there is an event. From this you will see what happens. Then, put a breakpoint at the most promising event handler and explore what data the event has to offer.