Esempio n. 1
0
	def __init__(self, master=None, lemma_configpath="", lemma_modulepath=""):
		Frame.__init__(self, master)
		self.currentFile = ""
		self.updateTitle()
		common.detectPlatform()
		self.modulePath = lemma_modulepath

		# If Linux and installed in /usr or /usr/local, use ~/.lemma for config directory
		# otherwise, store settings in application folder
		if lemma_configpath == "":
			if self.modulePath in ("/usr/local/share/lemma", "/usr/share/lemma") and common.isLinux:
				self.configPath = os.path.expanduser("~/.lemma")
				# Create the directory if this is missing
				if not os.path.isdir(self.configPath):
					os.mkdir(self.configPath)
					logging.debug("[app] Creating directory " + self.configPath)
			else:
				self.configPath = os.path.abspath(sys.path[0])
		else:
			# user-defined config path
			self.configPath = os.path.abspath(lemma_configpath)
		logging.debug("[app] Settings will be stored in " + self.configPath)
		common.setConfigPath(self.configPath)
	
		common.readSettings()
		settings.readGrooves()
		fonts.readFonts()

		self.grid(sticky=N+S+E+W)
		self.option_add("*font", autoScaleFont(FONTS["Base"]))
		self.createWidgets()
Esempio n. 2
0
	def apply(self):
		# read variables and strip trailing spaces	
		pythonPath = self.pythonPathEntry.get().strip(' ')
		mmaPath = self.mmaPathEntry.get().strip(' ')
		libDir = self.mmaLibDirEntry.get().strip(' ')
		midiEngine = self.midiEngineButton["text"]
		midiPlayer = self.midiPlayerEntry.get().strip(' ')
		customGroovePath = self.customGroovePathEntry.get().strip(' ')
		measuresPerRow = self.measuresPerRowEntry.get().strip(' ')

		logging.debug("[Settings] Settings are: (" + pythonPath + "," + mmaPath + "," + midiPlayer + "," + customGroovePath + ")")
		# validate the existence of these paths
		if not os.path.exists(pythonPath):
			tkMessageBox.showerror("Error", "Python path: '" + pythonPath + "' does not exist.")
			return
		if not os.path.exists(mmaPath):
			tkMessageBox.showerror("Error", "MMA path: '" + mmaPath + "' does not exist.")
		if os.path.isdir(pythonPath):
			tkMessageBox.showerror("Error", "Python path: '" + pythonPath + "' is a directory and not a filename.")
			return
		if os.path.isdir(mmaPath):
			tkMessageBox.showerror("Error", "MMA path: '" + mmaPath + "' is a directory and not a filename.")
			return

		if not os.path.exists(libDir):
			tkMessageBox.showerror("Error", "MMA grooves path: '" + libDir + "' does not exist.")
			return

		realmidipath = re.compile(r'\s-[^\s]*').sub("", midiPlayer)	# strip any command-line options
		if not os.path.exists(realmidipath):
			tkMessageBox.showwarning("Warning", "Midi player path: '" + midiPlayer + "' does not exist. You won't be able to play MMA files.")
		if os.path.isdir(realmidipath):
			tkMessageBox.showwarning("Warning", "Midi player path: '" + midiPlayer + "' is a directory and not a filename. You won't be able to play the MMA file.")

		if customGroovePath != "" and not os.path.exists(customGroovePath):
			tkMessageBox.showwarning("Warning", "Custom groove path: '" + customGroovePath + "' does not exist.")

		# save the settings into settings file

		config = ConfigParser.ConfigParser()
		config.read(common.settingsFile)
		if not config.has_section("paths"):
			config.add_section("paths")
		config.set("paths", "python", pythonPath)
		config.set("paths", "mma", mmaPath)
		config.set("paths", "midiplayer", midiPlayer)
		config.set("paths", "grooves", libDir)
		config.set("paths", "customgrooves", customGroovePath)

		if not config.has_section("misc"):
			config.add_section("misc")
		config.set("misc", "measures_per_row", measuresPerRow)
		config.set("misc", "midiengine", midiEngine)

		f = open(common.settingsFile, "w")
		config.write(f)
		f.close()

		common.printOutput("Settings saved in " + common.settingsFile)

		# read the settings file to set the global variables
		common.readSettings()
Esempio n. 3
0
    def apply(self):
        # read variables and strip trailing spaces
        pythonPath = self.pythonPathEntry.get().strip(' ')
        mmaPath = self.mmaPathEntry.get().strip(' ')
        libDir = self.mmaLibDirEntry.get().strip(' ')
        midiEngine = self.midiEngineButton["text"]
        midiPlayer = self.midiPlayerEntry.get().strip(' ')
        customGroovePath = self.customGroovePathEntry.get().strip(' ')
        measuresPerRow = self.measuresPerRowEntry.get().strip(' ')

        logging.debug("[Settings] Settings are: (" + pythonPath + "," +
                      mmaPath + "," + midiPlayer + "," + customGroovePath +
                      ")")
        # validate the existence of these paths
        if not os.path.exists(pythonPath):
            tkMessageBox.showerror(
                "Error", "Python path: '" + pythonPath + "' does not exist.")
            return
        if not os.path.exists(mmaPath):
            tkMessageBox.showerror(
                "Error", "MMA path: '" + mmaPath + "' does not exist.")
        if os.path.isdir(pythonPath):
            tkMessageBox.showerror(
                "Error", "Python path: '" + pythonPath +
                "' is a directory and not a filename.")
            return
        if os.path.isdir(mmaPath):
            tkMessageBox.showerror(
                "Error", "MMA path: '" + mmaPath +
                "' is a directory and not a filename.")
            return

        if not os.path.exists(libDir):
            tkMessageBox.showerror(
                "Error", "MMA grooves path: '" + libDir + "' does not exist.")
            return

        realmidipath = re.compile(r'\s-[^\s]*').sub(
            "", midiPlayer)  # strip any command-line options
        if not os.path.exists(realmidipath):
            tkMessageBox.showwarning(
                "Warning", "Midi player path: '" + midiPlayer +
                "' does not exist. You won't be able to play MMA files.")
        if os.path.isdir(realmidipath):
            tkMessageBox.showwarning(
                "Warning", "Midi player path: '" + midiPlayer +
                "' is a directory and not a filename. You won't be able to play the MMA file."
            )

        if customGroovePath != "" and not os.path.exists(customGroovePath):
            tkMessageBox.showwarning(
                "Warning", "Custom groove path: '" + customGroovePath +
                "' does not exist.")

        # save the settings into settings file

        config = ConfigParser.ConfigParser()
        config.read(common.settingsFile)
        if not config.has_section("paths"):
            config.add_section("paths")
        config.set("paths", "python", pythonPath)
        config.set("paths", "mma", mmaPath)
        config.set("paths", "midiplayer", midiPlayer)
        config.set("paths", "grooves", libDir)
        config.set("paths", "customgrooves", customGroovePath)

        if not config.has_section("misc"):
            config.add_section("misc")
        config.set("misc", "measures_per_row", measuresPerRow)
        config.set("misc", "midiengine", midiEngine)

        f = open(common.settingsFile, "w")
        config.write(f)
        f.close()

        common.printOutput("Settings saved in " + common.settingsFile)

        # read the settings file to set the global variables
        common.readSettings()