I'm using python 2.7 and TK to make a gui which accesses text files and uses data in them to do many things, but the one relevant here is sending a gchat message. Currently, I have everything working, the point I need some help with is when I call my module to send the message, the message is sent perfectly, although I wanted the user to have an indication of the process happening, so I created a ttk.progressbar. but there is a few things I'd like to improve on this:
1) I would like to change the appearance of the actual bar, upon viewing the source files, I couldn't see any options, and when I googled the problem the only fix I could find was to change the source code, I'm pretty sure this would only change it when ran with my files, then when the user runs it, it would be the standard? preferably, I'd like the bar to be transparent, although blue would work, I've seen some people having blue as a state in window machines, windows is my main concern, so if I could get say, blue in windows, but native elsewhere, that would be fine.
2)this one is hopefully a bit more simple, but when the button is pressed it takes values from user input which can still be changed, maybe altering the outcome of the function, is there anyway to stop all input to a tk window, then resume when the function is complete?
below is what I have so far, thank you for the help
self.progressbar = ttk.Progressbar(self.gcTableButtonsFrame, length = 70, orient=HORIZONTAL, mode ='determinate')
self.progressbar.grid(column = 0, row = 0, sticky = 'n s')
#we then pass through the extension and the string 'test' through this fnction from the gchat module which will then send a
#gchat message to the extension passed through
self.bytes = 0
self.maxbytes = 0
self.start()
self.t = thread.start_new_thread(gchat.sendGChatMessage,(text, "test"))
except IndexError:
tkMessageBox.showinfo("Invalid Entry", "Please first select an Entry to send to")
def start(self):
self.progressbar["value"] = 0
self.maxbytes = 50000
self.progressbar["maximum"] = 50000
self.read_bytes()
def read_bytes(self):
'''simulate reading 500 bytes; update progress bar'''
selection2 = self.gcTable.selection()
self.bytes += 700
self.progressbar["value"] = self.bytes
if self.bytes < self.maxbytes:
# read more bytes after 100 ms
Tk.after(self.mainPyWindow, 100, self.read_bytes)
else:
tkMessageBox.showinfo("Message Sent", "A GChat message has been sent to " + self.gcTable.item(selection2, 'values')[1])
self.progressbar.destroy()