<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[vanilla Window opening 2nd Window]]></title><description><![CDATA[<p dir="auto">Hi, I have a vanilla <code>Window</code> that calls another <code>Window</code> when a <code>Button</code> is pressed (for example, to edit preferences).</p>
<p dir="auto">Is it better / preferred / more "canonical" to initialize and open the second <code>Window</code> once (and use the button only to run <code>.show()</code> and <code>.hide()</code>), or to initialize and open a new second <code>Window</code> (and close it completely) when the button is pressed?</p>
<p dir="auto">A couple of examples to show what I mean below.</p>
<p dir="auto">A) First <code>Window</code> initializes second <code>Window</code> on <code>__init__</code>; button shows/closes</p>
<pre><code class="language-python">from prefWindow import PrefWindow
class MainWindow:
    def __init__(self):
        self.w = Window((200, 200))
        self.w.prefButton = Button((10, 10, -10, 20),
                                   "Open Pref",
                                   callback=self.prefCB)

        self.prefOpened = False

        self.prefWindow = PrefWindow()
        self.prefWindow.w.open()
        self.prefWindow.w.hide()

    def prefCB(self, sender):
        if self.prefOpened:
            self.prefWindow.hide()
        else:
            self.prefWindow.w.show()

        self.prefOpened = !self.prefOpened
</code></pre>
<p dir="auto">B) Button initializes new second <code>Window</code> every time</p>
<pre><code class="language-python">from prefWindow import PrefWindow
class MainWindow:
    def __init__(self):
        self.w = Window((200, 200))
        self.w.prefButton = Button((10, 10, -10, 20),
                                   "Open Pref",
                                   callback=self.prefCB)

        self.prefOpened = False

    def prefCB(self, sender):
        if self.prefOpened:
            self.prefWindow.w.close()
        else:
            self.prefWindow = PrefWindow()
            self.prefWindow.w.open()      

        self.prefOpened = !self.prefOpened    
</code></pre>
<p dir="auto">I've gotten both versions to work, so I'm just wondering if there's one way that's preferred. Thanks!</p>
]]></description><link>https://forum.robofont.com/topic/533/vanilla-window-opening-2nd-window</link><generator>RSS for Node</generator><lastBuildDate>Tue, 09 Jun 2026 21:12:30 GMT</lastBuildDate><atom:link href="https://forum.robofont.com/topic/533.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 11 Nov 2018 20:22:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to vanilla Window opening 2nd Window on Sun, 11 Nov 2018 22:19:13 GMT]]></title><description><![CDATA[<p dir="auto">Hi, I have a vanilla <code>Window</code> that calls another <code>Window</code> when a <code>Button</code> is pressed (for example, to edit preferences).</p>
<p dir="auto">Is it better / preferred / more "canonical" to initialize and open the second <code>Window</code> once (and use the button only to run <code>.show()</code> and <code>.hide()</code>), or to initialize and open a new second <code>Window</code> (and close it completely) when the button is pressed?</p>
<p dir="auto">A couple of examples to show what I mean below.</p>
<p dir="auto">A) First <code>Window</code> initializes second <code>Window</code> on <code>__init__</code>; button shows/closes</p>
<pre><code class="language-python">from prefWindow import PrefWindow
class MainWindow:
    def __init__(self):
        self.w = Window((200, 200))
        self.w.prefButton = Button((10, 10, -10, 20),
                                   "Open Pref",
                                   callback=self.prefCB)

        self.prefOpened = False

        self.prefWindow = PrefWindow()
        self.prefWindow.w.open()
        self.prefWindow.w.hide()

    def prefCB(self, sender):
        if self.prefOpened:
            self.prefWindow.hide()
        else:
            self.prefWindow.w.show()

        self.prefOpened = !self.prefOpened
