Skip to content

Commit

Permalink
Merge pull request #1652 from dvbridges/master
Browse files Browse the repository at this point in the history
BF: DLG position customization. Fixes #1644
  • Loading branch information
peircej committed Jan 8, 2018
2 parents 230edaa + 1d6c804 commit d7c2ae4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
27 changes: 14 additions & 13 deletions psychopy/gui/qtgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(self, title=_translate('PsychoPy Dialog'),
self.inputFieldNames = []
self.data = []
self.irow = 0

self.pos = pos
# QtWidgets.QToolTip.setFont(QtGui.QFont('SansSerif', 10))

# add buttons for OK and Cancel
Expand All @@ -107,8 +107,6 @@ def __init__(self, title=_translate('PsychoPy Dialog'),
if style:
raise RuntimeWarning("Dlg does not currently support the "
"style kwarg.")

self.pos = pos
self.size = size
self.screen = screen
# self.labelButtonOK = labelButtonOK
Expand All @@ -123,6 +121,7 @@ def __init__(self, title=_translate('PsychoPy Dialog'),

self.setWindowTitle(title)


def addText(self, text, color='', isFieldLabel=False):
textLabel = QtWidgets.QLabel(text, parent=self)

Expand Down Expand Up @@ -309,16 +308,18 @@ def exec_(self):

self.layout.addWidget(self.buttonBox, self.irow, 0, 1, 2)

# Center Dialog on appropriate screen
frameGm = self.frameGeometry()
desktop = QtWidgets.QApplication.desktop()
qtscreen = self.screen
if self.screen <= 0:
qtscreen = desktop.primaryScreen()
centerPoint = desktop.screenGeometry(qtscreen).center()
frameGm.moveCenter(centerPoint)
self.move(frameGm.topLeft())

if self.pos is None:
# Center Dialog on appropriate screen
frameGm = self.frameGeometry()
desktop = QtWidgets.QApplication.desktop()
qtscreen = self.screen
if self.screen <= 0:
qtscreen = desktop.primaryScreen()
centerPoint = desktop.screenGeometry(qtscreen).center()
frameGm.moveCenter(centerPoint)
self.move(frameGm.topLeft())
else:
self.move(self.pos[0],self.pos[1])
QtWidgets.QDialog.show(self)
self.raise_()
self.activateWindow()
Expand Down
6 changes: 4 additions & 2 deletions psychopy/gui/wxgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,16 @@ class Dlg(wx.Dialog):
"""

def __init__(self, title=_translate('PsychoPy dialogue'),
pos=None, size=wx.DefaultSize,
pos=wx.DefaultPosition, size=wx.DefaultSize,
style=wx.DEFAULT_DIALOG_STYLE | wx.DIALOG_NO_PARENT,
labelButtonOK=_translate(" OK "),
labelButtonCancel=_translate(" Cancel ")):
style = style | wx.RESIZE_BORDER
global app # avoid recreating for every gui
if pos is None:
pos = wx.DefaultPosition
app = ensureWxApp()
super().__init__(parent=None, id=-1, title=title, style=style)
super().__init__(parent=None, id=-1, title=title, style=style, pos=pos)
self.inputFields = []
self.inputFieldTypes = []
self.inputFieldNames = []
Expand Down

0 comments on commit d7c2ae4

Please sign in to comment.