Jan-05-2018, 03:28 PM
(This post was last modified: Jan-05-2018, 03:28 PM by Gribouillis.)
I think what may happen is that the lxterminal closes immediately after the program exits. You could try
Edit: Support added for holding the terminal if the program fails (with exception).
import argparse import subprocess import sys import traceback def main_work(args): print('Hello from term-example') def main(): parser = argparse.ArgumentParser() parser.add_argument( '--noterminal', help="don't start a new terminal'", action='store_true') ns = parser.parse_args() try: sys.stdout.fileno() except Exception: # not a terminal for sure if ns.noterminal: raise RuntimeError('Need a terminal to run.') else: subprocess.call(['lxterminal', '-e', '{} {} --noterminal'.format(sys.executable, __file__)]) else: try: main_work(ns) except Exception: if ns.noterminal: traceback.print_exc() input()# <---- this is to prevent the program to end and close the terminal else: raise else: if ns.noterminal: input() # <---- this is to prevent the program to end and close the terminal if __name__ == '__main__': main()Also you can try to run directly this command in a terminal to see if it says anything (this is not python):
lxterminal -e "python3 Calculator.py --noterminal"Edit: I installed lxterminal in my kubuntu system and the above code works!
Edit: Support added for holding the terminal if the program fails (with exception).