Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
450 views
in Technique[技术] by (71.8m points)

linux - embedding external app into frame Tkinter

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...