Ask coding questions

← Back to all posts
Replit does not support pyperclip?
EnglishRain (1)

Can someone please tell me any other clipboard module that replit supports? I just want something that can copy a multi-line string variable to the clipboard.

TiA! :)

Comments
hotnewtop
HackermonDev (2074)

Even if they did support something like that it won't be able to work. Since repl.it runs the code on their computer not yours it wouldn't change your clipboard.

EnglishRain (1)

@PDanielY damn that's a real shame. Do you know of any other website whereon I could host my code which would allow usage of clipboard? Or should I be looking at some other library to achieve this when hosting the code online like on replit?

CodeLongAndPros (1631)

@EnglishRain There's no way to have a external program access your clipboard. That would be a huge vulnerability. The only way would be to:

  • Break your browsers sandboxing, and
  • Use javascript
EnglishRain (1)

Thanks, I guess I should start learning JavaScript @CodeLongAndPros as I do realize python is incapable of doing this. Such a shame... Will stop learning Python, nevermind the hours wasted in learning it.

CodeLongAndPros (1631)

@EnglishRain, Python can do a lot. It's just the platform that is the limit. However, here is a link on how to interact with the clipboard in javascript:

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard

EnglishRain (1)

@CodeLongAndPros thank you, appreciate it. I can't just embed this js code into my python code at the place where the variable needs to be copied to clipboard, can I? Just to avoid having to rewrite my program in JavaScript. (which I'll have to learn from scratch firstly!)

CodeLongAndPros (1631)

@EnglishRain This is meant to be used in a webpage. You can't interact with the clipboard using any language on repl.it other than html, js, css/Django & flask

EnglishRain (1)

@CodeLongAndPros understood thank you. Need to start learning JavaScript in that case.

CodeLongAndPros (1631)

@EnglishRain, You could use flask, which has python at it's core. I've made a web app using flask despite being terrible at javascript. You'll only need a small bit of js.

EnglishRain (1)

@CodeLongAndPros Hmmm... that's very interesting. Could you elaborate a bit on how to use Flask? My python code which pastes a variable onto the user's clipboard is absolutely ready. Can i just paste it into Flask somewhere & it'll work?

CodeLongAndPros (1631)

@EnglishRain Flask is a web server framework. I've collaborated on a Flask website, https://repl.it/@CodeLongAndPros/COVID
I used python on the backend. You'll still have to use JavaScript. You'll just need to make a function in your Flask webpage to call the js.

EnglishRain (1)

@CodeLongAndPros Wow, nice code! I ran it and it seemed to be installing a ton of things. Let me see I'll try & study some tutorials on Flask to understand it better. Hope then I'll be able to host my code on there so I can run my code which copies to clipboard from anywhere. :)

CodeLongAndPros (1631)

@EnglishRain Plus, now you get to make a frontend! :D

EnglishRain (1)

@CodeLongAndPros haha fingers crossed i succeed, thanks a lot for all your help mate! :D Highly appreciated!