[Tutor] Tkinter layout question

boB Stepp robertvstepp at gmail.com
Wed Apr 19 23:21:28 EDT 2017


I don't know (now) how to solve your challenges below.  But if I were
trying to figure this out, I would try to find more complex tkinter
example applications that contain some of the issues I'd be interested
in.  Then I would dig into the code, find the relevant pieces, and
then start playing with them until I understood them.  I know Alan
suggested some resources in one of your earlier threads.  One of the
books he suggested was, "Python and Tkinter Programming" by John E.
Grayson.  It is a fairly old book from the Python 2 days, copyrighted
2000.  However, I own this book and have gotten a lot of use out of
it.  He has _lots_ of complete examples, including such things as a
scientific calculator that looks like something HP sells!  The other
book, "Programming Python" by Mark Lutz has a very large section on
tkinter with plenty of examples.  I have gotten much good use out this
book as well.  It is much more recent, covering Python 3 (and mentions
Python 2 differences as well).  And then there is the Internet.
Surely you could find relevant material out there.  Maybe even the
source code for IDLE would be helpful.  I understand it is written
using tkinter.

On Wed, Apr 19, 2017 at 5:48 PM, Phil <phil_lor at bigpond.com> wrote:
> I'm looking for ideas here.
>
> A working solution for my sudoku solver is a 9 x 9 grid of entry boxes but it looks a bit basic. So I created a 9 x 9 grid on a canvas which looks much better. I can display digits in the centre of the squares but entering the digits from the keyboard seems to be beyond me. I experimented with entering a digit at the mouse location but it all seems to be too complicated. Perhaps someone can offer a repetitively simple solution?
>

Surely doing the keyboard entries isn't a horribly difficult problem?
It sounds like it breaks down to two different types of key bindings:
(1) Binding some keys (perhaps the arrow keys) to change focus from
cell to cell; and, (2) binding keys to do the actual numerical data
entry in each cell.

> A second experiment involved the earlier grid of entry boxes but with a space between every third row and column. This seems to be more achievable, eventually.
>

I think I have done some of this type of "spacing" stuff using empty
narrow frames.  I don't know if would be helpful or not for you in
your use case, but perhaps it is something to think about.  In the
Grayson book he has lots of examples of achieving very precise spacing
and placement of widgets, etc.

Just some thoughts.  Perhaps they might inspire a creative thought or
two.  Of course one of the experienced tkinter pros out there might
chime in with very detailed, specific help.


-- 
boB


More information about the Tutor mailing list