home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 September / maximum-cd-2009-09.iso / DiscContents / digsby_setup.exe / lib / gui / native / win / toplevel.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-02-26  |  4.1 KB  |  96 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import wx
  5. import sys
  6. import ctypes
  7. from util import ffi
  8. from ctypes import sizeof, byref
  9. from ctypes.wintypes import UINT, HWND, DWORD
  10. from gui.native.win.winutil import WinStruct
  11. ffi.cimport(user32 = [
  12.     'FlashWindowEx',
  13.     'FlashWindow'])
  14. FLASHW_STOP = 0
  15. FLASHW_CAPTION = 1
  16. FLASHW_TRAY = 2
  17. FLASHW_ALL = FLASHW_CAPTION | FLASHW_TRAY
  18. FLASHW_TIMER = 4
  19. FLASHW_TIMERNOFG = 12
  20.  
  21. class FLASHWINFO(WinStruct):
  22.     _fields_ = [
  23.         ('cbSize', UINT),
  24.         ('hwnd', HWND),
  25.         ('dwFlags', DWORD),
  26.         ('uCount', UINT),
  27.         ('dwTimeout', DWORD)]
  28.  
  29. if not FlashWindowEx:
  30.     
  31.     wx.TopLevelWindow.StopFlashing = lambda win: pass
  32. else:
  33.     FLASHWINFOsize = sum((lambda .0: for zz in .0:
  34. sizeof(zz))((UINT, HWND, DWORD, UINT, DWORD)))
  35.     tlw = wx.TopLevelWindow
  36.     
  37.     def StopFlashing(win):
  38.         f = FLASHWINFO(cbSize = FLASHWINFOsize, hwnd = win.Handle, dwFlags = FLASHW_STOP)
  39.         FlashWindowEx(f.ptr)
  40.         
  41.         def doint():
  42.             if not wx.IsDestroyed(win):
  43.                 tlw.SetTitle(win, tlw.GetTitle(win))
  44.             
  45.  
  46.         wx.CallLater(1000, doint)
  47.         wx.CallLater(3000, doint)
  48.         doint()
  49.  
  50.     wx.TopLevelWindow.StopFlashing = StopFlashing
  51.  
  52. def Flash(win, titlebar = True, taskbar = True, timeout = 0, count = 1, until = 'foreground'):
  53.     flags = 0
  54.     None |= flags if titlebar else 0
  55.     None |= flags if taskbar else 0
  56.     flashinfo = FLASHWINFO(hwnd = win.Handle, dwFlags = flags, uCount = count, dwTimeout = 0)
  57.     flashinfo.cbSize = sizeof(FLASHWINFO)
  58.     print flashinfo
  59.     print FlashWindowEx(flashinfo.ptr)
  60.  
  61.  
  62. def FlashOnce(win):
  63.     return FlashWindow(win.Handle, 1)
  64.  
  65.  
  66. def main():
  67.     a = wx.PySimpleApp()
  68.     f = wx.Frame(None, title = 'test')
  69.     f.Title = 'test %s' % f.Handle
  70.     f.Show()
  71.     f2 = wx.Frame(None, title = 'control')
  72.     r = f.Rect
  73.     f2.Rect = wx.Rect(r.Right, r.Top, r.Width, r.Height)
  74.     
  75.     def b(t, c):
  76.         button = wx.Button(f2, -1, t)
  77.         button.Bind((wx.EVT_BUTTON,), (lambda e: c()))
  78.         return button
  79.  
  80.     flashex = b(('FlashWindowEx',), (lambda : Flash(f)))
  81.     request = b('RequestUserAttention', f.RequestUserAttention)
  82.     settitle = b(('Set Title',), (lambda : (f.SetTitle(f.GetTitle() + ' Yay'), Flash(f))))
  83.     stop = b(('Stop Flashing',), (lambda : StopFlashing(f)))
  84.     s.AddMany([
  85.         flashex,
  86.         request,
  87.         settitle,
  88.         stop])
  89.     s.Layout()
  90.     f2.Show()
  91.     a.MainLoop()
  92.  
  93. if __name__ == '__main__':
  94.     main()
  95.  
  96.