[ create a new paste ] login | about

Link: http://codepad.org/vNj9EkOC    [ raw code | fork ]

Python, pasted on Apr 20:
#!/usr/bin/python2
import Tix, base64
top = Tix.Tk()

def cmd_file_selected(filename):
	my_file = open (filename, 'r')
	file_contents = my_file.read()
	encoded = base64.b64encode(file_contents)
	textw =  stext.subwidget('text')
	textw.delete("1.0", Tix.END)
	textw.insert(Tix.INSERT, '<img alt="" src="data:image/jpeg;base64,' + encoded + '" />')
	return None
def btn_callback():# Copy to clipboard.
	textw =  stext.subwidget('text')
	text = textw.get("1.0",Tix.END)
	print text
	#top.withdraw() #???
	top.clipboard_clear()
	top.clipboard_append(text)
	return None
	

# OUT: Traceback (most recent call last):
# OUT:   File "<input>", line 1, in <module>
# OUT: TypeError: __init__() takes at least 2 arguments (1 given)
fe = Tix.FileEntry(top, command = cmd_file_selected)
stext = Tix.ScrolledText(top)
copybtn = Tix.Button(text = 'Clipboard', command = btn_callback)

fe.pack()
stext.pack()
copybtn.pack()
top.mainloop()


Create a new paste based on this one


Comments: