New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task/Todo textboxes based on code? #1751
Comments
I'm not aware of any attempts to do something similar in Thonny's context, but it shouldn't be too hard to do. Thonny's editor's superclass has couple of methods which can be helpful here, see Unortunately, there is no clean way for getting the modified behavior into Thonny's editor class. The best way I can think of, is simply patching the class. See the last 2 lines in I'm happy to help when you get stuck. Out of curiousity, why can't you just tell the students to edit only the marked areas in the code? What kind of confusion do you expect? |
Thanks, I'll see how that works!
Think high school students in puberty ;-). This is not an issue for the university students, but it makes the life easier for the high school students that they are sure they can not "destroy" the scaffolding code and clearly see what needs to be filled out. I'll keep you posted how it goes. |
Hi @aivarannamaa, |
What about |
Hm, "restricted" is a bit too technical and, in my understanding, implies the restriction for the whole file. What about |
Hi @aivarannamaa , When a file is opened (or Thonny is loaded or a tab is changed), how could I go through text and set background on all the lines between How do I hook into the corresponding events? To set the background I assume I need to set the tags appropriately somehow? |
@aivarannamaa I spent some more time tonight and finally figured out how I can set my one tags. I monkey-patch the method I'm still in the dark about how to set the background of the write-restricted text between the markers -- any hints are much appreciated! |
I guess it is pretty good place for this.
If you marked the area with tag, then you need to use |
Thanks, @aivarannamaa! I think the work on the plug-in is progressing well. Let me finish the first working version and then it would be great if you could have a brief look? |
Sure! |
Hi @aivarannamaa , I'm pretty much done. Currently, I'm implementing a script that is signing the sealed blocks so that the user can't just type in the comments and have them sealed (or, which is a more probable case, copy/paste them). The "seals" are defined by a hash (MD5) of the content of a sealed block. The seals are generated using a separate script. An example workflow would be:
I'd like to warn the user on |
I think |
Hi @aivarannamaa , Thank you a lot in advance! :-) |
P.S. The readme is not finished yet. I'd like to wait for your feedback in case behavior or appearance needs to change so that I don't have to re-capture the screenshots. |
Looks good to me! I'm impressed about your thoroughness -- typings, contracts (of course :) ) , tests... Some remarks:
|
Hi @aivarannamaa , While manually testing, I discovered that the coloring comes out a bit weird: I tried hacking around, and suspect that the issue is in the plugin old_raise_tags = thonny.plugins.coloring.SyntaxColorer._raise_tags
def _raise_tags(self: thonny.plugins.coloring.SyntaxColorer):
"""Raise sealing tags above all the other tags."""
old_raise_tags(self)
self.text.tag_raise(TAG_NAME)
self.text.tag_raise(TAG_END_NAME)
thonny.plugins.coloring.SyntaxColorer._raise_tags = _raise_tags But is this the expected way to change the coloring? Is there any other way how I can override the tag priority so that the tags of the sealed blocks take precedence over the syntax coloring? An alternative solution would be to only change the appearance of the two sealing comments. This makes the sealed text much more readable. Here's the screenshot with only the sealing comments highlighted: The user is not as aware that the sealed blocks are indeed sealed, but the text is easier on the eyes. What do you think? |
Here's another solution. I allow for arbitrary spaces in the comments as well as unicode characters for the arrows (instead of Here's an example screenshot: This also looks a bit neater and less distracting than the solutions where the background color was set to light grey. |
You could also draw a 3d border around the sealed areas, but I'm not sure how good it looks with dark theme. Regarding raising tags -- I think the solution you found is best there is. Thonny's plug-in system currently isn't prepared for editor tweaking. |
Closing for now. Please reopen if you have more questions. |
@aivarannamaa thanks! Sorry, I forgot to close the issue myself. I went with the underline in the end. |
Hi @aivarannamaa,
Please apologize if this feature has been already requested or implemented. I couldn't find a relevant issue.
We are looking into how to use contracts for educational purposes (see thonny-icontract-hypothesis and thonny-crosshair). Consider a classroom exercise. I thought that it would be practical if the teacher could write the interfaces of the functions (including the contracts) and mark the blank areas in the code (e.g., a "solution area"), while the pupils would fill out the blanks. To avoid confusion, A thonny plug-in would prevent editing of the non-blank areas.
Do you know if somebody already looked into it? If not, how hard would it be to implement such a plug-in in your opinion? (Would you be perhaps interested to help me implement it if nobody looked into it thus far? I can do the "hard lifting", but I'd need some guidance.)
The text was updated successfully, but these errors were encountered: