how to print a variable in a tkinter label using python?

The only thing you are missing is that os.system does not return the command output, but rather

On Unix, the return value is the exit status of the process (…)

So in order for your example to work, you’d need something like:

var = StringVar()
exit_code = os.system("lsmod |grep uvcvideo")
message = f"Camera is {'loaded' if exit_code == 0 else 'not loaded'}"
var.set(message)

Because 0 exit code implies that the process finished successfully. Although for that I’d check the exit codes for grep and lsmod to be sure.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top