EVT_CLOSE(self.frame, self.OnCloseWindow)
+ def OnCloseWindow(self, event):
+ if self.frame is not None:
+ self.frame.Destroy()
+ self.frame = None
+ self.text = None
+
+
# These methods provide the file-like output behaviour.
def write(self, text):
"""
wx.CallAfter(self.frame.Close)
- def OnCloseWindow(self, event):
- if self.frame is not None:
- self.frame.Destroy()
- self.frame = None
- self.text = None
#----------------------------------------------------------------------
self.RestoreStdio()
- def RedirectStdio(self, filename):
+ def RedirectStdio(self, filename=None):
"""Redirect sys.stdout and sys.stderr to a file or a popup window."""
if filename:
_sys.stdout = _sys.stderr = open(filename, 'a')
return _core.GetAccelFromString(*args, **kwargs)
#---------------------------------------------------------------------------
+WINDOW_VARIANT_DEFAULT = _core.WINDOW_VARIANT_DEFAULT
+WINDOW_VARIANT_NORMAL = _core.WINDOW_VARIANT_NORMAL
+WINDOW_VARIANT_SMALL = _core.WINDOW_VARIANT_SMALL
+WINDOW_VARIANT_MINI = _core.WINDOW_VARIANT_MINI
+WINDOW_VARIANT_LARGE = _core.WINDOW_VARIANT_LARGE
class Window(EvtHandler):
"""
wx.Window is the base class for all windows and represents any visible
"""
GetLabel() -> String
- Generic way of getting a label from any window, for identification
- purposes. The interpretation of this function differs from class to
- class. For frames and dialogs, the value returned is the title. For
- buttons or static text controls, it is the button text. This function
- can be useful for meta-programs (such as testing tools or
- special-needs access programs) which need to identify windows by name.
+ Generic way of getting a label from any window, for
+ identification purposes. The interpretation of this function
+ differs from class to class. For frames and dialogs, the value
+ returned is the title. For buttons or static text controls, it is
+ the button text. This function can be useful for meta-programs
+ (such as testing tools or special-needs access programs) which
+ need to identify windows by name.
"""
return _core.Window_GetLabel(*args, **kwargs)
"""
SetName(String name)
- Sets the window's name. The window name is used for ressource setting
- in X, it is not the same as the window title/label
+ Sets the window's name. The window name is used for ressource
+ setting in X, it is not the same as the window title/label
"""
return _core.Window_SetName(*args, **kwargs)
"""
GetName() -> String
- Returns the window's name. This name is not guaranteed to be unique;
- it is up to the programmer to supply an appropriate name in the window
- constructor or via wx.Window.SetName.
+ Returns the window's name. This name is not guaranteed to be
+ unique; it is up to the programmer to supply an appropriate name
+ in the window constructor or via wx.Window.SetName.
"""
return _core.Window_GetName(*args, **kwargs)
+ def SetWindowVariant(*args, **kwargs):
+ """
+ SetWindowVariant(int variant)
+
+ Sets the variant of the window/font size to use for this window,
+ if the platform supports variants, (for example, wxMac.)
+ """
+ return _core.Window_SetWindowVariant(*args, **kwargs)
+
+ def GetWindowVariant(*args, **kwargs):
+ """GetWindowVariant() -> int"""
+ return _core.Window_GetWindowVariant(*args, **kwargs)
+
def SetId(*args, **kwargs):
"""
SetId(int winid)
"""
Freeze()
- Freezes the window or, in other words, prevents any updates from
- taking place on screen, the window is not redrawn at all. Thaw must be
- called to reenable window redrawing.
+ Freezes the window or, in other words, prevents any updates from taking place
+ on screen, the window is not redrawn at all. Thaw must be called to reenable
+ window redrawing. Calls to Freeze/Thaw may be nested, with the actual Thaw
+ being delayed until all the nesting has been undone.
This method is useful for visual appearance optimization (for example,
it is a good idea to use it before inserting large amount of text into
"""
Thaw()
- Reenables window updating after a previous call to Freeze.
+ Reenables window updating after a previous call to Freeze. Calls to
+ Freeze/Thaw may be nested, so Thaw must be called the same number of times
+ that Freeze was before the window will be updated.
"""
return _core.Window_Thaw(*args, **kwargs)
"""
return _core.Window_IsExposedPoint(*args, **kwargs)
- def isExposedRect(*args, **kwargs):
+ def IsExposedRect(*args, **kwargs):
"""
- isExposedRect(Rect rect) -> bool
+ IsExposedRect(Rect rect) -> bool
Returns true if the given point or rectangle area has been exposed
since the last repaint. Call this in an paint event handler to
optimize redrawing by only redrawing those areas, which have been
exposed.
"""
- return _core.Window_isExposedRect(*args, **kwargs)
+ return _core.Window_IsExposedRect(*args, **kwargs)
def SetBackgroundColour(*args, **kwargs):
"""
"""
GetFont() -> Font
- Returns a reference to the font for this window.
+ Returns the default font used for this window.
"""
return _core.Window_GetFont(*args, **kwargs)
return _core.FindWindowByLabel(*args, **kwargs)
def Window_FromHWND(*args, **kwargs):
- """Window_FromHWND(unsigned long hWnd) -> Window"""
+ """Window_FromHWND(Window parent, unsigned long _hWnd) -> Window"""
return _core.Window_FromHWND(*args, **kwargs)
#---------------------------------------------------------------------------
"""GetProportion() -> int"""
return _core.SizerItem_GetProportion(*args, **kwargs)
+ SetOption = SetProportion
+ GetOption = GetProportion
def SetFlag(*args, **kwargs):
"""SetFlag(int flag)"""
return _core.SizerItem_SetFlag(*args, **kwargs)
except NameError:
__builtins__.True = 1==1
__builtins__.False = 1==0
+ def bool(value): return not not value
+ __builtins__.bool = bool
class FutureCall:
"""
- A convenience class for wxTimer, that calls the given callable
+ A convenience class for wx.Timer, that calls the given callable
object once after the given amount of milliseconds, passing any
positional or keyword args. The return value of the callable is
availbale after it has been run with the GetResult method.
self.callable = callable
self.SetArgs(*args, **kwargs)
self.runCount = 0
+ self.running = False
self.hasRun = False
self.result = None
self.timer = None
self.Stop()
self.timer = wx.PyTimer(self.Notify)
self.timer.Start(self.millis, wx.TIMER_ONE_SHOT)
+ self.running = True
Restart = Start
"""
if self.callable and getattr(self.callable, 'im_self', True):
self.runCount += 1
+ self.running = False
self.result = self.callable(*self.args, **self.kwargs)
self.hasRun = True
- wx.CallAfter(self.Stop)
+ if not self.running:
+ # if it wasn't restarted, then cleanup
+ wx.CallAfter(self.Stop)
#----------------------------------------------------------------------------