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 6938240

Browse files
Merge pull request avinashkranjan#773 from Priyadarshan2000/master
Simple Python IDE using Tkinter
2 parents 2e21318 + 4269de0 commit 6938240

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Simple Python IDE using Tkinter
2+
This is a Simple Python IDE using Tkinter. We can Run our Python Code here. we open our saved code in this IDE.
3+
when you can't save your code and run it an error message show **"Please save your code"**.
4+
This Python IDE develops using Tkintertable & subprocess. run module.
5+
After your code will run successfully, to exit from the IDE go to File and click the Exit Button.
6+
7+
8+
## Setup instructions
9+
There are two ways to run it on your Linux,MAC or Windows
10+
11+
- Run the executable(.exe) file.
12+
- Run the program in your IDE or terminal/command line.
13+
14+
## Requirements:
15+
- Python3
16+
17+
```bash
18+
pip install tkintertable
19+
```
20+
```bash
21+
pip install subprocess.run
22+
```
23+
Click on the **Click Here** to see the Simple Python IDE using Tkinter Demo on YouTube.
24+
25+
| Name of Script | YouTube Link | Author | Tools Used |
26+
| --- | --- | --- | ---
27+
|Simple Python IDE using Tkinter| [Click Here](https://www.youtube.com/watch?v=-oGVdnelHv8)| [Priyadarshan Ghosh](https://github.com/Priyadarshan2000) | tkintertable, subprocess.run
28+
29+
## Output
30+
31+
![image](https://user-images.githubusercontent.com/62868878/112800376-32ae3c00-908d-11eb-96ac-38b7d1f2fb76.png)
32+
33+
34+
## Demo
35+
36+
![20210329_130409](https://user-images.githubusercontent.com/62868878/112802134-7013c900-908f-11eb-806a-157f8b6a6770.gif)
37+
38+
39+
## Author(s)
40+
41+
- Priyadarshan Ghosh (Priyadarshan2000)
42+
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
def open_file():
20+
path = askopenfilename(filetypes=[('Python Files', '*.py')])
21+
with open(path, 'r') as file:
22+
code = file.read()
23+
editor.delete('1.0', END)
24+
editor.insert('1.0', code)
25+
set_file_path(path)
26+
27+
28+
def save_as():
29+
if file_path == '':
30+
path = asksaveasfilename(filetypes=[('Python Files', '*.py')])
31+
else:
32+
path = file_path
33+
with open(path, 'w') as file:
34+
code = editor.get('1.0', END)
35+
file.write(code)
36+
set_file_path(path)
37+
38+
39+
def run():
40+
if file_path == '':
41+
save_prompt = Toplevel()
42+
text = Label(save_prompt, text='Please save your code')
43+
text.pack()
44+
return
45+
command = f'python {file_path}'
46+
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
47+
output, error = process.communicate()
48+
code_output.insert('1.0', output)
49+
code_output.insert('1.0', error)
50+
51+
52+
menu_bar = Menu(compiler)
53+
54+
file_menu = Menu(menu_bar, tearoff=0)
55+
file_menu.add_command(label='Open', command=open_file)
56+
file_menu.add_command(label='Save', command=save_as)
57+
file_menu.add_command(label='Save As', command=save_as)
58+
file_menu.add_command(label='Exit', command=exit)
59+
menu_bar.add_cascade(label='File', menu=file_menu)
60+
61+
run_bar = Menu(menu_bar, tearoff=0)
62+
run_bar.add_command(label='Run', command=run)
63+
menu_bar.add_cascade(label='Run', menu=run_bar)
64+
65+
compiler.config(menu=menu_bar)
66+
67+
editor = Text()
68+
editor.pack()
69+
70+
code_output = Text(height=10)
71+
code_output.pack()
72+
73+
# Starting the GUI
74+
compiler.mainloop()

0 commit comments

Comments
(0)

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