Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- import os
- try:
- import pyperclip
- except ModuleNotFoundError:
- os.system('pip install pyperclip')
- import pyperclip
- _root = frame1
- commandslist = [
- "CLEAR Syntax: (clear) Usage: clears the screen of all previous commands",
- "CLS Syntax: (cls) Usage: clears the screen of all previous commands\n"
- " (same as CLEAR)",
- "COLORS Syntax: (colors [color1] [color2]) Usage: changes the foreground and background color\n"
- " of the command interface",
- "HELP Syntax: (help) (help [command]) Usage: shows this menu, or gives information about\n"
- " a specific command",
- "PROMPT Syntax: (prompt [text]) Usage: changes the prompt text in the command line\n"
- " from '>' to a custom string",
- "RESET Syntax: (reset) Usage: clears the screen, shows startup text, and\n"
- " resets all settings to default",
- "RS Syntax: (rs) Usage: clears the screen, shows startup text, and\n"
- " resets all settings to default (same as RESET)",
- "START Syntax: (start [program name]) Usage: starts a program using Techpad SmartProgram,\n"
- " or creates window with given title if program\n"
- " does not exist",
- "VERSION Syntax: (version) Usage: displays the current version of TechOS"
- ]
- buusnumber = 0
- def show(out):
- global output
- output.insert('end', f'\n{out}')
- output.see('end')
- def command(e):
- global _input
- global show
- global output
- global prompt
- global buusnumber
- global commandslist
- global _root
- global tk
- cmd = _input.get()
- lcmd = cmd.lower()
- _input.delete(0, "end")
- params = cmd.split()
- lparams = lcmd.split()
- show(f"> {cmd}")
- if lparams[0] == 'start':
- if len(params) > 1:
- program = ' '.join([i for i in params[1:]])
- startprogram(program)
- else:
- show("Invalid syntax: Use (start [program name])")
- elif lcmd == "version":
- with open("T:/TechOS/Virtual/Info/Version.info", "r") as vf:
- version = f"TechOS version {vf.read()}"
- show(version)
- elif lcmd == "clear" or lcmd == "cls":
- output.delete(1.0, "end")
- elif lcmd == "reset" or lcmd == "rs":
- output.delete(1.0, "end")
- output.insert(1.0, "Commands v0.0\n")
- prompt.config(text='>')
- c1 = '#00afff'
- c2 = 'black'
- output.config(fg=c1, insertbackground=c1, selectbackground=c1, bg=c2, selectforeground=c2)
- prompt.config(bg=c2, fg=c1)
- _input.config(bg=c2, fg=c1, insertbackground=c1, selectbackground=c1, selectforeground=c2)
- elif lparams[0] == "prompt":
- if len(params) > 1:
- prompt.config(text=' '.join([i for i in params[1:]]))
- else:
- show("Invalid syntax: Use (prompt [text])")
- elif lparams[0] == "colors":
- if len(lparams) == 3:
- try:
- c1 = lparams[1]
- c2 = lparams[2]
- output.config(fg=c1, insertbackground=c1, selectbackground=c1, bg=c2, selectforeground=c2)
- prompt.config(bg=c2, fg=c1)
- _input.config(bg=c2, fg=c1, insertbackground=c1, selectbackground=c1, selectforeground=c2)
- except:
- show("Invalid colors: Use hexadecimal format or any valid color name.")
- else:
- show("Invalid syntax: Use (colors [color1] [color2])")
- elif lcmd == "help":
- show("Available commands:\n\n" + '\n\n'.join(i for i in commandslist))
- elif lparams[0] == "help":
- if len([i for i in commandslist if i.lower().startswith(lparams[1] + " ")]) == 0:
- show(f"That command doesn't exist: {lparams[1]}")
- else:
- show("\n" + ''.join([i for i in commandslist if i.lower().startswith(lparams[1] + ' ')]) + "\n")
- elif cmd == "BUUS":
- if buusnumber < 2:
- show(f"Invalid command: {params[0]}")
- buusnumber += 1
- elif buusnumber == 2:
- show("Seriously, we've told you already! BUUS is not a valid command!")
- buusnumber += 1
- elif buusnumber == 3:
- for child in _root.winfo_children():
- child.destroy()
- buuslabel = tk.Label(_root, bg='red', text="BUUS", anchor='center')
- buuslabel.image = tk.PhotoImage(file="T:/TechOS/Virtual/Images/BUUS.{SYSTEM}/BUUS.png")
- buuslabel.config(image=buuslabel.image)
- buuslabel.pack(expand=True, fill='both')
- from threading import Thread
- def buusthread():
- import time
- import random
- DISABLE_ANIMATIONS = open("T:/TechOS/Virtual/Settings/DISABLE_ANIMATIONS.set", "r").read()
- if DISABLE_ANIMATIONS == "False":
- while True:
- anchors = ["nw", "n", "ne", "e", "se", "s", "sw", "w", "center"]
- anchors.remove(buuslabel["anchor"])
- buuslabel.config(anchor=random.choice(anchors))
- buuslabel.config(bg='red')
- time.sleep(0.05)
- buuslabel.config(bg='orange')
- time.sleep(0.05)
- buuslabel.config(bg='yellow')
- time.sleep(0.05)
- buuslabel.config(bg='green')
- time.sleep(0.05)
- buuslabel.config(bg='blue')
- time.sleep(0.05)
- buuslabel.config(bg='purple')
- time.sleep(0.05)
- else:
- while True:
- anchors = ["nw", "n", "ne", "e", "se", "s", "sw", "w", "center"]
- anchors.remove(buuslabel["anchor"])
- buuslabel.config(anchor=random.choice(anchors))
- time.sleep(0.5)
- Thread(target=buusthread, daemon=True).start()
- else:
- show(f"Invalid command: {params[0]}")
- def copyselection(e):
- global output
- global pyperclip
- pyperclip.copy(output.selection_get())
- output = tk.Text(_root, bg='black', fg='#00afff', insertbackground='#00afff', insertofftime=0, bd=0, selectbackground='#00afff', selectforeground='black', font='consolas 12', height=1)
- output.bind('<Key>', 'break')
- output.bind('<Button-3>', copyselection)
- output.pack(expand=True, fill='both')
- output.insert(1.0, "Commands v0.0\n")
- prompt = tk.Label(_root, bg='black', fg='#00afff', justify='left', text='>', font='consolas 10', pady=1)
- prompt.pack(side='left', anchor='sw')
- _input = tk.Entry(_root, bg='black', fg='#00afff', justify='left', bd=0, insertbackground='#00afff', selectbackground='#00afff', selectforeground='black', font='consolas 12')
- _input.pack(side='left', expand=True, fill='x', anchor='se')
- _input.bind('<Return>', command)
- _input.focus()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement