tkinter - Create a simple output textbox in python -
i'm doing program i'm simulating tennis match. @ moment i'm printing result in shell follows:
15 - 0 30 - 0 40 - 0 40 - 15 40 - 30 game: b borg 0 - 15 0 - 30 15 - 30 etc.... how create simple textbox updated every time results updated in code?
i have tried different codes whenever textbox created gets stuck in mainloop showing 15 - 0...
i need able send 2 variables gui function every time score changes.
tkinter import * root = tk() var = stringvar() l = label(root, textvariable = var) l.pack() root.update_idletasks() def gui(player1_points, player2_points): var.set(player1_points,"-" ,player2_points)
to begin with, should call tk.mainloop() @ point, rather tk.update_idletasks(). code need several more changes work properly, though.
here's nice tkinter example should bring close want (scroll down last section labelled "dynamical content in label").
Comments
Post a Comment