Support Forums

Full Version: pyCommand
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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:
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 Smile. I may add more features to make it practical or a may even make a text editor! Blackhat
It'd be nice if you could post some print screens of the program.
Sure,
Although I am running it on linux it will work on all platforms.
I've always been interested in learning how to use Tkinter... I guess I need to study the module. Smile
(02-28-2010, 10:16 AM)Μαύρο Wrote: [ -> ]I've always been interested in learning how to use Tkinter... I guess I need to study the module. Smile

I would personally suggest wxpython, also uber1337 I would reccomend popen'ing in a seperate thread.
Looks really good. It inspires me to learn more python.
nice share dude! thanks Smile
(04-05-2010, 06:19 PM)Fallen Wrote: [ -> ]I would personally suggest wxpython, also uber1337 I would reccomend popen'ing in a seperate thread.
Hah yeah I was unfamiliar with threads when I wrote this, idk why all my old threads keep bumping xD