python实现的php -r 可视化界面

from tkinter import *
import os

class PHP(object):
    """docstring for PHP"""
    def __init__(self,phpPath):
        super(PHP, self).__init__()
        self.phpPath = phpPath
        master = Tk()
        master.geometry('500x400')
        self.Input = Text(master)
        self.Input.pack()
        self.Btn = Button(master, text="OK", command=self.run)
        self.Btn.pack()
        mainloop()
    def run(self):
        code = self.Input.get("0.0", "end")
        self.code = code.replace('\n','').replace('"','\\"')
        self.cmd = self.phpPath + " -r \"" + self.code + "\""
        print(self.cmd)
        rt = os.popen(self.cmd)
        print(rt.read())

        
#phpPath为php可执行程序的路径
phpPath = "D:\\phpStudy\\PHPTutorial\\php\\php-5.4.45\\php.exe"
php = PHP(phpPath)

 

posted @ 2019-03-27 16:34  NAVYSUMMER  阅读(178)  评论(0)    收藏  举报
交流群 编程书籍