Use Tkinter to create GUI development tools (41) Nesting other application windows in Tkinter windows. In the
previous article, we introduced the design of really many sub-windows in Tkinter. If we want to add an external Toplevel sub-window, it can be nested into the main window. ? Of course you can use HP_mtk2.
We can even nest the cmd window and stock software into the main tkinter window.
The code is given directly below.
import tkinter as tk
import HP_mtk2 as hmtk
root = hmtk.MainWindows(picture='img/bj2.jpg')
root.geometry('800x600+200+100')
root.title('主窗口')
w1=root.newsubwin()
lb=tk.Label(w1,text='标签')
lb.pack(side=tk.TOP)
bt=tk.Button(w1,text='按钮')
bt.pack()
top=tk.Toplevel(root)
top.title('外部窗口1')
top.geometry('200x100+100+100')
root.update()
mywin=hmtk.mywindowid()
xw=mywin.findwin('外部窗口1')
mywin.set_parent(xw['hwnd'],root.myw)
xw2=mywin.findwin('cmd')
mywin.set_parent(xw2['hwnd'],root.myw)
xw3=mywin.findwin('Jupyter')
mywin.set_parent(xw3['hwnd'],root.myw)
xw4=mywin.findwin('大智慧')
mywin.set_parent(xw4['hwnd'],root.myw)
root.update()
root.mainloop()
Look at the results of the program execution as shown below.
Is the Tkinter GUI library included with Python very powerful?
#独狼荷蒲qq:2775205
#通通小白python quantitative group: 524949939
#电话微信:18578755056
#通通小白python quantitative group: 524949939
#tkinter,pyqt,gui,Python learning group: 647866213