When executing a tool made with python, there is no problem if you call it from the command line if you made it yourself, but if it is a tool used by people who are not related to development, it is better to be able to operate it from the screen It's convenient. I researched various things to see if I could make an application with python and summarized the contents I made. It's still not very well made, so I plan to adjust it gradually.
It is published on github. https://github.com/snowpff14/etcresource/tree/master/pythonGui
Script for operating selenium practice site see here, script for adding columns and deleting rows in Excel file [see here](https: // qiita.com/snowp/items/94f8bb06a08e42af6bba) can now be started.
StringVar () as shown below.
    inputFolder=StringVar()
    outputFolder=StringVar()
    def openFile(self):
        fTyp = [('','*.xlsx')]
        iDir = os.path.abspath(os.path.dirname(__file__))
        filename = filedialog.askopenfilename(filetypes = fTyp,initialdir = iDir)
        return filename
    def fileButton(self):
       filename= self.openFile()
       self.inputFileName.set(filename)
doExecute.
    def doExecute(self):
        # threading.Lock
        thread=threading.Thread(target=self.execute)
        thread.start()
    def execute(self):
        excelFile=pd.ExcelFile(self.inputFileName.get())
        reserveSheetTemp=excelFile.parse(sheet_name='Reservation sheet',dtype='str',header=1)
        print(reserveSheetTemp.head())
        log=LoggerObj()
        driver=webdriver.Chrome('C:/webdrivers/chromedriver.exe')
        driver.get('http://example.selenium.jp/reserveApp/')
        reserveSheet=reserveSheetTemp.query('Invalid flag!= "1"')
        testSideOrder=TestSiteOrder(driver,log,'test')
        #Enter working hours
        testSideOrder.inputOrder(reserveSheet)
        testSideOrder.createOkDialog('Processing completed','登録Processing completed')
tkinter.TK () as shown below.root= tkinter.Tk()
    def main(self):
        root.title("Python GUI")
        content = ttk.Frame(root)
        frame = ttk.Frame(content,  relief="sunken", width=400, height=500)
StringVar using text variable.command.mainloop ().        content.grid(column=0, row=0)
        title.grid(column=0, row=0, columnspan=4)
        fileLabel=ttk.Label(content,text="Reservation information")
        resultFolderLabel=ttk.Label(content,text="Folder specification")
        fileInput=ttk.Entry(content,textvariable=self.inputFileName,width=70)
        resultFolderInput=ttk.Entry(content,textvariable=self.outputFolder,width=70)
        self.progressMsgBox=ttk.Label(content,textvariable=self.progressMsg,width=70)
        self.progressBar=ttk.Progressbar(content,orient=HORIZONTAL,length=140,mode='indeterminate')
        self.progressBar.configure(maximum=10,value=0)
        fileInputButton=ttk.Button(content, text=BUTTON_LABEL_REFERENCE,command=self.fileButton)
        resultDirectoryInputButton=ttk.Button(content, text=BUTTON_LABEL_REFERENCE,command=self.inputResultFolderButton)
         
        executeButton=ttk.Button(content,text='Run',command=self.doExecute)
        fileExecuteButton1=ttk.Button(content,text='File operation Insert execution',command=self.fileInsert)
        fileExecuteButton2=ttk.Button(content,text='File operation delete execution',command=self.fileDelete)
        root.mainloop()
When you start it, the following screen will be displayed.

For the time being, this time around Continued created
Recommended Posts