I'm trying to embed external into tkinter frame on LINUX.
I've already achieved a solution for Windows10 but I can't use win32gui on Linux :
import subprocess
from subprocess import Popen, CREATE_NEW_CONSOLE
import pygetwindow as gw
import win32gui
import regex as re
import time
from tkinter import *
def my_proc():
file = "Notepad.exe"
proc = subprocess.Popen(["%s" % file])
time.sleep(1) # make sure the window has been started and available to find.
pid = gw.getWindowsWithTitle('Sans titrexa0- Bloc-notes') # getting the hwnd window
hwnd = re.findall(r'd+', str(pid))
print(hwnd)
x = 0 # widget is the target tkinter frame
y = 0
width = 800
height = 500
stream_id = frame.winfo_id()
win32gui.SetParent(int(hwnd[-1]), int(stream_id))
win32gui.MoveWindow(int(hwnd[-1]), int(x), int(y), int(width), int(height),
1) # trying to move the window to the widget geometry
root = Tk()
root.geometry("1000x1000")
root.title("Coucou")
frame = Frame(root, width=800, height=800, bg="red")
frame.pack()
root.after(100, my_proc)
root.mainloop()
I've tried with xdotool calling Popen : xdotool windowreparent [source_window] destination_window
My source just disappears. Have you some ideas ? Maybe with another Windows Manager ?
Cheers
question from:
https://stackoverflow.com/questions/65904558/embedding-external-app-into-frame-tkinter 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…