Beispiel #1
0
    def OnSave(self, evt):
        """Save the current file."""
        if self.currentFilename:
            # Save the current filename (prompt for overwrite)
            confirmDialog = wx.MessageDialog(self, \
                    _("Overwrite the existing file?"), \
                    _("Confirm overwrite"), wx.YES_NO)
            # If not overwriting, return now
            if confirmDialog.ShowModal() == wx.ID_NO:
                return

        # currentFilename is empty; prompt for a filename
        else:
            outFileDialog = wx.FileDialog(self, \
                    _("Choose a filename to save"), \
                    self.dirname, "", "*.*", wx.SAVE)
            if outFileDialog.ShowModal() == wx.ID_OK:
                self.dirname = outFileDialog.GetDirectory()
                self.currentFilename = outFileDialog.GetPath()

        outFile = open(self.currentFilename, "w")
        for line in self.editWindow.GetText():
            outFile.write("%s\n" % line)
        outFile.close()
        # Update title bar
        self.SetTitle("%s (MiniEditor)" % self.currentFilename)
Beispiel #2
0
    def __init__(self, parent, id, curFacename="Default"):
        wx.Dialog.__init__(self, parent, id, _("Font chooser"),
                           wx.DefaultPosition, (400, 400))

        # Center dialog
        self.Centre()

        # Get global configuration
        self.curConfig = TovidConfig()

        # Construct a list of fonts. Always list "Default" first.
        strFontChoices = []
        strFontChoices.extend(self.curConfig.strAvailFonts)
        strFontChoices.insert(0, "Default")

        # List of fonts, label and sample of selected font
        self.listFonts = wx.ListBox(self, wx.ID_ANY, wx.DefaultPosition,
                                    wx.DefaultSize, strFontChoices,
                                    wx.LB_SINGLE)
        self.lblFont = wx.StaticText(self, wx.ID_ANY,
                                     _("Sample of the selected font:"))
        self.lblFontSample = wx.StaticText(
            self, wx.ID_ANY, "The quick brown fox\n "
            "jumps over the lazy dog.")
        wx.EVT_LISTBOX(self, self.listFonts.GetId(), self.OnSelectFont)

        # Set listbox selection to given facename
        curFontIdx = self.listFonts.FindString(curFacename)
        self.listFonts.SetSelection(curFontIdx)
        # Remember given facename
        self.font = wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                            wx.FONTWEIGHT_NORMAL, False, "Default")
        # Show sample in current font
        self.lblFontSample.SetFont(self.font)

        # OK/Cancel buttons
        self.btnOK = wx.Button(self, wx.ID_OK, "OK")
        self.btnCancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
        sizButtons = wx.BoxSizer(wx.HORIZONTAL)
        sizButtons.Add(self.btnOK, 1, wx.EXPAND | wx.ALL, 16)
        sizButtons.Add(self.btnCancel, 1, wx.EXPAND | wx.ALL, 16)
        # Sizer to hold controls
        sizMain = wx.BoxSizer(wx.VERTICAL)
        sizMain.Add(self.listFonts, 1, wx.EXPAND | wx.ALL, 8)
        sizMain.Add(self.lblFont, 0, wx.EXPAND | wx.ALL, 8)
        sizMain.Add(self.lblFontSample, 0, wx.EXPAND | wx.ALL, 16)
        sizMain.Add(sizButtons, 0, wx.EXPAND)
        self.SetSizer(sizMain)
        self.Show()

        # If there are very few (<6) fonts available,
        # show a message telling how to get more
        if len(self.curConfig.strAvailFonts) < 6:
            dlgGetMoreFonts = wx.MessageDialog(
                self, "You have less than six fonts to choose from. See the\n"
                "tovid documentation (http://tovid.org/)\n"
                "for instructions on how to get more.",
                "How to get more fonts", wx.OK | wx.ICON_INFORMATION)
            dlgGetMoreFonts.ShowModal()
