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

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from __future__ import with_statement
  5. import os
  6. import sys
  7. import wx
  8. import wx.py as py
  9. from util import traceguard
  10. from gui.toolbox import loadWindowPos, saveWindowPos
  11. import gui.native.helpers as gui
  12. __all__ = [
  13.     'PyCrustFrame']
  14. if hasattr(sys, 'gettotalrefcount'):
  15.     
  16.     def get_total_refcount():
  17.         return '-- totalrefs: %d' % sys.gettotalrefcount()
  18.  
  19. else:
  20.     
  21.     def get_total_refcount():
  22.         return ''
  23.  
  24.  
  25. class PyCrustFrame(wx.Frame):
  26.     
  27.     def __init__(self, parent = None, id_ = -1, title = 'Digsby Shell', standalone = False, name = 'Digsby Shell'):
  28.         wx.Frame.__init__(self, parent, id_)
  29.         self.SetTitle(self.ShellTitle)
  30.         self.Bind(wx.EVT_SHOW, self.on_show)
  31.         self.title_timer = (wx.PyTimer,)((lambda : self.SetTitle(self.ShellTitle)))
  32.         self.title_timer_interval = 500
  33.         
  34.         try:
  35.             import digsbyprofile
  36.             prefs = digsbyprofile.profile.prefs
  37.         except ImportError:
  38.             prefs = { }
  39.         except AttributeError:
  40.             prefs = { }
  41.  
  42.         py.editwindow.FACES['mono'] = prefs.get('debug.shell.font', 'Courier New')
  43.         if prefs.get('debug.shell.minimal', True):
  44.             crust = shell = py.shell.Shell(self)
  45.         else:
  46.             crust = py.crust.Crust(self, intro = 'Digsby Shell')
  47.             shell = crust.shell
  48.         wx.GetApp().shell_locals = shell.interp.locals
  49.         import common.commandline as common
  50.         shell.interp.locals.update(common.commandline.__dict__)
  51.         self.input = shell
  52.         if 'debug.shell.history.size' in prefs:
  53.             maxsize = prefs['debug.shell.history.size']
  54.             h = prefs['debug.shell.history.lines']
  55.             h = h[:maxsize]
  56.             prefs['debug.shell.history.lines'] = shell.history = h
  57.         
  58.         self.crust = crust
  59.         self.Bind(wx.EVT_CLOSE, self.on_close)
  60.         loadWindowPos(self)
  61.         self.standalone = standalone
  62.         traceguard.__enter__()
  63.         
  64.         try:
  65.             skin = skin
  66.             import gui
  67.             self.SetFrameIcon(skin.get('AppDefaults.TaskbarIcon').Inverted)
  68.         finally:
  69.             pass
  70.  
  71.  
  72.     
  73.     def FocusInput(self):
  74.         self.input.SetFocus()
  75.  
  76.     
  77.     def on_close(self, e = None):
  78.         if self.IsShown():
  79.             saveWindowPos(self)
  80.         
  81.         self.Show(False)
  82.         if self.standalone:
  83.             sys.exit()
  84.         
  85.  
  86.     
  87.     def on_show(self, shown):
  88.         shown.Skip()
  89.         if shown:
  90.             self.title_timer.Start(self.title_timer_interval, False)
  91.         else:
  92.             self.title_timer.Stop()
  93.  
  94.     if 'wxMSW' in wx.PlatformInfo:
  95.         
  96.         def ShellTitle(self):
  97.             m = memory_info()
  98.             ramusage = '%s' % nicebytecount(m.WorkingSetSize)
  99.             if m.PrivateUsage:
  100.                 ramusage += '/%s' % nicebytecount(m.PrivateUsage)
  101.             
  102.             return 'Digsby Shell -- %s -- (gdi: %s, user: %s) -- pid: %s %s' % (ramusage, count_gdi_objects(), count_user_objects(), os.getpid(), get_total_refcount())
  103.  
  104.         ShellTitle = property(ShellTitle)
  105.     else:
  106.         ShellTitle = 'Digsby Shell'
  107.     
  108.     def toggle_shown(self):
  109.         if self.Visible:
  110.             self.on_close()
  111.         else:
  112.             self.Show()
  113.             if self.IsIconized():
  114.                 self.Iconize(False)
  115.             
  116.             self.Raise()
  117.  
  118.  
  119. if 'wxMSW' in wx.PlatformInfo:
  120.     from gui.native.win.process import memory_info, count_gdi_objects, count_user_objects
  121.     from util import nicebytecount
  122.     import gc
  123.  
  124.