Running from Sublime

Here is a link to Josh Korn's Sublime install tutorial: Mac or Windows to install Sublime, a text editor.

Once you've finished his tutorial, run Python to make sure it can run.

Open Sublime -> Preferences -> Browse Packages -> User and open python-with-ui-options.py

Copy and paste this code at the end of the file:

###########################################################
#Panda3D

class PydevpandaCommand(sublime_plugin.WindowCommand):
    def run(self):     
        if (self.window.num_groups() != 2):
            self.window.run_command(
                'set_layout',
                {"cols":[0.0, 1.0],
                 "rows":[0.0, 0.5, 1.0],
                 "cells":[[0, 0, 1, 1], [0, 1, 1, 2]]
                }
            )
        pythonEditorsGroup = 0
        self.window.focus_group(pythonEditorsGroup)
        view = self.window.active_view()
        if (view.is_dirty()):
            view.run_command('save')
        pythonInterpretersGroup = 1
        for view in self.window.views_in_group(pythonInterpretersGroup):
            view.close()
        self.window.run_command(
            'repl_open',
            {"type": "subprocess",
             "encoding": "utf8",
             "cmd": ["ppython", "-i", "-u", "$file"],
             "cwd": "$file_path",
             "syntax": "Packages/Text/Plain text.tmLanguage",
             "external_id": "python"
            }
        )
        self.window.run_command(
            'move_to_group',
            { "group": pythonInterpretersGroup }
        )
        view = self.window.active_view()
        layout_width, layout_height = view.layout_extent()
        window_width, window_height = view.viewport_extent()
        new_top = layout_height - window_height
        view.set_viewport_position((0, max(new_top, 0)

Then, go to Preferences -> Key Bindings and add

{ "keys": ["command+q"], "command": "pydevpanda"}, 
{ "keys": ["control+q"], "command": "pydevpanda"}

to the list in the User settings file.

Save both files.

Now, try and run ppython by hitting control/command+q on a sample Panda3D file!

results matching ""

    No results matching ""