• A natural magnet for the craziest TKinter lovers out there

    From Dan Kolis@21:1/5 to All on Wed Jan 18 17:01:01 2023
    Hangs after maybe between 4 and 50 screen rewrites. sometimes CTRL C under Ubuntu starts it up again. Click go rewrites al the fonts the thing can find in a few windows.... Repeated.

    TKinter has a cult following. I don''t really expect others to fix my problems, but you know, es since its a cult thing to love TCL ( or something .... ) Here is is.

    Same on two different computers in Python 3.6 and 3.8

    Plus I suppose you get to see for sure all your finest fonts as rendered in a real TK thing, not that this changes the worlds so much.


    Thanks for the advice so far...
    Regards,
    Dan Kolis

    # Code version 18Jan2023 19:48 EST Dan Kolis
    # Click 'go' on main page. when run over and over after a while it freezes


    import tkinter as tk
    from tkinter import ttk
    from tkinter import font as luFont


    # Empty object maker ( M T ) ... get it say it !
    class MT():
    pass


    # Module level variables
    mod = MT()
    mod.itsPlaces = MT()
    mod.itsPlaces = []


    # Apply XY Size to things like windows, variable place 31Jul22
    def apply_Width_Height_Position( toThis, aWidth, aHeight, *argsPlace ):

    # Width and height is expected

    # Argument overflow is quite variable size is it its usual hint for me
    aLen = len( argsPlace )

    # Sometimes, just width and height are given ( not that + position )
    wAndH = str( int( aWidth ) ) +'x' + str( int( aHeight ) ) # Size has a funny text line interface
    toThis.geometry( wAndH ) # Apply

    # Sometimes position too
    if aLen == 2:
    eP = "+" + str( argsPlace[ 0 ] ) + "+" + str( argsPlace[ 1 ] )
    param4 = wAndH + eP # Combine size and position
    toThis.geometry( param4 ) # Apply

    jjjjjj = 560


    # Create local toplevel to whoever calls me 11Dec22 bc-endive
    def make_Tk_Window( sReason, *attribKc ):

    # Top level window maker and rememberer
    # Kc = 'Kind code'

    aCode = "na" # Not available
    if attribKc:
    aCode = attribKc [ 0 ] # Better code then 'na'

    # Make window
    ansWin = tk.Toplevel()

    # Keep track of this creation step
    newEntry = {}
    newEntry[ 'tkaddress' ] = ansWin # Real TK window accessor
    newEntry[ 'ideanamed' ] = sReason # Casual description
    newEntry[ 'kindcode' ] = aCode # So can be worked with together

    mod.itsPlaces.append( newEntry )

    return ansWin


    # Idle time rewrite
    def justRedisplayNow( wThings, *argsR ):

    # Redisplay a named tj thing
    # Dont use this frivolously, if it's needed its here you have to study it

    wThings.update()


    # Look at fonts possible 6Oct22
    def showAllFonts():

    # Show fonts possible

    mod.lines_In_Window = 30; mod.window_Seq_Number = 1

    # What we want to see
    mod.seeFonts = list( luFont.families() )
    mod.seeFonts.sort() # Alpha order is nice

    # Fill windows as a look at me report
    try:
    populateW()
    except:
    tttttt = 456

    rrrrrr = 245


    # Show fonts regarding avoiding BAD ones that crash, etc size limits in buffers too 19Dec22
    def populateW():

    # Put in the fonts

    aLen = len( mod.seeFonts ) # Fun to know, debug really
    last_considered_name = "gghfjhljfl" # Don't show doubles

    # Loop through all fonts the system named
    thisPassMakeWindow = True; a_Line_Count = 0; list_Number = 0
    for item in mod.seeFonts:

    # Multiple windows ( Python has funny ideas on this, ok like this )
    if thisPassMakeWindow:
    winTk_Now = winMakerFontsW(); thisPassMakeWindow = False; a_Line_Count = 0 # We gots one now

    if a_Line_Count < mod.lines_In_Window: # Will a window we made
    list_Number += 1 # Counts
    aN = str( list_Number ) + " "; name_In_lower = item.lower()

    # Various reasons to not render this one
    isOk = True
    if name_In_lower == last_considered_name:
    isOk = False
    a_Bad_Thing = name_In_lower.find( 'emoji' ) > -1
    if a_Bad_Thing:
    isOk = False
    a_Bad_Thing = item.find( 'Noto Sans Mono CJK' ) > -1
    if a_Bad_Thing:
    isOk = False

    # Good good
    if isOk:
    label = "listlabel" + str( list_Number )
    label = tk.Label( winTk_Now, text=aN + item, font=( item, 18 ), anchor='w' ).pack()
    a_Line_Count += 1
    last_considered_name = name_In_lower
    else:
    justRedisplayNow( winTk_Now )
    thisPassMakeWindow = True; mod.window_Seq_Number += 1 # New window next time

    # Done
    a_Msg = "on this machine"


    # Look at fonts possible 6Oct22
    def showAllFonts():

    # Show fonts possible

    mod.lines_In_Window = 30; mod.window_Seq_Number = 1

    # What we want to see
    mod.seeFonts = list( luFont.families() )
    mod.seeFonts.sort() # Alpha order is nice

    # Fill windows as a look at me report
    try:
    populateW()
    except:
    tttttt = 456

    rrrrrr = 245


    # Just window shape aka size
    def applyWidthHeight( toThis, aWidth, aHeight ):

    # TK window size no change in code anyway, to placement

    # Op sys like thing likes this x that numbers
    wAndH = str( int( aWidth ) ) +'x' + str( int( aHeight ) ) # Size
    toThis.geometry( wAndH ) # Apply
    tttttt = 385


    # Window making
    def winMakerFontsW():

    # Window with scroll bars, etc canvassy, ready to fill up

    # The real window gets created
    mInf = ' ' + str( mod.window_Seq_Number )
    wsFr = make_Tk_Window( 'Font peek' + mInf, 'fontpeek' );
    wsFr.title( 'Fonts' + mInf )
    start_Hor = 50; Kh = 110; start_Ver = 35; Kv = 40
    moved_Some_H = start_Hor + ( mod.window_Seq_Number * ( Kh - 1 ) )
    moved_Some_V = start_Ver + ( mod.window_Seq_Number * ( Kv - 1 ) )
    apply_Width_Height_Position( wsFr, 480, 500, moved_Some_H, moved_Some_V )

    # Canvas is the form pretty much
    my_Canvas = tk.Canvas( wsFr, borderwidth=0 )
    myFrm = tk.Frame( my_Canvas ) # Now the 'do it on me' thing

    # Vertical scroll bars go onto form
    vsb = tk.Scrollbar( wsFr, orient="vertical", command=my_Canvas.yview )
    my_Canvas.configure( yscrollcommand=vsb.set )

    # Assemble via relations of pieces
    vsb.pack( side="right", fill="y" )
    my_Canvas.pack( side="left", fill="both", expand=True )
    my_Canvas.create_window( (4, 4 ), window=myFrm, anchor="nw" )

    return myFrm


    def callIt():

    # A click do it

    showAllFonts()


    # This is main
    root = tk.Tk()

    applyWidthHeight( root, 300, 300 )

    b1 = tk.Button( root, text='go', command=callIt )
    b1.grid( row=0, column=0 )


    root.mainloop()

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael Torrie@21:1/5 to Dan Kolis on Wed Jan 18 18:56:48 2023
    On 1/18/23 18:01, Dan Kolis wrote:
    Hangs after maybe between 4 and 50 screen rewrites. sometimes CTRL C under Ubuntu starts it up again. Click go rewrites al the fonts the thing can find in a few windows.... Repeated.


    Not sure what you mean by "screen rewrites."

    I ran your test program here and it generates 25 windows on my machine,
    and I can click "run" at least half a dozen times. I tried closing the
    font windows before clicking run again, and also just leaving the
    windows up and generating many more windows. 300 windows. No hangs here
    at all. Fedora 35 with Mate Desktop on X11 with compositing enabled.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Passin@21:1/5 to Michael Torrie on Wed Jan 18 23:46:38 2023
    On 1/18/2023 8:56 PM, Michael Torrie wrote:
    On 1/18/23 18:01, Dan Kolis wrote:
    Hangs after maybe between 4 and 50 screen rewrites. sometimes CTRL C under Ubuntu starts it up again. Click go rewrites al the fonts the thing can find in a few windows.... Repeated.


    Not sure what you mean by "screen rewrites."

    I ran your test program here and it generates 25 windows on my machine,
    and I can click "run" at least half a dozen times. I tried closing the
    font windows before clicking run again, and also just leaving the
    windows up and generating many more windows. 300 windows. No hangs here
    at all. Fedora 35 with Mate Desktop on X11 with compositing enabled.

    It could be using up some system resource. tk could have some memory or resource leak, possibly specific to the OP's machine. Try looking at
    system memory with the system monitor as the program goes through its
    paces. Maybe you will notice something suspicious.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Passin@21:1/5 to Thomas Passin on Thu Jan 19 00:41:42 2023
    On 1/18/2023 11:46 PM, Thomas Passin wrote:
    On 1/18/2023 8:56 PM, Michael Torrie wrote:
    On 1/18/23 18:01, Dan Kolis wrote:
    Hangs after maybe between 4 and 50 screen rewrites. sometimes CTRL C
    under Ubuntu starts it up again. Click go rewrites al the fonts the
    thing can find in a few windows.... Repeated.


    Not sure what you mean by "screen rewrites."

    I ran your test program here and it generates 25 windows on my machine,
    and I can click "run" at least half a dozen times. I tried closing the
    font windows before clicking run again, and also just leaving the
    windows up and generating many more windows.  300 windows. No hangs here
    at all. Fedora 35 with Mate Desktop on X11 with compositing enabled.

    It could be using up some system resource.  tk could have some memory or resource leak, possibly specific to the OP's machine.  Try looking at
    system memory with the system monitor as the program goes through its paces.  Maybe you will notice something suspicious.


    Also reduce the number of windows that get opened to a small number. If
    there are no freezes, increase the number little by little. This may
    give you some bounds on what's going on, or at least let your ultimate
    program work by keeping the resource use under control.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Weatherby,Gerard@21:1/5 to Dan Kolis on Thu Jan 19 12:34:00 2023
    Works fine on my work machine. (Ubuntu 20.04 / 32 G / 32 CPUS). Scalene (https://github.com/plasma-umass/scalene) shows it using 9 MB of memory.

    From: Python-list <python-list-bounces+gweatherby=uchc.edu@python.org> on behalf of Michael Torrie <torriem@gmail.com>
    Date: Wednesday, January 18, 2023 at 8:58 PM
    To: python-list@python.org <python-list@python.org>
    Subject: Re: A natural magnet for the craziest TKinter lovers out there
    *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***

    On 1/18/23 18:01, Dan Kolis wrote:
    Hangs after maybe between 4 and 50 screen rewrites. sometimes CTRL C under Ubuntu starts it up again. Click go rewrites al the fonts the thing can find in a few windows.... Repeated.


    Not sure what you mean by "screen rewrites."

    I ran your test program here and it generates 25 windows on my machine,
    and I can click "run" at least half a dozen times. I tried closing the
    font windows before clicking run again, and also just leaving the
    windows up and generating many more windows. 300 windows. No hangs here
    at all. Fedora 35 with Mate Desktop on X11 with compositing enabled.

    -- https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!iGQaGdd9t2QPVQJDhyDTQmXgCwx4YG7m8jFbRd11dF1BweJHCd0wC4UyZUfQGQjqxeulMYagnDqInfA81A$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-
    list__;!!Cn_UX_p3!iGQaGdd9t2QPVQJDhyDTQmXgCwx4YG7m8jFbRd11dF1BweJHCd0wC4UyZUfQGQjqxeulMYagnDqInfA81A$>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Passin@21:1/5 to Gerard on Thu Jan 19 10:06:43 2023
    Works fine through 10 "go" button presses on my Windows 10 machine. You
    might want to run pylint and pyflakes on it

    On 1/19/2023 7:34 AM, Weatherby,Gerard wrote:
    Works fine on my work machine. (Ubuntu 20.04 / 32 G / 32 CPUS). Scalene (https://github.com/plasma-umass/scalene) shows it using 9 MB of memory.

    From: Python-list <python-list-bounces+gweatherby=uchc.edu@python.org> on behalf of Michael Torrie <torriem@gmail.com>
    Date: Wednesday, January 18, 2023 at 8:58 PM
    To: python-list@python.org <python-list@python.org>
    Subject: Re: A natural magnet for the craziest TKinter lovers out there
    *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***

    On 1/18/23 18:01, Dan Kolis wrote:
    Hangs after maybe between 4 and 50 screen rewrites. sometimes CTRL C under Ubuntu starts it up again. Click go rewrites al the fonts the thing can find in a few windows.... Repeated.


    Not sure what you mean by "screen rewrites."

    I ran your test program here and it generates 25 windows on my machine,
    and I can click "run" at least half a dozen times. I tried closing the
    font windows before clicking run again, and also just leaving the
    windows up and generating many more windows. 300 windows. No hangs here
    at all. Fedora 35 with Mate Desktop on X11 with compositing enabled.

    -- https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!iGQaGdd9t2QPVQJDhyDTQmXgCwx4YG7m8jFbRd11dF1BweJHCd0wC4UyZUfQGQjqxeulMYagnDqInfA81A$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-
    list__;!!Cn_UX_p3!iGQaGdd9t2QPVQJDhyDTQmXgCwx4YG7m8jFbRd11dF1BweJHCd0wC4UyZUfQGQjqxeulMYagnDqInfA81A$>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Kolis@21:1/5 to All on Thu Jan 19 07:21:22 2023
    Hello !

    Works fine on my work machine. (Ubuntu 20.04 / 32 G / 32 CPUS). Scalene (https://github.com/plasma-umass/scalene) shows it using 9 MB of memory.

    I ran your test program here and it generates 25 windows on my machine,
    and I can click "run" at least half a dozen times. I tried closing the
    font windows before clicking run again, and also just leaving the
    windows up and generating many more windows. 300 windows. No hangs here
    at all. Fedora 35 with Mate Desktop on X11 with compositing enabled.


    Thanks a lot These reports are very helpful !

    I seemed to have 'fixed it' by changing one line, really. I used:

    # Do each thing
    ..for aWs in workWsL:
    ....aWs.update()


    TO:
    # Do each thing
    ..for aWs in workWsL:
    ....aWs.update_idletasks()


    Dan says:
    Thanks a lot ! This helps me visualise this is managed as a problem in a technical sense. I mean, there is always a requirement for real integration testing of all sorts for an attempt to release a program on a larger scale.

    Now I know it works without stopping on 4 computers. Better then yesterday hugely.

    Thank you.

    Regs
    Daniel B. Kolis

    my ref: nafl, 19 Jan 2023, https://groups.google.com/g/comp.lang.python/c/FNlXg0Od39o/m/9stiUtLSAQAJ

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Passin@21:1/5 to Thomas Passin on Thu Jan 19 11:24:38 2023
    Works through 20 presses of the "go" button on a Linux Mint VM. Because
    of limited RAM allocated for the VM, after some iterations the program
    slowed down because the VM had to start using swap memory. But there
    did not seem to be any glitches or failures.

    Python 3.9.5
    Linux Mint 20 Ulyana /Cinnamon 3.07 GB
    Linux kernel 5.4.0-137-generic
    tk: 0.1.0


    On 1/19/2023 10:06 AM, Thomas Passin wrote:
    Works fine through 10 "go" button presses on my Windows 10 machine.  You might want to run pylint and pyflakes on it

    On 1/19/2023 7:34 AM, Weatherby,Gerard wrote:
    Works fine on my work machine. (Ubuntu 20.04 / 32 G / 32 CPUS).
    Scalene (https://github.com/plasma-umass/scalene) shows it using 9 MB
    of memory.

    From: Python-list <python-list-bounces+gweatherby=uchc.edu@python.org>
    on behalf of Michael Torrie <torriem@gmail.com>
    Date: Wednesday, January 18, 2023 at 8:58 PM
    To: python-list@python.org <python-list@python.org>
    Subject: Re: A natural magnet for the craziest TKinter lovers out there
    *** Attention: This is an external email. Use caution responding,
    opening attachments or clicking on links. ***

    On 1/18/23 18:01, Dan Kolis wrote:
    Hangs after maybe between 4 and 50 screen rewrites. sometimes CTRL C
    under Ubuntu starts it up again. Click go rewrites al the fonts the
    thing can find in a few windows.... Repeated.


    Not sure what you mean by "screen rewrites."

    I ran your test program here and it generates 25 windows on my machine,
    and I can click "run" at least half a dozen times. I tried closing the
    font windows before clicking run again, and also just leaving the
    windows up and generating many more windows.  300 windows. No hangs here
    at all. Fedora 35 with Mate Desktop on X11 with compositing enabled.

    --
    https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!iGQaGdd9t2QPVQJDhyDTQmXgCwx4YG7m8jFbRd11dF1BweJHCd0wC4UyZUfQGQjqxeulMYagnDqInfA81A$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/
    python-list__;!!Cn_UX_p3!iGQaGdd9t2QPVQJDhyDTQmXgCwx4YG7m8jFbRd11dF1BweJHCd0wC4UyZUfQGQjqxeulMYagnDqInfA81A$>


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Passin@21:1/5 to Dan Kolis on Thu Jan 19 12:24:00 2023
    On 1/19/2023 10:21 AM, Dan Kolis wrote:
    Hello !

    Works fine on my work machine. (Ubuntu 20.04 / 32 G / 32 CPUS). Scalene (https://github.com/plasma-umass/scalene) shows it using 9 MB of memory.

    I ran your test program here and it generates 25 windows on my machine,
    and I can click "run" at least half a dozen times. I tried closing the
    font windows before clicking run again, and also just leaving the
    windows up and generating many more windows. 300 windows. No hangs here
    at all. Fedora 35 with Mate Desktop on X11 with compositing enabled.


    Thanks a lot These reports are very helpful !

    I seemed to have 'fixed it' by changing one line, really. I used:

    # Do each thing
    ..for aWs in workWsL:
    ....aWs.update()


    TO:
    # Do each thing
    ..for aWs in workWsL:
    ....aWs.update_idletasks()

    I was going to suggest update_idletasks(), but I forgot to scan your
    code to see it it was already being done.

    Dan says:
    Thanks a lot ! This helps me visualise this is managed as a problem in a technical sense. I mean, there is always a requirement for real integration testing of all sorts for an attempt to release a program on a larger scale.

    Now I know it works without stopping on 4 computers. Better then yesterday hugely.

    Thank you.

    Regs
    Daniel B. Kolis

    my ref: nafl, 19 Jan 2023, https://groups.google.com/g/comp.lang.python/c/FNlXg0Od39o/m/9stiUtLSAQAJ









    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)