Search code examples
pythonpython-2.7wxpythonsuperclass

pos argument for popup transient window in wxpython


I am trying to make custom popup window and did following stuff.

class MyDialog(wx.PopupTransientWindow):

    def __init__(self, parent, title, cellnum, cmd, **kwargs): 
        super(MyDialog, self).__init__(parent, style=wx.CLIP_CHILDREN | wx.FRAME_NO_TASKBAR |wx.FRAME_SHAPED, **kwargs)
        # def __init__(self, parent, style, cellnum, cmd):
        # super(MyDialog, self).__init__(parent, style=wx.CLIP_CHILDREN | wx.FRAME_NO_TASKBAR | wx.NO_BORDER|wx.FRAME_SHAPED)

        # self.panel = wx.Panel(self)
        #size=(255,200)#one kind of size
        self.panel = Panel1(self)

But when i call it by:

dial = MyDialog(self, "mydialog", wx.id, cmd, pos=ldPos)

It shows following error:

Traceback (most recent call last):
  File "D:\X000T9P77\projects\MYTEST\docs\MYTEST_gui_module_src\MYTESTGUI.py", line 1465, in ShowMessage1
    dial = MyDialog(self, "CELL "+id, id, cmd, pos=ldPos)
  File "D:\X000T9P77\projects\MYTEST\docs\MYTEST_gui_module_src\MYTESTGUI.py", line 103, in __init__
    super(MyDialog, self).__init__(parent, style=wx.CLIP_CHILDREN | wx.FRAME_NO_TASKBAR |wx.FRAME_SHAPED, **kwargs)
  File "C:\Python27\lib\site-packages\wx-3.0-msw\wx\_windows.py", line 2141, in __init__
    _windows_.PopupTransientWindow_swiginit(self,_windows_.new_PopupTransientWindow(*args, **kwargs))
TypeError: new_PopupTransientWindow() takes at most 2 arguments (3 given)

Can anyone help me in this. Thanks A lot in advance.


Solution

  • Since PopupTransientWindow() takes at most 2 arguments, I suggest you change it to:

    super(MyDialog, self).__init__(parent, style=wx.CLIP_CHILDREN | wx.FRAME_NO_TASKBAR |wx.FRAME_SHAPED) #, **kwargs)
    

    To set the position of the transient window, you could use Position:

      def Position(*args, **kwargs):
    
      """Position(self, Point ptOrigin, Size size)"""
      return _windows_.PopupWindow_Position(*args, **kwargs)