im learning Python and making GUI program with Tkinter. i want to update status bar's message 2 times when button clicked. 1st message is will update when button clicked. 2nd message will update after when program successfully work. The problem is that 1st message isnt showing at all when i click the button21
encryption_tab
def encryption_tab(self):
self.input3 = tk.LabelFrame(self.tab1, bg="black", fg='white', text=" Source Image ")
self.input3.pack(expand=1, fill='both', padx=5, pady=5)
self.target_image_path = tk.StringVar()
self.verb_ent = tk.Entry(self.input3, width=55, textvariable=self.target_image_path)
self.verb_ent.pack(side=tk.LEFT, expand=1, fill="both", padx=5, pady=5)
button2 = tk.Button(self.input3, text="Search Image", command=lambda: self.get_path(0))
button2.pack(side=tk.LEFT, padx=5, pady=5)
button2.configure(bg="black", fg='white', activebackground='#0080ff', activeforeground='white')
self.input = tk.LabelFrame(self.tab1, text=" Hide text ", background="black", foreground='white')
self.textvar = tk.StringVar()
self.textbox = tk.Text(self.input, height=5, width=70, wrap='word', undo=True)
self.textbox.pack(expand=1, fill="both", padx=5, pady=5)
self.textbox.bind("<Key>", self.update)
self.counter = tk.StringVar()
self.counter.set('Одоогоор текст: ' +'0'+ ' тэмдэгттэй байна')
self.char_count = tk.Label(self.input, textvariable=self.counter, bg="Black", fg= '#0080ff')
self.char_count.pack(side=tk.LEFT, expand=1, fill="both", padx=5, pady=5)
button21 = tk.Button(self.input, text="hide text", command=lambda: self.hide())
button21.pack(side=tk.RIGHT, padx=5, pady=5)
button21.configure(bg="black", fg='white', activebackground='#0080ff', activeforeground='white')
#guess here's the problem tho
self.input.pack(expand=1, fill="both", padx=5, pady=5)
self.input1 = tk.LabelFrame(self.tab1, bg="black", fg='white', text=" Status ")
self.status_message = tk.StringVar()
self.status_message.set('\n program not yet started \n')
textwidget = tk.Label(self.input1, textvariable=self.status_message, bg='black', fg="white", wraplength=590)
textwidget.configure(relief='flat', state="normal")
textwidget.pack(expand=1, fill="both", padx=5, pady=5)
self.input1.pack(expand=1, fill="both", padx=5, pady=5)
here's hide() function
def hide(self):
#this message is 1st... but not working tho
self.status_update(" program is working...")
#
original_image_file = self.target_image_path.get()
img = Image.open(original_image_file)
import ntpath
encoded_image_file = ntpath.split(original_image_file)[0] + "/enc_" + ntpath.basename(original_image_file)
secret_msg = self.textbox.get("1.0", tk.END)
img_encoded = self.encode_image(img, secret_msg)
if img_encoded:
img_encoded.save(encoded_image_file)
# this is 2nd message.. its working fine
self.status_update("{} хадгалагдсан!".format(encoded_image_file))
if sys.platform == "win32":
os.startfile(encoded_image_file)
else:
opener ="open" if sys.platform == "darwin" else "xdg-open"
subprocess.call([opener, encoded_image_file])
status_update function... maybe its seems useless... but i use this function in another tabs. and they're working fine.
def status_update(self, status):
self.status_message.set(status)
when i call hide() function the 1st message not updating... after program work successfully, 2nd message is appearing only... Someone know issue? am i just made simple mistake?
sorry, my english isnt perfect :{, its my 1st time to asking from stackoverflow :)