将Powershell代码打印到Tkinter GUI(Python)中

问题描述 投票:1回答:1

是否可以在Python中从Powershell打印代码。我目前拥有的代码只是将结果打印到Python终端中,而不是GUI中。如何将其打印到Tkinter GUI中?

Powershell代码:

Write-Output "[BIOS:config:Network:MACAdressPassThr]$status_mac"

Python代码:

def biossettings():
        p = subprocess.Popen(["powershell.exe", "C:\\Users\\zra01\\PycharmProjects\\py\\src"
                                                "\\center\\bios_settings.ps1"], stdout=sys.stdout)
        p.communicate()

    labelbios = Label(root, text=str(biossettings()))
python powershell tkinter communication
1个回答
0
投票
p = repr(subprocess.Popen(["powershell.exe", "C:\\Users\\zra01\\PycharmProjects\\py\\src"
                                                 "\\center\\bios_settings.ps1"],
                            stdout=subprocess.PIPE).communicate()[0])
labelbios = Label(root, text=p)
© www.soinside.com 2019 - 2024. All rights reserved.