findthatword
index
/home/jonny/Documents/python workspace/wordsearch_v2/src/findthatword.py

Copyright 2009 Jonny Jones and Ieuan Jones
 
    This file is part of FindThatWord.
 
    FindThatWord is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

 
Modules
       
cPickle
cairo
copy
datetime
gnomevfs
gobject
gtk
math
os
pango
pangocairo
pygtk
random
string
sys
time

 
Classes
       
FindThatWord

 
class FindThatWord
    GTK-based wordsearch puzzle
 
  Methods defined here:
__init__(self)
initialise a new puzzle
confirm_lose_changes(self)
Ask the user whether they really want to lose their changes.
Returns True or False
display_failure(self)
Display warning that puzzle could not be completed
draw_as_cairo(self, surface, size_x, size_y, margin_top, margin_right, margin_bottom, margin_left, dpi, highlight_selected)
Draws the puzzle onto a cairo surface.  dpi is the number of desired pixels per 'inch' - on the screen, this is a 
scaled inch that represents on inch on the final printed output
draw_as_pdf(self, filename)
Write a PDF containing the puzzle to filname
draw_as_png(self, filename)
Write a PNG containing the puzzle to filname
draw_as_svg(self, filename)
Write a PNG containing the puzzle to filname
draw_as_text(self, filename)
Write a text stream containing the puzzle to filname
draw_as_widget(self)
Draw the puzzle onto the ResultsArea screen widget
draw_to_printer(self, print_operation, print_context, page_no)
Render the puzzle to the provided print surface
export_file(self)
Open a Export dialogue and export the file in the format specified by the user
load_file(self, filename, type='URI')
Opens the FTW file with a the supplied URI or filename and returns True if successful.  We
prefer to work with URIs than files, as they're easier to add to the recent file list.  In the
interests of simplicity, we only add URIs to the recent file list
new_puzzle(self)
Start a new puzzle
on_AddButton_clicked(self, widget)
Add a word to the puzzle
on_ApplyButton_clicked(self, widget)
Update the word being edited
on_AscendingButton_clicked(self, widget)
Sort the puzzle words alphabetically
on_CancelButton_clicked(self, widget)
Cancel editing the word
on_DeleteButton_clicked(self, widget)
Delete a word from the puzzle
on_EditButton_clicked(self, widget)
Edit a word that already exists in the puzzle
on_FileExportMenuItem_activate(self, widget)
File > Export menu item
on_FileNewMenuItem_activate(self, widget)
File | New - Start a new project file, blank out
the current project and start from scratch
on_FileOpenMenuItem_activate(self, widget)
File > Open menu item
on_FilePageSetupMenuItem_activate(self, widget)
File > Page setup menmu item
on_FilePrintMenuItem_activate(self, widget)
on_FileQuitMenuItem_activate(self, widget)
Leave the application
on_FileSaveAsMenuItem_activate(self, widget)
File > Save As menu item
on_FileSaveMenuItem_activate(self, widget)
File > Save menu item
on_ForceSizeCheckButton_toggled(self, widget)
Toggle the forced-size option and resize as appropriate
on_HelpAboutMenuItem_activate(self, widget)
Help > About Menu Item
on_HiddenMessageCheckButton_toggled(self, widget)
Toggle the hidden message option
on_HiddenMessageEntry_changed(self, widget)
Update the hidden message
on_MainWindow_delete_event(self, widget, response)
Intercept main window closure if data is unsaved
on_MainWindow_destroy(self, widget)
Quit the main application
on_MoveDownButton_clicked(self, widget)
Move a word down in the puzzle
on_MoveUpButton_clicked(self, widget)
Move a word up in the puzzle
on_NarrativeWidget_changed(self, widget)
Change made to puzzle narrative
on_NewDescriptionEntry_changed(self, widget)
Enable / disable the Add / Update buttons according to the newly typed word
on_NewIcon_clicked(self, widget)
New icon clicked
on_NewWordEntry_changed(self, widget)
Enable / disable the Add / Update buttons according to the newly typed word
on_OpenIcon_clicked(self, widget)
Open icon clicked
on_PrintIcon_clicked(self, widget)
Print icon clicked
on_PuzzleTitleEntry_changed(self, widget)
Change made to puzzle title
on_RecentChooser_activate(self, widget)
Open a file from the recently used files list
on_RefreshIcon_clicked(self, widget)
Refresh icon clicked
on_ResultsArea_expose_event(self, widget, signal)
Draw the puzzle
on_SaveIcon_clicked(self, widget)
Save icon clicked
on_ShowGridCheckButton_toggled(self, widget)
Toggle the show entire solution option and print if its working
on_ShowSolutionCheckButton_toggled(self, widget)
Toggle the show solution options and print if its working
on_ShowTitleCheckButton_toggled(self, widget)
Toggle the show entire solution option and print if its working
on_ShowWordlistCheckButton_toggled(self, widget)
Toggle the show entire solution option and print if its working
on_WordsListWidgetSelection_changed(self, widget)
New word selected in the wordlist widget
on_xSpin_output(self, widget)
Increase or decrease the puzzle's forced width
on_ySpin_output(self, widget)
Increase or decrease the puzzle's forced height
open_file_with_dialog(self)
Open an Open dialogue and opens the selected file
save_file(self)
Save the file.  The filename must already have been set
save_file_as(self)
Open a Save As dialogue and save the file
set_dirty(self, dirty)
Make the puzzle dirty or clean and update the title bar and
save icons accordingly
set_edit_mode(self, edit_mode)
Edit mode indicates that a word in the wordlist is being edited
set_filename(self, filename, uri, auto_extension=True)
Change the puzzle's filename and optionally correct the
file extension
show_print_dialogue(self)
Display a print dialogue box and print the puzzle
update_add_button(self)
Enable or disable the Add and Cancel buttons according to the contents of the
new_word_entry_widget
update_all_widgets(self)
Redraw all widgets on screen.  This has the effect of making
the puzzle dirty
update_ascending_button(self)
Enables or disables the sort button based on the number of words in the puzzle
update_grid_size_widget(self)
Enable / disable the grid size spinners
update_hidden_message_widget(self)
Enable / disable the hidden message widget
update_results_area_aspect_frame(self)
Updates the aspect ratio of the results area
update_results_widget(self)
Redraw the puzzle output
update_save_icons(self)
Disable the Save icons if the puzzle isn't dirty
update_window_title(self)
Set the window title based on the filename and whether the file is dirty
update_words_list(self)
Redraw the Words_list widget by recreating the associated data model

 
Data
        APP_NAME = 'FindThatWord'
APP_VERSION = '0.1'
AUTHORS = ['Jonny Jones', 'Ieuan Jones']
BG_COLOUR = (1, 1, 1)
COPYRIGHT = 'Copyright Jonny Jones and Ieuan Jones 2009'
FILE_EXT = 'ftw'
GRID_COLOUR = (0.5, 0.5, 0.5)
PADDING_COLOUR = (0, 0, 0)
SELECTED_COLOUR = (0.5, 0.0, 0.75, 0.59999999999999998)
WORD_COLOUR = (0.75, 0.0, 0.0, 0.29999999999999999)
a = None