Commit 9b7a4469 authored by nextime's avatar nextime

run_action in panel

parent fff8557b
......@@ -27,12 +27,16 @@ import threading
import logging
import subprocess
import queue
# Read configuration
config = configparser.ConfigParser()
config.read('shmcamstudio.conf')
qcore = queue.Queue()
builtins.qcore = qcore
builtins.config = config
# Setup logging
......
......@@ -121,10 +121,13 @@ color = teal
[BUTTON:3:scene_manual]
title = SCENE MANUAL
action = open_all
action = scene_manual
color = blue
[ACTION:scene_manual]
setstatus = manual
[ACTION:private_shine]
execute = /usr/local/bin/smblur_private
......
......@@ -19,8 +19,9 @@ import vlc
import webbrowser
import sys
import os
from utils import run_command
from utils import run_command, run_action
from guiutils import get_buttons
import queue
class VideoPlayer:
def __init__(self, master, video_url):
......@@ -102,11 +103,11 @@ def create_panel_gui():
command=None
if config.has_section('ACTION:'+buttons[row][b]['action']):
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']
print(command)
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')
col = col+1
......
......@@ -17,6 +17,8 @@ import subprocess
import socket
import os
import sys
import queue
def run_command(command):
try:
......@@ -29,6 +31,14 @@ def run_command(command):
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):
"""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