예제 #1
0
파일: media.py 프로젝트: gordon-cs/JES4py
def setMediaPath(file=None):
    global mediaFolder
    if (file == None):
        FileChooser.pickMediaPath()
    else:
        FileChooser.setMediaPath(file)
    mediaFolder = getMediaPath()
    return mediaFolder
예제 #2
0
파일: Picture.py 프로젝트: gordon-cs/JES4py
    def setMediaPath(self, directory):
        """Method to set the directory for the media

        Parameters
        ----------
        directory : str
            the directory to use for the media path

        """
        FileChooser.setMediaPath(directory)
예제 #3
0
파일: media.py 프로젝트: gordon-cs/JES4py
def pickAFolder():
    # Note: this needs to be done in a threadsafe manner, see FileChooser
    # for details how this is accomplished.
    dir = FileChooser.pickADirectory()
    if (dir != None):
        return str(dir + os.sep)
    return None
예제 #4
0
파일: Picture.py 프로젝트: gordon-cs/JES4py
    def getMediaPath(self, fileName):
        """Method to get the directory for the media

        Parameters
        ----------
        fileName : str
            the fileName the base file name to use

        Returns
        -------
        str
            the full path name by appending the file name to the media directory
        """
        return FileChooser.getMediaPath(fileName)
예제 #5
0
파일: Picture.py 프로젝트: gordon-cs/JES4py
 def __init__(self, *args, **kwargs):
     """Initializer for Picture class
     """
     self.filename = self.title = 'None'
     if len(args) == 0:
         # no parameters, make 100x200 picture with white background
         self.image = PIL.Image.new("RGB", (200, 100), (255, 255, 255))
     elif len(args) == 1:
         if isinstance(args[0], str):
             self.filename = self.title = args[0]
             # Assume 'we've been passed a filename
             if not os.path.isfile(self.filename):
                 # File not found, try prepending media path
                 filepath = FileChooser.getMediaPath(self.filename)
                 if os.path.isfile(filepath):
                     self.filename = self.title = filepath
             try:
                 self.image = PIL.Image.open(self.filename)
             except:
                 self.image = PIL.Image.new("RGB", (600, 200))
                 draw = PIL.ImageDraw.Draw(self.image)
                 draw.text((0, 100), "Couldn't load " + self.filename)
         elif isinstance(args[0], Picture):
             # We've been passed a Picture object
             self.image = args[0].image.copy()
             self.filename = args[0].filename
             self.title = args[0].title
         elif isinstance(args[0], PIL.Image.Image):
             # We've been passed a PIL image object
             self.image = args[0]
             try:
                 self.filename = self.title = args[0].filename
             except AttributeError:
                 pass
     elif len(args) == 2 or len(args) == 3:
         # We've been passed width and height, and possibly a color
         size = (int(args[0]), int(args[1]))
         c = Color(255, 255, 255) if len(args) == 2 else args[2]
         self.image = PIL.Image.new("RGB", size, c.color)
     else:
         print("Could not construct Picture object")
예제 #6
0
파일: media.py 프로젝트: gordon-cs/JES4py
def getMediaPath(filename=""):
    return str(FileChooser.getMediaPath(filename))
예제 #7
0
파일: media.py 프로젝트: gordon-cs/JES4py
def pickAFile():
    # Note: this needs to be done in a threadsafe manner, see FileChooser
    # for details how this is accomplished.
    return str(FileChooser.pickAFile())