Hi Randall,

I assume you are asking about the Python programming language (tkinter??). This group discusses the Tcl programming language, from which Tk originates. See 2 answers below.
Xpost and Fup2 c.l.p

Christian

Am 22.03.20 um 00:59 schrieb Randall Wert:
I am trying to enhance a shell program -- you know, the kind that communicates with the 
user through simple lines of text, using print() and input() statements -- by adding a 
tkinter interface. I have successfully completed three projects using tkinter in the 
past, but this one is proving more difficult. The essence of the problem is, I want the 
program to still have the same control flow as in the "shell" program. It 
should issue messages to the user and receive their input. But tkinter seems to be purely 
designed for event-driven programs (responding to button clicks, for example).

To be more specific: It is a hangman game. The user enters different types of 
input as the program runs (choice of difficulty level, letters (guesses), Y/N 
for playing another game, etc.). I would like to be able to use a single user 
entry field for all of those purposes, and accept input from it when the user 
presses Enter, instead of having a different button for each type of user input.

I hope I am explaining it clearly. I would appreciate any tips on converting to 
a tkinter interface while maintaining the same program flow.


You must convert the program into a state machine. Luckily, both Tcl and Python can help you with this, in the form of a coroutine. For Tcl, take a look to this page

https://wiki.tcl-lang.org/page/Coroutines+for+event-based+programming

For Python, look up generators and google "asyncio tkinter".

Christian

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to