Exemplo n.º 1
0
    def OnItemRename(self, evt):
        """ Rename action has been invoked.
		"""

        item = self.GetSelection()
        name = self.GetItemText(item)

        ### dialog to ask new label
        if wx.VERSION_STRING < '4.0':
            d = wx.TextEntryDialog(self,
                                   _('New file name'),
                                   defaultValue=name,
                                   style=wx.OK)
        else:
            d = wx.TextEntryDialog(self,
                                   _('New file name'),
                                   value=name,
                                   style=wx.OK)
        d.ShowModal()

        ### new label
        new_label = d.GetValue()
        ### if new and old label are different
        if new_label != name:
            path = self.GetItemPyData(item)
            bn = os.path.basename(path)
            dn = os.path.dirname(path)
            name, ext = os.path.splitext(bn)
            ### relace on file system
            os.rename(path, os.path.join(dn, new_label) + ext)
            ### replace in __init__.py file
            replaceAll(os.path.join(dn, '__init__.py'),
                       os.path.splitext(bn)[0], new_label)

            self.UpdateAll()
Exemplo n.º 2
0
	def OnItemRename(self, evt):
		""" Rename action has been invoked.
		"""

		item = self.GetSelection()
		name = self.GetItemText(item)

		### dialog to ask new label
		if wx.VERSION_STRING<4.0:
			d = wx.TextEntryDialog(self, _('New file name'), defaultValue = name, style=wx.OK)
		else:
			d = wx.TextEntryDialog(self, _('New file name'), value = name, style=wx.OK)
		d.ShowModal()

		### new label
		new_label = d.GetValue()
		### if new and old label are different
		if new_label != name:
			path = self.GetItemPyData(item)
			bn = os.path.basename(path)
			dn = os.path.dirname(path)
			name, ext = os.path.splitext(bn)
			### relace on file system
			os.rename(path, os.path.join(dn, new_label)+ext)
			### replace in __init__.py file
			replaceAll(os.path.join(dn,'__init__.py'), os.path.splitext(bn)[0], new_label)

			self.UpdateAll()