</code></pre>
<p dir="auto">B) Button initializes new second <code>Window</code> every time</p>
<pre><code class="language-python">from prefWindow import PrefWindow
class MainWindow:
    def __init__(self):
        self.w = Window((200, 200))
        self.w.prefButton = Button((10, 10, -10, 20),
                                   "Open Pref",
                                   callback=self.prefCB)

        self.prefOpened = False

    def prefCB(self, sender):
        if self.prefOpened:
            self.prefWindow.w.close()
        else:
            self.prefWindow = PrefWindow()
            self.prefWindow.w.open()      

        self.prefOpened = !self.prefOpened    
</code></pre>
<p dir="auto">I've gotten both versions to work, so I'm just wondering if there's one way that's preferred. Thanks!</p>
]]></description><link>https://forum.robofont.com/post/1821</link><guid isPermaLink="true">https://forum.robofont.com/post/1821</guid><dc:creator><![CDATA[jesentanadi]]></dc:creator><pubDate>Sun, 11 Nov 2018 22:19:13 GMT</pubDate></item><item><title><![CDATA[Reply to vanilla Window opening 2nd Window on Mon, 12 Nov 2018 04:33:06 GMT]]></title><description><![CDATA[<p dir="auto">Its depends on what you would like to achieve. But take note that a window can be closed in different ways, <code>⌘ + w</code> or the red left top button... where you are not able to set the <code>prefOpened</code> attribute.</p>
<p dir="auto">Also you can not reopen a closed window. An other option is to overwrite the <code>close</code> callback in the window class used in the <code>vanilla.Window</code> object and just order out instead of closing the window.</p>
<p dir="auto">good luck!</p>
]]></description><link>https://forum.robofont.com/post/1824</link><guid isPermaLink="true">https://forum.robofont.com/post/1824</guid><dc:creator><![CDATA[frederik]]></dc:creator><pubDate>Mon, 12 Nov 2018 04:33:06 GMT</pubDate></item><item><title><![CDATA[Reply to vanilla Window opening 2nd Window on Mon, 12 Nov 2018 00:35:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.robofont.com/uid/1">@frederik</a> Good points, thanks. I was only using the <code>prefOpened</code> flags as examples above.</p>
<p dir="auto">I've been using the 2nd method (not using the flag, just initializing a new <code>PrefWindow()</code> every time I need that window). But because you can't reopen a closed window, like you said, I make a new <code>PrefWindow()</code> when the button is clicked. I'm just not sure if it's strange to be initializing all of the vanilla UI components over and over again?</p>
<p dir="auto">I'm thinking of switching to the first option (initialize once, and use <code>show()</code> and <code>hide()</code>), but also not sure if it's weird to have a hidden window in the "background."</p>
]]></description><link>https://forum.robofont.com/post/1825</link><guid isPermaLink="true">https://forum.robofont.com/post/1825</guid><dc:creator><![CDATA[jesentanadi]]></dc:creator><pubDate>Mon, 12 Nov 2018 00:35:22 GMT</pubDate></item><item><title><![CDATA[Reply to vanilla Window opening 2nd Window on Mon, 12 Nov 2018 21:50:37 GMT]]></title><description><![CDATA[<p dir="auto">depending on what you’re trying to build, you might also consider using a vanilla <code>Sheet</code> or <code>Drawer</code>. they work like separate windows attached to the parent window.</p>
]]></description><link>https://forum.robofont.com/post/1826</link><guid isPermaLink="true">https://forum.robofont.com/post/1826</guid><dc:creator><![CDATA[gferreira]]></dc:creator><pubDate>Mon, 12 Nov 2018 21:50:37 GMT</pubDate></item><item><title><![CDATA[Reply to vanilla Window opening 2nd Window on Mon, 12 Nov 2018 21:50:20 GMT]]></title><description><![CDATA[<p dir="auto">fyi: a drawer is not advised anymore by the <a href="http://developer.apple.com/design/human-interface-guidelines/macos/windows-and-views/drawers/" rel="nofollow">Human Interface guidelines</a>.</p>
]]></description><link>https://forum.robofont.com/post/1830</link><guid isPermaLink="true">https://forum.robofont.com/post/1830</guid><dc:creator><![CDATA[frederik]]></dc:creator><pubDate>Mon, 12 Nov 2018 21:50:20 GMT</pubDate></item><item><title><![CDATA[Reply to vanilla Window opening 2nd Window on Mon, 12 Nov 2018 23:44:21 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for the pointers <a class="plugin-mentions-user plugin-mentions-a" href="https://forum.robofont.com/uid/1">@frederik</a> &amp; <a class="plugin-mentions-user plugin-mentions-a" href="https://forum.robofont.com/uid/22">@gferreira</a>. Just to clarify... and maybe you guys can let me know if this way of thinking about things doesn't make sense.</p>
<p dir="auto">I'm building something that has a main <code>Window</code>, with a list of objects (using <code>vanilla.List</code>), and when the user clicks on a button, a second <code>Window</code> (or can be a <code>Sheet</code>) opens, where they can input some preferences.</p>
<p dir="auto">In my original thinking, the preference <code>Window</code> "belongs" to the object being edited, so I would initialize it every time the user hits the button. I only want one preference <code>Window</code> to be open at a time, so I use a flag to make sure the user can't open another preference <code>Window</code>.</p>
<p dir="auto">And this is where I started thinking of just using <code>show()</code> and <code>hide()</code>. Since I only want one preference <code>Window</code> anyway, it seems kind of strange to have to initialize and open one at every button click, and maybe I should just make one preference <code>Window</code> that's always open but is sometimes hidden. (In this case, the preference <code>Window</code> uses <code>closable=False</code>.)</p>
<p dir="auto">Either way, I'm passing in data from the object to the pref <code>Window</code>. In the first case, when initializing:</p>
<pre><code class="language-python">prefWindow = PrefWindow(some, data, here)
prefWindow.w.open()
</code></pre>
<p dir="auto">In the second case, I initialize with nothing and then have a method to update:</p>
<pre><code class="language-python">prefWindow = PrevWindow()
...

