예제 #1
0
def setMediaPath(directory):
    """Method to set the media path by setting the directory to use

    Parameters:
        directory - the directory to use for the media path
    """
    Config.setConfigVal("CONFIG_MEDIA_PATH", directory)
예제 #2
0
파일: Picture.py 프로젝트: gordon-cs/JES4py
    def __runScript(self, script, *argv):
        """Run a Python script in a subprocess

        Parameters
        ----------
        script : str
            the script to run; must be in the jes4py directory
        *argv : list
            parameters to pass to script on command line

        Returns
        -------
        Popen instance
        """
        # Start subprocess using current Python intepreter to run a script
        scriptpath = os.path.join(Config.getConfigVal("CONFIG_JES4PY_PATH"),
                                  script)
        proc = subprocess.Popen([sys.executable, scriptpath] + list(argv),
                                stdin=PIPE)

        # Register atexit handler if this is the first subprocess
        if len(self.subprocessList) == 0:
            atexit.register(self.__stopAllSubprocesses)

        # Record the process and return

        self.subprocessList.append(proc)
        return proc
예제 #3
0
def getMediaDirectory():
    """Method to get the directory for the media

    Returns:
        the media directory
    """
    return Config.getConfigVal("CONFIG_MEDIA_PATH")
예제 #4
0
def getMediaPath(fileName):
    """Method to get full path for the passed file name

    Parameters:
        fileName - the name of a file
    Returns:
        the full path for the file
    """
    return os.path.join(Config.getConfigVal("CONFIG_MEDIA_PATH"), fileName)
예제 #5
0
def pickADirectory():
    """Method to let the user pick a directory and return the full
       path as a string.

    Returns:
        the full directory path
    """
    # Create open file dialog
    directory = Config.getConfigVal('CONFIG_SESSION_PATH')
    scriptpath = os.path.join(Config.getConfigVal("CONFIG_JES4PY_PATH"),
                              'filePicker.py')
    path = subprocess.check_output(
        [sys.executable, scriptpath, 'folder', directory]).decode()
    if path == '':
        return None
    else:
        Config.setConfigVal('CONFIG_SESSION_PATH', path)
        return path
예제 #6
0
 def pickAColor(cls):
     # Start subprocess using current Python intepreter to run a script
     scriptpath = os.path.join(Config.getConfigVal("CONFIG_JES4PY_PATH"),
                               'colorPicker.py')
     color = subprocess.check_output([sys.executable, scriptpath]).decode()
     if color == '':
         color = None
     else:
         color = Color(list(map(int, color.split())))
     return color
예제 #7
0
def pickAFile():
    """Method to let the user pick a file and return the full name as
       as a string.  If the user didn't pick a file then the name
       will be None.

    Returns:
        the file file name of the picked file or None
    """
    # Create open file dialog
    directory = Config.getConfigVal('CONFIG_SESSION_PATH')
    scriptpath = os.path.join(Config.getConfigVal("CONFIG_JES4PY_PATH"),
                              'filePicker.py')
    path = subprocess.check_output(
        [sys.executable, scriptpath, 'file', directory]).decode()
    if path == '':
        return None
    else:
        Config.setConfigVal('CONFIG_SESSION_PATH', os.path.dirname(path))
        return path
예제 #8
0
    def __init__(self, sound, frameNumber):
        """Constructor

        Parameters
        ----------
        sound : Sound
            sound the frame (sample) belongs to
        frameNumber : int
            index of frame (sample)
        """
        self.wrapLevels = Config.getConfigVal("CONFIG_WRAPPIXELVALUES")
        self.sound = sound
        self.frameNumber = frameNumber
예제 #9
0
    def __init__(self, image=None, x=None, y=None):
        """Pixel constructor

        Parameters
        ----------
        image : PIL.Image
            image the pixel belongs to
        x : int
            column of the pixel
        y : int
            row of the pixel
        """
        self.wrapLevels = Config.getConfigVal("CONFIG_WRAPPIXELVALUES")
        self.image = image
        self.x = x
        self.y = y
예제 #10
0
from jes4py import Config

# Add other "top-level" modules here
from jes4py.media import *
#from jes4py.sound import *

Config.initDict()
Config.initPath()
예제 #11
0
def pickMediaPath():
    path = pickADirectory()
    Config.setConfigVal("CONFIG_MEDIA_PATH", path)