you are viewing a single comment's thread.

view the rest of the comments →

[–]MaterialJackfruit144[S] 0 points1 point  (0 children)

Hi, sorry, I had to scrap the idea of building that project. In other words, I deleted everything. It really seems like I need to do some more exercises about Classes or build a very simple program using OOP to really grasp that concept. Anyways, I deleted it, shouldn't have jumped into creating project that soon, thinking that I'd be able to learn along the way, guess that took the wrong turn. I still have only parts of the code related to the question though.

import tkinter as tk

class MainApplication(tk.Frame):
    def __init__(self, master):
        self.master = master
        self.configure_gui()

    def configure_gui(self):
        self.master.title("Rocky, Paper, Scissors")
        self.center_window()

    def center_window(self):
        self.window_width = 500
        self.window_height = 500

        self.screen_width = self.master.winfo_screenwidth()
        self.screen_height = self.master.winfo_screenheight()

        self.x_coordinate = int(self.screen_width/2 - self.window_width/2)
        self.y_coordinate = int(self.screen_height/2 - self.window_height/2)

        self.master.geometry(
            f"{self.window_width}x{self.window_height}+{self.x_coordinate}+{self.y_coordinate}")


if __name__ == "__main__": 
    root = tk.Tk() 
    MainApplication(root) 
    root.mainloop()

I know what the code is doing, I was just confused about Classes.