Exemplo n.º 1
0
import gettext

gettext.install("Digsby")
import gui.native.win.winhelpers
from gui.native.docking import Docker
import wx, sys

if __name__ == "__main__":

    from gui.toolbox import setuplogging
    from util import trace

    setuplogging()
    a = wx.PySimpleApp()

    f2 = wx.Frame(
        None, title=u"Docking Control", pos=(400, 600), size=(150, 130), style=wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP
    )

    f = wx.Frame(f2, -1, u"Docking Test", size=(250, 500))

    b = wx.Button(f, -1, "vars")

    f.Sizer = sz = wx.BoxSizer(wx.VERTICAL)
    sz.Add(b)

    f.docker = Docker(f)

    def printvars(e):
        from pprint import pprint
Exemplo n.º 2
0
import gettext; gettext.install('Digsby')
import gui.native.win.winhelpers
from gui.native.docking import Docker
import wx, sys

if __name__ == '__main__':

    from gui.toolbox import setuplogging
    from util import trace

    setuplogging()
    a = wx.PySimpleApp()

    f2 = wx.Frame(None, title = u'Docking Control',
                  pos = (400, 600), size = (150,130),
                  style=wx.DEFAULT_FRAME_STYLE|wx.STAY_ON_TOP)

    f = wx.Frame(f2, -1, u'Docking Test', size = (250, 500))


    b = wx.Button(f, -1, 'vars')



    f.Sizer = sz = wx.BoxSizer(wx.VERTICAL)
    sz.Add(b)

    f.docker = Docker(f)

    def printvars(e):
        from pprint import pprint
Exemplo n.º 3
0
            # Save, Clear, and Cancel buttons
            bottom = wx.BoxSizer(wx.HORIZONTAL)
            bottom.AddMany([(b, 1, wx.EXPAND | wx.ALL, 3) for b in self.buttons[3:]])
            sz.AddMany([(bottom, 0, wx.EXPAND | wx.ALL, 3)])

    def buttonfor(self, s):
        return self.buttons[self.buttonnames.index(s)]

def cuthole(ctrl):
    top = wx.GetTopLevelParent(ctrl)
    x = ctrl.ScreenRect.X - top.ScreenRect.X
    y = ctrl.ScreenRect.Y - top.ScreenRect.Y
    w, h = ctrl.ClientSize

    winsz = top.Size
    region = wx.Region(0, 0, winsz[0], y)
    region.UnionRect((0, 0, x, winsz[1]))
    region.UnionRect((x+w, y, winsz[0] - w - x, h))
    region.UnionRect((0, y + h, winsz[0], winsz[1] - h - y))

    ApplySmokeAndMirrors(top, region)

if __name__ == '__main__':    # Tests the editor
    _ = lambda s: s
    from gui.toolbox import setuplogging; setuplogging()
    app = wx.PySimpleApp()
    IconEditor(None).ShowModal()



Exemplo n.º 4
0
def testapp(pypath = None, appname = 'Digsby', skinname = 'default', prefs = None, username = '******',
            on_message = lambda message: None,
            plugins = True, logging = True):
    'A test application framework for test __main__s.'


    if wxMSW: preload_comctrls()

    import gettext, os.path

    import options
    sys.opts, _args = options.parser.parse_args()
    import logextensions

    digsbysite.COLORIZE_EXCEPTIONS = sys.opts.console_color

    # Install gui elements
    gettext.install(appname, unicode=True)

    from bootstrap import install_N_
    install_N_()

    # Create the app
    app = TestApp()
    app.SetAppName(appname)

    # initialize stdpaths
    from stdpaths import init
    init()

    if wxMSW:
        import gui.native.win.winutil as winutil
        winutil.disable_callback_filter()

    from gui import skin
    from gui.toolbox import setuplogging
    if logging:
        import logging
        setuplogging(level=logging.INFO)


    # make wxLogError go to stderr, not popup dialogs
    wx.Log.SetActiveTarget(wx.LogStderr())

    app.PreShutdown = Delegate()

    if pypath is None:
        pypath = discover_digsby_root()

    sys.path.insert(0, pypath)

    skin.set_resource_paths([
                             util.program_dir() / 'res', # Apparently this has to be first?
                             stdpaths.userdata,
                             stdpaths.config,
                             ])

    if plugins:
        from main import init_plugins
        app.plugins = init_plugins()
    else:
        app.plugins = []


    skin.skininit(os.path.join(pypath, 'res'), skinname = skinname)

    from util.threads.threadpool import ThreadPool
    ThreadPool(5)

    from prefs.prefsdata import flatten
    import syck
    from util.observe import ObservableDict


    prefs_path = os.path.join(pypath, 'res', 'defaults.yaml')

    prefs = ObservableDict(prefs) if prefs is not None else ObservableDict()
    prefs.update({'appearance.skin': skinname,
                  'appearance.variant': None,
                  'debug.shell.font': shellfont()})
    import common
    common.set_active_prefs(prefs, {})

    from util.observe import ObservableDict

    sys.modules['digsbyprofile'] = Storage()
    import digsbyprofile
    from common.notifications import default_notifications
    p = digsbyprofile.profile = Storage(name     = username,
                                    username = username,
                                    prefs    = prefs,
                                    on_message = on_message,
                                    notifications = default_notifications)



    f = file(prefs_path)
    defaults = Storage(flatten(syck.load(f)))
    f.close()
    user = ObservableDict(defaults)
    user.update(prefs)

    from prefs.prefsdata import localprefs
    import prefs
    p.defaultprefs = prefs.defaultprefs()
    p.localprefs = localprefs()

    import common
    common.setfakeprefs(user)

    def toggle_prefs(user=user, defaults=defaults):
        import prefs
        prefs.edit(user, defaults, None)

    def toggle_crust(app=app):
        if not getattr(app, 'crust', None):
            import gui.shell
            wins =  wx.GetTopLevelWindows()
            parent = wins[0] if wins else None
            app.crust = gui.shell.PyCrustFrame(None)
            if parent is not None:
                parent.crust = app.crust
            app.crust.Bind(wx.EVT_CLOSE, lambda evt: app.Exit())
        app.crust.toggle_shown()

        # keyboard focus goes to shell prompt
        if app.crust.IsShown():
            app.crust.crust.SetFocus()

    def on_key(e):
        code = e.GetKeyCode()
        if code == wx.WXK_F11:
            toggle_prefs()
        elif code == wx.WXK_F12:
            toggle_crust()
        elif code == wx.WXK_F5:
            from gui import skin
            skin.reload()
        else:
            e.Skip()

    app.Bind(wx.EVT_KEY_DOWN, on_key)
    app.toggle_crust = toggle_crust

    from main import initialize_webkit, SetStatusPrompt
    initialize_webkit()
    app.SetStatusPrompt = SetStatusPrompt

    return app