tk_scale_0.py

tk_scale_0.py is only 17 lines of code and will run without edits in Python 2.7.3 and 3.2.3. Demo of a horizontal and a vertical Scale widget scaled to 1-200 and 1-1000 plus a Button that, when pressed, captures the current position of the slider. You could use one of these (probably the horizontal, but it's up to you) to input your 'guess' in Guess the Number, avoiding problems with bad input data (out of range or non-integers). You'll need a variable for the upper range and switch it with the mode buttons (haven't actually tried that yet but I'm assuming it's easy). I assume there are other more modern looking display options for the slider but I'll leave it to you to uncover them. So make sure you understand this code and then try to integrate it into your version of GTN.  

Warning: I just hacked this quickly so I used the .pack() layout method.  You'll need to use the .grid() method if you integrate this with the code I've shown thus far. OK, try it and see how you do.  I'll probably have time to add this to my graphical GTN code by tomorrow so I'll post again later. And 'Thanks' to the student who suggested I make this demo of a Scale widget.  It's actually a better way to input integer data and I should have thought of it earlier!


tk_scale_1.py just adds the following features to tk_scale_0.py:

     name.set(integer) => sets slider to default value, i.e.  w_h1000.set(666)

     length = 250          # changes default 100 pixel slider length
     tickinterval = 50     # tick marks for display

     w_h.grid_remove()     # hides widget w_h so we can switch between Scales
     w_h1000.grid()        # displays widget w_h1000 to enable the switch

     click on 'Change Horizontal Scale' button to switch between Scales, like you would need to do for Guess the Number


There are 33 configuration options and I'm using just 5 of them, so give it a go if you want to improve on this.

One more tip -- on the 1-1000 scale you end up with each screen pixel being worth multiple slider values, i.e., if your slider is 200 pixels long then each pixel could represent 5 units on the scale, making it hard to dial in an exact number.  But if you click in the gutter on either side of the actual slider it nudges the value by 1 unit, giving you the needed granularity.