Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # list_sort_from_clipboard.py
- from tkinter import *
- import re
- import string
- import webbrowser
- import tempfile
- import random
- srcfilename=tempfile.mktemp(".html", "demo_")
- web="""<!DOCTYPE html><b>@"""
- root = Tk('200X200+1+1')
- def clipb():
- t = root.clipboard_get()
- L=[]
- if '#' in t:
- a,b = [z.splitlines() for z in t.split('#')]
- a.sort()
- random.shuffle(b)
- t = a+['#']+b
- else:
- t = t.splitlines()
- for z in t:
- z = z.strip()
- if z and z not in L:
- L+=[z]
- else:
- if z:
- print( '*** removed', z)
- print()
- print()
- r = []
- for z in L:
- try:
- r.append(z)
- except:
- s=''
- for char in z:
- if char in string.letters+' ': s+=char
- else: s+='_'
- r.append(s)
- r='<br>'.join(r)
- r = r.replace('#','#'+'<br>'*20)
- temp=open(srcfilename, 'w')
- temp.write(web.replace('@',r))
- temp.close()
- webbrowser.open_new_tab(srcfilename)
- Frame=LabelFrame(root,height=200,width=200,borderwidth=0,bg="light blue") # note: width=200 minimal
- Frame.pack(fill=X)
- Frame.pack_propagate(False)
- Label(Frame,text="Fix Lists Onto Browser",bg="light blue").pack(anchor=NW)
- cpb=Button(Frame,text="Copy From Clipboard",command=clipb)
- cpb.pack()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement