I am looking for a PysimpleGUI way to create dropdown menus.
Currently, I can create ComboBoxes as such:
import PySimpleGui as sg
sg.Combo(list1, size = params)
This creates an Input box and a dropdown list with a slider populated by list1 elements.
However, my users are very sloppy with inputs and I'd like to restrict them to a simple dropdown list.
Now I know I could maybe use the ListBox element but it doesn't have a slider/seems much less versatile than Combo.
What other arguments could I pass to Combo to make this work?
NB:In the documentation they state that Combo == InputCombo == Drop == DropDown but without giving more details but it confuses me a lot.
There is no slider when ListBox is has not enough entries however one appears when enough are added.
sg.Listbox(list(df_names.NAMES), size=(20,4), enable_events=False, key='_LIST_')
Set the readonly to True
sg.Combo(..., readonly=True)
Related
I have a Requirement Where a bundle of Items needs to be displayed in the Drop-Down List. The Problem for me is, because there are so many Items inside it, I need to Use Combobox over List-Box. The Reason for that is, if I know the name of the item, I can type in the search box of the drop-down and get my Item, Combo-Box allows you to do that. But the List Box doesn't allow the User Input.
Now, Because there are some which names cannot be remembered, I need to use the Scroll bar in the drop-down to pick up the time. This is hectic, to select a single Item. I would like to have the facility of Using a Multi-select in this case.
So the Requirements are below:
1) A Drop-Down that allows the user to type in part of the Input(Say Ref for Refreigerator)
2) A Drop-Down that allows the Multi-select.
Obviously, I don't want to have two drop-downs Splitting the data.
I am open to other Suggestions.
Please Share your thoughts.
[22 Feb 2016 update]
Regarding my previous questions about list box, I can move values between two listboxes and save values after I receive useful answers.
However, if I retrieve those saved values, the listboxes can display the proper values but I cannot move those values and get exception message.
I can only move values between two listboxes if I don't save them.
Therefore, I am planning to have another button for delete listboxes values. I am not sure this is a good practice/design in xpages but I don't have a better method solve the exception.
I am sorry if I caused any inconvenience in this question. Thank you.
[23 Feb 2016 update]
According to the latest comments and answer, I notice that I made a big mistake because I mixed the document and value together.
I decide to break the design into few steps to find the problem occurs.
Due to I can move values between two listboxes and save them. I use another listbox test whether I can retrieve those saved values or not.
The third list box, I use View Scope Variable(similar to listbox B) but I use another variable name to avoid vague.
Here is my code of the third listbox:
var item = getComponent("comboBox4").getValue();
if ((item == null) || (null == item))
{
return "void";
}
else if ((item != null) || (null != item))
{
var lookupItem = #DbLookup(#DbName(),"ViewName", item,3 )
return lookupItem;
}
if (!viewScope.totalItems)
{
viewScope.totalItems = [lookupItem];
}
return viewScope.totalItems;
In the combo box, I use onchange partial update and apply to the third list box . When I run the program, I select a value from the combo box, the third listbox can display the relevant values that I saved before.
That part is fine, so I keep the third listbox for testing. And I put some dummy but unique data (to prevent confusion) related to the combo box.
Here is my first attempt: I choose a value from a combo box, the third listbox can display the relevant values that I saved. I move one value from listbox A to listbox B and click save. The third list box can reflect the value that I save.
In my second attempt: after the first attempt, listbox B still contains the value from listbox A, so this time, I move that value back to listbox A and click save. In the result, in the third list box, I see that value disappear.
At this moment, there is no value in listbox B and I add another two button and write similar code to pretend move values between the third list box and listbox B.
I test it, I select the value from the combo box, the third list box shows the proper values. But when I select a value from the third list box and click the button to move it to listbox A. I think that value will move to the listbox A but the result is nothing happens.
I try the other way, I select a value from listbox A and click the button to move it to the third button. Again the result is nothing happens.
After those fail attempts, I think the problem occurs in the buttons.
Here are the code of the two buttons
Button 1 (move value to the third listbox):
if (viewScope.ALstBoxItem) {
var sel = [].concat(viewScope.ALstBoxItem);
for (var i = 0; i < sel.length; i++) {
viewScope.totalItems.add(sel[i]);
viewScope.AselectItems.remove(sel[i]);
}
viewScope.totalItems.sort();
viewScope.ALstBoxItem = "";
}
Button 2 (move value to the listbox A):
if (viewScope.TotalItemsVariable) {
var sel = [].concat(viewScope.TotalItemsVariable);
for (var i = 0; i < sel.length; i++) {
viewScope.AselectItems.add(sel[i]);
viewScope.totalInItem.remove(sel[i]);
}
viewScope.AselectItems.sort();
viewScope.TotalItemsVariable = "";
}
Recall to comments in the question, I guess I should focus on the values in the listbox, not the button. I search on the internet about hide selected value and find these websites almost can give me the idea to solve the problem:
xpages hiding/showing fields based on a combobox value
Hiding based on previous combo box choice in xpages?
https://www-10.lotus.com/ldd/ddwiki.nsf/dx/dynamical_elements_on_xpages.htm
I try to apply those summary to suit my case but I still cannot move values after I save.
Grateful if someone can give advice please. Thank you very much.
Please step back and think about what you are building. You have two list boxes. They contain values, not documents, so a deleteSelectedDocument simple action can't work. Similarly, access to delete documents isn't relevant.
Also, from previous questions of this topic, I don't think you are setting values in the listboxes, you are using the events to set options, i.e. the options are not highlighted and so selected in the listbox, they are just sitting in the listboxes as options available for selection. Look at the code you're using to add options to the listboxes and use the corresponding code to remove the options.
I've added an image that corresponds to what I think you're trying to build, and the difference between "value" and "option", except in your example it sounds like you're moving the option from ListBox 1 to ListBox 2 as soon as it's selected, not using an "Add" button. Or to break the process down further, it sounds like, when an option in ListBox 1 is selected, you are looking to remove it from the list of options in ListBox 1 and add it to the list of options in ListBox 2. On your save, it sounds like you're wanting to store the options into a NotesDocument and, when you return, set the options for your ListBoxes based on what is stored in the NotesDocument.
If so, the questions and answers on this topic have given you everything you need to code those steps in the process.
I am developing an windows application using syncfusion's grid grouping control(ggc). In ggc i have two columns. In that one column is of combobox type. When I expand this combo one grid is shown. Currently in that combo i can write only one character but i want to write multiple characters as we write in normal combo box.
Anybody knows how to do that?
The DropDownStyle of ComboBox can be set to Editable in order to enter contents in cell.
Here is the code that will achieve the behavior:
this.gridGroupingControl1.TableDescriptor.Columns[1].Appearance.AnyRecordFieldCell.CellType = "CheckBox";
GridTableCellStyleInfo style = this.gridGroupingControl1.TableDescriptor.Columns["Col2"].Appearance.AnyRecordFieldCell;
style.CellType = "GridListControl";
style.DropDownStyle = GridDropDownStyle.Editable ;
I hope this will resolve the issue.
I have a sharepoint list with several columns, one of which is a text box that is set to accept numbers. I would like to auto populate a drop down box based on the number entered into that text box.
I am not very code-savvy, and so far all the answers I have found involve getting a number/value from a drop down box to insert into a text field, not the other way around. Any help would be greatly appreciated!!
You need to set the SelectedValue of the dropdown in code based on the textbox value. You need to add an event handler to the textbox (I believe KeyPressed event should be a good start)
When we will use DrawItem for a listbox?
Normally, if the listbox is ownerdraw, we will use DrawItem. What are the other senarios we use drawitem?
To elaborate on Rashmi Pandit; A ListBox with override DrawItem can also be used to 'visualize' objects. In a project I'm working on, a ListBox is used to display rows from a database. Each row / item is visualized using formatted Strings, Icons etc.
Overriding DrawItem (and MeasureItem!) is ideal for this purpose. Of course, the internal structure has to be tweaked a bit (the standard Items property cannot be used for objects), but it is certainly worthwhile.
Message WM_DRAWITEM is sent only to owner-drawn List boxes.
You can use DrawItem when you want to override the default implementation and custom the way a listbox is drawn. For e.g. in the list there might be some item which should is the default item and you would want it to be highlighted so that the user knows it is the default item.
Here's an eg for a combo in C#: Higlighting a particular item in a combo box