Skip to content

Instantly share code, notes, and snippets.

@purvalpatel
Created March 28, 2016 08:50
Show Gist options
  • Save purvalpatel/abbe1f4dce3b0c99d347 to your computer and use it in GitHub Desktop.
Save purvalpatel/abbe1f4dce3b0c99d347 to your computer and use it in GitHub Desktop.
Path validation
def on_mkdir_clicked(self,widget):
path1=self.entry1.get_text()
if os.path.isabs(path1):
print("valid path")
else:
print("invalid path")
if not os.path.exists(path1):
os.mkdir(path1)
print path1
else:
dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.ERROR,Gtk.ButtonsType.CANCEL, "ERROR")
dialog.format_secondary_text("File Already Exist,Or Invalid Path Name")
dialog.run()
dialog.destroy()
# print("Directory exist")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment