Exiting/killing a program with tkinter but leaving the graphic on the screen - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: Exiting/killing a program with tkinter but leaving the graphic on the screen (/thread-17335.html) |
Exiting/killing a program with tkinter but leaving the graphic on the screen - jpezz - Apr-07-2019 I want the opposite of what most people want. I call a python subprogram to put a tk label on the screen. I want that program to terminate itself when it outputs the label (best) or to be sent a "kill" signal from the parent that will terminate the program but leave the label on the screen. Is that possible? Note that the label is not interactive (i.e. not a button or anything that returns a value). Note that the label will not have any titlebar. ".overrideredirect(1)" RE: Exiting/killing a program with tkinter but leaving the graphic on the screen - Gribouillis - Apr-07-2019 For me, if there is a label on the screen, or any image, it means that there is a running program that displays this image. Do you want te replace the python process by some other program? RE: Exiting/killing a program with tkinter but leaving the graphic on the screen - DeaD_EyE - Apr-07-2019 Something like this? In this example I use just the stdout of the subprogramm, to set the label. For demonstration, it's called after 5s. gui.py import sys from tkinter import Tk, Button, Variable from subprocess import check_output from threading import Timer def make_gui(): root = Tk() text = Variable(root) text.set('Before') Button(root, textvariable=text).pack() Button(root, text='Exit', command=root.destroy).pack() return root, text def main(): root, text_var = make_gui() # with threadnig timer #timer = Timer(5, label, args=(text_var,)) #timer.start() # root.after root.after(5000, label, text_var) root.mainloop() def label(text_var): stdout = check_output([sys.executable, 'subprogram.py'], encoding='utf8') text_var.set(stdout) if __name__ == '__main__': sys.exit(main())subprogram.py #!/usr/bin/env python3 print('Hello Label') RE: Exiting/killing a program with tkinter but leaving the graphic on the screen - jpezz - Apr-07-2019 DeaD_EyE, No. I would want a python program like your button program (but I don't need active buttons) that when it was executed by another script, it would output the "Button" (or in my case a "label" then it would terminate or be terminated but leave the "button" (in my case, jut a label) behind even though the program that produced it is gone. Think of a program like xsetbg. If my python program called it as a subprocess, it would set the background then terminate but the background would not be "unset". Now, I don't want to set a background. I just want to create a label (with text or images or both or ..) then exit leaving that label sitting on the screen. |