Repository: psychopy/psychopy

Issue:
gui.Dlg() ignoring position argument 
bug explained here:
https://discourse.psychopy.org/t/change-position-of-gui-dlg/3302




Discussion:
FYI this would preferably be fixed in qtgui.py as well as wxgui.py

**In qtgui.py** adapt the `_exec()` method to include something like
```
if self.pos is None: 
    <center the dlg> 
else: 
    <set pos>
```

**In wxgui.py** adapt the `super.__init__()` to include a `pos=self.pos` argument

Resolving patch:
diff --git a/psychopy/gui/qtgui.py b/psychopy/gui/qtgui.py
--- a/psychopy/gui/qtgui.py
+++ b/psychopy/gui/qtgui.py
@@ -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
@@ -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
@@ -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)
 
@@ -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()
diff --git a/psychopy/gui/wxgui.py b/psychopy/gui/wxgui.py
--- a/psychopy/gui/wxgui.py
+++ b/psychopy/gui/wxgui.py
@@ -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 = []


Test patch: