def failedToSend(reason): al = mtk.Ttk("Bug Send Error Win") al.geometry('200x200') al.title("Error") mtk.Label(al, text=reason).pack() mtk.Button(al, text='ok', command=lambda: quitWin(al)).pack() al.mainloop()
def sendReport(report, win): win.destroy() win.quit() r = requests.post('https://pyeditbugserver.herokuapp.com/bug-report', json=report.toJson()) if (r.status_code != 200): al = mtk.Ttk("Bug Send Error Win") al.title("Error") mtk.Label(al, text=r.reason).pack() mtk.Button(al, text='ok', command=lambda: quitWin(al)).pack() al.mainloop() else: al = mtk.Ttk("Bug Report Successfully Sent") al.title("Success!") mtk.Button(al, text='ok', command=lambda: quitWin(al)).pack() al.mainloop()
def failedToSend(reason): al = mtk.Ttk("Bug Send Error Win") al.geometry('600x600') al.title("Error") t = mtk.Text(al,width=500, height=500, wrap=word) t.insert(0.0, reason) t.pack() mtk.Button(al, text='ok', command=lambda: quitWin(al)).pack() al.mainloop()
def sendReport(report, win): win.destroy() win.quit() if os.environ['PY_EDIT_DEBUG']: r = requests.post('http://localhost:8099/bug-report', json=report.toJson()); else: r = requests.post('https://pyeditbugserver.herokuapp.com/bug-report', json=report.toJson()) if (r.status_code != 200): al = mtk.Ttk("Bug Send Error Win") al.geometry('200x200') al.title("Error") mtk.Label(al, text=r.reason).pack() mtk.Button(al, text='ok', command=lambda: quitWin(al)).pack() al.mainloop() else: al = mtk.Ttk("Bug Report Successfully Sent") al.geometry('200x200') al.title("Success!") mtk.Button(al, text='ok', command=lambda: quitWin(al)).pack() al.mainloop()
def askToSubmitBugs(name, steps, info, app, br): br.quit() _name = name.get() _steps = steps.get(0.0, mtk.END) _info = info.get(0.0, mtk.END) br.destroy() error_report = writeBugReport(_name, _steps, _info, app) tosend = mtk.Ttk("To Send") tosend.title("Bug Report") mtk.TLabel(tosend, text="The following information will be submitted \n" "(no personally identifiable information is sent) ").pack() a = mtk.Text(tosend, width=125, height=30) a.insert(0.0, error_report) a.pack() can = mtk.Button(tosend, text='Cancel', command=lambda: quitWin(tosend)) can.pack() qu = mtk.Button(tosend, text="Go", command=lambda: sendReport(error_report, tosend)) qu.pack() tosend.mainloop()
def askForBugs(app): """Dependent on <app> argument being PyEdit. Not a good repurpose""" bug_report = mtk.Ttk("Bug Report") bug_report.protocol("WM_DELETE_WINDOW", lambda: quitWin(bug_report)) bug_report.title("Submit a Bug") mtk.TLabel(bug_report, text="Enter a name: ").pack() name = mtk.Entry(bug_report) name.pack() mtk.TLabel(bug_report, text="Describe the steps to recreate the bug: ").pack() steps = mtk.Text(bug_report, width=40, height=10) steps.pack() mtk.TLabel(bug_report, text="Include any other additional" "information that could help: ").pack() info = mtk.Text(bug_report, width=40, height=10) info.pack() qu = mtk.Button(bug_report, text="Next...", command=lambda: askToSubmitBugs(name, steps, info, app, bug_report)) qu.pack() bug_report.mainloop()
def sendReport(report, win): win.destroy() win.quit() try: if os.environ['PY_EDIT_DEBUG']: r = requests.post('http://localhost:8099/bug-report', json=report.toJson()) else: r = requests.post( 'https://pyeditbugserver.herokuapp.com/bug-report', json=report.toJson()) except Exception as e: failedToSend("{}: {}".format(type(e), e.args[0])) return if (r.status_code != 200): failedToSend(r.reason) else: al = mtk.Ttk("Bug Report Successfully Sent") al.geometry('200x200') al.title("Success!") mtk.Button(al, text='ok', command=lambda: quitWin(al)).pack() al.mainloop()