manhole.py :  » IDE » PIDA » pida-0.6beta3 » pida » services » manhole » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » IDE » PIDA 
PIDA » pida 0.6beta3 » pida » services » manhole » manhole.py
# -*- coding: utf-8 -*-
"""
    The debug python shell

    :copyright: 2005-2008 by The PIDA Project
    :license: GPL 2 or later (see README/COPYING/LICENSE)
"""

import gtk

# PIDA Imports
from pida.core.service import Service
from pida.core.features import FeaturesConfig
from pida.core.commands import CommandsConfig
from pida.core.events import EventsConfig
from pida.core.actions import ActionsConfig
from pida.core.actions import TYPE_NORMAL,TYPE_MENUTOOL,TYPE_RADIO,TYPE_TOGGLE
from pida.ui.views import PidaView

from pida.utils.pyconsole import Console

# locale
from pida.core.locale import Locale
locale = Locale('manhole')
_ = locale.gettext

class ManholeActionsConfig(ActionsConfig):

    def create_actions(self):
        self.create_action(
            'show_manhole',
            TYPE_TOGGLE,
            _('PIDA Internal Shell'),
            _('Open the PIDA Internal Shell'),
            'face-monkey',
            self.on_show_manhole,
            '<Shift><Control>M',
        )

    def on_show_manhole(self, action):
        if action.get_active():
            self.svc.show_manhole()
        else:
            self.svc.hide_manhole()

class ManholeView(PidaView):

    key = 'manhole.shell'
    icon_name = 'face-monkey'

    label_text = _('Debug PIDA')

    def create_ui(self):
        console = Console(locals=self.svc.get_local_dict(),
                          banner=_("PIDA Shell. Keep breathing."),
                          use_rlcompleter=False)
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add(console)
        sw.show_all()
        self.add_main_widget(sw)

    def can_be_closed(self):
        self.svc.get_action('show_manhole').set_active(False)

# Service class
class Manhole(Service):
    """Describe your Service Here""" 

    actions_config = ManholeActionsConfig
    
    def start(self):
        self._view = ManholeView(self)

    def show_manhole(self):
        self.boss.cmd('window', 'add_view', paned='Terminal', view=self._view)

    def hide_manhole(self):
        self.boss.cmd('window', 'remove_view', view=self._view)

    def get_local_dict(self):
        return dict(boss=self.boss)

# Required Service attribute for service loading
Service = Manhole



# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.