Commit 9b7a4469 authored by nextime's avatar nextime

run_action in panel

parent fff8557b
...@@ -27,12 +27,16 @@ import threading ...@@ -27,12 +27,16 @@ import threading
import logging import logging
import subprocess import subprocess
import queue
# Read configuration # Read configuration
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read('shmcamstudio.conf') config.read('shmcamstudio.conf')
qcore = queue.Queue()
builtins.qcore = qcore
builtins.config = config builtins.config = config
# Setup logging # Setup logging
......
...@@ -121,10 +121,13 @@ color = teal ...@@ -121,10 +121,13 @@ color = teal
[BUTTON:3:scene_manual] [BUTTON:3:scene_manual]
title = SCENE MANUAL title = SCENE MANUAL
action = open_all action = scene_manual
color = blue color = blue
[ACTION:scene_manual]
setstatus = manual
[ACTION:private_shine] [ACTION:private_shine]
execute = /usr/local/bin/smblur_private execute = /usr/local/bin/smblur_private
......
...@@ -19,8 +19,9 @@ import vlc ...@@ -19,8 +19,9 @@ import vlc
import webbrowser import webbrowser
import sys import sys
import os import os
from utils import run_command from utils import run_command, run_action
from guiutils import get_buttons from guiutils import get_buttons
import queue
class VideoPlayer: class VideoPlayer:
def __init__(self, master, video_url): def __init__(self, master, video_url):
...@@ -102,11 +103,11 @@ def create_panel_gui(): ...@@ -102,11 +103,11 @@ def create_panel_gui():
command=None command=None
if config.has_section('ACTION:'+buttons[row][b]['action']): if config.has_section('ACTION:'+buttons[row][b]['action']):
command=config.get('ACTION:'+buttons[row][b]['action'], 'execute', fallback=None) command=config.get('ACTION:'+buttons[row][b]['action'], 'execute', fallback=None)
setstatus=config.get('ACTION:'+buttons[row][b]['action'], 'setstatus', fallback=None)
color=buttons[row][b]['color'] color=buttons[row][b]['color']
print(command)
button = tk.Button(bframes[row], text=buttons[row][b]['title'], font=helv36, width=bw, height=bh, bg=color, fg="white", button = tk.Button(bframes[row], text=buttons[row][b]['title'], font=helv36, width=bw, height=bh, bg=color, fg="white",
command=lambda cmd=command: run_command(cmd)) command=lambda cmd=command,sts=setstatus: run_action(cmd,sts))
button.grid(row=0, column=col, sticky='nsew') button.grid(row=0, column=col, sticky='nsew')
col = col+1 col = col+1
......
...@@ -17,6 +17,8 @@ import subprocess ...@@ -17,6 +17,8 @@ import subprocess
import socket import socket
import os import os
import sys import sys
import queue
def run_command(command): def run_command(command):
try: try:
...@@ -29,6 +31,14 @@ def run_command(command): ...@@ -29,6 +31,14 @@ def run_command(command):
return f"Error: {e}" return f"Error: {e}"
def run_action(command, setstatus=None):
if setstatus:
print('SETSTATUS:'+str(setstatus))
qcore.put('SETSTATUS:'+str(setstatus))
if command:
return run_command(command)
def check_port_available(port): def check_port_available(port):
"""Check if a port is available""" """Check if a port is available"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment