Skip to content

Commit ff39b98

Browse files
committed
Revert "0.23"
This reverts commit cdd849d.
1 parent 9004bd5 commit ff39b98

File tree

5 files changed

+77
-518
lines changed

5 files changed

+77
-518
lines changed

binpython-ideplus.py

Lines changed: 76 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -3,101 +3,89 @@
33
@author xingyujie https://github.com/xingyujie
44
@abstract BINPython main file
55
"""
6-
# BINPython By:XINGYUJIE AGPL-V3.0 LICENSE Release
7-
# Please follow the LICENSE AGPL-V3
8-
# ide plus version
9-
10-
6+
#BINPython By:XINGYUJIE AGPL-V3.0 LICENSE Release
7+
#Please follow the LICENSE AGPL-V3
8+
#ide plus version
119
####################################
12-
# build configure
13-
14-
import ctypes
15-
ver = "0.20-releases"
10+
#build configure
1611

17-
libs_warning = "1"
18-
# 1 is ture 0 is false.
19-
# Changing the value to 0 will close the prompt that the library does not exist
12+
ver="0.20-releases"
2013

21-
releases_ver = "offical-with-ideplus"
22-
importlibs = "os" # Don't use "import xxx"
14+
libs_warning="1"
15+
#1 is ture 0 is false.
16+
#Changing the value to 0 will close the prompt that the library does not exist
2317

24-
# Imported library name, please use "importlibs="<library name>" instead of "import <library name>"
25-
# Please note: The "importlibs" function does not support loading functions (such as from xxxx import xxxx, if necessary, please write it in the following location. However, please note that this operation may have the risk of error reporting, please report issues or solve it yourself
26-
# xxxxxxxxxxxxxx
18+
releases_ver="offical-with-ideplus"
19+
importlibs="os" #Don't use "import xxx"
20+
#Imported library name, please use "importlibs="<library name>" instead of "import <library name>"
21+
#Please note: The "importlibs" function does not support loading functions (such as from xxxx import xxxx, if necessary, please write it in the following location. However, please note that this operation may have the risk of error reporting, please report issues or solve it yourself
22+
#xxxxxxxxxxxxxx
2723

28-
# from xxxx import xxxx
29-
# xxxxxxxxxxxxxx
30-
apptitle = "BINPython " + ver
24+
#from xxxx import xxxx
25+
#xxxxxxxxxxxxxx
3126
####################################
32-
33-
34-
ctypes.windll.kernel32.SetConsoleTitleW(apptitle)
35-
36-
27+
import ctypes
28+
ctypes.windll.kernel32.SetConsoleTitleW("BINPython " + ver)
3729
def self_import(name):
3830
__import__(name)
39-
40-
4131
try:
4232
self_import(importlibs)
4333
except ImportError:
4434
if libs_warning == "1":
4535
print("Warning: Custom import library %s does not exist, please check the source code library configuration and rebuild" % importlibs)
4636
print("")
4737
try:
48-
# base import
38+
#base import
4939
import getopt
5040
import sys
5141
import platform
5242
import os
53-
# fix for exit()
43+
#fix for exit()
5444
from sys import exit
55-
# import for http_server
45+
#import for http_server
5646
import http.server
5747
import socketserver
58-
# except ImportError:
48+
#except ImportError:
5949
except ImportError:
6050
print("Unable to use any library, the program does not work properly, please rebuild")
61-
# gui import
51+
#gui import
6252
try:
6353
import tkinter
6454
import tkinter as tk
6555
from tkinter import *
6656
import turtle
67-
# warning for gui
57+
#warning for gui
6858
except ImportError:
6959
if libs_warning == "1":
7060
print("Warning: Some GUI (graphical) libraries for BINPython do not exist, such as tkinter and turtle. Because they are not built when they are built. If you need to fix this warning, please complete the support libraries imported in the source code at build time (use pip or build it yourself), if your system does not support these libraries, you can remove or change this hint in the source code and rebuild")
7161
print("")
7262

73-
# import math
63+
#import math
7464
try:
7565
import fractions
7666
import cmath
7767
except ImportError:
7868
if libs_warning == "1":
7969
print("Warning: Some math or computation libraries for BINPython do not exist, such as fractions and cmath. Because they weren't built when they were built. If you need to fix this warning, please complete the support libraries imported in the source code when building (use pip or build it yourself), if your system does not support these libraries, you can remove or change this prompt in the source code and rebuild")
8070
print("")
81-
# rlcompleter
82-
# import for normal
71+
#rlcompleter
72+
#import for normal
8373
try:
84-
# str
74+
#str
8575
import rlcompleter
8676
import array
8777
except ImportError:
8878
if libs_warning == "1":
8979
print("Warning: Some libraries for functions, data types, etc. for BINPython do not exist, such as rlcomplter and array. Because they weren't built when they were built. If you need to fix this warning, please complete the support libraries imported in the source code when building (use pip or build it yourself), if your system does not support these libraries, you can remove or change this prompt in the source code and rebuild")
9080
print("")
9181
try:
92-
import filecmp
93-
import tempfile
82+
import filecmp
83+
import tempfile
9484
except ImportError:
9585
if libs_warning == "1":
9686
print("Warning: Some file manipulation libraries for BINPython do not exist, such as filecmp and tempfile. Because they weren't built when they were built. If you need to fix this warning, please complete the support libraries imported in the source code when building (use pip or build it yourself), if your system does not support these libraries, you can remove or change this prompt in the source code and rebuild")
9787
print("")
98-
# def
99-
100-
88+
#def
10189
def help():
10290
print("[*] BINPython Help")
10391
print("""
@@ -109,33 +97,29 @@ def help():
10997
-i --idle Open BINPython IDLE Code Editor
11098
-p --plus Open BINPython IDE Plus Code Editor(beta) with http web server
11199
""")
112-
113-
114-
about = "BINPython " + ver + "-" + releases_ver + \
115-
" By:XINGYUJIE[https://github.com/xingyujie/binpython] AGPL-3.0 LICENSE Release"
116-
# getopt
100+
about = "BINPython " + ver + "-" + releases_ver + " By:XINGYUJIE[https://github.com/xingyujie/binpython] AGPL-3.0 LICENSE Release"
101+
#getopt
117102
try:
118-
opts, args = getopt.getopt(sys.argv[1:], '-h-f:-s:-g-i-p-e-v', ['help', 'file=', 'server=', 'gui', 'idle', 'plus', 'example', 'version'])
103+
opts,args = getopt.getopt(sys.argv[1:],'-h-f:-s:-g-i-p-v',['help','file=','server=','gui','idle','plus','version'])
119104
except:
120105
print("Please check help:")
121106
help()
122107
print("The parameters you use do not exist or are not entered completely, please check help! ! ! ! !")
123-
for opt_name, opt_value in opts:
124-
if opt_name in ('-h', '--help'):
108+
for opt_name,opt_value in opts:
109+
if opt_name in ('-h','--help'):
125110
help()
126111
sys.exit()
127-
if opt_name in ('-v', '--version'):
128-
print("BINPython " + ver + "-" + releases_ver +
129-
" By:XINGYUJIE[https://github.com/xingyujie/binpython] AGPL-3.0 LICENSE Release")
112+
if opt_name in ('-v','--version'):
113+
print("BINPython " + ver + "-" + releases_ver + " By:XINGYUJIE[https://github.com/xingyujie/binpython] AGPL-3.0 LICENSE Release")
130114
print("Python " + platform.python_version())
131115
exit()
132-
if opt_name in ('-f', '--file'):
116+
if opt_name in ('-f','--file'):
133117
file = opt_value
134-
f = open(file, encoding="utf-8")
118+
f = open(file,encoding = "utf-8")
135119
exec(f.read())
136120
input("Please enter to continue")
137121
sys.exit()
138-
if opt_name in ('-s', '--server'):
122+
if opt_name in ('-s','--server'):
139123
server_port = opt_value
140124
print("""
141125
PORT = """ + server_port + """
@@ -146,120 +130,45 @@ def help():
146130
print("serving at port", PORT)
147131
httpd.serve_forever()
148132
""")
149-
if opt_name in ('-g', '--gui'):
133+
if opt_name in ('-g','--gui'):
150134
from tkinter import *
151135
root = Tk()
152136
root.title("Welcome to BINPython")
153-
root.geometry('1600x1300')
154-
text = Text(root, width=35, heigh=15)
137+
root.geometry('600x300')
138+
text =Text(root, width=35, heigh=15)
155139
text.pack()
156140
text.insert("insert", "BINPython" + about)
157141
print(text.get("1.3", "1.end"))
158142
####
159-
text = Label(root, text="Welcome to BINPython" + ver,
160-
bg="yellow", fg="red", font=('Times', 20, 'bold italic'))
143+
text=Label(root,text="Welcome to BINPython" + ver,bg="yellow",fg="red",font=('Times', 20, 'bold italic'))
161144
text.pack()
162-
button = Button(root, text="EXIT", command=root.quit)
145+
button=Button(root,text="EXIT",command=root.quit)
163146
button.pack(side="bottom")
164147
root.mainloop()
165148
sys.exit()
166-
167149
def show():
168150
os.system('cls' if os.name == 'nt' else 'clear')
169151
print("<<<<<<<<<<START>>>>>>>>>>")
170152
exec(e1.get(1.0, END))
171-
if opt_name in ('-i', '--idle'):
153+
if opt_name in ('-i','--idle'):
172154
import tkinter as tk
173155
from tkinter import *
174156
import os
175157
master = tk.Tk()
176158
master.title("BINPython IDLE")
177-
159+
160+
178161
tk.Label(master, text="Type Code", height=5).grid(row=0)
179-
162+
180163
e1 = Text(master,
181-
width=150,
182-
height=40,)
183-
164+
width=150,
165+
height=40,)
166+
184167
e1.grid(row=0, column=1, padx=10, pady=5)
185-
tk.Button(master, text="Run", width=10, command=show).grid(
186-
row=3, column=0, sticky="w", padx=10, pady=5)
187-
tk.Button(master, text="EXIT", width=10, command=master.quit).grid(
188-
row=3, column=1, sticky="e", padx=10, pady=5)
168+
tk.Button(master, text="Run", width=10, command=show).grid(row=3, column=0, sticky="w", padx=10, pady=5)
169+
tk.Button(master, text="EXIT", width=10, command=master.quit).grid(row=3, column=1, sticky="e", padx=10, pady=5)
189170
master.mainloop()
190-
191-
if opt_name in ('-e', '--example'):
192-
examplecodenotice = "Here is the source code:"
193-
examplehelloworld = """
194-
helloworldnameinput = input("What's your name?")
195-
print("Hello world! Hello BINPython! Hello " + helloworldnameinput)
196-
"""
197-
exampleturtle = """
198-
from turtle import *
199-
title("BINPython turtle example")
200-
color("red", "yellow")
201-
speed(10)
202-
begin_fill()
203-
for x in range(50):
204-
forward(200)
205-
left(170)
206-
end_fill()
207-
done()"""
208-
exampletkinter = """
209-
import tkinter as tk
210-
app = tk.Tk()
211-
app.title('BINPython tkinter example')
212-
theLabel = tk.Label(app, text='BINPython Tkinter Example')
213-
theLabel.pack()
214-
app.mainloop()"""
215-
examplerequests = """
216-
import requests
217-
res = requests.get('http://bing.com')
218-
print(res.text)
219-
"""
220-
examplepywebio = """
221-
from pywebio import *
222-
223-
def main():
224-
name = input.input("what's your name")
225-
output.put_text("Hello BINPython, Hello ", name)
226-
227-
start_server(main, port=8080, debug=True)
228-
"""
229-
print("BINPython application example")
230-
print("LIST:")
231-
print("""
232-
1. Hello World
233-
2. turtle drawing demo
234-
3. Tkinter demo
235-
4. HTTP Requests
236-
5. PyWebIO demo
237-
""")
238-
239-
examplenum = input("Enter example number to run(like:1): ")
240-
#do sth
241-
242-
if examplenum == '1':
243-
exec(examplehelloworld)
244-
print(examplecodenotice)
245-
print(examplehelloworld)
246-
if examplenum == '2':
247-
exec(exampleturtle)
248-
print(examplecodenotice)
249-
print(exampleturtle)
250-
if examplenum == '3':
251-
exec(exampletkinter)
252-
print(examplecodenotice)
253-
print(exampletkinter)
254-
if examplenum == '4':
255-
exec(examplerequests)
256-
print(examplecodenotice)
257-
print(examplerequests)
258-
if examplenum == '5':
259-
exec(examplepywebio)
260-
print(examplecodenotice)
261-
print(examplepywebio)
262-
if opt_name in ('-p', '--plus'):
171+
if opt_name in ('-p','--plus'):
263172
serverport = input("Please enter server port(like 8080): ")
264173
import pywebio.input
265174
from pywebio.input import *
@@ -271,56 +180,50 @@ def main():
271180
import os
272181
print("______________________________________")
273182
print("BINPython WEB IDE STARTED")
274-
# IDE Plus main
275-
183+
#IDE Plus main
276184
def main():
277185
set_env(title="BINPython IDE Plus", auto_scroll_bottom=True)
278186
put_html("<h1>BINPython IDE Plus</h1>")
279187
put_text('Welcome to BINPython IDE Plus, Please type code',
280-
sep=' '
281-
)
282-
toast(
283-
"BINPython IDE Plus is a beta version. May be removed or changed in the future")
188+
sep=' '
189+
)
190+
toast("BINPython IDE Plus is a beta version. May be removed or changed in the future")
284191
put_text('_______________________',
285-
sep=' '
286-
)
192+
sep=' '
193+
)
287194
res = textarea('BINPython IDE Plus', rows=45, code={
288-
'mode': "python",
289-
'theme': 'darcula'
290-
})
195+
'mode': "python",
196+
'theme': 'darcula'
197+
})
291198
exec(res)
292199
toast("Run finished!")
293200
put_success("Finished, Please see BINPython Window or Terminal")
294201
put_text("Here is the code you wrote")
295202
put_code(res, language='python')
296-
savecodefilename = pywebio.input.input(
297-
'Do you want to save the code you wrote to a file? Enter a filename and save it')
203+
savecodefilename = pywebio.input.input('Do you want to save the code you wrote to a file? Enter a filename and save it')
298204
f = open(savecodefilename, 'wb+')
299205
f.write(res.encode("utf-8"))
300206
toast("Successfully saved")
301-
put_success("The save is successful, and the code is saved to binpython file path" +
302-
" \nThe file name is " + '"' + savecodefilename + '"')
207+
put_success("The save is successful, and the code is saved to binpython file path" + " \nThe file name is " + '"' + savecodefilename + '"')
303208
if __name__ == '__main__':
304-
start_server(main, debug=True, host='0.0.0.0', port=serverport)
209+
start_server(main, debug=True, host='0.0.0.0', port= serverport)
305210
pywebio.session.hold()
306-
binpywelcome = "BINPython " + ver + "-" + releases_ver + " (Python Version:" + platform.python_version() +")By:XINGYUJIE https://github.com/xingyujie/binpython[Running on " + platform.platform() + " " + platform.version() + "]"
307-
binpynotice = 'Type "about", "help", "copyright", "credits" or "license" for more information.'
211+
212+
213+
#main BINPython
308214

309-
# main BINPython
310-
print(binpywelcome)
311-
print(binpynotice)
215+
print("BINPython " + ver + "-" + releases_ver + " (Python Version:" + platform.python_version() + ")By:XINGYUJIE https://github.com/xingyujie/binpython[Running on " + platform.platform() + " " + platform.version() + "]")
216+
print('Type "about", "help", "copyright", "credits" or "license" for more information.')
312217
try:
313218
while True:
314-
pycmd = input(">>> ")
219+
pycmd=input(">>> ")
315220
if pycmd in globals().keys():
316221
print(globals()[pycmd])
317222
continue
318223
elif pycmd == 'about':
319-
print(
320-
"BINPython By:XINGYUJIE[https://github.com/xingyujie] AGPL-3.0 LICENSE Release")
224+
print("BINPython By:XINGYUJIE[https://github.com/xingyujie] AGPL-3.0 LICENSE Release")
321225
elif pycmd == 'help':
322-
print(
323-
"Type help() for interactive help, or help(object) for help about object.")
226+
print("Type help() for interactive help, or help(object) for help about object.")
324227
elif pycmd == 'copyright':
325228
print("""
326229
Copyright (c) 2001-2022 Python Software Foundation and BINPython xingyujie(https://github.com/xingyujie/binpython).
@@ -349,3 +252,4 @@ def main():
349252
except KeyboardInterrupt:
350253
print("EXIT!")
351254
sys.exit()
255+

0 commit comments

Comments
 (0)