prefWindow.update(some, data, here)
prefWindow.w.show()
</code></pre>
]]></description><link>https://forum.robofont.com/post/1831</link><guid isPermaLink="true">https://forum.robofont.com/post/1831</guid><dc:creator><![CDATA[jesentanadi]]></dc:creator><pubDate>Mon, 12 Nov 2018 23:44:21 GMT</pubDate></item><item><title><![CDATA[Reply to vanilla Window opening 2nd Window on Fri, 16 Nov 2018 16:11:51 GMT]]></title><description><![CDATA[<p dir="auto">maybe the easiest way todo is use a subclass like RoboFont is using for some windows:</p>
<pre><code class="language-python">from mojo.UI import ShowHideWindow
# a show hide window is a special window that disables the close callback and just hides the window on close.
w = ShowHideWindow((100, 100))
w.open()
# we close
w.close()
# and are able to open it again
w.open()
# this also works
w.hide()
w.show()
</code></pre>
<p dir="auto">hope this helps to have only one instance of your window</p>
<p dir="auto">good luck</p>
]]></description><link>https://forum.robofont.com/post/1845</link><guid isPermaLink="true">https://forum.robofont.com/post/1845</guid><dc:creator><![CDATA[frederik]]></dc:creator><pubDate>Fri, 16 Nov 2018 16:11:51 GMT</pubDate></item><item><title><![CDATA[Reply to vanilla Window opening 2nd Window on Fri, 16 Nov 2018 21:40:33 GMT]]></title><description><![CDATA[<p dir="auto">Oh, that's a good one. Thanks <a class="plugin-mentions-user plugin-mentions-a" href="https://forum.robofont.com/uid/1">@frederik</a>!</p>
]]></description><link>https://forum.robofont.com/post/1847</link><guid isPermaLink="true">https://forum.robofont.com/post/1847</guid><dc:creator><![CDATA[jesentanadi]]></dc:creator><pubDate>Fri, 16 Nov 2018 21:40:33 GMT</pubDate></item></channel></rss>