|
| 1 | +# pylint: disable=invalid-name |
| 2 | + |
| 3 | +""" |
| 4 | +This module is imported to create a modern GUI. |
| 5 | +""" |
| 6 | + |
| 7 | +import customtkinter |
| 8 | + |
| 9 | + |
| 10 | +class FeedBack(customtkinter.CTk): |
| 11 | + """ |
| 12 | + A class representing a feedback GUI. |
| 13 | +
|
| 14 | + This class inherits from customtkinter.CTk and provides a graphical user interface |
| 15 | + for collecting user feedback. |
| 16 | +
|
| 17 | + Attributes: |
| 18 | + textbox (customtkinter.CTkTextbox): The text box widget for displaying instructions. |
| 19 | + feedback (customtkinter.CTkEntry): The entry widget for collecting user feedback. |
| 20 | + button (customtkinter.CTkButton): The button widget for submitting the feedback. |
| 21 | +
|
| 22 | + Methods: |
| 23 | + __init__(): Initializes the FeedBack class. |
| 24 | + button_callback(): Callback function for the button click event. |
| 25 | + """ |
| 26 | + def __init__(self): |
| 27 | + super().__init__() |
| 28 | + |
| 29 | + self.geometry("300x200") |
| 30 | + self.title("User FeedBack") |
| 31 | + self.minsize(300, 200) |
| 32 | + |
| 33 | + self.grid_rowconfigure(0, weight=1) |
| 34 | + self.grid_columnconfigure(0, weight=1) |
| 35 | + |
| 36 | + self.textbox = customtkinter.CTkTextbox(master=self) |
| 37 | + self.textbox.grid(row=0, column=0, padx=10, pady=(10, 0), sticky="nsew") |
| 38 | + text = ( |
| 39 | + " Please enter your valuable Feedback \n" |
| 40 | + " We are sorry you have to delete your account \n" |
| 41 | + " Help us to improve\n" |
| 42 | + ) |
| 43 | + self.textbox.insert("1.0", text) |
| 44 | + |
| 45 | + self.feedback = customtkinter.CTkEntry(master=self, placeholder_text="FeedBack") |
| 46 | + self.feedback.grid(row=1, column=0, padx=10, pady=5, sticky='ew') |
| 47 | + |
| 48 | + self.button = customtkinter.CTkButton(master=self, command=self.button_callback,text="Done") |
| 49 | + self.button.grid(row=2, column=0, padx=10, pady=(0, 20), sticky="ew") |
| 50 | + |
| 51 | + def button_callback(self): |
| 52 | + """ |
| 53 | + Callback function for the button click event. |
| 54 | +
|
| 55 | + This function is triggered when the user clicks the "Done" button. |
| 56 | + It retrieves the user feedback from the input field and writes it to a file. |
| 57 | + """ |
| 58 | + def writing_feedback(): |
| 59 | + fdbck = self.feedback.get() |
| 60 | + with open('CustomTkinter-GUI/Feedback_GUI/FeedbackGUI','w',encoding="utf-8") as feedbck: |
| 61 | + feedbck.write(str(fdbck)) |
| 62 | + writing_feedback() |
| 63 | + self.destroy() |
| 64 | + |
| 65 | + |
| 66 | +if __name__ == "__main__": |
| 67 | + app = FeedBack() |
| 68 | + app.mainloop() |
0 commit comments