Skip to content

Instantly share code, notes, and snippets.

@krets
Last active August 29, 2015 14:00
Show Gist options
  • Save krets/11127896 to your computer and use it in GitHub Desktop.
Save krets/11127896 to your computer and use it in GitHub Desktop.
ach, whitespace.
"""
Flip slashes in ClipBoard
Now using Tk, so it should be cross-platform.
http://stackoverflow.com/questions/579687
"""
from Tkinter import Tk
w = Tk() # create window object
w.withdraw() # hide window from view.
def getClipboard():
return w.selection_get(selection = "CLIPBOARD")
def setClipboard(text):
w.clipboard_clear()
w.clipboard_append(text)
def main():
c=getClipboard()
if c.find('/')>-1:
c=c.replace('/','\\')
else:
c=c.replace('\\','/')
setClipboard(c)
if __name__=='__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment