from tkinter import * from functools import partial class DisplayHelp: def __init__(self, partner): background = "#ffe6cc" self.help_box = Toplevel() self.help_box.title("Help / Info") partner.config(state=DISABLED) self.help_box.protocol('WM_DELETE_WINDOW', partial(self.close_help, partner)) self.help_frame = Frame(self.help_box, width=300, height=200) self.help_frame.grid() self.help_heading_label = Label(self.help_frame, text="Help / Info", font=("Arial", "14", "bold")) self.help_heading_label.grid(row=0) help_text = ("To use the program, simply enter the weight " "you wish to convert and then choose to convert " "to either Kilograms (KGS) or Pounds (LBS).\n\n" "Note that 0 KG/LBS is the smallest possible weight. " "If you try to convert a weight less than 0 KG/LBS " "you will get an error message.\n\n" "To see your calculation history and export it to a " "text file, please click the 'History / Export' button.") self.help_text_label = Label(self.help_frame, text=help_text, wraplength=350, justify="left") self.help_text_label.grid(row=1, padx=10) self.dismiss_button = Button(self.help_frame, text="Dismiss", font=("Arial", "12", "bold"), bg="#CC6600", fg="#FFFFFF", command=partial(self.close_help, partner)) self.dismiss_button.grid(row=2, padx=10, pady=10) for item in [self.help_frame, self.help_heading_label, self.help_text_label]: item.config(bg=background) def close_help(self, partner): partner.config(state=NORMAL) self.help_box.destroy() if __name__ == "__main__": root = Tk() root.title("Weight Converter") btn = Button(root, text="Help / Info", bg="#CC6600", fg="#FFFFFF", font=("Arial", "12", "bold")) btn.config(command=lambda: DisplayHelp(btn)) btn.pack(padx=20, pady=20) root.mainloop()