Apr-19-2020, 08:58 AM
Hi All,
I started to learn Python a few years ago, and wrote my only useful program in python2 - which I use all the time.
I want to start learning python again (py3), but when I install py3 my useful program won't run (it just flashes a window and closes).
I've forgotten everything I previously learnt, is there a 'fix quick' problem that jumps out as to why it wont run in py3 ?
It's a very simple program that monitors the clipboard for a block of text (they are links), and when it finds some it converts them into a block of links suitable for inserting into a webpage
Eg it finds on the clipboard
h+tp://anysite.com/file/textfile1
h+tp://anysite.com/file/textfile2
it converts that to
<a href=http://anysite.com/file/textfile1 target=_blank>http://anysite.com/file/textfile1</a>
<a href=http://anysite.com/file/textfile2 target=_blank>http://anysite.com/file/textfile2</a>
Then puts that new links back on the clipboard ready for pasting.
I have installed
Python2.7.13 (x86)
Pythoncard 0.8.2 (x86)
Pywin32-218
wxpython3.0 (x86)
I want to install Python3.
Thank you for any help,
Steve
I started to learn Python a few years ago, and wrote my only useful program in python2 - which I use all the time.
I want to start learning python again (py3), but when I install py3 my useful program won't run (it just flashes a window and closes).
I've forgotten everything I previously learnt, is there a 'fix quick' problem that jumps out as to why it wont run in py3 ?
It's a very simple program that monitors the clipboard for a block of text (they are links), and when it finds some it converts them into a block of links suitable for inserting into a webpage
Eg it finds on the clipboard
h+tp://anysite.com/file/textfile1
h+tp://anysite.com/file/textfile2
it converts that to
<a href=http://anysite.com/file/textfile1 target=_blank>http://anysite.com/file/textfile1</a>
<a href=http://anysite.com/file/textfile2 target=_blank>http://anysite.com/file/textfile2</a>
Then puts that new links back on the clipboard ready for pasting.
I have installed
Python2.7.13 (x86)
Pythoncard 0.8.2 (x86)
Pywin32-218
wxpython3.0 (x86)
I want to install Python3.
Thank you for any help,
Steve
import win32clipboard as w
import sys, time
def cleanboard():
w.OpenClipboard(0)
w.SetClipboardText('')
w.CloseClipboard()
LastData=''
templine2=''
amountOfLines=0
cleanboard()
while 1:
time.sleep(1)
w.OpenClipboard()
data=w.GetClipboardData()
w.CloseClipboard()
nullIndex=data.find('\0')
if nullIndex != -1:
data=data[:nullIndex]
if data != LastData:
LastData=data
linkstoprint=[]
templine2=''
amountOfLines = len(data.splitlines());
ref=0
while ref < amountOfLines:
line = data.splitlines()
templine1=line[ref]
templine1 = '<a href='+str(templine1)+' target=_blank>'+str(templine1)+'</a>'
linkstoprint.append(templine1)
ref=ref+1
for i in range (0,amountOfLines):
templine2=templine2+linkstoprint[i]+'\n'
templine2=str(templine2)
w.OpenClipboard(0)
w.EmptyClipboard()
w.SetClipboardText(templine2)
w.CloseClipboard()
LastData=str(templine2)
