GhaziDev / Flash-Text-Editor

MIT License
5 stars 1 forks source link

pyautogui is an unnecessary dependency #5

Closed Akuli closed 3 years ago

Akuli commented 3 years ago

This project depends on pyautogui. It's used only for figuring out the size of a window:

class Window:
    def __init__(self):
        self.root = Tk()
        ...
        self.height, self.width = pyautogui.size()

You can use winfo_width() and winfo_height() instead. I find that it's sometimes necessary to .update() before that to make sure that the window is actually as big as it's going to be, because otherwise you might get the size of a window that isn't ready yet. This would allow getting rid of pyautogui.

class Window:
    def __init__(self):
        self.root = Tk()
        ...
        self.root.update()
        self.width = self.root.winfo_width()
        self.height = self.root.winfo_height()

There's also winfo_reqwidth() and winfo_reqheight(). I don't know which of those is what pyautogui.size() does.

GhaziDev commented 3 years ago

you are totally right, I used pyautogui because at that time I was still learning tkinter ,anyway I fixed it.