Exemplo n.º 1
0
	def on_folder_changed(self, o, interactive=True):
		# When folder is changed, update name accordingly
		if self._block_update:
			return
		self._folder_set = self._folder_set or interactive

		# Check notebook info (even when name was set already)
		if interactive or not self._name_set:
			folder = self.form['folder']
			if folder and folder.exists():
				info = get_notebook_info(folder)
				if info: # None when no config found
					self._block_update = True
					self.form['name'] = info.name
					self._block_update = False
					return

		# Else use basename unless the name was set explicitly already
		if self._name_set:
			return

		folder = self.form.widgets['folder'].get_text().strip('/\\')
		self._block_update = True
		self.form['name'] = os.path.basename(folder)
		self._block_update = False
Exemplo n.º 2
0
    def on_folder_changed(self, o, interactive=True):
        # When folder is changed, update name accordingly
        if self._block_update:
            return
        self._folder_set = self._folder_set or interactive

        # Check notebook info (even when name was set already)
        if interactive or not self._name_set:
            folder = self.form["folder"]
            if folder and folder.exists():
                info = get_notebook_info(folder)
                if info:  # None when no config found
                    self._block_update = True
                    self.form["name"] = info.name
                    self._block_update = False
                    return

        # Else use basename unless the name was set explicitly already
        if self._name_set:
            return

        folder = self.form.widgets["folder"].get_text().strip("/\\")
        self._block_update = True
        self.form["name"] = os.path.basename(folder)
        self._block_update = False