How to use the leo.core.leoGlobals.app function in leo

To help you get started, we’ve selected a few leo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github leo-editor / leo-editor / leo / plugins / qt_gui.py View on Github external
def close_event(self, event):

        noclose = False
        if g.app.sessionManager and g.app.loaded_session:
            g.app.sessionManager.save_snapshot()
        for c in g.app.commanders():
            allow = c.exists and g.app.closeLeoWindow(c.frame)
            if not allow:
                noclose = True
        if noclose:
            event.ignore()
        else:
            event.accept()
    #@+node:ekr.20110605121601.18481: *4* qt_gui.onDeactiveEvent
github leo-editor / leo-editor / leo / core / leoCompare.py View on Github external
def open_outline(self, fn):
        """
        Find the commander for fn, creating a new outline tab if necessary.
        
        Using open commanders works because we always read entire .leo files.
        """
        for frame in g.app.windowList:
            if frame.c.fileName() == fn:
                return frame.c
        gui = None if self.visible else g.app.nullGui
        return g.openWithFileName(fn, gui=gui)
    #@-others
github leo-editor / leo-editor / leo / core / leoGtkTree.py View on Github external
clickBoxOffset_x, clickBoxOffset_y = self._clickBoxOffset

        clickBoxCenterOffset_x, clickBoxCenterOffset_y = \
            self._clickBoxCenterOffset

        clickBoxSize_w, clickBoxSize_h = self._clickBoxSize

        iconSize_w, iconSize_h = self._iconSize

        lineHeight = self._lineHeight
        halfLineHeight = lineHeight//2


        # images
        gui = g.app.gui

        icons = gui.treeIcons
        globalImages = gui.globalImages
        plusBoxIcon = gui.plusBoxIcon
        minusBoxIcon = gui.minusBoxIcon

        currentPosition = c.currentPosition()

        #@-node:bob.20080118085835:<< setup local variables >>
        #@nl

        cr = self._buffer.cairo_create()


        cr.rectangle(0, 0, canvasWidth, canvasHeight)
        cr.clip()
github leo-editor / leo-editor / leo / core / leoConfig.py View on Github external
def doPopup(self, p, kind, name, val):
        """
        Handle @popup menu items in @settings trees.
        """
        popupName = name
        # popupType = val
        aList = []
        p = p.copy()
        self.doPopupItems(p, aList)
        if not hasattr(g.app.config, 'context_menus'):
            g.app.config.context_menus = {}
        g.app.config.context_menus[popupName] = aList
    #@+node:bobjack.20080324141020.5: *5* doPopupItems
github leo-editor / leo-editor / leo / plugins / qt_big_text.py View on Github external
def copy(self):
        '''Copy self.s (c.p.b) to the clipboard.'''
        g.app.gui.replaceClipboardWith(self.s)
    #@+node:ekr.20141018081615.18276: *3* btc.go_away
github leo-editor / leo-editor / leo / plugins / ipython.py View on Github external
def createCommands(self):

        '''Create all of the ipython plugin's minibuffer commands.'''

        c = self.c ; k = c.k

        table = (
            ('start-ipython',   self.startIPython),
            ('push-to-ipython', self.pushToIPythonCommand),
        )

        shortcut = None

        if not g.app.unitTesting:
            g.es('ipython plugin...',color='purple')

        for commandName,func in table:
            k.registerCommand (commandName,shortcut,func,pane='all',verbose=True)
    #@+node:ekr.20080201151802.1: *3* Commands
github leo-editor / leo-editor / leo / core / leoApp.py View on Github external
g.app.useIpython = options.use_ipython
        if trace: g.trace('g.app.useIpython',g.app.useIpython)
        # --fullscreen
        # --minimized
        # --maximized
        g.app.start_fullscreen = options.fullscreen
        g.app.start_maximized = options.maximized
        g.app.start_minimized = options.minimized
        # --no-cache
        if options.no_cache:
            if trace: print('scanOptions: disabling caching')
            g.enableDB = False
        # --no-plugins
        if options.no_plugins:
            if trace: print('scanOptions: disabling plugins')
            g.app.enablePlugins = False
        # --no-splash: --minimized disables the splash screen
        g.app.use_splash_screen = (
            not options.no_splash_screen and
            not options.minimized)
        # --screen-shot=fn
        screenshot_fn = options.screenshot_fn
        if screenshot_fn:
            screenshot_fn = screenshot_fn.strip('"')
            if trace: print('scanOptions: screenshot_fn',screenshot_fn)
        # --script
        script_path = options.script
        script_path_w = options.script_window
        if script_path and script_path_w:
            parser.error('--script and script-window are mutually exclusive')
        script_name = script_path or script_path_w
        if script_name:
github leo-editor / leo-editor / leo / plugins / image.py View on Github external
def onSelect (tag,keywords):

    new_v = keywords.get("new_v")
    h = new_v.h
    if h[:7] == "@image ":
        filename = h[7:]
        #@+<< Select Image >>
        #@+node:edream.110203113231.755: *3* << Select Image >>
        # Display the image file in the text pane, if you can find the file
        a = g.app
        c = keywords.get("c")
        body = c.frame.body
        photo = None

        if os.path.isfile(filename):
            if ImageTk: # ImageTk understands several file formats.
                try:
                    photo = ImageTk.PhotoImage(master=a.root, file=filename)
                except Exception:
                    # g.es_exception()
                    g.es("ImageTk.PhotoImage failed")
            if not photo:
                try:# Note that Tkinter only understands GIF
                    photo = Tk.PhotoImage(master=a.root, file=filename)
                except Exception:
                    g.es_exception()
github leo-editor / leo-editor / leo / plugins / at_produce.py View on Github external
def run(c,all):
    '''
    Run all @produce nodes in a separate thread.
    Report progress via a timer in *this* thread.
    '''
    aList = getList(c,all)
    g.app.at_produce_command = None
    def thread_target():
        # runList must not change Leo's outline or log!
        # runList uses c only to update c.at_produce_command.
        runList(c,aList)
    t = threading.Thread(target=thread_target)
    t.setDaemon(True)
    t.start()
    timer = g.IdleTime(handler=None,delay=500,tag='at-produce')
    c._at_produce_max = 20
    c._at_produce_count = c._at_produce_max -1
    def timer_callback(tag):
        timer_callback_helper(c,t,timer)
    timer.handler = timer_callback
    timer.start()
#@+node:ekr.20040915085351.2: *3* getList
github leo-editor / leo-editor / leo / plugins / quicksearch.py View on Github external
c.frame.nav = wdg

    # make activating this tab activate the input box
    def activate_input(idx, c=c):
        wdg = c.frame.nav
        tab_widget = wdg.parent().parent()
        if (tab_widget and
            hasattr(tab_widget, 'currentWidget') and
            tab_widget.currentWidget() == wdg
        ):
            wdg.ui.lineEdit.selectAll()
            wdg.ui.lineEdit.setFocus()

    # Careful: we may be unit testing.
    if wdg and wdg.parent() and not g.app.dock:
        tab_widget = wdg.parent().parent()
        tab_widget.currentChanged.connect(activate_input)
#@+node:ekr.20111014074810.15659: *3* matchLines