1

Is it possible to print code from Powershell in Python. The code I have at the moment just prints the result into the Python terminal and not into the GUI. How can I print it into the Tkinter GUI?

Powershell code:

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

Python code:

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()))

edit:

This works more or less:

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)
Joel S.
  • 64
  • 7
  • You probably just need `info, error = p.communicate()`, then add `return info`. For 2.7+ see https://stackoverflow.com/a/35857912/4777984 – tgikal Nov 25 '19 at 14:15

0 Answers0