[Tutor] Any Suggestions?
Mark Brown
mark.brown@rogers.com
Sat Nov 16 12:04:04 2002
Hello,
I'm just learning Python and would appreciate any suggestions regarding
the programs listed below. The programs do function.
runit2.py
#!/usr/bin/env python
import runit2tk
from os import system
from sys import exit
gui1 = runit2tk.Gui1()
gui1.mainloop()
if gui1.text != "":
command = "%s &" % gui1.text
system(command)
exit(0)
runit2tk.py
#!/usr/bin/env python
import Tkinter
class Gui1:
def __init__(self, text=""):
self.text = text
self.root = Tkinter.Tk()
self.root.title('PyRun')
self.label = Tkinter.Label(self.root, text="Run")
self.label.pack(side="left")
self.entry = Tkinter.Entry(self.root, takefocus="true")
self.entry.pack(side="left", fill="x", expand="true")
self.entry.bind('<Key-Return>', self.getinput)
self.entry.focus()
def mainloop(self):
self.root.mainloop()
def getinput(self, event):
self.text = self.entry.get()
self.root.destroy()
return self.text
Thanks
Mark Brown