02-21-2010, 05:37 PM
Well this is just a little program i whipped up. Really I am just testing out the text widget in Tkinter so I decided to make this:
Basically you just type a system command and it executes it, clear button is self explanatory. I realize this is impractical and you could simply use a terminal I was just testing out some cool feature's like awesome green text on a black background . I may add more features to make it practical or a may even make a text editor!
Code:
from Tkinter import *
import os
class Commandx(Frame):
def __init__(self):
global cmd, result
top = Tk()
top.title('pyCommand v1.0')
Frame.__init__(self)
result = Text(self, bg='#000000', fg='#0AC92B')
result.pack(side=BOTTOM)
go = Button(self, text='Execute', command=self.onclick).pack(side=RIGHT)
c = Button(self, text='Clear', command=self.clear).pack(side=RIGHT)
Label(self, text='Please enter your command:').pack(side=LEFT)
cmd = Entry(self)
cmd.pack()
def onclick(self):
global cmd, result
command = cmd.get()
status = os.popen(command).read()
if status == '':
result.delete(END)
result.insert(INSERT, 'You have entered an incorrect system command, try "help"')
else:
result.delete(END)
result.insert(INSERT, status)
def clear(self):
global cmd, result
cmd.delete(0, END)
result.delete(1.0, END)
if __name__ == '__main__' :
window = Commandx()
window.pack()
window.mainloop()
Basically you just type a system command and it executes it, clear button is self explanatory. I realize this is impractical and you could simply use a terminal I was just testing out some cool feature's like awesome green text on a black background . I may add more features to make it practical or a may even make a text editor!