Checking if a window is visible

Yes, I've checked the docs, as usual I can't find it.

I just want to check if a particular wigit is visible to the user (I've
several overlain on a sizer and swap them in and out) , I can't findanything
like

wigit.Visible().

Any help appreciated.

Richard

Richard,

I do not know if this will do it, but, I checked in the wxWidgets
documentation and it seems that many widgets are based on the wxWindow
class, which has the following method:

wxWindow::IsShown

virtual bool IsShown()
const

Returns true if the window
is shown, false if it has been hidden.

So my thought is if you
have a control, say, myButton, then myButton.IsShow( ) will return True
or False, depending on its state.

Ira

Richard Terry wrote:

···

wxPython-users-unsubscribe@lists.wxwidgets.orgwxPython-users-help@lists.wxwidgets.org

Richard,

Here is some sample code (I ran it under Windows XP with ActiveState
Python 2.4 from the PythonWin editor) that works and shows the use of
widget.IsShown( ) called when a button is shown and when it is hidden.
I assume you mean when a widget is swapped out that is has not been
destroyed.

Ira

import wx

class Frame(wx.Frame):

def __init__(self, parent=None, id=-1, title='Title',

             pos=wx.DefaultPosition, size=(300, 300)):

    wx.Frame.__init__(self, parent, id, title, pos, size)

       

    self.panel = wx.Panel(self, -1, pos=(0, 0), size=(300, 300))

    self.b = wx.Button(self.panel, -1, "Click me!", (50,50))

    self.Bind(wx.EVT_BUTTON, self.OnButton, self.b)

    result = self.b.IsShown()

    print "Button visible? : %s" % (result)

def OnButton(self, evt):

    self.b.Hide( )

    result = self.b.IsShown()

    print "Button visible? : %s" % (result)

------------------------------- application

···

wxPython-users-unsubscribe@lists.wxwidgets.orgwxPython-users-help@lists.wxwidgets.org

thanks, will give it a go tonight.

Richard

···

On Wednesday 25 January 2006 18:03, Ira Kaplan wrote:

Richard,

Here is some sample code (I ran it under Windows XP with ActiveState
Python 2.4 from the PythonWin editor) that works and shows the use of
widget.IsShown( ) called when a button is shown and when it is hidden.
I assume you mean when a widget is swapped out that is has not been
destroyed.

Ira

import wx

class Frame(wx.Frame):
    def __init__(self, parent=None, id=-1, title='Title',
                 pos=wx.DefaultPosition, size=(300, 300)):
        wx.Frame.__init__(self, parent, id, title, pos, size)

        self.panel = wx.Panel(self, -1, pos=(0, 0), size=(300, 300))

        self.b = wx.Button(self.panel, -1, "Click me!", (50,50))
        self.Bind(wx.EVT_BUTTON, self.OnButton, self.b)

        result = self.b.IsShown()
        print "Button visible? : %s" % (result)

    def OnButton(self, evt):
        self.b.Hide( )
        result = self.b.IsShown()
        print "Button visible? : %s" % (result)

# ------------------------------- application
--------------------------------
class App(wx.App):
    def OnInit(self):
        self.frame = Frame()
        self.frame.Show()
        return True

# ---------------------------------- main
------------------------------------
def main():
    app = App()
    app.MainLoop()

if __name__ == '__main__':
    main()

Richard Terry wrote:
>Yes, I've checked the docs, as usual I can't find it.
>
>I just want to check if a particular wigit is visible to the user (I've
>several overlain on a sizer and swap them in and out) , I can't
> findanything like
>
> wigit.Visible().
>
>Any help appreciated.
>
>Richard
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
>For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Success!!!!

···

On Wednesday 25 January 2006 18:09, Richard Terry wrote:

thanks, will give it a go tonight.

Richard

On Wednesday 25 January 2006 18:03, Ira Kaplan wrote:
> Richard,
>
> Here is some sample code (I ran it under Windows XP with ActiveState
> Python 2.4 from the PythonWin editor) that works and shows the use of
> widget.IsShown( ) called when a button is shown and when it is hidden.
> I assume you mean when a widget is swapped out that is has not been
> destroyed.
>
> Ira
>
> import wx
>
> class Frame(wx.Frame):
> def __init__(self, parent=None, id=-1, title='Title',
> pos=wx.DefaultPosition, size=(300, 300)):
> wx.Frame.__init__(self, parent, id, title, pos, size)
>
> self.panel = wx.Panel(self, -1, pos=(0, 0), size=(300, 300))
>
> self.b = wx.Button(self.panel, -1, "Click me!", (50,50))
> self.Bind(wx.EVT_BUTTON, self.OnButton, self.b)
>
> result = self.b.IsShown()
> print "Button visible? : %s" % (result)
>
>
> def OnButton(self, evt):
> self.b.Hide( )
> result = self.b.IsShown()
> print "Button visible? : %s" % (result)
>
>
> # ------------------------------- application
> --------------------------------
> class App(wx.App):
> def OnInit(self):
> self.frame = Frame()
> self.frame.Show()
> return True
>
>
> # ---------------------------------- main
> ------------------------------------
> def main():
> app = App()
> app.MainLoop()
>
>
> if __name__ == '__main__':
> main()
>
> Richard Terry wrote:
> >Yes, I've checked the docs, as usual I can't find it.
> >
> >I just want to check if a particular wigit is visible to the user (I've
> >several overlain on a sizer and swap them in and out) , I can't
> > findanything like
> >
> > wigit.Visible().
> >
> >Any help appreciated.
> >
> >Richard
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
> >For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org