Possible for ListCtrl Colspan, or similar functionality? - python-2.7

Is there a way to have a ListCtrl cell span several columns? Or perhaps to able to append a panel / other element to a ListCtrl item that will contain the info I need?

No. The ListCtrl does not support that functionality. There is a pure Python list control widget called the UltimateListCtrl that allows you add any widget to a cell, although it doesn't appear to allow cell spanning either. I would still try this widget and see if it works for you. If it does not, you may be able to patch it yourself because it's written in Python or you could do a feature request for it to be added to the UltimateListCtrl on the wxPython mailing list and see if anyone takes you up on it.
You can do spanning in a wx.Grid widget if you wanted to go that route, although it's pretty limited when it comes to embedding other widgets.

Related

Menu designed for use without mouse. What is the best way to implement?

I'm writing a GUI using QT for embedded system with linux. This device has no mouse. Only display and specific keyboard with keys: up, down, return and 7 number keys.
The software will be used to set some parameters of device and read them (some charts also).
Example of how menu could look:
after OPTION 1 selected
After SUBOPTION 1 selected some table with data is loaded.
Sometimes after selecting option i need to load specific widget and sometimes just another set of options.
I think it is possible to implement custom labels and kind of list widget that aligns them.
I guess it is also possible to use Qt's MVC classes for it. They are highly customizable, but i never made custom views and delegates.
Maybe i just need to create QtListView with stringlist model and apply stylesheet to it so it gets look more like buttons. And based on selection in list load next widget.
Which way is better and why?
Is there any easier ways to accomplish this?
Any ideas would be appreciated.

How can I sort Items in `CListCtrl` when the button is clicked?

How can I sort Items in CListCtrl when the button is clicked?
I made a Dialog based application in MFC.
I put CListCtrl control on my Dialog and set its view style to report type.
I have two columns in this list view.
In here when I clicked the "Sorting" button, it should sort item in the list.
I saw many examples related to this, but none is working for me.
Can some one guide me how to do that?
I assume that you mean the column header when you write "sorting button".
You probably forgot to put this into the message map of your dialog:
ON_NOTIFY(LVN_COLUMNCLICK, IDC_LIST1, OnColumnclickList1)
IDC_LIST1 is the id of the list control which may be different in your code.
Are you somewhat familiar with MFC ? If not, you should follow one of the numerous tutorials available on the net.
I would use a CMFCListCtrl. It is easier, as it as built in sorting functionality and you only have to provide a function with the comparing items algorithm for sorting. I have succeeded using it. You have to override the OnCompareItems on your class derived from CMFCListCtrl. I also recommend you to do a call to EnableMarkSortedColumn(); after your list is created.
The CListCtrl has a SortItems method.
All you need to do is provide your Compare function to it as the parameter.
I don't know much about the contents of your list control so I can't really give you more information.
Please read up on it and extend your question with example code and details of which column needs to be sorted and I can help more.
If the contents of your cells are just text then I usually just return the value of:
return Value1.CollateNoCase(Value2);
There are also lots of tutorials on the Internet. For example:
http://www.codeproject.com/Articles/27774/CListCtrl-and-sorting-rows
In fact, that tutorial suggests us in SortItemsEx. That is what I would use.

CTreeCtrl - only use checkboxes for certain rows/children

I have a CTreeCtrl and I filled it with content. Now I wanted to add checkboxes but JUST for certain ones. I've found the possibilty to activate checkboxes on the TreeCtrl with m_Tree.ModifyStyle(0, TVS_CHECKBOXES), but this adds a checkbox on each node/child on the whole Ctrl. Is it possible to turn this feature on, but just for certain ones?
All I found is the possibility to add three different pictures, catch the clickevent on a node and change the image. Is there an easier way? Let me know.
Thanks a lot,
jntme
I don't think that CTreeCtrl provide any method to add check boxes at specified node only.
Easiest way to do this is explain in following link.
http://www.tech-archive.net/Archive/VC/microsoft.public.vc.mfc/2005-10/msg00454.html.
please go through and let me know if you are facing problem.
You may be able to accomplish what you want with a custom draw tree control. But, you'll need to render the image states yourself. That could get messy because you'll need to account for all of the possible different states.

create a scrollbar in a submenu qt?

I have a map application and a submenu which has dynamically added objects (i.e. points on a map) added to the submenu, depending on the layer that is loaded. I have the ability to hide each individual objects (i.e. a point) by clicking on the corresponding submenu item. Is there any way to organize the submenu? When there are a lot of points (i.e. 100) the entire submenu takes up the screen. Can I add a scrollbar to a submenu? I looked in the documentation, but couldn't find anything that support this feature.
From this bug report I was able to find out that you could do the following:
submenu->setStyleSheet("QMenu { menu-scrollable: 1; }");
Works like a charm.
There is no such possibility as far as I know.
Maybe you shouldn't use a sub menu for this but prefer a menu entry that show a Point manager GUI of your own which would have a QListWidget displaying all your points items.
I'm aware that this solution will break a (big?) part of your code but I don't see anything else.
I think you may be able to get the effect you want by creating and using your own QStyle subclass (via QApplication::setStyle()), and overriding the styleHint virtual method to return 1 when the StyleHint parameter passed in is SH_Menu_Scrollable. At least, that works for me when I create large QMenu objects and show them as popup menus.... It may also work for QMenus attached to the menu bar, but I havent tried that.
Whilst it is possible by subclassing the QMenu class to create a custom widget and going from there you're better off looking at a better way to display that information. You'll save yourself time and it'll be much easier for your users to not have to scroll through a big list of items in a small area.

Does MFC have a built in grid control?

First what I want: The ability to display a grid with multiple columns, each cell having a custom render callback. So you might use such a control to display your inventory in a game, or something like the behaviour in Google Chrome where it shows a grid of popular pages you visit.
I've been playing with CListCtrl and while I can get custom rendering ability on each item, I can't get it work with columns - having say 3 items per row. The control has column-related methods but I think these are specifically for the built-in functionality where different attributes of an item are shown automatically in each column... not for providing a generic grid control.
So, does such functionality exist in MFC? If not then I wonder if the easiest approach is for me to actually insert each of the rows as an Item... and then the custom rendering draws the multiple cells in the row, I could also do custom UI to support clicking on the cells.
But what I really want is to be able to create a custom control, and add this as an item to a list - like in Flex for instance - so I/O etc is automatically handled.
Any advice/information welcome...
Dundas has thrown some of its (excellent) components in the public domain. Their Ultimate Grid is available on CodeProject.
I'm not aware of a built-in control, but I think you should take a look at this.
The article is describing in detail the functionality of a fully featured MFC grid control, derived from CWnd, for displaying tabular data.
YOUR_LIST_CONTROL.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_INFOTIP|LVS_EX_GRIDLINES);
I think it will help you (SetExtendedStyle).
I suggest this one:
https://code.google.com/p/cgridlistctrlex/
very complete