def __init__(self):
QtWidgets.QMainWindow.__init__(self)
Ui_MainWindow.__init__(self)
self.setupUi(self)
self.limit_button.clicked.connect(self.limittfunc)
self.diffButton_normal.clicked.connect(self.diff_normal)
self.diffButton_complex.clicked.connect(self.diff_complex)
self.integralButton_normal.clicked.connect(self.integral_normal)
self.integralButton_complex.clicked.connect(self.integral_complex)
self.allCalculator.clicked.connect(self.allcalc)
self.binomialButton.clicked.connect(self.binomialfunc)
self.solver_button.clicked.connect(self.solver)
self.sumButton.clicked.connect(self.sumfunc)
self.factorButton.clicked.connect(self.factorfunc)
self.fourierButton.clicked.connect(self.fourier)
self.integralButton_copy.clicked.connect(self.copy)
self.integralButton_copy_3.clicked.connect(self.copy)
self.integralButton_copy_9.clicked.connect(self.copy)
self.integralButton_copy_10.clicked.connect(self.copy)
self.integralButton_copy_11.clicked.connect(self.copy)
self.integralButton_copy_12.clicked.connect(self.copy)
self.integralButton_copy_13.clicked.connect(self.copy)
self.integralButton_copy_2.clicked.connect(self.copy)
self.integralButton_copy_4.clicked.connect(self.copy)
python类copy()的实例源码
def main():
my_message = 'If a man is offered a fact which goes against his instincts, he will scrutinize it closely, and unless the evidence is overwhelming, he will refuse to believe it. If, on the other hand, he is offered something which affords a reason for acting in accordance to his instincts, he will accept it even on the slightest evidence. The origin of myths is explained in this way. -Bertrand Russell'
my_key = 'LFWOAYUISVKMNXPBDCRJTQEGHZ'
my_mode = 'encrypt'
# Check my_key is valid or not
check_valid_key(my_key)
if my_mode=='encrypt':
translated = encrypt_message(my_key, my_message)
elif my_mode=='decrypt':
translated = decrypt_message(my_key, my_message)
print('Using key %s' % my_key)
print('THe %sed message is :' % my_mode)
print(translated)
pyperclip.copy(translated)
print()
print('This message has copied to clipboard')
def main():
if len(sys.argv) != 3:
print('Usage: $python decrypt.py [filename] [key]')
exit(1)
try:
f = open(sys.argv[1])
except FileNotFoundError as e:
print(e)
exit(1)
plain_text = f.read()
key = int(sys.argv[2])
cipher_text = decrypt_message(key, plain_text)
print(cipher_text + '|')
# Copy to clipboard
pyperclip.copy(cipher_text)
print('Plain text has save to clipboard')
def clip_df(df, tablefmt='html'):
"""
Copy a dataframe as plain text to your clipboard.
Probably only works on Mac. For format types see ``tabulate`` package
documentation.
:param pandas.DataFrame df: Input DataFrame.
:param str tablefmt: What type of table?
:return: None.
"""
if tablefmt == 'material':
html = tabulate.tabulate(df, headers=df.columns, tablefmt='html')
html = html.replace('<table>', '<table class="mdl-data-table mdl-js-data-table">')
header = '<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">\n<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">\n<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>'
html = header + '\n' + html
else:
html = tabulate.tabulate(df, headers=df.columns, tablefmt=tablefmt)
pyperclip.copy(html)
print('Copied {} table to clipboard!'.format(tablefmt))
return html
def copy_magnet(self, link):
"""Copy magnetic link to clipboard.
This method is different from copylink_clipboard().
This method handles the --copy argument.
If --copy argument is supplied, magnetic link is copied to clipboard.
"""
from torrench.Torrench import Torrench
tr = Torrench()
if tr.check_copy():
try:
pyperclip.copy(link)
print("(Magnetic link copied to clipboard)")
except Exception as e:
print("(Unable to copy magnetic link to clipboard. Is [xclip] installed?)")
print("(See logs for details)")
self.logger.error(e)
else:
print("(use --copy to copy magnet to clipboard)")
def product_search():
# Checks the individual products for the recaptcha sitekey
print("\nFound {} product links on page {}.\n".format(len(product_links), (params['start']+1)))
index = 0
for product in product_links:
index += 1
print('{} of {}: Checking for sitekey in: {}'.format(index + len(product_links)*(params['start']), len(product_links) * (params['start']+1), product))
site_key_results = sitekey_scraper(str(product))
if site_key_results:
pyperclip.copy(site_key_results)
print("\nFollowing Recaptcha Sitekey has been copied to clipboard:\n\n{}\n".format(
site_key_results))
return True
return False
# # where the magic happens, u feel?
def get_command(self, ctx, cmd_name):
"""Allow aliases for commands.
"""
if cmd_name == 'list':
cmd_name = 'ls'
elif cmd_name == 'search':
cmd_name = 'find'
elif cmd_name == 'gen':
cmd_name = 'generate'
elif cmd_name == 'add':
cmd_name = 'insert'
elif cmd_name in ['remove', 'delete']:
cmd_name = 'rm'
elif cmd_name == 'rename':
cmd_name = 'mv'
elif cmd_name == 'copy':
cmd_name = 'cp'
# TODO(benedikt) Figure out how to make 'show' the default
# command and pass cmd_name as the first argument.
rv = click.Group.get_command(self, ctx, cmd_name)
if rv is not None:
return rv
def cp(ctx, old_path, new_path, force):
"""Copies the password or directory names `old-path` to `new-path`.
This command is alternatively named `copy`. If `--force` is
specified, silently overwrite `new_path` if it exists. If
`new-path` ends in a trailing `/`, it is always treated as a
directory. Passwords are selectively reencrypted to the
corresponding keys of their new destination.
"""
try:
ctx.obj.copy_path(old_path, new_path, force)
except StoreNotInitialisedError:
click.echo(MSG_STORE_NOT_INITIALISED_ERROR)
return 1
except FileNotFoundError:
click.echo('{0} is not in the password store.'.format(old_path))
return 1
except PermissionError:
click.echo(MSG_PERMISSION_ERROR)
return 1
except RecursiveCopyMoveError:
click.echo(MSG_RECURSIVE_COPY_MOVE_ERROR.format('copy'))
return 1
def clipboard(text,prnt, clear):
'''
Copy data to clipboard and start a thread to remove it after 20 seconds
'''
try:
pyperclip.copy(text)
print("Copied to clipboard")
except:
print("There was an error copying to clipboard. Do you have xsel installed?")
quit()
if prnt:
print(text)
if clear:
global myThread
if myThread and myThread.is_running():
myThread.stop()
myThread.join()
myThread = StoppingThread(target=timer, args=(20,text,))
myThread.start()
def main(args):
ext = {"py":"python3","cpp":"cpp","c":"c"}
url = "https://paste.ubuntu.com/"
with open(args) as f:
file_name, syntax = sys.argv[1].rsplit("/")[-1].rsplit(".")
payload = {
"poster" : file_name,
"syntax" : ext[syntax],
"content" : str(f.read())
}
req = requests.post(url, data=payload)
print(req.url)
pyperclip.copy(str(req.url))
return 0
def upload_img(file, arg):
with open(file, 'rb') as f:
start_time = time()
ufile = requests.post(
img_server,
files={arg: f.read(),
'content_type': 'application/octet-stream'})
end_time = time()
url = ufile.text.split()[-1]
usage_time = round(end_time - start_time, 2)
print('upload time: {}s'.format(usage_time))
try:
pyperclip.copy(url)
except NameError:
pass
except:
pass
return url
def upload_text(file, arg):
postfix = file.split('.')[-1]
with open(file, 'r') as f:
start_time = time()
ufile = requests.post(
text_server,
data={arg: f.read(),
'content_type': 'application/octet-stream'})
end_time = time()
url = ufile.text
url = url.strip()
url = url + "/{}".format(postfix)
usage_time = round(end_time - start_time, 2)
print('upload time: {}s'.format(usage_time))
try:
pyperclip.copy(url)
except NameError:
pass
except:
pass
return url
def upload_pipe_test(arg):
args = sys.stdin
start_time = time()
ufile = requests.post(
text_server,
data={arg: args.read(),
'content_type': 'application/octet-stream'})
end_time = time()
url = ufile.text
url = url.strip()
usage_time = round(end_time - start_time, 2)
print('upload time: {}s'.format(usage_time))
try:
pyperclip.copy(url)
except NameError:
pass
return url
# opt
def build(file, copy):
click.echo('Transpiling to Javascript...')
t = envoy.run('transcrypt -p .none {}'.format(file))
if t.status_code != 0:
click.echo(t.std_out)
sys.exit(-1)
click.echo('Completed.')
if copy is True:
basename = os.path.basename(file)
basename = os.path.splitext(basename)[0]
basedir = os.path.dirname(file)
fpath = os.path.join(basedir, '__javascript__/{}.min.js'.format(basename))
with open(fpath, 'r') as minfile:
pyperclip.copy(minfile.read())
click.echo('Minified app.js copied to clipboard')
def main():
my_message = 'helloworld'
# Your Cipher key
my_key = 3
my_message = my_message.upper()
# mode = 'decrypt'
translated = caesar_cipher(my_message, my_key)
# Save to clipboard
pyperclip.copy(translated)
print(translated)
print('Cipher text has save to clipboard')
def main():
my_message = """Alan Mathison Turing was a British mathematician, logician
, cryptanalyst, and computer scientist. He was highly influential in the d
evelopment of computer science, providing a formalisation of the concepts of
"algorithm" and "computation" with the Turing machine. Turing is widely con
sidered to be the father of computer science and artificial intelligence. D
uring World War II, Turing worked for the Government Code and Cypher School
(GCCS) at Bletchley Park, Britain's codebreaking centre. For a time he was
head of Hut 8, the section responsible for German naval cryptanalysis. He
devised a number of techniques for breaking German ciphers, including the
method of the bombe, an electromechanical machine that could find settin
gs for the Enigma machine. After the war he worked at the National Physi
cal Laboratory, where he created one of the first designs for a stored-pr
ogram computer, the ACE. In 1948 Turing joined Max Newman's Computing Lab
oratory at Manchester University, where he assisted in the development of
the Manchester computers and became interested in mathematical biology.
He wrote a paper on the chemical basis of morphogenesis, and predicted o
scillating chemical reactions such as the Belousov-Zhabotinsky reaction,
which were first observed in the 1960s. Turing's homosexuality resulted i
n a criminal prosecution in 1952, when homosexual acts were still illegal
in the United Kingdom. He accepted treatment with female hormones (chemical
castration) as an alternative to prison. Turing died in 1954, just over
two weeks before his 42nd birthday, from cyanide poisoning. An inquest
determined that his death was suicide; his mother and some others believed
his death was accidental. On 10 September 2009, following an Internet
campaign, British Prime Minister Gordon Brown made an official public
apology on behalf of the British government for "the appalling way he was
treated." As of May 2012 a private member's bill was before the House of Lords
which would grant Turing a statutory pardon if enacted."""
print("Reverse Cipher")
translated = reverse_cipher(my_message)
print(translated)
# Copy to clipboard
pyperclip.copy(translated)
def main():
# replace your key and plain text
my_message = 'Hello world'
my_key = 5
cipher_text = encrypt_message(my_key, my_message)
print(cipher_text + '|')
# Copy to clipboard
pyperclip.copy(cipher_text)
print('Cipher text has save to clipboard')
def write_to_paste_buffer(txt):
"""Copy text to the clipboard / paste buffer.
:param txt: str - text to copy to the clipboard
"""
pyperclip.copy(txt)
def __init__(self, obj, attribs):
"""Use the instance attributes as a generic key-value store to copy instance attributes from outer object.
:param obj: instance of cmd2.Cmd derived class (your application instance)
:param attribs: Tuple[str] - tuple of strings listing attributes of obj to save a copy of
"""
self.obj = obj
self.attribs = attribs
if self.obj:
self._save()
def checkForCopy(self, arg):
if self.checkBox_copy.isChecked() == True:
pyperclip.copy(str(arg))
def copy(self):
pyperclip.copy(str(result))
def copylink_clipboard(self, link):
"""Copy Magnetic/Upstream link to clipboard"""
try:
self.logger.debug("Copying magnetic/upstream link to clipboard")
pyperclip.copy(link)
self.logger.debug("Copied successfully.")
message = "Link copied to clipboard.\n"
print(self.colorify("green", message))
except Exception as e:
print("Something went wrong.")
print("Please make sure [xclip] package is installed.")
print("See logs for details.\n\n")
self.logger.error(e)
def copy():
"""
Returns the current text on clipboard.
"""
data = pyperclip.paste()
## before using pyperclip
# if os.name == "posix":
# p = subprocess.Popen(["xsel", "-bo"], stdout=subprocess.PIPE)
# data = p.communicate()[0].decode("utf-8")
# elif os.name == "nt":
# data = None
# else:
# print("We don't yet support %s Operating System." % os.name)
# exit()
return data
def upload(username, password):
"""
Sends the copied text to server.
"""
payload = {"text": copy(), "device": ""}
res = requests.post(
server_url+"copy-paste/",
data = payload,
auth = (username, password)
)
if res.status_code == 200:
print("Succeses! Copied to Cloud-Clipboard.")
else:
print("Error: ", res.text)
def paste(data):
"""
Copies 'data' to local clipboard which enables pasting.
"""
# p = subprocess.Popen(["xsel", "-bi"], stdout=subprocess.PIPE,
# stdin=subprocess.PIPE)
# p = p.communicate(data.encode("utf-8"))
# if p[1] is not None:
# print("Error in accessing local clipboard")
pyperclip.copy(data)
def download(username, password):
"""
Downloads from server and updates the local clipboard.
"""
res = requests.get(server_url+"copy-paste/", auth=(username, password))
if res.status_code == 200:
paste(json.loads(res.text)["text"])
else:
print("Cannot download the data.")
def usage():
print("Error: Unknown argument")
print("Usage: cloudcb.py copy|paste|register <email> <password>")
def set_data(self, data):
assert isinstance(data, ClipboardData)
self._data = data
pyperclip.copy(data.text)
def set_data(self, data):
assert isinstance(data, ClipboardData)
self._data = data
pyperclip.copy(data.text)
def copy_to_clipboard(text):
"""Writes a text to clipboard."""
logger.info('Copying text to clipboard: %s', text)
pyperclip.copy(text)