Beispiel #3
0
    def __init__(self, parent, id, curFacename = "Default"):
        wx.Dialog.__init__(self, parent, id, _("Font chooser"), wx.DefaultPosition,
                (400, 400))

        # Center dialog
        self.Centre()

        # Get global configuration
        self.curConfig = TovidConfig()

        # Construct a list of fonts. Always list "Default" first.
        strFontChoices = []
        strFontChoices.extend(self.curConfig.strAvailFonts)
        strFontChoices.insert(0, "Default")

        # List of fonts, label and sample of selected font
        self.listFonts = wx.ListBox(self, wx.ID_ANY, wx.DefaultPosition,
                wx.DefaultSize, strFontChoices, wx.LB_SINGLE)
        self.lblFont = wx.StaticText(self, wx.ID_ANY, _("Sample of the selected font:"))
        self.lblFontSample = wx.StaticText(self, wx.ID_ANY, "The quick brown fox\n "
                "jumps over the lazy dog.")
        wx.EVT_LISTBOX(self, self.listFonts.GetId(), self.OnSelectFont)

        # Set listbox selection to given facename
        curFontIdx = self.listFonts.FindString(curFacename)
        self.listFonts.SetSelection(curFontIdx)
        # Remember given facename
        self.font = wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
            wx.FONTWEIGHT_NORMAL, False, "Default")
        # Show sample in current font
        self.lblFontSample.SetFont(self.font)

        # OK/Cancel buttons
        self.btnOK = wx.Button(self, wx.ID_OK, "OK")
        self.btnCancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
        sizButtons = wx.BoxSizer(wx.HORIZONTAL)
        sizButtons.Add(self.btnOK, 1, wx.EXPAND | wx.ALL, 16)
        sizButtons.Add(self.btnCancel, 1, wx.EXPAND | wx.ALL, 16)
        # Sizer to hold controls
        sizMain = wx.BoxSizer(wx.VERTICAL)
        sizMain.Add(self.listFonts, 1, wx.EXPAND | wx.ALL, 8)
        sizMain.Add(self.lblFont, 0, wx.EXPAND | wx.ALL, 8)
        sizMain.Add(self.lblFontSample, 0, wx.EXPAND | wx.ALL, 16)
        sizMain.Add(sizButtons, 0, wx.EXPAND)
        self.SetSizer(sizMain)
        self.Show()

        # If there are very few (<6) fonts available,
        # show a message telling how to get more
        if len(self.curConfig.strAvailFonts) < 6:
            dlgGetMoreFonts = wx.MessageDialog(self,
                "You have less than six fonts to choose from. See the\n"
                "tovid documentation (http://tovid.org/)\n"
                "for instructions on how to get more.",
                "How to get more fonts", wx.OK | wx.ICON_INFORMATION)
            dlgGetMoreFonts.ShowModal()
Beispiel #4
0
    def OnOpen(self, evt):
        inFileDialog = wx.FileDialog(self, _("Choose a file to open"), self.dirname, "", "*.*", wx.OPEN)
        if inFileDialog.ShowModal() == wx.ID_OK:
            self.dirname = inFileDialog.GetDirectory()
            # Open the file
            self.OpenFile(inFileDialog.GetPath())

        inFileDialog.Destroy()
Beispiel #5
0
    def OnFileOpen(self, evt):
        inFileDialog = wx.FileDialog(self, _("Choose a TDL file to open"), self.dirname, "", "*.tdl", wx.OPEN)
        if inFileDialog.ShowModal() == wx.ID_OK:
            self.dirname = inFileDialog.GetDirectory()
            proj = Project()
            proj.load_file(inFileDialog.GetPath())
            self.panAuthorFiles.SetElements(proj.topitems)

        inFileDialog.Destroy()
Beispiel #6
0
    def OnOpen(self, evt):
        inFileDialog = wx.FileDialog(self, _("Choose a file to open"), self.dirname, "",
            "*.*", wx.OPEN)
        if inFileDialog.ShowModal() == wx.ID_OK:
            self.dirname = inFileDialog.GetDirectory()
            # Open the file
            self.OpenFile(inFileDialog.GetPath())

        inFileDialog.Destroy()
Beispiel #7
0
    def OnFileOpen(self, evt):
        inFileDialog = wx.FileDialog(self, _("Choose a TDL file to open"),
            self.dirname, "", "*.tdl", wx.OPEN)
        if inFileDialog.ShowModal() == wx.ID_OK:
            self.dirname = inFileDialog.GetDirectory()
            proj = Project()
            proj.load_file(inFileDialog.GetPath())
            self.panAuthorFiles.SetElements(proj.topitems)

        inFileDialog.Destroy()
