vanilla
vanilla copied to clipboard
Error in getPosSize for parent-child windows, when child moves off-screen while dragging
I am using parent-child connected floating windows, and found that child-windows that move off the screen give an error on the getPosSize because self._window.screen() gets None when off-screen. I solved if for now with the following redefinition of the method. It may not be entirely right in the returned values, but now it works without errors when dragging the parent window. to the side of the screen. Petr
def getPosSize(self): """ A tuple of form (left, top, width, height) representing the window's position and size. """ frame = self._window.frame() if self._window.screen() is not None: l, t, w, h = _flipFrame(self._window.screen().visibleFrame(), frame) titlebarHeight = self._calculateTitlebarHeight() t += titlebarHeight h -= titlebarHeight else: (l, t), (w, h) = frame return (l, t, w, h)
What exactly do you mean with "off screen"? Can you provide a snippet that produces a window in such a state?
something like this:
it goes wrong on osx level, where the child window disappears when moving between screens vanilla does it good, so far
please close if this is not an issue anymore (2013 whoewhoe)
import AppKit
import vanilla
def callback(sender):
print(w.getPosSize())
print(w2.getPosSize())
print()
w = vanilla.Window((400, 400))
w.b = vanilla.Button((10, 10, 200, 22), "hit", callback)
w.open()
w2 = vanilla.FloatingWindow((500, 100, 200, 200))
w2.b = vanilla.Button((10, 10, 200, 22), "hit", callback)
w.getNSWindow().addChildWindow_ordered_(w2.getNSWindow(), AppKit.NSWindowBelow)