Display checkbox inside a listbox - matlab

In my (programmatic) Matlab GUI, I have a listbox uicontrol.
What I want is to display checkboxes in front of each option. When a user clicks the checkbox, it's marked (and the element will be considered during the calculations later). While if the user clicks the label, a description of the selected option will be displayed in a text uicontrol to inform the user what the option means.
Basically, I want functionality similar to installation programs where you can select components to install and can get information about said components by clicking them (which does not necessarily mark them as selected).
Is there a way to do this with checkboxes or something similar?

There are actually 2 built-in controls that you could use within Matlab:
com.jidesoft.swing.CheckboxList
com.mathworks.mwswing.checkboxlist.CheckBoxList
Usage example (more details in my Matlab-Java book):
jList = java.util.ArrayList; % any java.util.List will be ok
jList.add(0,'First');
jList.add(1,'Second');
jList.add(2,'Third');
jList.add(3,'and last');
jCBList = com.mathworks.mwswing.checkboxlist.CheckBoxList(jList);
jScrollPane = com.mathworks.mwswing.MJScrollPane(jCBList);
[jhCBList,hContainer] = javacomponent(jScrollPane,[10,10,80,65],gcf);
set(jCBList, 'ValueChangedCallback', #myMatlabCallbackFcn);
jCBModel = jCBList.getCheckModel;
jCBModel.checkAll;
jCBModel.uncheckIndex(1);
jCBModel.uncheckIndex(3);

There's no "ready" way for doing that - as listboxes take only plain strings as entries.
You could "manually" draw checkbox fitted into the area of the listbox, but that might mean quite a lot of work to get everything working...
Another alternative is to go for a java-componenent - e.g. using the jide components available in matlab. See e.g.
http://undocumentedmatlab.com/blog/using-jide-combo-boxes/
for a few examples.

Related

Multiple selection made via list box in uitable

I have a uitable and originally last two columns work as popup menus which allows only one selection.
uitable('blah blah blah',...
'ColumnFormat'{'logical','char',cell_array1,cell_array2},...
'ColumnEditable',[true false true true],...
'Data',[blah blah cell_array2 cell_array2])
Now my customer wants to be able to make multiple selections (by holding down CTRL or whatever).
My understanding is that popup menu does not allow multiselect, but listbox does.
I couldn't find a way to put listboxes in a uitable.
I'm open to any other means.
There's only so much you can do with Matlab uicontrols / uitable etc. You would get ultimate flexibility if you just resort to pure java solutions, e.g. wonderful swing-based JIDE Grids which are pre-packaged with each Matlab release. By the way, uitable is not much more than a trimmed-down version of Jide table in the first place. There's also a number of articles on using Jide within Matlab out there to get you started.

Bokeh - How to use box tool without default selections?

I have built a bokeh app that allows users to select windows in data and run python code to find and label (with markers) extreme values within these limits. For ease of interaction, I use the box select tool for the range selection. My problem arises when repeating this process for subsequent cases. After markers are placed for the results, they are rendered invisible by setting alpha to zero and another case needs to be chosen. When the new select box includes previous markers, they become visible based on the selection. How do I override this default behavior? Can markers be made unselectable? or can I add code to the customJS to hide them after they are selected?
Thanks in advance for any help!
There are a few possible approaches. If you just want non-selected glyphs to "disappear" visually, you can set a policy to do that as described here:
http://docs.bokeh.org/en/latest/docs/user_guide/styling.html#selected-and-unselected-glyphs
Basically, for bokeh.plotting, pass
nonselection_fill_alpha=0.0,
nonselection_line_alpha=0.0,
as arguments to your plot.circle call or whatever. Or if you are using the low level bokeh.models interface, something like:
renderer.nonselection_glyph = Circle(fill_alpha=0.0, line_alpha=0.0)
But be aware (I think you already are) that the invisible markers are still there, and still selectable if the user happens to draw a box over them with the selection tool.
If you truly want only a subset of the data to be visible and selectable after a selection, I'd say you want to replace the data in the column data source wholesale with the subset in your selection callback.

How do I set size of colums in a table subform datasheet view in MS Access

I have a subform bugging me. The mainform contains buttons etc. Everytime the user close/open the form, the columns width is reset to whatever the table likes. If i open the table directly, the size is as i want. If i change it in the subform, it is not saved. (See screendump)
I would like "Phase" to stay about 2 cm width. I can enter the subform and edit the "Width" but that is only applied to the other views.
I hope you can help, Emil.
I realize this post is almost 2 years old, but I ran into the same problem and came across this post.
I am running MS Access 2013 on Windows 7 Ultimate. I did not find the solutions offered here to work for me, so, I set out to find something that would work for me before I went to VBA code. (Incidentally, I appreciate the link offered by #Patrick_Honorez in his comment on the original post because that was going to be my fall-back solution.)
Anyway, here is what worked for me and I hope perhaps it will work for others as well:
Open the parent form.
In the subform, right-click the column header
for the column for which you wish to adjust the width.
Select the “Field Width” item from the context menu.
In the “Column Width” dialog that appears in step 3, enter the desired column width in points, or, use the [Best Fit] button. Then click the [OK] button to close the dialog and return to the form.
Right-click the parent form’s border to bring up the parent form’s context menu. Click the “Save” item in the context menu.
Now close the parent form.
The next time the form is loaded, the column widths should be as set it step 4 above--at least they are for my setup.
I see this post is quite old and OP must have figured someway to tackle the issue. I came across same issue today and found solution on this link.
For anybody else having same issue, use following code (I modified the code a little because original code from the above mentioned post saves column width of only text boxes but my form has combo boxes too, column width of which was not getting saved) in close and open events of your subform and then open main form in Form View and then manually select desired widths either by mouse, by entering column width value or using best fit. Save the form and reopen to check results. That's it.
Private Sub Form_Close()
Dim ctrl As Control
For Each ctrl In Me.Controls
If (ctrl.ControlType = acTextBox Or ctrl.ControlType = acComboBox) Then
SaveSetting "propertiesDBS", Me.Name, ctrl.Name, ctrl.ColumnWidth
End If
Next
End Sub
Private Sub Form_Open(Cancel As Integer)
Dim ctrl As Control
Dim frm As Form
Dim w As Long
For Each ctrl In Me.Controls
If (ctrl.ControlType = acTextBox Or ctrl.ControlType = acComboBox) Then
w = GetSetting("propertiesDBS", Me.Name, ctrl.Name, 0)
If w <> 0 Then ctrl.ColumnWidth = w
End If
Next
End Sub
I know this is late to the party and most likely going to be the last comment anyone reads, but this can be done quite simply in MS Access 2016 - by someone like myself who has no more than 4 days experience in databasing overall and no experience with writing custom Macro's or VB Script (using only what is native to MS Access).
Here's how I did it.
Scenario - Split Form (Form + Datasheet).
Extra Recommendations:
It pays to be across all properties of every object type in your database, as a change in a field property can cause unpredictable erratic effects, which take ages to figure out why it happened and how to stop it from happening again, whilst delivering your desired outcome.
Me.Requery in your VBA script after every necessary event and also in your main form (generally the 'After Update' event is used most), and be wary that too many Me.Requery's (in unnecessary events) can also be detrimental - so too much of a good thing can be a bad thing.
Bottom Line Up Front - Modify the format of your query that is to be exported/printed.
In 'Design View' of the query you are concerned with, ensure that the fields are in the order you need them outputted in first as this is exactly how the macro will present them for export/print (example could be "Australia" then "Northern Territory" then "Town's In The Northern Half Of The State" then "Darwin" then "Suburbs In The Northern Half Of City").
Switch to 'DataSheet View' in the same query and use the top left folded over triangle looking thingy to highlight the entire data set then right click that same triangle to present an options menu. Select 'Row Height' and type in "15" (default row height in Excel).
Deselect the entire spreadsheet and this time select every column (left click the left most column, hold shift button, scroll over to the right to the far end of the data set and click the last column) and then right click one of the highlighted columns to present another menu. Select 'Field Width' and within that new pop-up menu select 'Best Fit' and then 'OK'.
(Optional - not sure if this helps or hinders but I did it for my purpose) With the columns still selected right click one of the highlighted columns again and select 'Freeze Fields'.
My scenario had buttons with macros configured to run filtered reports so I was able to check this by simply clicking any of those buttons and seeing the report formatting, which it held true to the work I had just done. I exported using another button with a macro that exports to Excel with 'Print Formatting' selected (my main form also had the datasheet view as the only thing that could be printed and was also set in 'Print' formatting.
The Excel spreadsheet opened with all row heights and column widths in a way that I could read every field/record with perfect ease and without extra modification.
This also worked for cascaded combo boxes, with the export only outputting the 'drilled down/filtered' datasheet records, in a format that required no further modifications.
Hope this helps someone, as its saved my hide! :)
Open the Main form in Design. Go to the SubForm. Click on the square at the top left of the SubForm and select 'Properties'. Right-Click the control 'Phase' and click 'Properties'.Click the 'Format' tab and select 'Width'. What do you see there? That should control the widht of control 'Phase' unless you have some overriding coding elsewhere. Input the size you want and see what happens.
Use continuous forms instead. It gives you complete control over how your subform displays.
If you open your subform directly, your property sheet menu should display automatically if the default view is "Datasheet." Click on "All" and change the "Auto Resize" property to "No." This should solve the issue and avoid the need for VBA.
This only works when you open the subform separately. So if you want the changes to be reflected within your main form, you'll have to close it and switch back and forth.
Super annoying by default.
It seems to work as one would expect of you set the view mode to layout view. Drag column widths as needed and save. Go back to form view and it works. It's really dumb it doesn't work the same way in form view our design view.
In Access 365, open main form, right-click sub-form datasheet columns that need width adjustment, use the Field Width to adjust, click on border of main form to select Layout view, and save changes.
Open subform in datasheet view (by double click on subform in the left pannel)
Resize columns as you want by dragging or by right-click the column header for the column for which you wish to adjust the width and select the “Field Width” item from the context menu.
Right-click the subform border to bring up the context menu. Click the “Save” item in the context menu.
Either open the Main Form in Layout View or directly open your Subform in Datasheet View. Right Click on the Field Header, select Field Width, and enter the desired width. Save. Bewm.
My solution (Access 2016) was to create the main & subform, recreate the subform on its own using form wizard and set it up the way I want it, rename the original subform to something else, and finally rename the recreated subform to the original form name. Open the main form and the subform should be laid out the way you want it. You can then delete the original subform you renamed.

how to hide existing uicontrol in Matlab before printing figure?

I am using a Matlab based program that does some nice plots of some model results. It adds uicontrol slides and buttons in figures. I have no expierence with gui programming in Matlab, and I dont need it, I just wanna add on my matlab script a couple of lines to hide slides and buttons. I can do it manually from the property editor and set "Visible" to "off", but I was reading the Matlab manual and it does not explain how to retrieve an existing uicontrol and change its properties. Any hint? I tried this with no luck:
b = get(gcf,'uicontrol');
set(b,'Style','pushbutton','Visible','off');
Thanks
You simply need to access the element from the handles structure and change its property from there.
For example, if the pushbutton is stored in the handles structure like this:
handles.b %// Whatever name you gave it and see in the Property Inspector
you can make it not visible using the command
set(handles.b,'Visible','off')
and likewise for every other properties.
Little trick: If you need to repeatedly turn on and off elements of your GUI, you can put them in an array of handles for example in the Opening_Fcn of the GUI and change them all at once using this array anywhere in the GUI. This way you won't have to always call them one by one which can be tedious.
Example:
handles.AllButtons = [handles.button1; handles.button2; handles.button3]
this contains the handles to 3 pushbuttons let's say. Now if yu need to turn them all off/on at the same time, you can do:
set(handles.AllButtons,'Visible','off')
instead of doing
set(handles.button1,'Visible','off')
set(handles.button2,'Visible','off')
set(handles.button3,'Visible','off')
From GUIDE, you can check the actual name of any uicontrol component in the Property Inspector. Here is a screenshot from a GUI I made with GUIDE:
In this case, the Tag associated with the button is pushbutton28_ReferenceChannelApply.
Therefore, in order to change any of its properties I would need to use:
set(handles.pushbutton28_ReferenceChannelApply,'Property','value')
EDIT 2
You can look for pushbuttons in your GUI with the findobj command like so:
FindButtons = findobj('Style','push')
which will output an array of handles to those pushbuttons. Then you can query their properties using the get command:
get(FindButtons(1))

Is it possible to add Sencha grid filter to some TextBox?

I'm using gxt 3.0.1 and I have Basic Grid added on my form.
Now I've added filter for each column which can be used over TextBox in menu of grid columns (basically it's Filter Grid now).
I have to make my own TextBox above grid and apply filter to it. And do that for each column of grid.
Filtering is done locally.
My idea was to look for code they made for their TextBox and apply it on mine TextBox.
But I failed.
It should be just String filter, which should work exactly as filter provided in Filter Grid.
Also I'm using UiBinder.
From the GridFilters javadoc
* Filtering is adjusted by the user using the grid's column header menu (this
* menu can be disabled through configuration). Through this menu users can
* configure, enable, and disable filters for each column.
This is meant to be used to configure column header menus to have filters built in, not set up text boxes outside of the grid - see http://www.sencha.com/examples/#ExamplePlace:filtergrid for how this is intended to work.
To build the way you are describing, start instead with making a StoreFilter object based on the contents of the TextBox, adding it to the store, and re-applying the filter each time the contents of the text box change.
Check out StoreFilterField for a working example, or follow the above instructions to build your own.
If this doesn't work, please provide a code sample in your question...