Beispiel #8
0
    def OnSave(self, evt):
        """Save the current file."""
        if self.currentFilename:
            # Save the current filename (prompt for overwrite)
            confirmDialog = wx.MessageDialog(self, _("Overwrite the existing file?"), _("Confirm overwrite"), wx.YES_NO)
            # If not overwriting, return now
            if confirmDialog.ShowModal() == wx.ID_NO:
                return

        # currentFilename is empty; prompt for a filename
        else:
            outFileDialog = wx.FileDialog(self, _("Choose a filename to save"), self.dirname, "", "*.*", wx.SAVE)
            if outFileDialog.ShowModal() == wx.ID_OK:
                self.dirname = outFileDialog.GetDirectory()
                self.currentFilename = outFileDialog.GetPath()

        outFile = open(self.currentFilename, "w")
        for line in self.editWindow.GetText():
            outFile.write("%s\n" % line)
        outFile.close()
        # Update title bar
        self.SetTitle("%s (MiniEditor)" % self.currentFilename)
Beispiel #9
0
 def __init__(self,
              format='dvd',
              tvsys='ntsc',
              title=_("Untitled menu"),
              isTop=False):
     self.SetDiscFormat(format)
     self.SetDiscTVSystem(tvsys)
     self.title = title
     self.outPrefix = title.replace(' ', '_')
     self.isTopMenu = isTop
     # Default font
     self.font = wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                         wx.FONTWEIGHT_NORMAL, False, "Default")
Beispiel #10
0
    def OnFileSave(self, evt):
        """Save the current project to a TDL file."""
        outFileDialog = wx.FileDialog(self, _("Select a save location"), self.dirname, "", "*.tdl", wx.SAVE)
        if outFileDialog.ShowModal() == wx.ID_OK:
            # Remember current directory
            self.dirname = outFileDialog.GetDirectory()
            # Open a file for writing
            outFile = open(outFileDialog.GetPath(), "w")

            elements = self.panAuthorFiles.GetElements()
            for element in elements:
                outFile.write(element.to_string())

            outFile.close()
Beispiel #11
0
    def OnFileSave(self, evt):
        """Save the current project to a TDL file."""
        outFileDialog = wx.FileDialog(self, _("Select a save location"),
            self.dirname, "", "*.tdl", wx.SAVE)
        if outFileDialog.ShowModal() == wx.ID_OK:
            # Remember current directory
            self.dirname = outFileDialog.GetDirectory()
            # Open a file for writing
            outFile = open(outFileDialog.GetPath(), 'w')
            
            elements = self.panAuthorFiles.GetElements()
            for element in elements:
                outFile.write(element.to_string())

            outFile.close()
Beispiel #12
0
class SlideOptions:
    """Options related to generating a slideshow"""
    # Type of item being encoded (menu, video, or slides)
    type = ID_SLIDE
    # Title of the group of slides
    title = _("Untitled slides")
    # List of image files to convert to slides
    files = []
    # -dvd, -vcd, or -svcd
    format = 'dvd'
    # -ntsc or -pal
    tvsys = 'ntsc'

    def __init__(self, format='dvd', tvsys='ntsc', files=[]):
        self.tvsys = tvsys
        self.format = format
        self.files = files

    def GetCommand(self):
        """Return the makeslides command to generate this slideshow."""
        strCommand = "makeslides -%s -%s " % \
            (self.tvsys, self.format)

    def SetDiscFormat(self, format):
        """Make slides compliant with given disc format."""
        self.format = format

    def SetDiscTVSystem(self, tvsys):
        """Make slides compliant with given disc TV system."""
        self.tvsys = tvsys

    def CopyFrom(self, opts):
        """Copy the given options into this object."""
        # If types are different, return
        if self.type != opts.type:
            return
        # Copy opts into self
        self.format = opts.format
        self.tvsys = opts.tvsys
Beispiel #13
0
class MenuOptions:
    """Options related to generating a menu"""
    # Type of item being encoded (menu, video, or slides)
    type = ID_MENU
    isTopMenu = False
    # Title of the menu itself
    title = _("Untitled menu")
    # -ntsc or -pal
    tvsys = 'ntsc'
    # -dvd, -vcd, or -svcd
    format = 'dvd'
    # -background FILE
    background = ""
    # -audio FILE
    audio = ""
    # -align [northwest|north|northeast]
    alignment = 'northwest'
    # Other settings
    titles = []
    colorText = wx.Colour(255, 255, 255)
    colorHi = wx.Colour(255, 255, 0)
    colorSel = wx.Colour(255, 0, 0)
    outPrefix = ""

    def __init__(self,
                 format='dvd',
                 tvsys='ntsc',
                 title=_("Untitled menu"),
                 isTop=False):
        self.SetDiscFormat(format)
        self.SetDiscTVSystem(tvsys)
        self.title = title
        self.outPrefix = title.replace(' ', '_')
        self.isTopMenu = isTop
        # Default font
        self.font = wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                            wx.FONTWEIGHT_NORMAL, False, "Default")

    def toElement(self):
        """Convert the current options into a Menu and return it."""
        # Get global configuration (for output directory)
        curConfig = TovidConfig()
        # Create Menu Element and set relevant options
        menu = Menu(self.title)
        menu['tvsys'] = self.tvsys
        menu['format'] = self.format
        menu['align'] = self.alignment
        # Image and audio backgrounds, if any
        if self.background != "":
            menu['background'] = self.background
        if self.audio != "":
            menu['audio'] = self.audio
        menu['textcolor'] = '"#%X%X%X"' % \
            (self.colorText.Red(), self.colorText.Green(), self.colorText.Blue())
        # For DVD, highlight and select colors
        if self.format == 'dvd':
            menu['highlightcolor'] = '"#%X%X%X"' % \
                (self.colorHi.Red(), self.colorHi.Green(), self.colorHi.Blue())
            menu['selectcolor'] = '"#%X%X%X"' % \
                (self.colorSel.Red(), self.colorSel.Green(), self.colorSel.Blue())
        if self.font.GetFaceName() != "":
            menu['font'] = self.font.GetFaceName()
        # Convert self.titles to ordinary strings
        strtitles = []
        for title in self.titles:
            strtitles.append(str(title))
        menu['titles'] = strtitles
        return menu

    def fromElement(self, menu):
        """Load options from a Menu."""
        print "Loading Menu:"
        print element.to_string()
        self.type = ID_MENU
        self.tvsys = menu['tvsys']
        self.format = menu['format']
        self.alignment = menu['align']
        self.background = menu['background']
        self.audio = menu['audio']
        self.titles = menu['titles']
        # TODO: Find a good way to parse/assign colors and font

    def GetCommand(self):
        """Return the complete makemenu command to generate this menu."""
        # Get global configuration (for output directory)
        curConfig = TovidConfig()

        strCommand = "makemenu "
        # Append format and tvsys
        strCommand += "-%s -%s " % (self.tvsys, self.format)
        # Append alignment
        strCommand += "-align %s " % self.alignment

        # Image and audio backgrounds, if any
        if self.background != "":
            strCommand += "-background \"%s\" " % self.background
        if self.audio != "":
            strCommand += "-audio \"%s\" " % self.audio

        # Append text color
        strCommand += "-textcolor \"rgb(%d,%d,%d)\" " % \
            (self.colorText.Red(), self.colorText.Green(), self.colorText.Blue())
        # For DVD, append highlight and select colors
        if self.format == 'dvd':
            strCommand += "-highlightcolor \"rgb(%d,%d,%d)\" " % \
                (self.colorHi.Red(), self.colorHi.Green(), self.colorHi.Blue())
            strCommand += "-selectcolor \"rgb(%d,%d,%d)\" " % \
                (self.colorSel.Red(), self.colorSel.Green(), self.colorSel.Blue())

        # Append font
        if self.font.GetFaceName() != "":
            strCommand += "-font \"%s\" " % self.font.GetFaceName()

        # Append video/still titles
        for title in range(len(self.titles)):
            strCommand += "\"%s\" " % self.titles[title]

        strCommand += "-out \"%s/%s\"" % \
                (curConfig.strOutputDirectory, self.outPrefix)
        return strCommand

    def SetDiscFormat(self, format):
        """Make menu compliant with given disc format."""
        self.format = format

    def SetDiscTVSystem(self, tvsys):
        """Make menu compliant with given disc TV system."""
        self.tvsys = tvsys

    def CopyFrom(self, opts):
        """Copy the given MenuOptions' data into this menu."""
        # Return if types are different
        if self.type != opts.type:
            return
        # Copy opts into self
        self.format = opts.format
        self.tvsys = opts.tvsys
        self.background = opts.background
        self.audio = opts.audio
        self.colorText = opts.colorText
        self.colorHi = opts.colorHi
        self.colorSel = opts.colorSel
        self.font = opts.font
        self.alignment = opts.alignment