[Tutor] tkinter code executes before function returned

Chris Roy-Smith chris_roysmith at internode.on.net
Mon Apr 16 05:09:23 EDT 2018


On 15/04/18 18:10, Alan Gauld via Tutor wrote:
> On 15/04/18 03:57, Chris Roy-Smith wrote:
>
>> I am trying to get tkinter to return a number from a window, which then
>> sets how many times to print a sign.
> I don;t jhave time to look at this in detail just now, maybe later.
>
> But first impressions is that you have a very unorthodox style of
> Tkinter programming. Its more traditional to build the entire GUI
> up front rather than creating and destroying widgets each time you
> execute an event handler. Its less disturbing to the user than
> having things appear/disappear etc, as you seem to be doing.
>
> You can make widget hide/show/deactivate themselves without
> destroying them just by withdrawing/unpacking them etc or
> changing their status, if that's really what you want to do.
>
>> The code does not wait till the function returns a value, resulting in
>> the signcount variable in having a None value, giving an output like
>> below.
> I'll look at this a bit more closely later if nobody else
> answers by then...
>
> This is where you call your function. Looking at it quickly
> I think you would be as well using the standard Tkinter
> simpledialogs/messagebox modules to get user input.
> Have you looked at the simpledialogs?
Thank you Alan, I didn't know of simpledialogs. That was all I needed to 
search documentation for these. I have

now achieved what I was trying to do, with user interface as I was planning.


> Or better still having a static entry field on your GUI
> and just reading that?
>
I'll have to figure out how to achieve that!

Perhaps my intended design is not in line with modern styles?


Regards, Chris Roy-Smith



More information about the Tutor mailing list