Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DIRECTORY.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down
77 changes: 77 additions & 0 deletions scripts/text_splitter.py
Original file line numberDiff line numberDiff line change
@@ -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()