Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- import sys
- class ModifiedPrint:
- def __init__(self):
- self.old = sys.stdout
- def write(self, text):
- sys.stdout = self.old
- print(text)
- sys.stdout = self
- def flush(self):
- self.old.flush()
- sys.stdout = ModifiedPrint()
- class Gui:
- def __init__(self, root):
- self.Space = 0
- self.root = root
- root.geometry('700x400')
- root.title('PyTerminal')
- root.configure(background='black')
- root.option_add('*font', 'calibri 12')
- ent = self._in(0, 0, 30, 2)
- ent.bind("<Return>", (lambda event: self.processcmd(ent)))
- root.mainloop()
- class ModifiedPrint:
- def __init__(self):
- self.old = sys.stdout
- def write(self, text, banana):
- sys.stdout = self.old
- print(banana, text)
- sys.stdout = self
- def flush(self):
- self.old.flush()
- def processcmd(self, cmd):
- self.Space += 60
- cmd.unbind('<Return>')
- return self._out(0, self.Space - 30, cmd.get())
- def _in(self, sx, sy, cx, cy):
- Label(self.root, text=f'>>>', fg='white', bg='black').place(x=sx, y=sy)
- cmd = Entry(self.root, bg='black', fg='white', borderwidth=0, width=500, insertbackground='white')
- cmd.place(x=cx, y=cy)
- return cmd
- def _out(self, x, y, cmd):
- To_Deduct = 0
- try:
- Label(self.root, text=eval(cmd), fg='white', bg='black').place(x=x, y=y)
- except:
- try:
- exec(cmd, globals())
- To_Deduct = 30
- except Exception as e:
- Label(self.root, text=e, fg='white', bg='black').place(x=x, y=y-To_Deduct)
- entry = self._in(0, self.Space-To_Deduct, 30, (self.Space + 2)-To_Deduct)
- entry.bind("<Return>", (lambda event: self.processcmd(entry)))
- if To_Deduct:
- self.Space -= 30
- return 'OK'
- Gui(Tk())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement