Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Conversation

@Ashwolaa
Copy link
Contributor

@Ashwolaa Ashwolaa commented Oct 23, 2025

Pattern completer subpart of PR#105:

This PR contains:

  • the PatternCompleter class which can be used with QTextEdit/QLineEdit/QPlainTextEdit, resulting in PatternTextEdit/PatternLineEdit/PatternPlainTextEdit
    See pattern_completer_demo.py in examples for some demonstration.
  • the PatternParameter which makes use of the PatternCompleter class. It provides a QPlainTextEdit making it similar to the usual parameter item but with the PatternCompleter methods.
    See parameter_ex.py in examples for an application

@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 284 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.39%. Comparing base (19a66e8) to head (000a12d).
⚠️ Report is 23 commits behind head on 5.0.x_dev.

Files with missing lines Patch % Lines
...modaq_gui/parameter/pymodaq_ptypes/text_pattern.py 29.49% 153 Missing ⚠️
src/pymodaq_gui/utils/widgets/pattern_completer.py 61.86% 127 Missing ⚠️
src/pymodaq_gui/parameter/ioxml.py 75.00% 4 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           5.0.x_dev     #109      +/-   ##
=============================================
- Coverage      64.22%   63.39%   -0.84%     
=============================================
  Files             73       75       +2     
  Lines           9201     9768     +567     
=============================================
+ Hits            5909     6192     +283     
- Misses          3292     3576     +284     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@seb5g
Copy link
Contributor

seb5g commented Oct 24, 2025

A few comments to start on this huge PR:

  • when there is only one elt in the proposed choices (from the pattern filtering) it would be nice to just press enter to use it. As it is, one has to use the down arrow key or the mouse click
  • for emoji, you should include a space just after the emoji otherwise it breaks the emoji representation
  • could not see any difference in your wordwrap example

@Ashwolaa
Copy link
Contributor Author

A few comments to start on this huge PR:

  • when there is only one elt in the proposed choices (from the pattern filtering) it would be nice to just press enter to use it. As it is, one has to use the down arrow key or the mouse click

I agree, I changed it to have a behavior close to an IDE. The first item proposed is selected by default. Pressing Enter/Tab will autocomplete it (Tab only works well with QPlainText though)

  • for emoji, you should include a space just after the emoji otherwise it breaks the emoji representation

I removed them and I changed the example with more standard Unicodes. The issue with the emojis is that they consist of multiple characters which make the whole identification struggle.

  • could not see any difference in your wordwrap example

I updated the example, it should be more explanatory now.

@seb5g seb5g requested a review from malik-irain November 5, 2025 09:39
@seb5g
Copy link
Contributor

seb5g commented Nov 5, 2025

@malik-irain could you have a go to check this as well and merge it if it is fine. We have to move on to the monorepo ...

Comment on lines +46 to +48
widget.value = widget.toPlainText
widget.setValue = widget.setPlainText
widget.sigChanged = widget.textChanged
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that's what's the doc says about subclassing WidgetParameterItem but I would be careful about monkeypatching qt methods as it already made tests fails without any apparent reason. I would have implemented a value attribute and a setValue method in PatternPlainTextEdit widget that call toPlainText and setPlainText. For the signal, it might be tricky.

Anyways for now, it works so we can leave it like that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add this if you think it is better. There is no impact on the tests.

Not sure, how to deal with the signal though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude calls it "Duck typing adapter"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it works very well in python, but when using objects from C++ it can lead to segmentation faults (we had the issue recently), but as it doesn't seem to make tests fail, it's ok with me!

@malik-irain
Copy link
Contributor

@Ashwolaa Can you rebase or merge the last modification of pymodaq_gui in you PR so that I can see if tests are passing?

@malik-irain malik-irain merged commit ac05dbd into PyMoDAQ:5.0.x_dev Nov 5, 2025
25 of 28 checks passed
@Ashwolaa Ashwolaa deleted the feature/str_pattern_completion branch November 5, 2025 14:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants