Skip to content

Commit

Permalink
wxGUI: add single window to settings (#1810)
Browse files Browse the repository at this point in the history
* add note it's experimental
* fix saving settings, fix for Python 3.10
  • Loading branch information
petrasovaa committed Jan 3, 2022
1 parent 443635d commit 55079f3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions gui/wxpython/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def _defaultSettings(self):
"region": {
"resAlign": {"enabled": False},
},
"singleWindow": {"enabled": False},
},
#
# datacatalog
Expand Down
20 changes: 19 additions & 1 deletion gui/wxpython/gui_core/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,19 @@ def _createGeneralPage(self, notebook):
gridSizer = wx.GridBagSizer(hgap=3, vgap=3)

row = 0
singleWindow = wx.CheckBox(
parent=panel,
id=wx.ID_ANY,
label=_("Use single-window mode (experimental, requires GUI restart)"),
name="IsChecked",
)
singleWindow.SetValue(
self.settings.Get(group="general", key="singleWindow", subkey="enabled")
)
self.winId["general:singleWindow:enabled"] = singleWindow.GetId()
gridSizer.Add(singleWindow, pos=(row, 0), span=(1, 2))

row += 1
posDisplay = wx.CheckBox(
parent=panel,
id=wx.ID_ANY,
Expand Down Expand Up @@ -1822,7 +1835,12 @@ def _updateSettings(self):
size = mapdisp.GetSize()

# window size must be larger than zero, not minimized
if not mapdisp.IsIconized() and (size[0] > 0 and size[1] > 0):
# when mapdisp is inside single window (panel has no IsIconized), don't save dim
if (
hasattr(mapdisp, "IsIconized")
and not mapdisp.IsIconized()
and (size[0] > 0 and size[1] > 0)
):
dim += ",%d,%d,%d,%d" % (pos[0], pos[1], size[0], size[1])

self.settings.Set(
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/main_window/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ def show_menu_errors(messages):

# set pane sizes according to the full screen size of the primary monitor
size = wx.Display().GetGeometry().GetSize()
self.PANE_BEST_SIZE = tuple(t / 3 for t in size)
self.PANE_MIN_SIZE = tuple(t / 5 for t in size)
self.PANE_BEST_SIZE = tuple(t // 3 for t in size)
self.PANE_MIN_SIZE = tuple(t // 5 for t in size)

# create widgets and build panes
self.CreateMenuBar()
Expand Down
9 changes: 8 additions & 1 deletion gui/wxpython/wxgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

from core import globalvar
from core.utils import registerPid, unregisterPid
from core.settings import UserSettings

import wx

Expand Down Expand Up @@ -83,7 +84,13 @@ def OnInit(self):

def show_main_gui():
# create and show main frame
from lmgr.frame import GMFrame
single = UserSettings.Get(
group="general", key="singleWindow", subkey="enabled"
)
if single:
from main_window.frame import GMFrame
else:
from lmgr.frame import GMFrame

mainframe = GMFrame(parent=None, id=wx.ID_ANY, workspace=self.workspaceFile)
mainframe.Show()
Expand Down

0 comments on commit 55079f3

Please sign in to comment.