4
Parzi
4y

aight cool so this is fucking stupid thanks Tk

my python teacher is putting us through Tkinter right after "this is how to do basic math" in a class meant for those with no programming knowledge at all

and i remember now why i only do CLI

i've got 2 lines in a func (because "command" params in Tk are fucking retarded), the first changes the text on a button and then the second does shit with os.system ("have this button change this other button then do *something*" ok sure) and yet the button's text does not update until AFTER THE OS.SYSTEM COMMAND FINISHES. I can't even insert a moment between them for it to update in case it needs a sec as time.sleep does *FUCK ALL*

fuck tk, luckily we're gonna move on to files next

(goddamn prereqs, sticking me in this shitty class...)

Comments
  • 2
    Tangentially related:
    I remember discovering that a VB project may only call sleep() in exactly one place in the code; any second reference to it throws an error, I believe? Or maybe just doesn't work at all; idr. But if you make a "sub" (or whatever is VB for method) that contains your one allotted sleep() call and use that everywhere, it works just fine. GG
  • 2
    @Root on python after a nondescript number of uses time.sleep() just gets undefined sometimes.
  • 2
    @Parzi Isn't it great when programming arbitrarily turns non-deterministic? 🙄
  • 2
    @Root atl i'm not using JS, where types are determined at every access by D20 roll.
  • 0
    Because that's how the event loops work.

    You block the main thread with your callback function (which is a bad idea in most GUI frameworks).

    The Tkinter event loop is following (simplified):
    (Wait for event) -> call event functions -> redraw graphics -> (Wait for event) -> ...

    This means if your event handlers take a long time, it will not update the graphics.

    In your case - as you seem to ignore the results of os.system anyway - why not start the subprocess with functions from the subprocess module? There are some functions in this module where you don't have to wait for the subprocess and the execution (and graphical update) immediately continues.
  • 0
    @sbiewald it's an example program, i really don't care about it, it's just annoying. I'll keep that in mind for later, tho.
  • 1
    I have yet to see a documentation that tells you what it does immediately and what as a later stage in the mainloop.
  • 1
    @Lor-inc Something like this:
    https://wiki.tcl-lang.org/page/...
Add Comment