1.3.0a
Completely rewritten the terminal and some minor bug fixes
This commit is contained in:
parent
98085e84a4
commit
6667185945
24 changed files with 1058 additions and 45 deletions
73
Programs/PyIDE.py
Normal file
73
Programs/PyIDE.py
Normal file
|
@ -0,0 +1,73 @@
|
|||
from tkinter import *
|
||||
import sys
|
||||
from tkinter.filedialog import askopenfilename, asksaveasfilename
|
||||
|
||||
|
||||
def PyIDE():
|
||||
def openFile():
|
||||
file = askopenfilename(defaultextension=".py",
|
||||
filetypes=[("Python .py", ".py"), ("Python .pyw", ".pyw")])
|
||||
|
||||
if file != "":
|
||||
with open(file, "r") as openfile:
|
||||
input.delete(0.0, END)
|
||||
input.insert(0.0, openfile.read())
|
||||
|
||||
def save():
|
||||
file = asksaveasfilename(defaultextension=".py",
|
||||
filetypes=[("Python .py", ".py"), ("Python .pyw", ".pyw")])
|
||||
|
||||
if file != "":
|
||||
with open(file, "w") as saveFile:
|
||||
saveFile.write(input.get(0.0, END))
|
||||
|
||||
class TextRedirector(object):
|
||||
def __init__(self, widget, tag="stdout"):
|
||||
self.widget = widget
|
||||
self.tag = tag
|
||||
|
||||
def write(self, str):
|
||||
output.delete(0.0, END)
|
||||
self.widget.configure(state="normal")
|
||||
self.widget.insert("end", str, (self.tag,))
|
||||
self.widget.configure(state="disabled")
|
||||
self.widget.see(END)
|
||||
|
||||
def run():
|
||||
exec(input.get(0.0, END))
|
||||
|
||||
rootInterpreter = Tk()
|
||||
rootInterpreter.title("Terminal")
|
||||
rootInterpreter.geometry("200x200")
|
||||
rootInterpreter.minsize(200, 200)
|
||||
|
||||
menu = Menu(rootInterpreter)
|
||||
rootInterpreter.config(menu=menu)
|
||||
filemenu = Menu(menu)
|
||||
menu.add_cascade(label="File", menu=filemenu)
|
||||
filemenu.add_command(label="New")
|
||||
filemenu.add_command(label="Open", command=openFile)
|
||||
filemenu.add_command(label="Save", command=save)
|
||||
filemenu.add_command(label="Save As", state=DISABLED)
|
||||
filemenu.add_separator()
|
||||
filemenu.add_command(label="Exit", command=sys.exit)
|
||||
|
||||
output = Text(rootInterpreter, state=DISABLED, wrap="word")
|
||||
output.configure(state=NORMAL)
|
||||
output.configure(state=DISABLED)
|
||||
output.pack(side=TOP, expand=YES, fill=BOTH)
|
||||
|
||||
input = Text(rootInterpreter)
|
||||
input.focus()
|
||||
input.pack(side=BOTTOM, expand=YES, fill=BOTH)
|
||||
|
||||
sys.stderr = TextRedirector(output, "stderr")
|
||||
|
||||
sys.stdout = TextRedirector(output, "stdout")
|
||||
|
||||
rootInterpreter.mainloop()
|
||||
|
||||
# rootInterpreter.protocol("WM_DELETE_WINDOW", closeApp)
|
||||
|
||||
|
||||
PyIDE()
|
BIN
Programs/__pycache__/imageViewer.cpython-35.pyc
Normal file
BIN
Programs/__pycache__/imageViewer.cpython-35.pyc
Normal file
Binary file not shown.
BIN
Programs/__pycache__/info.cpython-35.pyc
Normal file
BIN
Programs/__pycache__/info.cpython-35.pyc
Normal file
Binary file not shown.
BIN
Programs/__pycache__/jpad.cpython-35.pyc
Normal file
BIN
Programs/__pycache__/jpad.cpython-35.pyc
Normal file
Binary file not shown.
BIN
Programs/__pycache__/minesweeper.cpython-35.pyc
Normal file
BIN
Programs/__pycache__/minesweeper.cpython-35.pyc
Normal file
Binary file not shown.
BIN
Programs/__pycache__/terminal.cpython-35.pyc
Normal file
BIN
Programs/__pycache__/terminal.cpython-35.pyc
Normal file
Binary file not shown.
|
@ -2,7 +2,7 @@ import logging
|
|||
from tkinter import *
|
||||
from tkinter.filedialog import askopenfilename, asksaveasfilename
|
||||
|
||||
jpadLog = logging.getLogger("jpad.py")
|
||||
jpadLog = logging.getLogger(__name__)
|
||||
|
||||
jpadLog.debug("Atempting to read settings file")
|
||||
try:
|
||||
|
@ -15,14 +15,14 @@ except Exception as e:
|
|||
|
||||
class jpadEditor:
|
||||
def minimize(self):
|
||||
jpadLog.debug("Running minimize")
|
||||
jpadLog.debug("Running "+jpadEditor.minimize.__name__)
|
||||
try:
|
||||
self.appFocus = 0
|
||||
except Exception as e:
|
||||
jpadLog.error(str(e))
|
||||
|
||||
def closeApp(self):
|
||||
jpadLog.debug("Running closeApp")
|
||||
jpadLog.debug("Running "+jpadEditor.closeApp.__name__)
|
||||
try:
|
||||
# self.appIcon.destroy()
|
||||
self.window.destroy()
|
||||
|
@ -30,7 +30,7 @@ class jpadEditor:
|
|||
jpadLog.error(str(e))
|
||||
|
||||
def focusApp(self):
|
||||
jpadLog.debug("Running focusApp")
|
||||
jpadLog.debug("Running "+jpadEditor.focusApp.__name__)
|
||||
try:
|
||||
if self.appFocus == 0:
|
||||
self.window.focus_force()
|
||||
|
@ -43,7 +43,7 @@ class jpadEditor:
|
|||
jpadLog.error(str(e))
|
||||
|
||||
def createMenu(self):
|
||||
jpadLog.debug("Running createMenu")
|
||||
jpadLog.debug("Running "+jpadEditor.createMenu.__name__)
|
||||
try:
|
||||
self.menu = Menu(self.window)
|
||||
self.window.config(menu=self.menu)
|
||||
|
@ -63,7 +63,7 @@ class jpadEditor:
|
|||
jpadLog.error(str(e))
|
||||
|
||||
def new(self):
|
||||
jpadLog.debug("Running new")
|
||||
jpadLog.debug("Running "+jpadEditor.new.__name__)
|
||||
try:
|
||||
self.window.title("Jpad Text Editor" + " File: New File")
|
||||
self.textPad.delete(0.0, END)
|
||||
|
@ -71,14 +71,14 @@ class jpadEditor:
|
|||
jpadLog.error(str(e))
|
||||
|
||||
def exit_command(self):
|
||||
jpadLog.debug("Running exit_command")
|
||||
jpadLog.debug("Running "+jpadEditor.exit_command.__name__)
|
||||
try:
|
||||
self.closeApp()
|
||||
except Exception as e:
|
||||
jpadLog.error(str(e))
|
||||
|
||||
def saveAs_command(self):
|
||||
jpadLog.debug("Running saveAs_command")
|
||||
jpadLog.debug("Running "+jpadEditor.saveAs_command.__name__)
|
||||
try:
|
||||
self.jpadFile = asksaveasfilename(defaultextension=".txt",
|
||||
filetypes=[("Text Files", ".txt"), ("Python .py", ".py"),
|
||||
|
@ -95,7 +95,7 @@ class jpadEditor:
|
|||
jpadLog.error(str(e))
|
||||
|
||||
def save_command(self):
|
||||
jpadLog.debug("Running save_command")
|
||||
jpadLog.debug("Running "+jpadEditor.save_command.__name__)
|
||||
try:
|
||||
self.jpadFile = open(str(self.jpadFile), "w")
|
||||
if self.jpadFile != None:
|
||||
|
@ -109,7 +109,7 @@ class jpadEditor:
|
|||
jpadLog.error(str(e))
|
||||
|
||||
def open_command(self):
|
||||
jpadLog.debug("Running open_command")
|
||||
jpadLog.debug("Running "+jpadEditor.open_command.__name__)
|
||||
try:
|
||||
self.jpadFile = askopenfilename(defaultextension=".txt",
|
||||
filetypes=[("Text Files", ".txt"), ("Python .py", ".py"),
|
||||
|
|
110
Programs/terminal.py
Normal file
110
Programs/terminal.py
Normal file
|
@ -0,0 +1,110 @@
|
|||
__author__ = "Jordonbc"
|
||||
|
||||
__version__ = "1.1.0"
|
||||
from tkinter import *
|
||||
|
||||
default_stdin = sys.stdin
|
||||
default_stdout = sys.stdout
|
||||
default_stderr = sys.stderr
|
||||
|
||||
disabledCommands = ["help()", "exit()", "sys.exit()", "quit()"]
|
||||
availableCommands = ["set", "bg", "fg", "clear"]
|
||||
|
||||
|
||||
def commands():
|
||||
print("Available Commands:")
|
||||
print("set bg [HEX COLOUR]")
|
||||
print("set fg [HEX COLOUR]")
|
||||
print("clear")
|
||||
print("run [file]")
|
||||
|
||||
|
||||
class terminal:
|
||||
class TextRedirector(object):
|
||||
def __init__(self, widget, tag="stdout"):
|
||||
self.widget = widget
|
||||
self.tag = tag
|
||||
|
||||
def write(self, str):
|
||||
self.widget.configure(state="normal")
|
||||
self.widget.insert("end", str, (self.tag,))
|
||||
self.widget.configure(state="disabled")
|
||||
self.widget.see(END)
|
||||
|
||||
def __init__(self, master, command=None):
|
||||
def run(command=None):
|
||||
if input.get() != "":
|
||||
print(input.get())
|
||||
if input.get().startswith("set "):
|
||||
if input.get().startswith("set bg "):
|
||||
try:
|
||||
output.configure(bg=str(input.get()).replace("set bg ", "").replace("\n", ""))
|
||||
input.configure(bg=str(input.get()).replace("set bg ", "").replace("\n", ""))
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
elif input.get().startswith("set fg "):
|
||||
try:
|
||||
if str(input.get()).replace("set fg ", "").replace("\n", "").lower() == "#ffffff":
|
||||
output.configure(insertbackground="#000000")
|
||||
input.configure(insertbackground="#000000")
|
||||
elif str(input.get()).replace("set fg ", "").replace("\n", "").lower() == "#000000":
|
||||
output.configure(insertbackground="#ffffff")
|
||||
input.configure(insertbackground="#ffffff")
|
||||
output.configure(fg=str(input.get()).replace("set fg ", "").replace("\n", ""))
|
||||
input.configure(fg=str(input.get()).replace("set fg ", "").replace("\n", ""))
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
if input.get() == "clear":
|
||||
print("\n" * 25)
|
||||
elif input.get() in disabledCommands:
|
||||
input.delete(0, END)
|
||||
print("Command is disabled.")
|
||||
|
||||
elif input.get().startswith("run "):
|
||||
try:
|
||||
exec(open(str(input.get()).replace("run ", ""), "r").read())
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
else:
|
||||
try:
|
||||
exec(input.get())
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
input.delete(0, END)
|
||||
|
||||
def closeApp():
|
||||
sys.stdin = default_stdin
|
||||
sys.stdout = default_stdout
|
||||
sys.stderr = default_stderr
|
||||
rootTerminal.destroy()
|
||||
|
||||
rootTerminal = Toplevel(master)
|
||||
rootTerminal.title("Terminal")
|
||||
rootTerminal.geometry("400x300")
|
||||
rootTerminal.minsize(200, 200)
|
||||
rootTerminal.configure(bg="#000000")
|
||||
|
||||
output = Text(rootTerminal, state=DISABLED, height=10, bg="#000000", fg="#FFFFFF", wrap="word", relief=FLAT)
|
||||
output.configure(state=NORMAL)
|
||||
output.insert(END, "JDE Terminal V " + __version__ + "\n")
|
||||
output.insert(END, "Type commands() to see available commands\n")
|
||||
output.configure(state=DISABLED)
|
||||
output.pack(side=TOP, expand=YES, fill=BOTH)
|
||||
|
||||
input = Entry(rootTerminal, width=400, bg="#000000", fg="#FFFFFF", relief=FLAT)
|
||||
input.focus()
|
||||
input.bind("<Return>", run)
|
||||
input.pack(side=BOTTOM)
|
||||
|
||||
output.configure(insertbackground="#ffffff")
|
||||
input.configure(insertbackground="#ffffff")
|
||||
|
||||
sys.stdin = self.TextRedirector(output, "stdin")
|
||||
sys.stderr = self.TextRedirector(output)
|
||||
sys.stdout = self.TextRedirector(output)
|
||||
|
||||
rootTerminal.protocol("WM_DELETE_WINDOW", closeApp)
|
||||
rootTerminal.mainloop()
|
9
Programs/webEdit/Templates/HTML 5/Default.HET
Normal file
9
Programs/webEdit/Templates/HTML 5/Default.HET
Normal file
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>NEW WEBSITE</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Your Website Text</p>
|
||||
</body>
|
||||
</html>
|
BIN
Programs/webEdit/__pycache__/htmlEdit.cpython-35.pyc
Normal file
BIN
Programs/webEdit/__pycache__/htmlEdit.cpython-35.pyc
Normal file
Binary file not shown.
175
Programs/webEdit/htmlEdit.py
Normal file
175
Programs/webEdit/htmlEdit.py
Normal file
|
@ -0,0 +1,175 @@
|
|||
__author__ = "Jordonbc"
|
||||
import os
|
||||
from tkinter import *
|
||||
from tkinter.filedialog import *
|
||||
from tkinter.messagebox import *
|
||||
from tkinter.simpledialog import askstring
|
||||
import webbrowser
|
||||
|
||||
|
||||
|
||||
settings = {}
|
||||
|
||||
try:
|
||||
exec(open("Programs/webEdit/settings", "r").read(), settings)
|
||||
except:
|
||||
print("Settings Currupted!, Resetting")
|
||||
with open("Programs/webEdit/settings", "w") as file:
|
||||
file.write("""fgColour = '#000000'
|
||||
bgColour = '#FFFFFF'
|
||||
cursor = '#FFFFFF'""")
|
||||
|
||||
class webEdit:
|
||||
def open(self):
|
||||
self.saveLocation = askopenfilename(filetypes=[("HTML", "html"), ("All Files", "*")])
|
||||
if self.saveLocation != "":
|
||||
self.textbox.delete(0.0, END)
|
||||
self.textbox.insert(0.0, open(self.saveLocation, "r").read().strip())
|
||||
self.root.title("WebEdit - " + str(self.saveLocation))
|
||||
|
||||
def save(self):
|
||||
self.saveLocation = asksaveasfilename(filetypes=[("HTML", "html"), ("All Files", "*")])
|
||||
if self.saveLocation != "":
|
||||
file = open(self.saveLocation, "w")
|
||||
file.write(str(self.textbox.get(0.0, END)).strip())
|
||||
file.close()
|
||||
self.root.title("WebEdit - " + str(self.saveLocation))
|
||||
|
||||
def new(self):
|
||||
if self.textbox.get(0.0, END) == "\n":
|
||||
# template = askopenfile(defaultextension="HET", filetypes=[("Template", "HET"), ("All Files", "*")])
|
||||
template = open("Programs/webEdit/Templates/HTML 5/Default.HET", "r")
|
||||
if template != None:
|
||||
template = template.read()
|
||||
self.textbox.delete(0.0, END)
|
||||
self.textbox.insert(0.0, template)
|
||||
else:
|
||||
if askyesno(title="Sure?", message="Are you sure?"):
|
||||
# template = askopenfile(defaultextension="HET", filetypes=[("Template", "HET"), ("All Files", "*")])
|
||||
template = open("Programs/webEdit/Templates/HTML 5/Default.HET", "r")
|
||||
if template != None:
|
||||
template = template.read()
|
||||
self.textbox.delete(0.0, END)
|
||||
self.textbox.insert(0.0, template)
|
||||
self.root.title("WebEdit - New File")
|
||||
|
||||
def createMenu(self):
|
||||
menu = Menu(self.root)
|
||||
menu.configure(bg=settings["bgColour"], fg=settings["fgColour"])
|
||||
fileMenu = Menu(menu)
|
||||
fileMenu.configure(bg=settings["bgColour"], fg=settings["fgColour"])
|
||||
viewMenu = Menu(menu)
|
||||
viewMenu.configure(bg=settings["bgColour"], fg=settings["fgColour"])
|
||||
snippetsMenu = Menu(menu)
|
||||
snippetsMenu.configure(bg=settings["bgColour"], fg=settings["fgColour"])
|
||||
headlineMenu = Menu(menu)
|
||||
headlineMenu.configure(bg=settings["bgColour"], fg=settings["fgColour"])
|
||||
self.root.configure(menu=menu)
|
||||
menu.add_cascade(label="File", menu=fileMenu)
|
||||
menu.add_cascade(label="Code Snippets", menu=snippetsMenu)
|
||||
|
||||
def paragraph():
|
||||
self.textbox.insert(INSERT, "<p></p>")
|
||||
|
||||
def div():
|
||||
self.textbox.insert(INSERT, "<div></div>")
|
||||
|
||||
def br():
|
||||
self.textbox.insert(INSERT, "<br>")
|
||||
|
||||
def headline_1():
|
||||
self.textbox.insert(INSERT, "<h1></h1>")
|
||||
|
||||
def headline_2():
|
||||
self.textbox.insert(INSERT, "<h2></h2>")
|
||||
|
||||
def headline_3():
|
||||
self.textbox.insert(INSERT, "<h3></h3>")
|
||||
|
||||
def headline_4():
|
||||
self.textbox.insert(INSERT, "<h4></h4>")
|
||||
|
||||
def headline_5():
|
||||
self.textbox.insert(INSERT, "<h5></h5>")
|
||||
|
||||
def headline_6():
|
||||
self.textbox.insert(INSERT, "<h6></h6>")
|
||||
|
||||
def insertImage():
|
||||
location = askstring(title="Image", prompt="Image")
|
||||
self.textbox.insert(INSERT, "<img src='" + location + "'/>")
|
||||
|
||||
def Link():
|
||||
address = askstring(title="Link", prompt="Link Address")
|
||||
text = askstring(title="Link", prompt="Text")
|
||||
self.textbox.insert(INSERT, "<a href='" + address + "'>"+text+"</a>")
|
||||
|
||||
def openSettings():
|
||||
self.textbox.delete(0.0, END)
|
||||
self.textbox.insert(0.0, open("settings").read())
|
||||
|
||||
def view_default():
|
||||
if self.saveLocation != "":
|
||||
webbrowser.open_new(self.saveLocation)
|
||||
|
||||
snippetsMenu.add_command(label="Paragraph", command=paragraph)
|
||||
snippetsMenu.add_command(label="Division", command=div)
|
||||
snippetsMenu.add_command(label="Image", command=insertImage)
|
||||
snippetsMenu.add_command(label="Link", command=Link)
|
||||
snippetsMenu.add_command(label="Break", command=br)
|
||||
snippetsMenu.add_cascade(label="Headline", menu=headlineMenu)
|
||||
headlineMenu.add_command(label="1", command=headline_1)
|
||||
headlineMenu.add_command(label="2", command=headline_2)
|
||||
headlineMenu.add_command(label="3", command=headline_3)
|
||||
headlineMenu.add_command(label="4", command=headline_4)
|
||||
headlineMenu.add_command(label="5", command=headline_5)
|
||||
headlineMenu.add_command(label="6", command=headline_6)
|
||||
|
||||
fileMenu.add_command(label="New", command=self.new)
|
||||
fileMenu.add_command(label="Save", command=self.save)
|
||||
fileMenu.add_command(label="Open", command=self.open)
|
||||
fileMenu.add_separator()
|
||||
fileMenu.add_command(label="Settings", command=openSettings)
|
||||
fileMenu.add_separator()
|
||||
fileMenu.add_command(label="Exit", command=quit)
|
||||
|
||||
menu.add_command(label="View in browser", command=view_default)
|
||||
|
||||
# menu.add_cascade(label="View", menu=viewMenu)
|
||||
|
||||
# viewMenu.add_command(label="Default program", command=view_default)
|
||||
|
||||
def createWidgets(self):
|
||||
self.scrollbar = Scrollbar(self.root)
|
||||
self.scrollbar.pack(side=RIGHT, fill=Y)
|
||||
|
||||
self.textbox = Text(self.root)
|
||||
self.textbox.pack(side=TOP, expand=YES, fill=BOTH)
|
||||
self.textbox.configure(bg=settings["bgColour"], fg=settings["fgColour"], insertbackground=settings["cursor"],
|
||||
yscrollcommand=self.scrollbar.set)
|
||||
|
||||
self.scrollbar.config(command=self.textbox.yview)
|
||||
|
||||
def saveShortcut(event):
|
||||
self.save()
|
||||
|
||||
def openShortcut(event):
|
||||
self.open()
|
||||
|
||||
def newShortcut(event):
|
||||
self.new()
|
||||
|
||||
self.textbox.bind("<Control-s>", saveShortcut)
|
||||
self.textbox.bind("<Control-o>", openShortcut)
|
||||
self.textbox.bind("<Control-n>", newShortcut)
|
||||
|
||||
def __init__(self, master):
|
||||
self.saveLocation = ""
|
||||
self.root = Toplevel(master)
|
||||
self.root.title("WebEdit")
|
||||
self.root.configure(bg=settings["bgColour"])
|
||||
self.createWidgets()
|
||||
self.createMenu()
|
||||
self.new()
|
||||
|
||||
self.root.mainloop()
|
3
Programs/webEdit/settings
Normal file
3
Programs/webEdit/settings
Normal file
|
@ -0,0 +1,3 @@
|
|||
fgColour = '#FFFFFF'
|
||||
bgColour = '#111111'
|
||||
cursor = '#FFFFFF'
|
Reference in a new issue