I made some improvement for IDLE, can I contribute to idlelib library in Python project? #

Project Introduction

GitHub: GitHub - znsoooo/IDLE-Advance: Python3 IDLE增强计划

PyPI: idlea · PyPI

Test on Windows

For compatible with Windows XP, project supports python 3.4 and above.

Install and test instance in cmd:

pip install idlea -U
idlea

I have tested on the Windows platform.

Maybe it can be run in Linux after installed IDLE (idlelib library), but it has not been tested.

Notice

Will generate .pybak format file(s) in current script file’s folder.

Will generate recent-saved.lst file in the Python user directory.

Avoid exist same name files cause rewrite.

Functions Introduction

I introduce SOME functions, and show usage through animated pictures.

SmartSelect.py

Double-click mouse to highlight words, or select more meaningful selections.

SmartSelect

  • Highlight the selected word.
  • Click the boundaries of string to select the whole string. (by using pre-tagged TAG in tk.Text)
  • Quick select the whole comments by click the comment mark (# sign).
  • Quick select the matched parentheses, including in comments.
  • Select a row by double-click the end of line.
  • Multi-line select by click the colon mark or click the space in indent.
  • Select escape character (\n, \xhh, \uxxxx, …).

SmartPairing.py

Quick add/delete/change pair or bracket or quotation marks.

SmartPairing1

SmartPairing2

  • Auto complete 3 types of brackets and 2 types of quotation marks in pairs.
  • Moving cursor without insert char when entering closing bracket (but not quotation mark).
  • Auto delete the closing bracket when deleting the opening bracket or quotation mark. (if you need to enter the opening bracket independently, enter the opening bracket and press Delete to delete the closing bracket)
  • Select text with brackets or quotation marks, press Backspace to remove the outer one.
  • Select text with brackets or quotation marks, type another type of brackets or quotation marks to replace the old one.

ScrollHorizontal.py

Add horizontal scroll bar.

ScrollHorizontal

CopyNoSelect.py

When the selection is empty, select and copy/cut the current line.

CopyNoSelect

Original Python’s IDLE can copy empty text, but it doesn’t seem make meaningful sense.

SelectVertical.py

Select text vertically.

SelectVertical

  • Pops up a input box after selecting text vertically.
  • Enter text witch what you want to replace, enter empty text to delete selection.
  • Cancel the input box to copy the selection to clipboard.

CalltipSelect.py

CallTips was originally an object of type tk.Label, I hack it into type tk.Text, keeping the size and content unchanged, so the text in calltip can be SELECTED.

CalltipSelect

CursorHistory.py

Record cursor’s history positons

CursorHistory

  • Left-click and record cursor’s history positions.
  • Alt-Left to move cursor backward.
  • Alt-Right to move cursor forward.

AutoReload.py

Detect file modified in disk and prompt for reload.

Avoid forget editing files in different editors, but didn’t syncing them in IDLE.

AutoReload

  • Prompt message box while the file on disk changed.
  • Choose yes to reload file, lost local edit history.
  • Choose not to not reload, set script unsaved state.
  • Select Reload in menu to reload file manually.

Others

Other extensions were shown in my project, there are about 33 extensions as whole.

If anyone is interested, I will give a full introduction.

My wish

The Python IDEs I most usually used is IDLE and PyCharm. PyCharm is powerful but slow to start-up, and it need install separately. IDLE is more simply, but lack some useful features.

For this reason, I added some functions to IDLE by hack into idlelib library. I draw from my personal experience and some functions in PyCharm.

Do you think ANY of these functions are worth adding to Python’s idlelib library, or maybe become basic functions of IDLE?

Do you have any suggestions? What can I do?

5 Likes

Seems like some GIF pictures were cropped or failed to upload… :frowning:

Ask me if you have any questions!

Hi Shixian Li, the person who usually reviews IDLE contributions is @tjreedy . Your contribution would be most easily reviewed in the form of a PR against the cpython repo. Since it looks like your work consists of multiple somewhat independent modifications, it might be good to split it up into multiple PRs, but before you put much effort into that, I would wait for Terry to give you some guidance.

3 Likes

Thank you for your suggestion.
I’m not proficient with git, but I’d like to contribute to python, and I will try to make PRs.
I discuss this topic, because I want to know is it meaningful, or just interest myself. And whether these features will generate negative effects? (include bugs or make python complicated)

Yes, even without looking at everything. A few notes:

Calltip selection seems more useful than dismissing the calltip when clicked on. It should be technically easy, and your animation shows a sensible usecase (copying non-trivial keyword parameter names).

Double click already selects a ‘word’ (sequence of ‘similar’ chars), but current selection for non-alpha chars is useless. I would like to make double clicking on or beside a quote or fence char more useful.

There is already an old issue, #42010, for a bottom scrollbar, and a patch with a test. But thorough testing reveal a technical problem.

I have recorded the URLs for both this discussion and your repository on my IDLE todo list. I will pip-install your package to browse your enhancements when I am ready to work on enhancements. But I currently need to work on some bugs. I would want a PR for each feature when I am ready to consider it.

Can you write unittests? Patches generally require tests using unittest and unittest.mock. Are you familiar with them?

3 Likes

My GIF picture was cropped…

In a situation, such as s.split('\n')[:ln], tk’s auto selection will select ')[: (and ('\), but this seems does not benefit to editing.

In my solution (in SmartSelect.py), I can double-click to select ('\n'), '\n', \n, and [:ln] (these were 3 types of match mode). I think this will help you copy or cut code for what you want much more easier.

And not only double-click to select a ‘word’, but highlight these same words in current script. (by add tag to these words by built-in tag hit)


Maybe I didn’t understand the meaning of this sentence. Could you please explain it in more detail? My English is not very good…


I will write unittest by referring developer’s guide before I making PR. But in my package currently, I write unittest differently, each extension can be run directly, e.g. run in cmd:

python SmartSelect.py

But these tests are interactive, but not mock.


Well, let’s try to start it from here. :slight_smile:

Did I reply to the right post? Maybe I did wrong settings. my reply is above.

You responded fine. My sentence you questioned says that we agree that selections like ')[: are useless, so improving these might be a good place to start.

1 Like