Hi Sebastiaan, I had some problems with correctly setting the state of items in a plugin. I created this bug report with gemini.
Description:
When developing a plugin using QtAutoPlugin in OpenSesame 4.0+, there is an inconsistency in how the enabled state of widgets is handled during initialization.
While QLineEdit widgets correctly maintain an setEnabled(False) state set within init_edit_widget(), other widgets like QComboBox and QCheckBox appear to be "reset" to Enabled=True by the framework immediately after init_edit_widget() finishes.
Steps to reproduce:
- Create a plugin based on
QtAutoPlugin.
- In
init_edit_widget(), set several widgets to setEnabled(False) based on the state of a "master" checkbox.
- Observe that
QLineEdit objects are correctly disabled when the UI loads.
- Observe that
QComboBox and QCheckBox objects remain enabled, despite widget.isChecked() returning the expected value and the manual setEnabled(False) call being executed.
Current workaround:
The only way to force the correct state is by using a QTimer.singleShot(0, self.update_ui_states) to defer the setEnabled calls until after the framework has completed its internal setup/variable binding.
Expected behavior:
The framework should respect the enabled state set by the developer in init_edit_widget(), or provide a specific hook that is called after variable binding is complete but before the UI is shown to the user.
Environment:
- OpenSesame version: 4.1.8
- Operating System: Debian Trixie
Example snippet:
class MyPlugin(QtAutoPlugin):
"""
Minimal example showing that QLineEdit respects setEnabled(False)
during init, but QComboBox and QCheckBox do not.
"""
def init_edit_widget(self):
super().init_edit_widget()
# Assume self.checkbox_master is the trigger (default Unchecked)
master_state = self.checkbox_master.isChecked() # Returns False
# 1. This WORKS: LineEdit will be disabled on startup
self.line_edit_test.setEnabled(master_state)
# 2. This FAILS: ComboBox will be enabled on startup despite master_state being False
self.combobox_test.setEnabled(master_state)
# 3. This FAILS: CheckBox will be enabled on startup
self.checkbox_test.setEnabled(master_state)
# Connections work fine once the user starts interacting:
self.checkbox_master.stateChanged.connect(self.combobox_test.setEnabled)
Hi Sebastiaan, I had some problems with correctly setting the state of items in a plugin. I created this bug report with gemini.
Description:
When developing a plugin using
QtAutoPluginin OpenSesame 4.0+, there is an inconsistency in how theenabledstate of widgets is handled during initialization.While
QLineEditwidgets correctly maintain ansetEnabled(False)state set withininit_edit_widget(), other widgets likeQComboBoxandQCheckBoxappear to be "reset" toEnabled=Trueby the framework immediately afterinit_edit_widget()finishes.Steps to reproduce:
QtAutoPlugin.init_edit_widget(), set several widgets tosetEnabled(False)based on the state of a "master" checkbox.QLineEditobjects are correctly disabled when the UI loads.QComboBoxandQCheckBoxobjects remain enabled, despitewidget.isChecked()returning the expected value and the manualsetEnabled(False)call being executed.Current workaround:
The only way to force the correct state is by using a
QTimer.singleShot(0, self.update_ui_states)to defer thesetEnabledcalls until after the framework has completed its internal setup/variable binding.Expected behavior:
The framework should respect the
enabledstate set by the developer ininit_edit_widget(), or provide a specific hook that is called after variable binding is complete but before the UI is shown to the user.Environment:
Example snippet: