shethjenil commited on
Commit
8f9c6dc
·
verified ·
1 Parent(s): c073004

Update HandWriteMachine.py

Browse files
Files changed (1) hide show
  1. HandWriteMachine.py +32 -31
HandWriteMachine.py CHANGED
@@ -1,31 +1,32 @@
1
- from PIL.Image import open as open_image , Image
2
- from tkinter.simpledialog import askstring
3
- from tkinter.filedialog import asksaveasfilename
4
- from os import chdir
5
- import sys
6
- chdir(sys._MEIPASS)
7
- def condition(cont: str) -> Image:
8
- back = open_image("zback.png")
9
- width,height = 50,0
10
- for letter in cont:
11
- if letter in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+,.-? ":
12
- if letter == " ":
13
- letter = "zspace"
14
- if letter.isupper():
15
- letter = "c"+letter.lower()
16
- if letter == ",":
17
- letter = "coma"
18
- if letter == ".":
19
- letter = "fs"
20
- if letter == "?":
21
- letter = "que"
22
- if width + 150 >= back.width:
23
- height = height + 227
24
- width = 50
25
- cases = open_image(letter+".png")
26
- back.paste(cases,(width,height))
27
- width += cases.width
28
- return back
29
- img = condition(askstring("TEXT","Hand Written Text"))
30
- img.show()
31
- img.save(asksaveasfilename(filetypes=[("Image Files","*.png *jpg *jpeg *ico")],initialfile="Handwriting.png"))
 
 
1
+ #https://github.com/Ankit404butfound/HomeworkMachine/tree/master/Image for image download
2
+ from PIL.Image import open as open_image , Image
3
+ from tkinter.simpledialog import askstring
4
+ from tkinter.filedialog import asksaveasfilename
5
+ from os import chdir
6
+ import sys
7
+ chdir(sys._MEIPASS)
8
+ def condition(cont: str) -> Image:
9
+ back = open_image("zback.png")
10
+ width,height = 50,0
11
+ for letter in cont:
12
+ if letter in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+,.-? ":
13
+ if letter == " ":
14
+ letter = "zspace"
15
+ if letter.isupper():
16
+ letter = "c"+letter.lower()
17
+ if letter == ",":
18
+ letter = "coma"
19
+ if letter == ".":
20
+ letter = "fs"
21
+ if letter == "?":
22
+ letter = "que"
23
+ if width + 150 >= back.width:
24
+ height = height + 227
25
+ width = 50
26
+ cases = open_image(letter+".png")
27
+ back.paste(cases,(width,height))
28
+ width += cases.width
29
+ return back
30
+ img = condition(askstring("TEXT","Hand Written Text"))
31
+ img.show()
32
+ img.save(asksaveasfilename(filetypes=[("Image Files","*.png *jpg *jpeg *ico")],initialfile="Handwriting.png"))