pythontkinteromxplayer

Make tkinter GUI window on top over omxplayer HDMI video screen


I have a project of IOT where i am using python-3.6 on raspberry pi zero and tkinter for GUI.

Pi is always playing video on a TV with direct HDMI (omxplayer).

Problem: I need to open a tkinter GUI window to connect wifi but GUI display index is below than the omxplayer screen.

What i want I want to display GUI on top over omxplayer screen to connect wi-fi.

I have tried:

1 root.wm_attributes("-topmost", 1) 
  #Not working wm is not defined

2 root.overridedirect(1)
  root.wm_attributes("-topmost", 1)
  #Window is jumping on top of every other applications but not over omxplayer.

3 root.attributes("-topmost", 1)
  #Window is jumping on top of every other applications but not over omxplayer.

4 root.lift()
  #Not working

Solution

  • I got a solution although its not a valid solution.

    What i did ?

    Instead of making tkinter GUI on top i just bind hot key ctrl+j to hide omxplayer screen and ctrl+k to show screen.

    from omxplayer.player import OMXPlayer
    import omxplayer.keys
    import codecs
    from pynput import keyboard
    import threading
    
    xpress = False
    
    # The key combination to check
    COMBINATIONS = [
        {keyboard.Key.ctrl, keyboard.KeyCode(char='j')},
        {keyboard.Key.ctrl, keyboard.KeyCode(char='J')},
        {keyboard.Key.ctrl, keyboard.KeyCode(char='k')},
        {keyboard.Key.ctrl, keyboard.KeyCode(char='K')}
    ]
    
    # The currently active modifiers
    current = set()
    
    def execute(key):
        keys = str(key).replace("'", "")
        print ("Do Something", keys)
    
        if keys == 'j':
            global xpress
            xpress = True
            print(xpress)
        else:
            xpress = False
            print(xpress)
    
    def on_press(key):
        if any([key in COMBO for COMBO in COMBINATIONS]):
            current.add(key)
            if any(all(k in current for k in COMBO) for COMBO in COMBINATIONS):
                execute(key)
    
    def on_release(key):
        if any([key in COMBO for COMBO in COMBINATIONS]):
            current.remove(key)
    
    def ThKeyboad():
        with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
            listener.join()
    
    
    t1 = threading.Thread(target=ThKeyboad, args=[])
    t1.start()
    
    #OMXPlayer Code
    
    player = OMXPlayer('/home/pi/outhum/video/default.mp4', dbus_name='org.mpris.MediaPlayer2.omxplayer2')
    
    if xpress:
        player.hide_video()
    else:
        player.show_video()
    a = player.duration()
    time.sleep(a)
    player.quit()