tags:

views:

149

answers:

1

The program is supposed to take user input, turn it into html and pass it into the clipboard.

Start the program with welcome_msg()

If you enter 1 in the main menu, it takes you through building an anchor tag. You'll add the link text, the url, then the title. After you enter the title, I get the following errors:

File "<pyshell#23>", line 1, in <module>
  welcome_msg()
File "C:\Python26\html_hax.py", line 24, in welcome_msg
  anchor()
File "C:\Python26\html_hax.py", line 71, in anchor
  copy_to_clipboard(anchor_output)
File "C:\Python26\html_hax.py", line 45, in copy_to_clipboard
  wc.SetClipboardData(win32con.CF_TEXT, msg)
error: (0, 'SetClipboardData', 'No error message is available')

Here's the Code: http://pastie.org/398163

What is causing the errors above?

+3  A: 

In your make_link function you construct a link_output, but you don't actually return it as the functions result. Use return to do this:

def make_link(in_link):
  ...
  if title == '':
    link_output = ...
  else:
    link_output = ...
  return link_output

This way you get the value passed to your anchor_output variable here:

anchor_output = make_link(anchor_text)

This was None because the function didn't return any value, and setting the clipboard to None failed. With the function returning a real string it should work as expected.

sth
Thank you for your detailed explanation. It is much appreciated.
tester
It seems my other functions are returning None as well, is there any way to make it not return anything visible?
tester
At the moment you're using print to explicitly output the results of the functions, which happen to be None. If you don't want that output, simply remove these print statements...
sth