-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
212 lines (169 loc) · 9.49 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# ████████████████████████████████████████████████████████████████████████████████████████████████████
# █─▄▄▄─█▄─██─▄█▄─▄▄▀█▄─▄███▄─█─▄█░█─▄▄▄▄███─▄▄▄─█─▄▄─█▄─▄▄▀█▄─▄▄─███▄─▄▄─█▄─▄▄▀█▄─▄█─▄─▄─█─▄▄─█▄─▄▄▀█
# █─███▀██─██─███─▄─▄██─██▀██▄─▄██▄█▄▄▄▄─███─███▀█─██─██─██─██─▄█▀████─▄█▀██─██─██─████─███─██─██─▄─▄█
# ▀▄▄▄▄▄▀▀▄▄▄▄▀▀▄▄▀▄▄▀▄▄▄▄▄▀▀▄▄▄▀▀▀▀▄▄▄▄▄▀▀▀▄▄▄▄▄▀▄▄▄▄▀▄▄▄▄▀▀▄▄▄▄▄▀▀▀▄▄▄▄▄▀▄▄▄▄▀▀▄▄▄▀▀▄▄▄▀▀▄▄▄▄▀▄▄▀▄▄▀
#Made by Curly
#Made on 2022-6-3
#Path: main.py
#Modules:
#tkinter
#subprocess
#os
#sys
#time
#Automatically install modules
import pip
import os
os.system("echo auto installing is the worst ")
#pip.main(['install', 'time'])
#
#
#
#
# ░█████╗░░█████╗░██████╗░███████╗ ██████╗░███████╗██╗░░░░░░█████╗░░██╗░░░░░░░██╗
# ██╔══██╗██╔══██╗██╔══██╗██╔════╝ ██╔══██╗██╔════╝██║░░░░░██╔══██╗░██║░░██╗░░██║
# ██║░░╚═╝██║░░██║██║░░██║█████╗░░ ██████╦╝█████╗░░██║░░░░░██║░░██║░╚██╗████╗██╔╝
# ██║░░██╗██║░░██║██║░░██║██╔══╝░░ ██╔══██╗██╔══╝░░██║░░░░░██║░░██║░░████╔═████║░
# ╚█████╔╝╚█████╔╝██████╔╝███████╗ ██████╦╝███████╗███████╗╚█████╔╝░░╚██╔╝░╚██╔╝░
# ░╚════╝░░╚════╝░╚═════╝░╚══════╝ ╚═════╝░╚══════╝╚══════╝░╚════╝░░░░╚═╝░░░╚═╝░░
#
#
#
###############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
from asyncio import SubprocessProtocol
from tkinter import *
import os
import time
import random
import math
import sys
import subprocess
from tkinter.filedialog import asksaveasfilename, askopenfilename
#Make sure the user is running python 3.6 or higher
if sys.version_info[0] < 3:
print("This program requires Python 3.6 or higher.")
sys.exit(1)
sd = f'pip install tkinter'
zx = subprocess.Popen(sd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
#Variabls
Code_Editor = Tk()
Code_Editor.title("Curly's Code Editor")
#Make window size
Code_Editor.geometry("800x600")
#Code_Editor.geometry("800x600")
#Code_Editor.resizable(0,0)
#Make the textbox for the code
textbox = Text(Code_Editor, width=80, height=20, bg="grey", fg="black", font=("Helvetica", 12))
textbox.pack()
#make the buttons functtions
def set_file_path(path):
global file_path
file_path = path
def alert(text):
#If text is not a string
if not isinstance(text, str):
#Make it a string
text = str(text)
#Make a new window
alert = Tk()
alert.title("Alert")
#Make the textbox
textbox = Text(alert, width=80, height=20, bg="black", fg="white", font=("Helvetica", 12))
textbox.pack()
#Set the text in the textbox
textbox.insert(1.0, text)
#Make the buttons
button = Button(alert, text="OK", command=alert.destroy)
button.pack()
file_path =""
#Make the setup what makes the folder "EXPORTS"
def setup():
#Make the folder
#os.system("mkdir EXPORTS")
os.system("heres go some cool code idea written perfectly")
def clear():
textbox.delete(1.0, END)
#Run the code in a new terminal
def run():
if file_path == '':
save_prompt = Toplevel()
text = Label(save_prompt, text='Please save your code')
text.pack()
return
command = ""
#command = f'python {fil
if str(file_path).endswith(".py"):
command = f'python {file_path}'
if command == "":
alert(f'Unable to run {file_path}')
else:
os.system(command)
def save():
#Open the file ex
path = asksaveasfilename(filetypes=[('*', '*')])
with open(path, 'w') as file:
code = textbox.get(1.0, END)
file.write(code)
set_file_path(path)
def load():
path = askopenfilename(filetypes=[('*', '*')])
with open(path, 'r') as file:
code = file.read()
textbox.delete(1.0, END)
textbox.insert(1.0, code)
def exit():
#Exit the program
Code_Editor.destroy()
def help():
#Make a new window what shows the help
txt = "Curly's Code_Editor\n\n"
txt += "This is a simple Code_Editor for programming .\n\n"
txt += "The Code_Editor has the following features:\n\n"
txt += "1. Save\n"
txt += "2. Load\n"
txt += "3. Run\n"
txt += "4. Clear\n"
txt += "5. Help\n"
txt += "6. Exit\n"
txt += "7. Setup\n"
txt += "And the most important one is:\n"
txt += "8. Editing the Code_Editor \n"
txt += "\n\n"
#Make a new window
help = Tk()
help.title("Help")
#Make the textbox
textbox = Text(help, width=80, height=20, bg="grey", fg="white", font=("Helvetica", 12))
textbox.pack()
#Set the text in the textbox
textbox.insert(1.0, txt)
#Make the buttons
#Make the buttons for saving and opening files
menu = Menu(Code_Editor)
Code_Editor.config(menu=menu)
filemenu = Menu(menu)
menu.add_cascade(label="File", menu=filemenu)
filemenu.add_command(label="Save", command=save)
filemenu.add_command(label="Load", command=load)
filemenu.add_command(label="Exit", command=exit)
#Make the buttons for the help
helpmenu = Menu(menu)
menu.add_cascade(label="Help", menu=helpmenu)
helpmenu.add_command(label="Help", command=help)
#Make the buttons for the run
runmenu = Menu(menu)
menu.add_cascade(label="Run", menu=runmenu)
runmenu.add_command(label="Run (python)", command=run)
runmenu.add_command(label="Clear", command=clear)
#Make the buttons for the setup
setupmenu = Menu(menu)
menu.add_cascade(label="Setup", menu=setupmenu)
setupmenu.add_command(label="Setup", command=setup)
#Binds
#Background
Code_Editor.configure(background='black')
if __name__ == '__main__':
#Make the folder
setup()
#Start the program
Code_Editor.mainloop()