From 74c8b815c26ca502936b1feb28f58968c3f46c47 Mon Sep 17 00:00:00 2001 From: dimonalik <114773527+dimonalik@users.noreply.github.com> Date: Mon, 2 Oct 2023 10:32:44 +0300 Subject: [PATCH 1/2] Create text_splitter.py Text splitter by the number of symbols with GUI --- scripts/text_splitter.py | 77 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 scripts/text_splitter.py diff --git a/scripts/text_splitter.py b/scripts/text_splitter.py new file mode 100644 index 000000000000..fe182bd3fb15 --- /dev/null +++ b/scripts/text_splitter.py @@ -0,0 +1,77 @@ +import PySimpleGUI as SG + +splitted = "" +text = "" +SG.theme("DarkBlue4") +layout = [ + [SG.Text("Text for splitting"), SG.InputText(size=(20, 5), key="input")], + [ + SG.Text("How many symbols in one part"), + SG.InputText(size=(5, 1), key="symbols"), + SG.Text("(Count on additional symbols for amount of parts)"), + ], + [SG.Checkbox("Do we add amount of parts?", key="split")], + [SG.Button("Split")], + [SG.Multiline(splitted, key="-logtext-", size=(None, 10), rstrip=False)], + [ + SG.Button("Clear"), + SG.Text( + " © @uahave.fun", + text_color="dark blue", + font=("Helvetica", 10), + justification="right", + ), + ], + [SG.Text("------------------------------------------------------")], + [SG.Button("Close")], +] + +window = SG.Window("Splitter", layout) + +while True: + event, values = window.read() + if event in (None, "Close"): + break + if event == "Split": + if values["input"] == "": + SG.popup("Add text to split!") + continue + if values["symbols"].isdigit() is False: + SG.popup("Symbols amount must be numeric only!") + continue + if values["symbols"] == "": + SG.popup("Enter symbols amount!") + continue + if int(values["symbols"]) < 1: + SG.popup("Enter symbols amount > 0!") + continue + if int(values["symbols"]) > len(values["input"]): + SG.popup("Enter symbols amount less then whole text size!") + continue + if int(values["symbols"]) == len(values["input"]): + SG.popup("Enter symbols amount less then whole text size!") + continue + es = [ + values["input"][i : i + int(values["symbols"])] + for i in range(0, len(values["input"]), int(values["symbols"])) + ] + for i in es: + if values["split"] is True: + text = ( + text + + str(es.index(i) + 1) + + "/" + + str(len(es)) + + " " + + splitted + + i + + "\n" + + "\n" + ) + else: + text = text + splitted + i + "\n" + "\n" + window["-logtext-"].update(text) + if event == "Clear": + window["-logtext-"].update("") + text = "" +window.close() From ec994cfde0c4eb1ba05b99f5496e4815628d4e31 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Mon, 2 Oct 2023 07:33:03 +0000 Subject: [PATCH 2/2] updating DIRECTORY.md --- DIRECTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index 7d3ceee144be..24c68171c9bc 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -233,6 +233,7 @@ * [Merge Two Lists](data_structures/linked_list/merge_two_lists.py) * [Middle Element Of Linked List](data_structures/linked_list/middle_element_of_linked_list.py) * [Print Reverse](data_structures/linked_list/print_reverse.py) + * [Reverse K Group](data_structures/linked_list/reverse_k_group.py) * [Rotate To The Right](data_structures/linked_list/rotate_to_the_right.py) * [Singly Linked List](data_structures/linked_list/singly_linked_list.py) * [Skip List](data_structures/linked_list/skip_list.py)