Page 1 of 1

Open Lxterminal window in script?

Posted: Mon Nov 16, 2020 7:14 pm
by mmkw43
Friends --
Probably asking the impossible (I'm good at that) but is there any way to open the Lxterminal window in a script? I need to have it open to display raspi-config.

Have tried all sorts of things with subprocess.call -- even tried root.bind for the ctl-alt-t keys etc etc. Perhaps I'm asking the impossible? many thanks.

Re: Open Lxterminal window in script?

Posted: Mon Nov 16, 2020 7:27 pm
by GlowInTheDark
The obvious answer is "Yes". Just run it (using whatever syntax "Python" uses to run external programs).

If you need it to run a script (you mention raspbi-config), then you'd do:

Code: Select all

lxterminal -e raspi-config
So, the obvious question then becomes: What have you tried? In what ways has it not met your expectations?

The next question is: Why can't you just run it directly inline with your Python program? Why does it have to run in a separate terminal?

Finally, I'm sorta guessing that what's really going on here is that you want the Python program to wait for the lxterminal to finish - and that's a problem. lxterminal, unlike most other X terminals applications, has a client/server architecture, where when you run lxterminal, it doesn't actually run as a normal process, but rather just sends a message to the master lxterminal to open up another window. This makes it impossible to know when that terminal window gets closed.

To get around this problem, I would suggest installing and using either xterm or rxvt, since they behave more "normally". I generally use rxvt for most such tasks.

Re: Open Lxterminal window in script?

Posted: Mon Nov 16, 2020 7:35 pm
by klricks
This is what I use (Python 3):

Code: Select all

subprocess.run(["lxterminal","-e","sudo", "raspi-config"])

Re: Open Lxterminal window in script?

Posted: Mon Nov 16, 2020 8:59 pm
by mmkw43
Thanks, this works fine --

subprocess.run(["lxterminal","-e","sudo", "raspi-config"])

had to use "call" instead. and now like you say, how do I get rid of the window.
which from what I just read, is pretty much impossible.

anyway, thanks.
amateur question, what does the '-e' do?

Re: Open Lxterminal window in script?

Posted: Mon Nov 16, 2020 9:08 pm
by mmkw43
SWEET !

Actually when you go through the process in raspi-config for localization and click finish, it closes the window.

! -- thanks much.


actually, my mistake was not creating a list in subprocess -- my bad -- I've always just done one command. from now on, step 1 is to go back and READ the python documentation.