Skip to content

Commit

Permalink
Changed grid size entry method
Browse files Browse the repository at this point in the history
  • Loading branch information
riverrun committed Apr 15, 2012
1 parent 5c769db commit b3681cd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
11 changes: 7 additions & 4 deletions genxword/control.py
Expand Up @@ -49,10 +49,13 @@ def grid_size(self, gtkmode=False):
gsize = str(self.ncol) + ', ' + str(self.nrow)
grid_size = raw_input('Enter grid size (' + gsize + ' is the default): ')
if grid_size:
try:
self.ncol, self.nrow = int(grid_size.split(',')[0]), int(grid_size.split(',')[1])
except:
pass
self.check_grid_size(grid_size)

def check_grid_size(self, grid_size):
try:
self.ncol, self.nrow = int(grid_size.split(',')[0]), int(grid_size.split(',')[1])
except:
pass

def calcgrid(self, incgsize=False):
if incgsize:
Expand Down
26 changes: 13 additions & 13 deletions genxword/gui.py
Expand Up @@ -41,21 +41,21 @@
The clue is everything after the first space.\n
Open word list
Clicking the 'open' button, or pressing Control + O, lets you open, and edit, a word list, which needs to be \
formatted as written above. The word list can be thousands of words long. If you use a large word list, \
the crossword will be created with a set amount of words randomly selected from it. The default number of words is 50.\n
formatted as written above. The word list can be thousands of words long, and the crossword will be created \
with a set amount of words randomly selected from it. The default number of words is 50.\n
Calculate - create the crossword
Click on the 'create' button, or press Control + G, to create the crossword. If you click on it a second time, \
the crossword will be recalculated.\n
Inc grid size - increase the grid size and recalculate
This button, or Control + R, gives you the option of increasing the grid size before recalculating the crossword.\n
Increase grid size - increase the grid size and recalculate
Clicking on this button, or pressing Control + R, increases the grid size before recalculating the crossword.\n
Save - save the crossword
This button, or Control + S, lets you choose where you save the crossword files.\n
Further options
You can save the crossword in pdf, png and / or svg format. Just click on the appropriate entries in the 'Save options' menu.
On the bottom row of this window, there are boxes in which you can write the name of the crossword, choose the number \
of words used, and choose the grid size. To change the grid size, you will need to enable this option in the 'Crossword' \
menu first (normally, the grid size will be automatically calculated based on the number of words used). \
The number in the grid size box refers to the number of columns, and rows, that will be used.
The numbers in the grid size box refer to the number of columns and rows, and they need to be separated by a comma.
"""
save_recalc = """\nIf you want to save this crossword, press the Save button.
If you want to recalculate the crossword, press the Calculate button.
Expand Down Expand Up @@ -130,7 +130,7 @@ def __init__(self):

self.textview_win()
self.bottom_row()
#self.win_icon()
self.win_icon()

def add_main_actions(self, action_group):
action_filemenu = Gtk.Action('FileMenu', '_Word list', None, None)
Expand Down Expand Up @@ -235,11 +235,10 @@ def bottom_row(self):
gsize_label = Gtk.Label('Grid size')
self.grid.attach(gsize_label, 4, 3, 1, 1)

adjustment = Gtk.Adjustment(17, 9, 101, 2, 10, 0)
self.choose_gsize = Gtk.SpinButton()
self.choose_gsize.set_adjustment(adjustment)
self.choose_gsize.set_update_policy(Gtk.SpinButtonUpdatePolicy.IF_VALID)
self.choose_gsize = Gtk.Entry()
self.choose_gsize.set_text('17,17')
self.choose_gsize.set_tooltip_text('Choose the crossword grid size')
self.choose_gsize.set_sensitive(False)
self.grid.attach(self.choose_gsize, 5, 3, 1, 1)

def entry_cleared(self, entry, position, event):
Expand Down Expand Up @@ -311,10 +310,9 @@ def calc_xword(self, button):
self.gen = Genxword()
with open(wordlist) as infile:
self.gen.wlist(infile, nwords)
self.gen.grid_size(True)
if self.gsize:
self.gen.ncol = self.gen.nrow = self.choose_gsize.get_value_as_int()
else:
self.gen.grid_size(True)
self.gen.check_grid_size(self.choose_gsize.get_text())
self.textbuffer.set_text(self.gen.calcgrid())
self.add_tag(self.tag_mono, 0, -1)
self.textbuffer.insert_at_cursor(save_recalc)
Expand All @@ -330,8 +328,10 @@ def incgsize(self, button):
def set_gsize(self, button):
if button.get_active():
self.gsize = True
self.choose_gsize.set_sensitive(True)
else:
self.gsize = False
self.choose_gsize.set_sensitive(False)

def save_xword(self, button):
self.xwordname = self.enter_name.get_text()
Expand Down

0 comments on commit b3681cd

Please sign in to comment.