Search code examples
pythonwxpythonwxwidgets

How can I choose the default wx.Display in wxpython?


Is it also possible to choose in which display a certain wx.Frame should appear in?


Solution

  • I don't think you can change the default display, but this snippet creates a frame on each display.

    import wx
    
    def set_frame_display(frame, display_index):
        display = wx.Display(display_index)
        x, y, w, h = display.GetGeometry()
        frame.SetPosition((x, y))
    
    def main():
        app = wx.PySimpleApp()
        count = wx.Display_GetCount()
        for index in range(count):
            frame = wx.Frame(None, -1, 'Display %d of %d' % (index + 1, count))
            set_frame_display(frame, index)
            frame.Center()
            frame.Show()
        app.MainLoop()
    
    if __name__ == '__main__':
        main()