alejandroautalan / pygubu

A simple GUI builder for the python tkinter module
MIT License
2.04k stars 213 forks source link

window opens outside of vision after using dual monitor #267

Closed paulocorleone closed 2 years ago

paulocorleone commented 2 years ago

Hey,

I've found an issue where after using pygubu-designer on the second monitor, it will show outside of vision once you unplug the second monitor and reopen the program. I tried using windows shortcuts to move it, but was unable to.

I've solved it by adding the following code to PygubuDesigner.setup_app_preferences()

def setup_app_preferences(self):
        # Restore windows position and size
        geom = pref.get_window_size()

        # Check if window is outside of bounds
        window_size, x_axis, y_axis = geom.split("+")
        if (int(x_axis) < 0):
            x_axis = "0"
        if (int(y_axis) < 0):
            y_axis = "0"
        geom = "+".join((window_size, x_axis, y_axis))

        self.mainwindow.geometry(geom)
        # Load preferred ttk theme
        theme = pref.get_option('ttk_theme')
        self._change_ttk_theme(theme)

The downside to this is that, now the pygubu-designer will always popup in the main monitor.

Hope it helps.

paulocorleone commented 2 years ago

wrong project, sorry