robertoj Posted October 6 Posted October 6 Hello, I am having a lot of fun making my first apps with python and tkinter... and with my recent good experiences with LCD TFT displays, I want to create an "appliance" project. I can start non-GUI apps with systemctl service files, and they run with the proper user permissions... and I don't worry about giving it root access. But I would like to do the same with GUI apps. They would be full screen, 320x240 on the LCD TFT. All I can do now is: * start with armbian minimal (with orange pi zero in my case) * add the DTS for LCD and touch, and the ko for spi-gpio (as seen in my threads in the orangepi zero section) * install the bare minimum for X11: xorg, xorg-video-fbdev, xorg-input-evdev, python3-tk, openbox, xterm * create an auxiliary starter script: launch_my_app.sh #!/bin/sh openbox --startup 'python3 /home/roberto/tkinter_test/tktest.py' Then, I execute from within my python project folder, in an ssh session as my username DISPLAY=:0.0 sudo startx ./launch_my_app.sh Then my tkinter app runs, until I press ctrl-C in the ssh. But I feel that sudo is unnecessary and too much for a cybersecurity perspective. Is there a way to make it start automatically? (it would be ideal if xorg would exit if the window is closed) Sample python code. Credits: https://www.pythonguis.com/tutorials/create-gui-tkinter/ Spoiler from tkinter import * root = Tk() # create a root widget root.title("Tk Example") root.configure(background="yellow") root.minsize(100, 100) # width, height root.maxsize(320, 240) root.geometry("300x200+10+10") # width x height + x + y text = Label(root, text="Nothing will work unless you do.") text.pack() text2 = Label(root, text="- Maya Angelou") text2.pack() image = PhotoImage(file="/home/roberto/tkinter_test/pikachu.png") img = Label(root, image=image) img.pack() root.mainloop() 0 Quote
robertoj Posted October 16 Author Posted October 16 Interesting references: https://learn.sparkfun.com/tutorials/how-to-run-a-raspberry-pi-program-on-startup/all https://community.element14.com/products/raspberry-pi/f/forum/5609/launching-an-x11-app-exclusivly-on-startup-with-a-pi https://forums.raspberrypi.com/viewtopic.php?t=314455 https://forums.raspberrypi.com/viewtopic.php?t=353649 https://raspberrypi.stackexchange.com/questions/52099/using-openbox-to-autostart-gui-application-raspberry-pi-3 0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.