Strange multi monitor behavior

I’m trying to launch a frame on a secondary monitor in Windows, and having trouble. Note the code below:

import wx

def set_frame_display(frame, display_index):

display = wx.Display(display_index)

x, y, w, h = display.GetGeometry()

print display_index, " monitor -> ",x,y,w,h

frame.SetPosition((x, y))

#frame.ShowFullScreen(True)

def main():

app = wx.App()

count = wx.Display_GetCount()

print "Monitor : ",count

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()

That should launch a frame on each of my two monitors, but instead they both appear on my primary monitor. Interestingly, if I uncomment the ShowFullScreen(), they will each go fullscreen on the correct monitor (in other words, one on each monitor).

Any tips to place a frame on a secondary monitor?

wrybread wrote:

I'm trying to launch a frame on a secondary monitor in Windows, and
having trouble. Note the code below:
...
That should launch a frame on each of my two monitors, but instead
they both appear on my primary monitor. Interestingly, if I uncomment
the ShowFullScreen(), they will each go fullscreen on the correct
monitor (in other words, one on each monitor).

Any tips to place a frame on a secondary monitor?

Interesting. I just ran your exact code -- no changes -- on my XP
system, and the windows appeared one on each monitor.

Do the coordinates it displays match your expectations? Do you have
something docked at the top or left edge that might interfere? Does it
change if you offset x and y by, say, 50 pixels?

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Tim Roberts wrote:

wrybread wrote:

I'm trying to launch a frame on a secondary monitor in Windows, and
having trouble. Note the code below:
...
That should launch a frame on each of my two monitors, but instead
they both appear on my primary monitor. Interestingly, if I uncomment
the ShowFullScreen(), they will each go fullscreen on the correct
monitor (in other words, one on each monitor).

Any tips to place a frame on a secondary monitor?

Interesting. I just ran your exact code -- no changes -- on my XP
system, and the windows appeared one on each monitor.

Do the coordinates it displays match your expectations? Do you have
something docked at the top or left edge that might interfere? Does it
change if you offset x and y by, say, 50 pixels?

Or use display.GetClientArea() to find the area on the display that is not reserved for something else.

···

--
Robin Dunn
Software Craftsman