本文整理汇总了Python中kivy.core.clipboard.Clipboard类的典型用法代码示例。如果您正苦于以下问题:Python Clipboard类的具体用法?Python Clipboard怎么用?Python Clipboard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Clipboard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copy
def copy(self,text):
try:
from kivy.core.clipboard import Clipboard
Clipboard.copy(text)
except:
logger.error("Could not be copied to clipboard: "+text)
pass
示例2: _update_pos
def _update_pos(self, dt):
'''
get and update position
'''
#self.dat = get_nmea(self)
e, n, d = get_nmea(self)
#now = time.asctime().replace(' ','_').replace(':','_')
try:
self.e_txt.text = e[:10]#self.dat['e'][:10]
self.n_txt.text = n[:10]#self.dat['n'][:10]
except:
pass
#self.textinput.text += 'Position obtained: '+now+'\n'
Clipboard.copy(self.n_txt.text+':'+self.e_txt.text)
tmp = Clipboard.paste()
self.n_txt.text = tmp.split(':')[0]
self.e_txt.text = tmp.split(':')[1]
#self.textinput.text += 'N: '+str(self.n_txt.text)+', E: '+str(self.e_txt.text)+', D: '+str(self.dat['depth_m'])+'\n'
#self.textinput2.text += str(self.dat['depth_m'])+' m'+'\n'
self.textinput2.text += d+' m'+'\n'
if float(d)>10: #self.dat['depth_m']>10:
self.textinput2.foreground_color = (0.6,0.5,0.0,1.0)
elif d=='NaN':#self.dat['depth_m']=='NaN':
self.textinput2.foreground_color = (0.25,0.5,0.25,0.25)
else:
self.textinput2.foreground_color = (0.0,0.0,0.0,0.0)
示例3: copy
def copy(data):
if module == "mac":
clipboard_macosx.copy(data)
else:
assert module == "kivy"
Clipboard.put(data, 'UTF8_STRING')
Clipboard.put(data, 'text/plain')
示例4: on_touch_down
def on_touch_down(self, touch):
if touch.is_double_tap:
try:
Clipboard.copy(self.query_tree.selected_node.text)
except AttributeError:
Logger.debug("SQL Panel: Object didn't have text.")
ScrollView.on_touch_down(self, touch)
示例5: _update_pos
def _update_pos(self, dt):
'''
get and update position
'''
e, n, lon, lat = get_nmea(self)
try:
self.e_txt.text = e[:10]#self.dat['e'][:10]
self.n_txt.text = n[:10]#self.dat['n'][:10]
except:
pass
Clipboard.copy(self.n_txt.text+':'+self.e_txt.text)
tmp = Clipboard.paste()
self.n_txt.text = tmp.split(':')[0]
self.e_txt.text = tmp.split(':')[1]
if MAKEMAP:
self.map.simple_marker([lat, lon], marker_color='red')
self.map.save(self.mapname)
if SHOWMAP:
# plot position and color code by time elapsed
secs = time.mktime(time.localtime())-self.starttime
self.fig.gca().scatter(float(e),float(n),s=30,c=secs, vmin=1, vmax=1200, cmap='Greens')
self.fig.gca().set_ylim([float(n)-IMBOX_Y, float(n)+IMBOX_Y])
self.fig.gca().set_xlim([float(e)-IMBOX_X, float(e)+IMBOX_X])
self.fig.canvas.draw()
示例6: paste_clipboard
def paste_clipboard(text):
#convert to generic
text = text.encode('ascii')
clipboard_types = Clipboard.get_types()
for cb_type in clipboard_types:
if str(cb_type).lower().strip().startswith('text'):
Clipboard.put(text, cb_type)
return
raise Exception('Could not find plain text clipboard in ' + str(clipboard_types))
示例7: build
def build(self):
root= GridLayout()
layout = FloatLayout(orientation='horizontal', size=(450,300), size_hint=(None, None))
#call function when text changes inside TextInput
textinput.bind(text=on_text)
print ('value is ', textinput.text)
print Clipboard.put(textinput.text,'UTF8_STRING')
print Clipboard.get('UTF8_STRING')
#Use copied clipboard value as text for Button
button.text= Clipboard.get('UTF8_STRING')
layout.add_widget(button)
layout.add_widget(textinput)
root.add_widget(layout)
return root
示例8: _update_pos
def _update_pos(self, dt):
'''
get and update position
'''
e, n, lon, lat = get_nmea(self)
# d = get_nmeadepth(self)
try:
self.e_txt.text = e[:10]#self.dat['e'][:10]
self.n_txt.text = n[:10]#self.dat['n'][:10]
# self.d_txt.text = d
except:
pass
Clipboard.copy(self.n_txt.text+':'+self.e_txt.text)
示例9: paste_text
def paste_text(self):
self.pasted_str = Clipboard.paste()
if len(self.pasted_str) >= 1000:
MaxClipboardPopup().open()
return ""
else:
return self.pasted_str
示例10: _update_pos
def _update_pos(self, dt):
'''
get and update position
'''
e, n, lon, lat = get_nmea(self)
try:
self.e_txt.text = e[:10]#self.dat['e'][:10]
self.n_txt.text = n[:10]#self.dat['n'][:10]
except:
pass
Clipboard.copy(self.n_txt.text+':'+self.e_txt.text)
tmp = Clipboard.paste()
self.n_txt.text = tmp.split(':')[0]
self.e_txt.text = tmp.split(':')[1]
示例11: TakePicture
def TakePicture(self, fig, mode):#*args):
'''takes a picture and saves it to the folder according to 'mode'
'''
self.export_to_png = export_to_png
tmp = Clipboard.paste()
self.n_txt.text = tmp.split(':')[0]
self.e_txt.text = tmp.split(':')[1]
now = time.asctime().replace(' ','_').replace(':','_')
if mode==1:
filename = 'st'+self.txt_inpt.text+'_sand_'+now+'_'+self.e_txt.text+'_'+self.n_txt.text+'.png'
elif mode==2:
filename = 'st'+self.txt_inpt.text+'_gravel_'+now+'_'+self.e_txt.text+'_'+self.n_txt.text+'.png'
elif mode==3:
filename = 'st'+self.txt_inpt.text+'_rock_'+now+'_'+self.e_txt.text+'_'+self.n_txt.text+'.png'
elif mode==4:
filename = 'st'+self.txt_inpt.text+'_sandrock_'+now+'_'+self.e_txt.text+'_'+self.n_txt.text+'.png'
elif mode==5:
filename = 'st'+self.txt_inpt.text+'_sandgravel_'+now+'_'+self.e_txt.text+'_'+self.n_txt.text+'.png'
elif mode==6:
filename = 'st'+self.txt_inpt.text+'_gravelsand_'+now+'_'+self.e_txt.text+'_'+self.n_txt.text+'.png'
self.export_to_png(self.ids.camera, filename=filename)
if mode==1:
subprocess.Popen("python resize_n_move.py -i "+filename+" -o eyeballimages", shell=True)
self.textinput.text += 'Sand image collected:\n'
elif mode==2:
subprocess.Popen("python resize_n_move.py -i "+filename+" -o gravelimages", shell=True)
self.textinput.text += 'Gravel image collected:\n'
elif mode==3:
subprocess.Popen("python resize_n_move.py -i "+filename+" -o rockimages", shell=True)
self.textinput.text += 'Rock image collected:\n'
elif mode==4:
subprocess.Popen("python resize_n_move.py -i "+filename+" -o sandrockimages", shell=True)
self.textinput.text += 'Sand/Rock image collected:\n'
elif mode==5:
subprocess.Popen("python resize_n_move.py -i "+filename+" -o sandgravelimages", shell=True)
self.textinput.text += 'Sand/Gravel image collected:\n'
elif mode==6:
subprocess.Popen("python resize_n_move.py -i "+filename+" -o gravelsandimages", shell=True)
self.textinput.text += 'Gravel/Sand image collected:\n'
if SHOWMAP:
if mode==1:
fig.gca().plot(float(self.e_txt.text),float(self.n_txt.text),'ys')
elif mode==2:
fig.gca().plot(float(self.e_txt.text),float(self.n_txt.text),'s',color=(.5,.5,.5))
elif mode==3:
fig.gca().plot(float(self.e_txt.text),float(self.n_txt.text),'rs')
elif mode==4:
fig.gca().plot(float(self.e_txt.text),float(self.n_txt.text),'s', color=(1.0, 0.6, 0.0))
elif mode==5:
fig.gca().plot(float(self.e_txt.text),float(self.n_txt.text),'s', color=(0.75, 0.6, 0.8))
elif mode==6:
fig.gca().plot(float(self.e_txt.text),float(self.n_txt.text),'s', color=(0.7, 0.7, 0.1))
fig.canvas.draw()
示例12: do
def do(self, action):
textinput = self.textinput
global Clipboard
if Clipboard is None:
from kivy.core.clipboard import Clipboard
if action == 'cut':
Clipboard.put(textinput.selection_text, 'text/plain')
textinput.delete_selection()
elif action == 'copy':
Clipboard.put(textinput.selection_text, 'text/plain')
elif action == 'paste':
data = Clipboard.get('text/plain')
if data:
textinput.delete_selection()
textinput.insert_text(data)
示例13: setUp
def setUp(self):
from kivy.core.clipboard import Clipboard
self._clippy = Clipboard
clippy_types = Clipboard.get_types()
cliptype = clippy_types[0]
if 'UTF8_STRING' in clippy_types:
cliptype = 'UTF8_STRING'
self._cliptype = cliptype
示例14: _window_on_key_down
def _window_on_key_down(self, window, key, scancode=None, unicode=None,
modifiers=None):
global Clipboard
if Clipboard is None:
from kivy.core.clipboard import Clipboard
is_osx = sys.platform == 'darwin'
# Keycodes on OSX:
ctrl, cmd = 64, 1024
if unicode and not key in (self.interesting_keys.keys() + [27]):
# This allows *either* ctrl *or* cmd, but not both.
if modifiers == ['ctrl'] or (is_osx and modifiers == ['meta']):
if key == ord('x'): # cut selection
Clipboard.put(self.selection_text, 'text/plain')
self.delete_selection()
elif key == ord('c'): # copy selection
Clipboard.put(self.selection_text, 'text/plain')
elif key == ord('v'): # paste selection
data = Clipboard.get('text/plain')
if data:
self.delete_selection()
self.insert_text(data)
elif key == ord('a'): # select all
self.selection_from = 0
self.selection_to = len(self.text)
self._update_selection(True)
else:
if self._selection:
self.delete_selection()
self.insert_text(unicode)
#self._recalc_size()
return
if key == 27: # escape
self.focus = False
return True
elif key == 9: # tab
self.insert_text('\t')
return True
k = self.interesting_keys.get(key)
if k:
key = (None, None, k, 1)
self._key_down(key)
示例15: _keyboard_on_key_down
def _keyboard_on_key_down(self, window, keycode, text, modifiers):
global Clipboard
if Clipboard is None:
from kivy.core.clipboard import Clipboard
is_osx = sys.platform == "darwin"
# Keycodes on OSX:
ctrl, cmd = 64, 1024
key, key_str = keycode
if text and not key in (self.interesting_keys.keys() + [27]):
# This allows *either* ctrl *or* cmd, but not both.
if modifiers == ["ctrl"] or (is_osx and modifiers == ["meta"]):
if key == ord("x"): # cut selection
Clipboard.put(self.selection_text, "text/plain")
self.delete_selection()
elif key == ord("c"): # copy selection
Clipboard.put(self.selection_text, "text/plain")
elif key == ord("v"): # paste selection
data = Clipboard.get("text/plain")
if data:
self.delete_selection()
self.insert_text(data)
elif key == ord("a"): # select all
self.selection_from = 0
self.selection_to = len(self.text)
self._update_selection(True)
else:
if self._selection:
self.delete_selection()
self.insert_text(text)
# self._recalc_size()
return
if key == 27: # escape
self.focus = False
return True
elif key == 9: # tab
self.insert_text("\t")
return True
k = self.interesting_keys.get(key)
if k:
key = (None, None, k, 1)
self._key_down(key)