Ver Fonte

add: raylib RAY-DMX

micha há 11 meses atrás
pai
commit
199312ff9e
3 ficheiros alterados com 142 adições e 1 exclusões
  1. 29 0
      _LibreLightDesk.py
  2. 2 1
      install.sh
  3. 111 0
      tkray/dmx.py

+ 29 - 0
_LibreLightDesk.py

@@ -3064,6 +3064,7 @@ if __run_main:
     data.append({"text":"CLOCK"})
     data.append({"text":"SDL-DMX"})
     data.append({"text":"SDL-VPU"})
+    data.append({"text":"RAY-DMX"})
     data.append({"text":"---"})
     data.append({"text":"---"})
     data.append({"text":"---"})
@@ -3192,6 +3193,34 @@ if __run_main:
     cls = sdl_config #: None #GUI_CONF
     cb_ok = None
 
+    c = window_create_sdl_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
+    window_manager.new(None,name,wcb=c)
+    if libwin.split_window_show(pos_list,_filter=name):
+        window_manager.top(name)
+
+    # =======================================================================
+    #python3 /opt/LibreLight/Xdesk/vpu/watchdog_vpu.py -single
+    name="RAY-DMX"
+    def sdl_config():
+        cmd="nohup /usr/bin/python3 /opt/LibreLight/Xdesk/tksdl/config.py &"
+        cmd="/usr/bin/python3 /opt/LibreLight/Xdesk/tkray/dmx.py " #&"
+        print(cmd)
+        #os.popen(cmd)
+
+        def xyz123(cmd):
+            os.system(cmd)
+        thread.start_new_thread(xyz123,(cmd,))
+        return [None,None,None]
+    #class window_create_sdl_buffer():
+    args = {"title":name,"master":0,"width":W1,"height":H1,"left":L1,"top":TOP}
+    geo = libwin.split_window_position(pos_list,name)
+    if geo:
+        args.update(geo)
+
+    data = []
+    cls = sdl_config #: None #GUI_CONF
+    cb_ok = None
+
     c = window_create_sdl_buffer(args=args,cls=cls,data=data,cb_ok=cb_ok,gui=master,scroll=1)
     window_manager.new(None,name,wcb=c)
     if libwin.split_window_show(pos_list,_filter=name):

+ 2 - 1
install.sh

@@ -11,7 +11,7 @@ apt update
 
 echo ""
 echo "-- system tools"
-pkg="vim lm-sensors htop nmap tcpdump rsync git psmisc screen git gitk" 
+pkg="vim lm-sensors htop nmap tcpdump rsync git psmisc screen git gitk memtest86" 
 apt install -y $pkg 
 
 echo ""
@@ -60,6 +60,7 @@ pip install glnext
 pip install glcontext
 pip3 install pyopengltk
 pip install imutils
+pip install raylib
 EOF
 
 echo ""

+ 111 - 0
tkray/dmx.py

@@ -0,0 +1,111 @@
+from pyray import *
+init_window(800, 450, "RAY-DMX")
+
+import time
+
+import memcache
+mc = memcache.Client(['127.0.0.1:11211'], debug=0)
+
+
+#x=mc.get(k)
+
+old_x = 0
+old_y = 0
+
+while not window_should_close():
+    try:
+        y=mc.get("index")#cmd)
+        begin_drawing()
+        clear_background(BLACK)
+        GREY = [122,122,122,255]
+        p=0
+        keys = []
+        for k in y:
+            keys.append(k)
+        keys.sort()
+
+        k=keys[2]
+        xi=0
+        yi=0
+        for i,v in enumerate(range(20+1)):
+            txt=str(i+1)
+            draw_text(txt, 180+xi*30, 5+yi*13, 11, YELLOW)# VIOLET)
+            xi+=1
+            if xi % 20 == 0:
+                break
+        xi=0
+        yi=0
+
+        #draw_text(str(1), 170+xi*30, 5+yi*13, 11, YELLOW)# VIOLET)
+        for i,v in enumerate(mc.get(k)):
+            #print(i,v)
+            txt = str(i)+":"+str(v)
+            txt = str(v)
+            x2 = 180+xi*30
+            y2 =  25+yi*13
+
+            try:
+                draw_rectangle(x2-2, y2-2,24,13,[255,255,255,int(v)])
+            except:
+                draw_rectangle(x2-2, y2-2,24,13,[255,2,2,255])
+            try:
+                int(v)
+            except:
+                v=0
+            if int(v) > 100:
+                draw_text(txt, x2, y2, 11, BLACK)# VIOLET)
+            else:
+                draw_text(txt, x2, y2, 11, GREY)# VIOLET)
+            xi+=1
+
+            if xi % 20 == 0:
+                #for o in FontType:
+                #    print(o)
+                ##exit()
+                #draw_texture_pro(FontType.FONT_DEFAULT,"hi",[10,10],[0,0],0,10)
+                #draw_text_pro(font: Font, text: str, position: Vector2, origin: Vector2, rotation: float, fontSize: float, spacing: float, tint: Color)
+                draw_text(str(int(yi*20)+1), 170-30, y2, 11, YELLOW)# VIOLET)
+                xi = 0
+                yi += 1
+
+
+
+        draw_text(str(int(yi*20)+1), 170-30, y2, 11, YELLOW)# VIOLET)
+        p=0
+        for k in keys:
+            #print(k)
+            txt =":"+str(k) 
+            draw_text(txt, 10, 20+p, 20, GREY)# VIOLET)
+            p+=20
+
+        x=100
+        y=100
+        w=200
+        h=50
+        #draw_rectangle(x, y,w,h,[255,0,20,255])
+        x=200
+        y=200
+        #draw_rectangle_lines(x,y,w,h,[255,200,20,255])
+        #for i in  MouseButton:
+        #    if is_key_down(i):
+        #        print(i)
+        #for i in  range(0,512):
+        #    if is_key_down(i):
+        #        print(i)
+        #draw_text("Hello world", 190, 200, 20, VIOLET)
+        #Color(255,0,0,0)
+        m=get_mouse_position()
+        if m.x != old_x or m.y != old_y:
+            old_x = m.x
+            old_y = m.y
+            print(m.x,m.y)
+        end_drawing()
+        time.sleep(0.1)
+    except KeyboardInterrupt as e:
+        raise e
+    except Exception as e:# KeyInterupt
+        print("err",e)
+        time.sleep(1)
+        #raise e
+close_window()
+