mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-09-19 12:10:33 +02:00
Merge pull request #645 from frennkie/enable-touch
Enable touch using Python tkinter
This commit is contained in:
@@ -564,7 +564,8 @@ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2
|
||||
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1
|
||||
echo "to switch between python2/3: sudo update-alternatives --config python"
|
||||
sudo apt-get -f -y install virtualenv
|
||||
sudo -u admin bash -c "cd; sudo virtualenv python-env-lnd; source /home/admin/python-env-lnd/bin/activate; sudo pip install grpcio grpcio-tools googleapis-common-protos pathlib2"
|
||||
sudo chown -R admin /home/admin
|
||||
sudo -u admin bash -c "cd; virtualenv python-env-lnd; source /home/admin/python-env-lnd/bin/activate; pip install grpcio grpcio-tools googleapis-common-protos pathlib2"
|
||||
echo ""
|
||||
|
||||
# "*** Installing Go ***"
|
||||
|
142
home.admin/00infoLCDTK.py
Normal file
142
home.admin/00infoLCDTK.py
Normal file
@@ -0,0 +1,142 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# 00infoLCDTK.py
|
||||
#
|
||||
# called by #
|
||||
# /home/pi/autostart.sh
|
||||
# dev/test/run with:
|
||||
# sudo -i -u pi DISPLAY=:0.0 /usr/bin/python3 /home/admin/00infoLCDTK.py
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import logging
|
||||
import logging.config
|
||||
import tkinter as tk
|
||||
|
||||
COLOR = "black"
|
||||
WINFO = None
|
||||
|
||||
log = logging.getLogger()
|
||||
|
||||
|
||||
def setup_logging(default_path='00infoLCDw.json'):
|
||||
"""Setup logging configuration"""
|
||||
path = default_path
|
||||
if os.path.exists(path):
|
||||
with open(path, 'rt') as f:
|
||||
config = json.load(f)
|
||||
logging.config.dictConfig(config)
|
||||
else: # if $default_path does not exist use the following default log setup
|
||||
default_config_as_json = """
|
||||
{
|
||||
"version": 1,
|
||||
"disable_existing_loggers": false,
|
||||
"formatters": {
|
||||
"simple": {
|
||||
"format": "%(asctime)s - %(levelname)s - %(message)s"
|
||||
},
|
||||
"extended": {
|
||||
"format": "%(asctime)s - %(name)s - %(levelname)s - %(module)s:%(lineno)d - %(message)s"
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"handlers": {
|
||||
"console": {
|
||||
"class": "logging.StreamHandler",
|
||||
"level": "INFO",
|
||||
"formatter": "simple",
|
||||
"stream": "ext://sys.stdout"
|
||||
},
|
||||
|
||||
"file_handler": {
|
||||
"class": "logging.handlers.RotatingFileHandler",
|
||||
"level": "DEBUG",
|
||||
"formatter": "extended",
|
||||
"filename": "00infoLCDTK.log",
|
||||
"maxBytes": 10485760,
|
||||
"backupCount": 0,
|
||||
"encoding": "utf8"
|
||||
}
|
||||
},
|
||||
|
||||
"loggers": {
|
||||
"infoblitz": {
|
||||
"level": "INFO",
|
||||
"handlers": ["console", "file_handler"],
|
||||
"propagate": "no"
|
||||
}
|
||||
},
|
||||
|
||||
"root": {
|
||||
"level": "INFO",
|
||||
"handlers": ["console", "file_handler"]
|
||||
}
|
||||
}
|
||||
"""
|
||||
config = json.loads(default_config_as_json)
|
||||
logging.config.dictConfig(config)
|
||||
|
||||
|
||||
def callback_b1():
|
||||
global WINFO
|
||||
log.info("clicked b1")
|
||||
if sys.platform != "win32":
|
||||
os.system("xterm -fn fixed -into %d +sb -hold /home/admin/00infoLCD.sh &" % WINFO)
|
||||
|
||||
|
||||
def callback_b2():
|
||||
global WINFO
|
||||
log.info("clicked b2")
|
||||
if sys.platform != "win32":
|
||||
os.system("xterm -fn fixed -into %d +sb -hold /home/admin/XXbutton2.sh &" % WINFO)
|
||||
|
||||
|
||||
def callback_b4():
|
||||
global WINFO
|
||||
log.info("clicked b4")
|
||||
if sys.platform != "win32":
|
||||
os.system("xterm -fn fixed -into %d +sb -hold /home/admin/XXshutdown.sh &" % WINFO)
|
||||
|
||||
|
||||
def main():
|
||||
global WINFO
|
||||
setup_logging()
|
||||
log.info("Starting 00infoLCDTK.py")
|
||||
|
||||
root = tk.Tk()
|
||||
root.config(bg=COLOR)
|
||||
root.overrideredirect(1)
|
||||
root.geometry("480x320+0+0")
|
||||
root.title("RaspiBlitz 1.x")
|
||||
|
||||
entry = tk.Entry(root)
|
||||
entry.config(bg=COLOR, highlightbackground=COLOR)
|
||||
|
||||
frame1 = tk.Frame(entry, width=60, background="black")
|
||||
frame2 = tk.Frame(entry, width=420, background="grey")
|
||||
|
||||
button1 = tk.Button(frame1, text='\u0397', fg='black', command=callback_b1)
|
||||
button2 = tk.Button(frame1, text='\u0399', fg='black', command=callback_b2)
|
||||
label3 = tk.Label(frame1, text='1.x', bg=COLOR, fg='white')
|
||||
button4 = tk.Button(frame1, text='\N{BLACK CIRCLE}', fg='red', command=callback_b4)
|
||||
|
||||
button1.pack(pady=24)
|
||||
button2.pack(pady=24)
|
||||
label3.pack(pady=24)
|
||||
button4.pack(pady=24)
|
||||
|
||||
entry.pack(side="bottom", fill="x")
|
||||
frame1.pack(side="left", fill="both", expand=True)
|
||||
frame2.pack(side="right", fill="both", expand=True)
|
||||
|
||||
WINFO = frame2.winfo_id()
|
||||
if sys.platform != "win32":
|
||||
os.system("xterm -fn fixed -into %d +sb -hold /home/admin/00infoLCD.sh &" % WINFO)
|
||||
|
||||
root.mainloop()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
11
home.admin/XXbutton2.sh
Executable file
11
home.admin/XXbutton2.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo ""
|
||||
echo "Thanks"
|
||||
echo "You pressed B2"
|
||||
echo "-----------------------------------------------"
|
||||
echo "Sleep for 10"
|
||||
sleep 10
|
||||
echo "Goodbye"
|
||||
echo "-----------------------------------------------"
|
||||
exit 0
|
28
home.admin/XXreboot.sh
Executable file
28
home.admin/XXreboot.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# CONFIGFILE - configuration of RaspiBlitz
|
||||
configFile="/mnt/hdd/raspiblitz.conf"
|
||||
|
||||
# INFOFILE - state data from bootstrap
|
||||
infoFile="/home/admin/raspiblitz.info"
|
||||
|
||||
# MAIN MENU AFTER SETUP
|
||||
source ${infoFile}
|
||||
source ${configFile}
|
||||
|
||||
echo ""
|
||||
echo "LCD turns white when shutdown complete."
|
||||
echo "Then wait 5 seconds and disconnect power."
|
||||
echo "-----------------------------------------------"
|
||||
echo "stop lnd - please wait .."
|
||||
sudo systemctl stop lnd
|
||||
echo "stop ${network}d (1) - please wait .."
|
||||
sudo -u bitcoin ${network}-cli stop
|
||||
sleep 10
|
||||
echo "stop ${network}d (2) - please wait .."
|
||||
sudo systemctl stop ${network}d
|
||||
sleep 3
|
||||
sync
|
||||
echo "starting shutdown ..."
|
||||
sudo shutdown -r now
|
||||
exit 0
|
30
home.admin/XXshutdown.sh
Executable file
30
home.admin/XXshutdown.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
# CONFIGFILE - configuration of RaspiBlitz
|
||||
configFile="/mnt/hdd/raspiblitz.conf"
|
||||
|
||||
# INFOFILE - state data from bootstrap
|
||||
infoFile="/home/admin/raspiblitz.info"
|
||||
|
||||
# MAIN MENU AFTER SETUP
|
||||
source ${infoFile}
|
||||
source ${configFile}
|
||||
|
||||
network=bitcoin
|
||||
|
||||
echo ""
|
||||
echo "LCD turns white when shutdown complete."
|
||||
echo "Then wait 5 seconds and disconnect power."
|
||||
echo "-----------------------------------------------"
|
||||
echo "stop lnd - please wait .."
|
||||
sudo systemctl stop lnd
|
||||
echo "stop ${network}d (1) - please wait .."
|
||||
sudo -u bitcoin ${network}-cli stop
|
||||
sleep 10
|
||||
echo "stop ${network}d (2) - please wait .."
|
||||
sudo systemctl stop ${network}d
|
||||
sleep 3
|
||||
sync
|
||||
echo "starting shutdown ..."
|
||||
sudo shutdown -h now
|
||||
exit 0
|
Reference in New Issue
Block a user