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.
-
- Posts: 1244
- Joined: Sat Nov 09, 2019 12:14 pm
Re: Open Lxterminal window in script?
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:
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.
If you need it to run a script (you mention raspbi-config), then you'd do:
Code: Select all
lxterminal -e raspi-config
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.
GitD's list of things that are not ready for prime time:
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth
Loves Linux; loves to dance.
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth
Loves Linux; loves to dance.
-
- Posts: 7442
- Joined: Sat Jan 12, 2013 3:01 am
- Location: Grants Pass, OR, USA
- Contact: Website
Re: Open Lxterminal window in script?
This is what I use (Python 3):
Code: Select all
subprocess.run(["lxterminal","-e","sudo", "raspi-config"])
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.
Re: Open Lxterminal window in script?
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?
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?
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.
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.