Parcourir la source

add: raylib resizewindow, add: autostart tkray/...

micha il y a 5 mois
Parent
commit
fe929e2dcd
2 fichiers modifiés avec 39 ajouts et 28 suppressions
  1. 33 28
      tkray/dmx.py
  2. 6 0
      tool/movewin.py

+ 33 - 28
tkray/dmx.py

@@ -1,5 +1,7 @@
 #from pyray import *
 import pyray 
+#import ralib_sdl as pyray
+#import raylib as pyray
 import sys
 sys.path.insert(0,"/opt/LibreLight/Xdesk/")
 #for i in dir(pyray):
@@ -8,8 +10,10 @@ sys.path.insert(0,"/opt/LibreLight/Xdesk/")
 
 #exit()
 #pyray.ConfigFlags(pyray.FLAG_MSAA_4X_HINT) #|pyray.FLAG_WINDOW_RESIZABLE  )
-#pyray.ConfigFlags(pyray.FLAG_WINDOW_RESIZABLE  )
-#pyray.ConfigFlags(pyray.FLAG_WINDOW_HIGHDPI )
+pyray.ConfigFlags(pyray.FLAG_WINDOW_RESIZABLE  )
+pyray.set_config_flags(pyray.FLAG_WINDOW_HIGHDPI )
+pyray.set_config_flags(pyray.FLAG_MSAA_4X_HINT)
+pyray.set_config_flags(pyray.FLAG_WINDOW_RESIZABLE)
 
 
 CAPTION = 'RAY-DMX'
@@ -25,11 +29,17 @@ win_title =CAPTION.strip().split()[-1]
 store = movewin.load_all_sdl(win_title)
 print(store)
 POS=[10,10]
+W=760
+H=450
 if store:
     POS=[store[-2],store[-1]]
+    POS[0] += 5   #frame kompensation
+    POS[1] += 29  #frame kompensation
+    print(store)
+    W=int(store[-4])
+    H=int(store[-3])
 
-
-pyray.init_window(760, 450, CAPTION) #"RAY-DMX")#,10,10,10,10)
+pyray.init_window(W, H, CAPTION) #"RAY-DMX")#,10,10,10,10)
 #pyray.TextureFilter(font10,1)
 
 
@@ -62,16 +72,11 @@ start = time.time()
 frame_count = 0
 fps_count = 0
 
-#a = "resources/pixantiqua.ttf"
-#a = "/lib/firefox-esr/fonts/TwemojiMozilla.ttf"
-#a = "/lib/python3/dist-packages/pygame/freesansbold.ttf"
 #a = "/usr/share/fonts/truetype/freefont/FreeMono.ttf"
 #a = "/usr/share/fonts/truetype/freefont/FreeSerif.ttf"
-#a = "/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf"
-a = "/usr/share/fonts/truetype/freefont/FreeSans.ttf"
-a = "/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf"
-a = "/usr/share/fonts/truetype/freefont/FreeSansBold.ttf"
 #a = "/usr/share/fonts/truetype/freefont/FreeSans.ttf"
+#a = "/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf"
+#a = "/usr/share/fonts/truetype/freefont/FreeSansBold.ttf"
 
 
 k=200
@@ -197,7 +202,7 @@ def draw_mouse_box(window,pos1,mouse=[None,None,None],color=[128,128,128],text=1
             pyray.draw_text_ex(font10l,str(pos2[0])+" "+str(pos2[1]), [pos2[0]+5,pos2[1]+10], font_size, 0, pyray.WHITE)
             pyray.draw_text_ex(font10l,str(w), [pos2[0]+5+w/2*wd,pos2[1]], font_size, 0, pyray.WHITE)
             pyray.draw_text_ex(font10l,str(h), [pos2[0]+5,pos2[1]+h/2*hd], font_size, 0, pyray.WHITE)
-            return pos1,pos2
+            return pos1,pos2,[pos1[0]-pos2[0],pos1[1]-pos2[1]]
 
 mouse_old=[None,None,None]
 
@@ -234,16 +239,17 @@ def render_spectrum(cur,x,y):
         spectrum.pop(0)
 
     for i,lines in enumerate(spectrum):
-        for j,pix in enumerate(lines):
-            if type(pix) is not int:
-                pix=0
-            if pix > 255:
-                pix=255
-            if pix < 0:
-                pix=0
-            c=[255,255,255,pix]
-            #pyray.draw_pixel(x+j,y+i*6,c)
-            pyray.draw_line(x+j,y+i*6,x+j,y+i*6-5,c)
+        if lines:
+            for j,pix in enumerate(lines):
+                if type(pix) is not int:
+                    pix=0
+                if pix > 255:
+                    pix=255
+                if pix < 0:
+                    pix=0
+                c=[255,255,255,pix]
+                #pyray.draw_pixel(x+j,y+i*6,c)
+                pyray.draw_line(x+j,y+i*6,x+j,y+i*6-5,c)
 
 
 def render_grid(cur,x,y):
@@ -337,6 +343,9 @@ while not pyray.window_should_close():
 
         if cur is None:
             cur = k #k[3] #"xx123" # k
+        if cur not in host_list:
+            if host_list:
+                cur = keys[0] #host_list[0]
 
         if spectrum_btn.btn.btn1.val.get():
             render_spectrum(cur,230,50)
@@ -414,18 +423,14 @@ while not pyray.window_should_close():
             
         for k,btn in buttons.items():
             btn.event(old_x,old_y,mouse_old)
-            #if "press" == mouse_old[0]:
             if "release" == mouse_old[0]:
                 btn.button = 1
-                #if check_area(btn.btn.pos,[old_x,old_y]):#event_pos):
                 if check_area(btn.btn.pos,[old_y,old_x]):#event_pos):
-                    #print(k,btn.btn.pos)
-                    #btn.btn.btn1.val.set(255)
-                    #cur = k
-                    cur = k # btn.btn.btn1.name
+                    cur = k
             btn.draw()
             aapos = draw_mouse_box(None,[old_x,old_y],mouse_old,color=[128,128,128],text=1)
 
+
         
         pyray.draw_text_ex(font20,"POS:{}:{}".format(int(m.x),int(m.y)),[10,34], 20, 0,  pyray.VIOLET)
 

+ 6 - 0
tool/movewin.py

@@ -225,6 +225,8 @@ def startup_all_sdl():
             continue
 
         cmd = "python3 /opt/LibreLight/Xdesk/tksdl/{}"
+        if "RAY" in line[1]:
+            cmd = "python3 /opt/LibreLight/Xdesk/tkray/{}"
         if "--easy" in sys.argv:
             if line[1] == "EXEC-BTN":
                 cmd = "python3 /opt/LibreLight/Xdesk/tkgui/{}"
@@ -240,6 +242,10 @@ def startup_all_sdl():
                 cmd=cmd.format("dmx.py")
                 #os.popen(cmd)
                 start_sub(cmd,"SDL-DMX",mute=1)
+            elif line[1] == "RAY-DMX":
+                cmd=cmd.format("dmx.py")
+                #r=os.popen(cmd)
+                start_sub(cmd,"RAY-DMX",mute=1)
             elif line[1] == "SDL-FIX-LIST":
                 cmd=cmd.format("fix.py")
                 #r=os.popen(cmd)