Skip to content

Commit 7685cc0

Browse files
committed
0.24 fix many bugs
0.24 fix many bugs
1 parent d0115b5 commit 7685cc0

File tree

1 file changed

+102
-4
lines changed

1 file changed

+102
-4
lines changed

binpythonfull.py

Lines changed: 102 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def binpython_shell():
178178
about = "BINPython " + ver + "-" + releases_ver + " By:XINGYUJIE[https://github.com/xingyujie/binpython] AGPL-3.0 LICENSE Release"
179179
#getopt
180180
try:
181-
opts,args = getopt.getopt(sys.argv[1:],'-h-f:-s:-g-i-p-v',['help','file=','server=','gui','idle','plus','version'])
181+
opts,args = getopt.getopt(sys.argv[1:],'-h-f:-s:-g-i-p-e-v',['help','file=','server=','gui','idle','plus','example','version'])
182182
except:
183183
print("Please check help:")
184184
help()
@@ -203,7 +203,7 @@ def binpython_shell():
203203
sys.exit()
204204
if opt_name in ('-s','--server'):
205205
server_port = opt_value
206-
print("""
206+
exec("""
207207
PORT = """ + server_port + """
208208
209209
Handler = http.server.SimpleHTTPRequestHandler
@@ -288,8 +288,106 @@ def main():
288288
toast("Successfully saved")
289289
put_success("The save is successful, and the code is saved to binpython file path" + " \nThe file name is " + '"' + savecodefilename + '"')
290290
if __name__ == '__main__':
291-
start_server(main, debug=True, host='0.0.0.0', port= serverport)
291+
start_server(main, debug=True, port= serverport)
292292
pywebio.session.hold()
293-
293+
if opt_name in ('-e','--example'):
294+
print("Welcome to BINPython example")
295+
print("""
296+
List of examples:
297+
1.Turtle
298+
2.Tkinter GUI
299+
3.Tornado WEB Server
300+
4.PywebIO WEB
301+
5.Hello World
302+
6.HTTP requests
303+
7.BINPython() function example
304+
305+
""")
306+
examplenum = input("Please enter the option you want to enter(like 1):")
307+
if examplenum == "1":
308+
def exampleturtle():
309+
import turtle
310+
import time
311+
turtle.speed(10)
312+
turtle.color("red", "yellow")
313+
turtle.begin_fill()
314+
for _ in range(50):
315+
turtle.forward(200)
316+
turtle.left(170)
317+
turtle.end_fill()
318+
turtle.done()
319+
exampleturtle()
320+
sys.exit()
321+
if examplenum == "2":
322+
def exampletkinter():
323+
import tkinter as tk
324+
app = tk.Tk()
325+
app.title('BINPython tkinter example')
326+
theLabel = tk.Label(app, text='Welcome to BINPython!!!')
327+
theLabel.pack()
328+
app.mainloop()
329+
exampletkinter()
330+
sys.exit()
331+
if examplenum == "3":
332+
def exampletornado():
333+
import asyncio
334+
import tornado.web
335+
class MainHandler(tornado.web.RequestHandler):
336+
def get(self):
337+
self.write("Hello, BINPython!")
338+
def make_app():
339+
return tornado.web.Application([
340+
(r"/", MainHandler),
341+
])
342+
async def main():
343+
app = make_app()
344+
app.listen(8080)
345+
await asyncio.Event().wait()
346+
if __name__ == "__main__":
347+
asyncio.run(main())
348+
exit()
349+
print("Server Started listen on port:8080(http://ip:8080)")
350+
exampletornado()
351+
sys.exit()
352+
if examplenum == "4":
353+
import pywebio.input
354+
from pywebio.input import *
355+
from pywebio.output import *
356+
from pywebio import *
357+
from pywebio.session import *
358+
print("Listen on port 9000(http://ip:9000)")
359+
def examplepywebio():
360+
def main():
361+
set_env(title="Welcome to BINPython", auto_scroll_bottom=True)
362+
put_html("<h1>Welcome to BINPython</h1>")
363+
if __name__ == '__main__':
364+
start_server(main, debug=True, host='0.0.0.0', port='9000')
365+
pywebio.session.hold()
366+
examplepywebio()
367+
sys.exit()
368+
if examplenum == "5":
369+
setwindowtitle("Hi, Welcome to BINPython")
370+
name = input("hi...What's your name:")
371+
print("hi," + name)
372+
sys.exit()
373+
if examplenum == "6":
374+
import requests
375+
def examplerequests():
376+
print(requests.get("http://google.com"))
377+
examplerequests()
378+
sys.exit()
379+
if examplenum == "7":
380+
print("BINPython() function example")
381+
import time
382+
binpython_ver()
383+
binpython_buildversion()
384+
binpython_libs_warning()
385+
binpython_build_importlibs()
386+
setwindowtitle("Title name(str)")
387+
binpythonallconf()
388+
time.sleep(5)
389+
#main shell
390+
binpython_shell()
391+
sys.exit()
294392
#go main shell
295393
binpython_shell()

0 commit comments

Comments
 (0)