I am trying to make a random shell in python... But the problem is i get an error with my code i have tried to remove __commands__[0]
from my code but then nothing comes.
My error:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:\Users\User1\Downloads\Stuff\untitled2.py", line 14, in commands
if text in __commands__[0]:
TypeError: 'set' object is not subscriptable
my code:
from tkinter import *
def tk_shell(Name=None):
def commands():
__commands__ = {'-v',
'-e',
'+a',
'DATA'}
text = (cmd.get("1.0","end"))
if text in __commands__[0]:
print("version 1.11")
else:
print("NOPE")
tk = Tk()
tk.resizable(width=False, height=False)
tk.geometry('700x490')
tk.title('Server Prompt-'+str(Name))
#main
cmd = Text(tk,bg='black',fg='#00FF00')
cmd.config(height=600,width=480)
cmd.pack()
r_button = Button(tk,width=12,height=2,text='Run',bg='#00FF00',command=commands)
r_button.place(x=610,y=0)
tk.mainloop()
tk_shell()