SOLVED how to make vanilla.Window not disappear



  • hi (hehe, me again)

    how to make simple vanilla.Window not disappear programmatically when the RoboFont app is becoming inactive?

    Eg:

    from vanilla import *
    class simpleWin:
        def __init__(self):
            self.w = FloatingWindow((200,200))
            self.w.open()
    simpleWin()
    

    If I will run the code above in the RF, and change the active app to any another (let's say Finder), I see only default RF windows like script window, font window or glyph window. I would like my simpleWin also be visible in that case. Is it possible?
    I realized that Erik's design space extension does it.
    https://github.com/LettError/designSpaceRoboFontExtension
    I was trying to find it in its code. Somehow I could not.
    Any help would be appreciated



  • @gferreira said in how to make vanilla.Window not disappear:

    self.w.getNSWindow().setHidesOnDeactivate_(False)

    Thanks Gustavo!!! That is exacly what I needed



  • hi @RafaŁ-Buchner,

    if you want a window to stay visible when the app focus changes, it is recommended to use Window instead of FloatingWindow:

    from vanilla import Window, FloatingWindow
    
    class SimpleWindow:
    
        def __init__(self):
            self.w = Window((200,200), 'Window')
            self.w.open()
    
    class SimpleFloatingWindow:
    
        def __init__(self):
            self.w = FloatingWindow((200,200), 'FloatingWindow')
            self.w.open()
    
    SimpleWindow() # this one stays visible when RF is inactive
    SimpleFloatingWindow() # this one does not
    

    if you really need a FloatingWindow which stays visible (like the Output Window, for example), it can be done by tweaking the native window object:

    from vanilla import FloatingWindow
    
    class SpecialFloatingWindow:
        def __init__(self):
            self.w = FloatingWindow((200,200), 'SpecialFloatingWindow')
            self.w.getNSWindow().setHidesOnDeactivate_(False)
            self.w.open()
    
    SpecialFloatingWindow()
    

    edit: written before reading @colinmford’s reply…



  • FloatingWindows are meant to act like NSPanel, which hide when the app is unfocused.

    If you want a standard window that stays open when you leave the app (like erik's), use the vanilla class Window instead.

    from vanilla import *
    
    class WindowDemo(object):
        def __init__(self):
            self.w = Window((200, 70), "Window Demo")
            self.w.myButton = Button((10, 10, -10, 20), "My Button")
            self.w.myTextBox = TextBox((10, 40, -10, 17), "My Text Box")
            self.w.open()
    WindowDemo()