Reputation: 1
Im using openbox to control a tkinter app. My app is t.py
and is located in ~
.
This is my ~/.config/openbox/autostart
:
python3 ~/t.py
This is t.py
:
import tkinter as tk
root = tk.Tk()
label = tk.Label(root, text="Hello")
label.pack()
root.mainloop()
When I run sudo startx
, I can see the cursor pop up then hide, but after that its just a black screen. I am running these commands over ssh as well. I had this working before with a separate .py
file but can no longer get it to work. I am running this on a Raspberry Pi Zero 2 W with a HDMI screen. The Pi is installed with the latest Raspberry Pi OS Lite.
Upvotes: 0
Views: 67
Reputation: 47085
Try using the following approach which does not depend on what window manager is used:
create a <anyname>.desktop
file inside ~/.config/autostart/
folder
e.g. ~/.config/autostart/demo.desktop
enter the following content inside the above file:
[Desktop Entry]
Type=Application
Exec=/bin/bash -c "/usr/bin/python3 $HOME/t.py"
The above works in my VM running Debian Bullseye with Raspberry Pi Desktop.
Upvotes: 0
Reputation: 26
As per the man page for openbox, you need to rename the startup script as autostart.sh
and also make it executable using
chmod +x ~/.config/openbox/autostart.sh
.
Finally, ensure you put an & sign at the end of the command.
python ~/t.py &
inside the autostart.sh
file.
Upvotes: 0