[Tutor] critique my script!

Christopher Spears cspears2002 at yahoo.com
Wed Jun 21 02:54:23 CEST 2006


Here is a little gui I created:


#!/usr/bin/python

import os, pygtk
pygtk.require('2.0')
import gtk

class GetCwd:

	def getcwd(self, widget, data=None):
		print os.getcwd()
		
	def delete_event(self, widget, event, data=None):
        	gtk.main_quit()
        	return False
		
	def __init__(self):
		self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
		self.window.set_title("Get Current Working Dir")
		self.window.set_border_width(10)
		self.window.connect("delete_event",
self.delete_event)
		
		self.box = gtk.HBox(False, 0)
		self.window.add(self.box)
		self.button = gtk.Button("Current Working
Directory")
		self.button.connect("clicked", self.getcwd)
		self.box.pack_start(self.button, True, True, 0)
		
		self.button.show()
		self.box.show()
		self.window.show()
		
	def main(self):
		gtk.main()
		
if __name__ == "__main__":
	gui = GetCwd()
	gui.main()
	
What do you think?  One of my main areas of confusion
is that I have seemed similar scripts written without
'self.button' or 'self.box'.  The programmer simply
uses 'button' or 'box' instead.


More information about the Tutor mailing list