home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 October / maximum-cd-2011-10.iso / DiscContents / digsby_setup.exe / lib / gui / native / win / toplevel.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-06-22  |  4.1 KB  |  95 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  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 = timeout)
  57.     flashinfo.cbSize = sizeof(FLASHWINFO)
  58.     FlashWindowEx(flashinfo.ptr)
  59.  
  60.  
  61. def FlashOnce(win):
  62.     return FlashWindow(win.Handle, 1)
  63.  
  64.  
  65. def main():
  66.     a = wx.PySimpleApp()
  67.     f = wx.Frame(None, title = 'test')
  68.     f.Title = 'test %s' % f.Handle
  69.     f.Show()
  70.     f2 = wx.Frame(None, title = 'control')
  71.     r = f.Rect
  72.     f2.Rect = wx.Rect(r.Right, r.Top, r.Width, r.Height)
  73.     
  74.     def b(t, c):
  75.         button = wx.Button(f2, -1, t)
  76.         button.Bind((wx.EVT_BUTTON,), (lambda e: c()))
  77.         return button
  78.  
  79.     flashex = b(('FlashWindowEx',), (lambda : Flash(f)))
  80.     request = b('RequestUserAttention', f.RequestUserAttention)
  81.     settitle = b(('Set Title',), (lambda : (f.SetTitle(f.GetTitle() + ' Yay'), Flash(f))))
  82.     stop = b(('Stop Flashing',), (lambda : StopFlashing(f)))
  83.     s.AddMany([
  84.         flashex,
  85.         request,
  86.         settitle,
  87.         stop])
  88.     s.Layout()
  89.     f2.Show()
  90.     a.MainLoop()
  91.  
  92. if __name__ == '__main__':
  93.     main()
  94.  
  95.