[Tkinter-discuss] Help needed

Michael Lange klappnase at web.de
Tue Jul 30 14:33:09 EDT 2019


On Tue, 30 Jul 2019 15:43:53 +0530
Balasubramani K <bala.pursuit at gmail.com> wrote:

> I have a questions :
> Cant we use tqdm progress bar in tkinter window ??
> In other words, can't we get a terminal window in tkinter window; where
> whatever the output of the code that is executed should be shown in the
> terminal. like how we use in pycharm or cmd prompt in windows ...etc

actually this can be done, at least with X11; here with debian I can do
something like:

from tkinter import *
from subprocess import Popen

f=Frame(root, container=1, width=300, height=300)
f.pack(fill='both', expand=1)
pipe = Popen(('urxvt', '-embed', str(f.winfo_id())))

Still, I am not so sure if this is a good idea.
First, those embedded windows can be tricky by themselves; there may also
be DE/WM dependent issues (no idea if this works on windows or OSX at
Then you will have to consider user interactions with the terminal,
for example what if the user decides to simply type "exit" at the command
prompt? Or hits Ctrl+\ while the process is running?

Of course I do not know what you want to achieve in detail, but maybe if
you want to use a gui with tqdm it would be a better approach to catch
the string (I guess the "data" in your code snippet?) and instead of
printing it to stdout just putting it on a tkinter Label.
I don't know about tqdm, maybe you could change the output format a bit
to omit the progress bar at all, calculate the value for the
ttk.Progressbar with the percent value and put an output string like

47% 76442/161258.81970214844 [14:12<16:26, 86.00KB/s]

on a Label next to the progress bar. That would give the user all the
information they need, would be easier for you to handle, be more
reliable and surely make a better looking gui.

Best regards


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

	"Life and death are seldom logical."
	"But attaining a desired goal always is."
		-- McCoy and Spock, "The Galileo Seven", stardate 2821.7

More information about the Tkinter-discuss mailing list