Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a02e627

Browse files
Adding the finalized python script of the Python IDE and detailed Readme
1 parent e41b2c3 commit a02e627

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Author:Priyadarshan2000 (Priyadarshan Ghosh)
2+
# Simple Python IDE using Tkinter
3+
# See the readme.md for how to Run this Project.
4+
5+
# importing the modules
6+
from tkinter import *
7+
from tkinter.filedialog import asksaveasfilename, askopenfilename
8+
import subprocess
9+
10+
compiler = Tk()
11+
compiler.title('Simple Python IDE')
12+
file_path = ''
13+
14+
15+
def set_file_path(path):
16+
global file_path
17+
file_path = path
18+
19+
20+
def open_file():
21+
path = askopenfilename(filetypes=[('Python Files', '*.py')])
22+
with open(path, 'r') as file:
23+
code = file.read()
24+
editor.delete('1.0', END)
25+
editor.insert('1.0', code)
26+
set_file_path(path)
27+
28+
29+
def save_as():
30+
if file_path == '':
31+
path = asksaveasfilename(filetypes=[('Python Files', '*.py')])
32+
else:
33+
path = file_path
34+
with open(path, 'w') as file:
35+
code = editor.get('1.0', END)
36+
file.write(code)
37+
set_file_path(path)
38+
39+
40+
def run():
41+
if file_path == '':
42+
save_prompt = Toplevel()
43+
text = Label(save_prompt, text='Please save your code')
44+
text.pack()
45+
return
46+
command = f'python {file_path}'
47+
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
48+
output, error = process.communicate()
49+
code_output.insert('1.0', output)
50+
code_output.insert('1.0', error)
51+
52+
53+
menu_bar = Menu(compiler)
54+
55+
file_menu = Menu(menu_bar, tearoff=0)
56+
file_menu.add_command(label='Open', command=open_file)
57+
file_menu.add_command(label='Save', command=save_as)
58+
file_menu.add_command(label='Save As', command=save_as)
59+
file_menu.add_command(label='Exit', command=exit)
60+
menu_bar.add_cascade(label='File', menu=file_menu)
61+
62+
run_bar = Menu(menu_bar, tearoff=0)
63+
run_bar.add_command(label='Run', command=run)
64+
menu_bar.add_cascade(label='Run', menu=run_bar)
65+
66+
compiler.config(menu=menu_bar)
67+
68+
editor = Text()
69+
editor.pack()
70+
71+
code_output = Text(height=10)
72+
code_output.pack()
73+
74+
# Starting the GUI
75+
compiler.mainloop()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /