there I am fairly new with python and object-oriented programming. Most of my experience is from C programming. However, for a personal project, I am using python and its Tkinter libraries to create a GUI on my computer. I was able to build the GUI and created different menu buttons for my project. However, for one of the menu buttons, I would like to open a new window with text and maybe images for the user.
The location of my error is one of the classes that are in charge of creating the windows menu bars. With its public function named "read_me_exit"
Here is the snippet of my function and its properties
def read_me_exit(self):
win = tk()
window_width = 400
window_height = 200
# get screen dimension
screen_width = win.winfo_screenwidth()
screen_height = win.winfo_screenheight()
# find the center point
center_x = int(screen_width / 2 - window_width / 2)
center_y = int(screen_height / 2 - window_height / 2)
# create the screen on window console
win.geometry(f'{window_width}x{window_height}+{center_x}+{center_y}')
win.title('Read Me')
win.resizable(False, False)
win.iconbitmap('./msoe.ico')
This function gets called in my menubar command line as shown below:
class Window(tk.Frame):
# Define settings upon initialization. Here you can specify
def __init__(self, master):
super().__init__(master)
# field options
# with that, we want to then run init_window, which doesn't yet exist
self.init_window()
# Creation of init_window
def init_window(self):
# creating a menu instance
menu = Menu(self.master)
self.master.config(menu=menu)
# create the file object
file = Menu(menu)
# adds a command to the menu option, calling it exit, and the
# command it runs on event is client_exit
file.add_command(label="Read Me", command=self.read_me_exit)
file.add_command(label="Exit", command=self.user_exit)........
When trying to click the Read Me button on my file menubar I receive this error:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\jurado-garciaj\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1892, in __call__
return self.func(*args)
File "C:\Users\jurado-garciaj\Documents\EKG\GUI.py", line 196, in read_me_exit
win = tk()
TypeError: 'module' object is not callable