Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Look over this code
#1
Hey guys would anyone be able to look over this for a buddy of mine and see why this is not working. I’m not familiar with really any python.

From what I understand they have an account who has to write 80 paragraphs for their thing and then need a break. Whenever they enter it it gets rid of the paragraphs. So he had the idea to come up with this to fix that problem.

This might be super simple,

Thank you very much!

def insert_line_breaks():

    editor.beginUndoAction()

    pos = 80

    while pos < editor.getTextLength():

        editor.insertText(pos, '\n')

        pos += 81  # Move to the next position after the newly inserted line break

    editor.endUndoAction()

 

insert_line_breaks()
Gribouillis write May-24-2024, 05:13 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#2
Hey guys would anyone be able to look over this for a buddy of mine and see why this is not working. I’m not familiar with really any python.

From what I understand they have an account who has to write 80 paragraphs for their thing and then need a break. Whenever they enter it it gets rid of the paragraphs. So he had the idea to come up with this to fix that problem.

This might be super simple,

Thank you very much!

def insert_line_breaks():

    editor.beginUndoAction()

    pos = 80

    while pos < editor.getTextLength():

        editor.insertText(pos, '\n')

        pos += 81  # Move to the next position after the newly inserted line break

    editor.endUndoAction()

 

insert_line_breaks()
It happens like that on my pc or online editor. Or blogging. Sometimes. But a whole paragraph or 80 paragraphs? Any idea what this function will look like?
Larz60+ write May-24-2024, 07:03 PM:
Please refer to BBCode help topic on how to post using proper bbcode tags.

Fixed for you this itme.
Programs are like instructions or rules. Learning it gets us closer to a solution. Desired outcome. Computer talk.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020