Python GUI -- Tkinter practice, pythongui -- tkinter
Previously I wrote the Testlink Automatic Execution program. Now I want to use Tkinter and GUI to try it out.
You can select the url to be executed and the report url to automatically execute the use case, or you can directly write the report result content.
Only some code functions are listed for project reasons.
From Tkinter import * from SimpleDialog import * from tkFileDialog import askopenfilenameroot = Tk () root. title ("automatically executed by TestLink") root. resizable (False, False) # Make the window not zoom in or out, and add the variable '''addvar = StringVar () vv. set ('executed test report: ') v = StringVar () ''' add label and text ''' urladdress = Label (root, text = 'testlink address: ') urladdress. grid (row = 0, sticky = W) address = Entry (root, text = 'input you text here ', textvariable = addvar) address. grid (row = 0, column = 1, sticky = E) user = Label (root, text = 'login Username: ') user. grid (row = 1, sticky = W) usertext = Entry (root, text = 'input you user here ') usertext. grid (row = 1, column = 1, sticky = E) Label (root, text = 'login password :'). grid (row = 2, sticky = W) password = Entry (root, text = 'input you passowrd here ') password. grid (row = 2, column = 1, sticky = E) Label (root, text = 'test project Keyword :'). grid (row = 3, sticky = W) testproject = Entry (root, text = 'input you testprojectid here ') testproject. grid (row = 3, column = 1, sticky = E) Label (root, text = 'test plan Keyword :'). grid (row = 4, sticky = W) testplan = Entry (root, text = 'input you testplanid here ') testplan. grid (row = 4, column = 1, sticky = E) planurl = StringVar () Label (root, text = 'test plan to be executed :'). grid (row = 5, sticky = W) testplanurl = Entry (root, text = 'input you testplanurl here ', textvariable = planurl) testplanurl. grid (row = 5, column = 1, sticky = E) choseplan = Button (root, text = 'select') choseplan. grid (row = 5, column = 1, sticky = E) reporturl = StringVar () report = Label (root, textvariable = vv, text = "completed test report: ") report. grid (row = 6, sticky = W) reportentry = Entry (root, textvariable = reporturl) reportentry. grid (row = 6, column = 1, sticky = E) chosereport = Button (root, text = 'select') chosereport. grid (row = 6, column = 1, sticky = E) addvar. set ('HTTP: // 192.168.3.247: 8080/testlink/login. php ') def planopen (event): global filename = askopenfilename () if filename = "": filename = None else: root. title ("xxxx" + OS. path. basename (filename) pathdir = OS. path. abspath (filename) if "http: //" not in pathdir: pathdir = "file: //" + pathdir planurl. set (pathdir) def reportopen (event): global filename = askopenfilename () try: if filename = "": filename = None else: root. title ("xxxx" + OS. path. basename (filename) pathdir = OS. path. abspath (filename) if "http: //" not in pathdir: pathdir = "file: //" + pathdir reporturl. set (pathdir) # return OS. path. abspath (filename) failed t Exception, e: print echoseplan. bind ("<Button-1>", planopen) chosereport. bind ("<Button-1>", reportopen) start = Button (root, text = 'start') stop = Button (root, text = 'stop ') chose = Checkbutton (root, text = 'write result through report', variable = v, command = callCheckbutton, onvalue = "executed test report :", offvalue = "Write result directly:") # b2.bind ("<Return>", cb2) # establishes the relationship between the event and the response function. Every time a Return event is generated, the program calls cb2start. grid (row = 7) stop. grid (row = 7, sticky = E) chose. grid (row = 7, sticky = E, column = 1) start. bind ('<Button-1>', printc) stop. bind ("<Button-1>", execut) var = StringVar () lb2 = Listbox (root, listvariable = var) s1 = Scrollbar (root) lb2.grid (row = 8, columnspan = 2, sticky = E + W) s1.grid (row = 8, columnspan = 2, rowspan = 5, sticky = N + E + S) lb2 ['yscrollcommand'] = s1.sets1 ['command'] = lb2.yviewroot. columnconfigure (0, minsize = 10) root. mainloop ()