Browse Source

fix: check_rgb, fix: if no dmx

micha 1 year ago
parent
commit
5a45d10679
2 changed files with 26 additions and 10 deletions
  1. 11 10
      tksdl/fix.py
  2. 15 0
      tool/sdl_elm.py

+ 11 - 10
tksdl/fix.py

@@ -137,16 +137,17 @@ def read_dmx():
     dmx = {} #univ
     iii = 0
     y=mc.get("index")
-    key=y.keys()
-    key = list(key)
-    key.sort()
-
-    for k in key:
-        if k.startswith("ltp-out"):
-            #v = y[k]
-            u = k.split(":")[-1]
-            x=mc.get(k)
-            dmx[u] = x
+    if y:
+        key=y.keys()
+        key = list(key)
+        key.sort()
+
+        for k in key:
+            if k.startswith("ltp-out"):
+                #v = y[k]
+                u = k.split(":")[-1]
+                x=mc.get(k)
+                dmx[u] = x
     return dmx
             
 def read_fix(dmx):

+ 15 - 0
tool/sdl_elm.py

@@ -14,6 +14,20 @@ font15 = pygame.font.SysFont("freemonobold",15)
 font22 = pygame.font.SysFont("FreeSans",22)
 #font = pygame.font.SysFont(None,30)
 
+def check_rgb(rgb):
+    rgb_out = [127,127,127,127]
+    try:    
+        for i,v in enumerate(rgb):
+            if v > 255:
+                v = 255
+            if v < 0:
+                v = 0
+            rgb_out[i] = v
+
+    except Exception as e:
+        print("rgb exception ",e)
+
+    return rgb_out
 
 class VALUE():
     def __init__(self,v=0,_min=0,_max=255):
@@ -332,6 +346,7 @@ class Button():
         pos = self.pos
 
         rgb = self.btn1.get_color()
+        rgb = check_rgb(rgb)
         pygame.draw.rect(self.window,rgb,pos)
 
     def _draw_fader(self):