Jump to content

Recommended Posts

Posted

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()

 

 

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines