Advertisement
Techpad

Commands 12

May 4th, 2021
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.37 KB | None | 0 0
  1. import tkinter as tk
  2. import os
  3. try:
  4. import pyperclip
  5. except ModuleNotFoundError:
  6. os.system('pip install pyperclip')
  7. import pyperclip
  8.  
  9. _root = frame1
  10.  
  11. commandslist = [
  12. "CLEAR Syntax: (clear) Usage: clears the screen of all previous commands",
  13. "CLS Syntax: (cls) Usage: clears the screen of all previous commands\n"
  14. " (same as CLEAR)",
  15. "COLORS Syntax: (colors [color1] [color2]) Usage: changes the foreground and background color\n"
  16. " of the command interface",
  17. "HELP Syntax: (help) (help [command]) Usage: shows this menu, or gives information about\n"
  18. " a specific command",
  19. "PROMPT Syntax: (prompt [text]) Usage: changes the prompt text in the command line\n"
  20. " from '>' to a custom string",
  21. "RESET Syntax: (reset) Usage: clears the screen, shows startup text, and\n"
  22. " resets all settings to default",
  23. "RS Syntax: (rs) Usage: clears the screen, shows startup text, and\n"
  24. " resets all settings to default (same as RESET)",
  25. "START Syntax: (start [program name]) Usage: starts a program using Techpad SmartProgram,\n"
  26. " or creates window with given title if program\n"
  27. " does not exist",
  28. "VERSION Syntax: (version) Usage: displays the current version of TechOS"
  29. ]
  30.  
  31. buusnumber = 0
  32.  
  33. def show(out):
  34. global output
  35. output.insert('end', f'\n{out}')
  36. output.see('end')
  37.  
  38. def command(e):
  39. global _input
  40. global show
  41. global output
  42. global prompt
  43. global buusnumber
  44. global commandslist
  45. global _root
  46. global tk
  47. cmd = _input.get()
  48. lcmd = cmd.lower()
  49. _input.delete(0, "end")
  50. params = cmd.split()
  51. lparams = lcmd.split()
  52. show(f"> {cmd}")
  53. if lparams[0] == 'start':
  54. if len(params) > 1:
  55. program = ' '.join([i for i in params[1:]])
  56. startprogram(program)
  57. else:
  58. show("Invalid syntax: Use (start [program name])")
  59. elif lcmd == "version":
  60. with open("T:/TechOS/Virtual/Info/Version.info", "r") as vf:
  61. version = f"TechOS version {vf.read()}"
  62. show(version)
  63. elif lcmd == "clear" or lcmd == "cls":
  64. output.delete(1.0, "end")
  65. elif lcmd == "reset" or lcmd == "rs":
  66. output.delete(1.0, "end")
  67. output.insert(1.0, "Commands v0.0\n")
  68. prompt.config(text='>')
  69. c1 = '#00afff'
  70. c2 = 'black'
  71. output.config(fg=c1, insertbackground=c1, selectbackground=c1, bg=c2, selectforeground=c2)
  72. prompt.config(bg=c2, fg=c1)
  73. _input.config(bg=c2, fg=c1, insertbackground=c1, selectbackground=c1, selectforeground=c2)
  74. elif lparams[0] == "prompt":
  75. if len(params) > 1:
  76. prompt.config(text=' '.join([i for i in params[1:]]))
  77. else:
  78. show("Invalid syntax: Use (prompt [text])")
  79. elif lparams[0] == "colors":
  80. if len(lparams) == 3:
  81. try:
  82. c1 = lparams[1]
  83. c2 = lparams[2]
  84. output.config(fg=c1, insertbackground=c1, selectbackground=c1, bg=c2, selectforeground=c2)
  85. prompt.config(bg=c2, fg=c1)
  86. _input.config(bg=c2, fg=c1, insertbackground=c1, selectbackground=c1, selectforeground=c2)
  87. except:
  88. show("Invalid colors: Use hexadecimal format or any valid color name.")
  89. else:
  90. show("Invalid syntax: Use (colors [color1] [color2])")
  91. elif lcmd == "help":
  92. show("Available commands:\n\n" + '\n\n'.join(i for i in commandslist))
  93. elif lparams[0] == "help":
  94. if len([i for i in commandslist if i.lower().startswith(lparams[1] + " ")]) == 0:
  95. show(f"That command doesn't exist: {lparams[1]}")
  96. else:
  97. show("\n" + ''.join([i for i in commandslist if i.lower().startswith(lparams[1] + ' ')]) + "\n")
  98. elif cmd == "BUUS":
  99. if buusnumber < 2:
  100. show(f"Invalid command: {params[0]}")
  101. buusnumber += 1
  102. elif buusnumber == 2:
  103. show("Seriously, we've told you already! BUUS is not a valid command!")
  104. buusnumber += 1
  105. elif buusnumber == 3:
  106. for child in _root.winfo_children():
  107. child.destroy()
  108. buuslabel = tk.Label(_root, bg='red', text="BUUS", anchor='center')
  109. buuslabel.image = tk.PhotoImage(file="T:/TechOS/Virtual/Images/BUUS.{SYSTEM}/BUUS.png")
  110. buuslabel.config(image=buuslabel.image)
  111. buuslabel.pack(expand=True, fill='both')
  112. from threading import Thread
  113. def buusthread():
  114. import time
  115. import random
  116. DISABLE_ANIMATIONS = open("T:/TechOS/Virtual/Settings/DISABLE_ANIMATIONS.set", "r").read()
  117. if DISABLE_ANIMATIONS == "False":
  118. while True:
  119. anchors = ["nw", "n", "ne", "e", "se", "s", "sw", "w", "center"]
  120. anchors.remove(buuslabel["anchor"])
  121. buuslabel.config(anchor=random.choice(anchors))
  122. buuslabel.config(bg='red')
  123. time.sleep(0.05)
  124. buuslabel.config(bg='orange')
  125. time.sleep(0.05)
  126. buuslabel.config(bg='yellow')
  127. time.sleep(0.05)
  128. buuslabel.config(bg='green')
  129. time.sleep(0.05)
  130. buuslabel.config(bg='blue')
  131. time.sleep(0.05)
  132. buuslabel.config(bg='purple')
  133. time.sleep(0.05)
  134. else:
  135. while True:
  136. anchors = ["nw", "n", "ne", "e", "se", "s", "sw", "w", "center"]
  137. anchors.remove(buuslabel["anchor"])
  138. buuslabel.config(anchor=random.choice(anchors))
  139. time.sleep(0.5)
  140. Thread(target=buusthread, daemon=True).start()
  141. else:
  142. show(f"Invalid command: {params[0]}")
  143.  
  144. def copyselection(e):
  145. global output
  146. global pyperclip
  147. pyperclip.copy(output.selection_get())
  148.  
  149. output = tk.Text(_root, bg='black', fg='#00afff', insertbackground='#00afff', insertofftime=0, bd=0, selectbackground='#00afff', selectforeground='black', font='consolas 12', height=1)
  150. output.bind('<Key>', 'break')
  151. output.bind('<Button-3>', copyselection)
  152. output.pack(expand=True, fill='both')
  153. output.insert(1.0, "Commands v0.0\n")
  154. prompt = tk.Label(_root, bg='black', fg='#00afff', justify='left', text='>', font='consolas 10', pady=1)
  155. prompt.pack(side='left', anchor='sw')
  156. _input = tk.Entry(_root, bg='black', fg='#00afff', justify='left', bd=0, insertbackground='#00afff', selectbackground='#00afff', selectforeground='black', font='consolas 12')
  157. _input.pack(side='left', expand=True, fill='x', anchor='se')
  158. _input.bind('<Return>', command)
  159. _input.focus()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement