Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from tkinter import ttk
- import os
- import threading
- import queue
- the_queue = queue.Queue()
- class ReportGUI:
- def __init__(self, master):
- frame = Frame(master)
- frame.grid()
- self.B1 = Button(frame, text = 'Generate Report', bg = 'blue', fg = 'white', bd = 5, command=self.PutVariablesIntoQ, font="Tahoma 9")
- self.B1.grid(column = 8, row = 11, columnspan = 1, pady=(10,10), padx=7)
- #Loading Screen
- self.pbar = ttk.Progressbar(frame)
- self.pbar_label = Label(frame, text="Loading...", font="Helvetica 9 italic")
- def PutVariablesIntoQ(self):
- # Make progress bar visible and start it
- self.pbar.grid(row=3, column=0, columnspan=3, padx=(4,0))
- self.pbar_label.grid(row=3, column=3, columnspan=1)
- self.pbar['mode'] = 'indeterminate'
- self.pbar.start(20)
- self.a = self.E1.get() # get variables from GUI
- self.b = self.E3.get()
- self.c = self.E6.get()
- SQL_Class = ClientReportSQL(self.a, self.b) # long running blocking function that is run on another thread
- the_queue.put(SQL_Class.openconnection())
- the_queue.put(SQL_Class.executeSQL())
- # more functions
- if self.layer_report_var.get():
- Layer_File_Class = LayerReportFile(self.clientname, SQL_Class.treaty_date)
- the_queue.put(Layer_File_Class.copyfinaltemplate(self.path)) # more functions
- else:
- pass
- #self.stop_program()
- def stop_program(self):
- self.pbar.stop()
- self.pbar['mode'] = 'determinate'
- self.pbar.grid_forget()
- self.pbar_label.config(text='Finished!')
- def thread_target():
- while True:
- task = the_queue.get()
- if task is None:
- return
- func = task[0]
- args = task[1:]
- func(*args)
- root = Tk()
- root.iconbitmap(icof)
- app = ReportGUI(root)
- root.lift()
- threading.Thread(target=thread_target).start()
- root.mainloop()
- the_queue.put(None)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement