from tkinter import * class Converter: """ Temperature conversion tool (C* to F* or F* to C*) """ def __init__(self): """ Temperature conversion GUI """ self.metric_frame = Frame(padx=10, pady=10) self.metric_frame.grid() self.to_help_button = Button(self.metric_frame, text="Help/ Info", bg="#00FF00", fg="#FFFFFF", font=("Arial", "14", "bold"), width=12, command=self.to_help) self.to_help_button.grid(row=1, padx=5, pady=5) def to_help(self): DisplayHelp() class DisplayHelp: def __init__(self): # setup dialogue box and background colour background = "#FFFFFF" self.help_box = Toplevel() self.help_frame = Frame(self.help_box, width=300, height=200, bg=background) 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 value " \ "you wish to convert and then choose the metric units " \ "you want to convert from and to (e.g., meters to kilometers, " \ "grams to kilograms, etc.). \n\n" \ "Note that negative values may not be valid for all conversions, " \ "such as length or mass. If you enter an invalid value, " \ "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, font=("Arial", "12", "bold"), text="Dismiss", bg="#FF0000", fg="#FFFFFF", command=self.close_help) self.dismiss_button.grid(row=2, padx=10, pady=10) # list and loop to set background colour on # everything except the buttons. recolour_list = [self.help_frame, self.help_heading_label, self.help_heading_label] for item in recolour_list: item.config(bg=background) def close_help(self): self.help_box.destroy() # main routine if __name__ == "__main__": root = Tk() root.title("Temperature Convertor") Converter() root.mainloop()