Comments (5)
i agree!
from magicgui.
actually, that sounds to me like a bug in our Qt backend... Qt itself has no problem with this:
from qtpy.QtWidgets import QComboBox, QApplication
app = QApplication([])
combo = QComboBox()
combo.addItems(['a', 'b', 'c', 'c'])
combo.show()
app.exec_()
![Screenshot 2024-03-18 at 1 58 17 PM](https://private-user-images.githubusercontent.com/1609449/313787227-fe71a420-6566-45b9-907d-f36cd156b6e3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk4MjY5MzAsIm5iZiI6MTcxOTgyNjYzMCwicGF0aCI6Ii8xNjA5NDQ5LzMxMzc4NzIyNy1mZTcxYTQyMC02NTY2LTQ1YjktOTA3ZC1mMzZjZDE1NmI2ZTMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcwMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MDFUMDkzNzEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OGU4OTY2Y2U4YjY1YzBhNGMzN2YxZDA0YjU5NTMzZDY4YmM4NzYzMjY2ODFiYTQ1YmYwMjgyNmI1NTBmMjIyOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.qNMblig31RYn0itSMqgdUGbjyNOVJ26OA2gqkzfstGQ)
specifically, i would expect this to work fine:
from magicgui.widgets import ComboBox
# two different data values for c
box = ComboBox(choices=[("a", 0), ("b", 1), ("c", 2), ("c", 3)])
box.show(run=True)
but it doesn't because the ComboBox._mgui_set_choices
implementation only looks at the name. Haven't dug too deeply there yet, but i'm not sure we should impose the restriction if both Qt and ipynb don't
from magicgui.
Yeah neither backend limit such use. Let's lift this restriction. The implementation now is to have unique choice names
magicgui/src/magicgui/backends/_qtpy/widgets.py
Lines 934 to 939 in 781a54a
from magicgui.
It appears that modifying the current implementation of the Qt ComboBox resulted in 3 failures among the original tests:
=========================== short test summary info ============================
FAILED tests/test_container.py::test_reset_choice_recursion - assert (0, 0, 1... <- original
FAILED tests/test_widgets.py::test_separator[ipynb] - assert (1, 2, 4, 6, 7, ... <- new test
FAILED tests/test_widgets.py::test_separator[qt] - AssertionError: assert 21 ... <- new test
FAILED tests/test_widgets.py::test_unhashable_choice_data - AssertionError: a... <- original
FAILED tests/test_widgets.py::test_categorical_change_choices[ComboBox] - ass... <- original
============= 5 failed, 357 passed, 22 skipped, 1 xfailed in 7.36s =============
I guess these changes would lead to a minor release? Let's consider another PR later this week if necessary. For #638, let's retain the original implementation. What do you think? 🤔
from magicgui.
If we allow multiple items with the same name, how would this impact the ability for users to select options by name?
from magicgui.
Related Issues (20)
- Styling Widgets HOT 7
- `Container.parent` type annotation incorrect HOT 1
- docs: pymdownx.inlinehilite (via mkdocs-gallery) breaking autorefs HOT 6
- `Literal` and `widget_type="RadioButtons"` not compatible HOT 1
- Add support for toolbars HOT 2
- Improve matplotlib example by implementing abstraction HOT 8
- MainWindow for ipywidgets HOT 5
- Errors in rendered widget image with 16-bit screen HOT 2
- File dialog for ipynb backend HOT 2
- How can we programatically intercept keystokes like `delete` in a magicgui table? HOT 3
- No parent with parent_changed HOT 1
- build_widget doesn't populate defaults when given a class object, rather than a class instance HOT 1
- Tests failing in tests
- user input validation HOT 5
- ListEdit widget buttons should be nested and always use horizontal layout HOT 2
- ComboBox with sections HOT 6
- File dialog in background HOT 4
- optional params as checkbox with widget HOT 4
- DirectWrite: CreateFontFaceFromHDC() failed HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magicgui.