This script did not run properly
jk nj --- [EMAIL PROTECTED] wrote: > Send Tutor mailing list submissions to > tutor@python.org > > To subscribe or unsubscribe via the World Wide Web, > visit > http://mail.python.org/mailman/listinfo/tutor > or, via email, send a message with subject or body > 'help' to > [EMAIL PROTECTED] > > You can reach the person managing the list at > [EMAIL PROTECTED] > > When replying, please edit your Subject line so it > is more specific > than "Re: Contents of Tutor digest..." > > > Today's Topics: > > 1. Re: Crossword program (Alan Gauld) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sun, 9 Jan 2005 22:07:31 -0000 > From: "Alan Gauld" <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Crossword program > To: "David Holland" <[EMAIL PROTECTED]>, > <tutor@python.org> > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset="iso-8859-1" > > Hi David, > > Its probably the kind of thing you could put on the > Useless Python website. Useless is a collection of > not-too-serious software written in Python which, > despite the name, is actually quite useful for > beginners > to download and look at and learn. They can try > improving it, or using the ideas for their own > programs. > > But you might well get some suggestions on tidying > it up a little first... > > Alan G. > > ----- Original Message ----- > From: "David Holland" <[EMAIL PROTECTED]> > To: <tutor@python.org> > Sent: Sunday, January 09, 2005 9:44 PM > Subject: [Tutor] Crossword program > > > > I wrote a program to create crosswords in python. > > It is not perfect but it works, is there any open > > source place I can put this for it to be used by > > anyone who wants it ? (Subject to the gpl > licence). > > Here is the code in case anyone is interested. > > > > from Tkinter import * > > #Crossword program David Holland > > class Crossword(Frame): > > > > def __init__(self, master): > > '''Default arguments''' > > Frame.__init__(self, master) > > self.grid() > > self.create_widgets() > > NUM_SQUARES = 169 > > EMPTY = " " > > global questionanswer > > questionanswer = {} > > global dictshort > > dictshort = {} > > > > def readdict(self): > > #get the dictionary from a file > > try: > > pickle_file = open(dictfile, "rb") > > dictread = cPickle.load(pickle_file) > > except: > > dictread = {} > > return dictread > > > > def writedict(self, dictent): > > #write dictionary to file > > pickle_file = open(dictfile, "wb") > > cPickle.dump(dictent, pickle_file) > > pickle_file.close() > > > > def showclues(self): > > #show clues on the screen > > questionanswer = self.readdict() > > textent = self.showinfo(questionanswer) > > #textent = questionanswer > > self.putinfo(textent) > > > > def showinfo(self, dictent): > > #make the clues look readable > > i = 0 > > listkeys = dictent.keys() > > #listkeys = listkeys.sort() > > textdisp = '' > > for item in listkeys: > > i = i+1 > > istr = str(i) + " " > > question = dictent[item] > > textdisp = textdisp + istr + " the > > question is " + question + " the answer is " + > item + > > "\n" > > return textdisp > > > > def newcrosswordboard(self): > > #create a crossword board > > board = [] > > for square in range (NUM_SQUARES): > > board.append(EMPTY) > > return board > > > > # def newcrosswordboard(self): > > # #this is create a board with the numbers > > # board = [] > > # for square in range (NUM_SQUARES): > > # text = str(square) > > # board.append(text) > > # return board > > > > def deleteclue(self): > > #delete a clue > > try: > > numberentered = self.delete_ent.get() > > dictent = self.readdict() > > numberentered = int(numberentered) > > listkeys = dictent.keys() > > i = 1 > > clue = '' > > for item in listkeys: > > if numberentered == i: > > del dictent[item] > > clue = item > > break > > i = i +1 > > text = "Clue " + clue + " has been > removed > > the list of clues now is :-" + "\n" > > self.writedict(dictent) > > moretext = self.showinfo(dictent) > > text = text + moretext > > except: > > text = "Please enter a number as a > figure" > > self.putinfo(text) > > > > def create_widgets(self): > > #create GUI > > self.question_lbl = Label(self, text = > "Enter > > the question ") > > self.question_lbl.grid(row = 0, column = > 0, > > columnspan = 2, sticky = W) > > self.answer_lbl = Label(self, text = > "Enter > > the answer") > > self.answer_lbl.grid(row = 1, column = 0, > > columnspan = 2, sticky = W) > > self.delete_lbl = Label(self, text = > "Enter > > the number of a clue you want deleted") > > self.delete_lbl.grid(row = 2, column = 0, > > columnspan = 2, sticky = W) > > #entry widget for the question > > self.question_ent = Entry(self) > > self.question_ent.grid(row=0, column = 2, > > columnspan = 1, sticky = W) > > self.answer_ent = Entry(self) > > self.answer_ent.grid(row=1, column = 2, > > columnspan = 2, sticky = W) > > self.delete_ent = Entry(self) > > self.delete_ent.grid(row=2, column = 2, > > columnspan = 1, sticky = W) > > > > #button to add entries > > Button(self, text = "Click to add clues ", > > command = self.create_questionsanswer).grid(row = > 0, > > column = 3, columnspan = 3) > > Button(self, text = "Click to show clues > ", > > command = self.showclues).grid(row = 1, column = > 3, > > columnspan = 3) > > Button(self, text = "Click to delete clue > ", > > command = self.deleteclue).grid(row = 2, column = > 3, > === message truncated === __________________________________ Do you Yahoo!? Yahoo! Mail - Find what you need with new enhanced search. http://info.mail.yahoo.com/mail_250 _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor