本文整理汇总了Python中efl.elementary.entry.Entry.file_set方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.file_set方法的具体用法?Python Entry.file_set怎么用?Python Entry.file_set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类efl.elementary.entry.Entry
的用法示例。
在下文中一共展示了Entry.file_set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Interface
# 需要导入模块: from efl.elementary.entry import Entry [as 别名]
# 或者: from efl.elementary.entry.Entry import file_set [as 别名]
#.........这里部分代码省略.........
self.mainBox.pack_end(self.mainEn)
def curChanged(self, entry, label):
# get linear index into current text
index = entry.cursor_pos_get()
# Replace <br /> tag with single char
# to simplify (line, col) calculation
tmp_text = entry.entry_get().replace("<br/>", "\n")
line = tmp_text[:index].count("\n") + 1
col = len(tmp_text[:index].split("\n")[-1]) + 1
# Update label text with line, col
label.text = "Ln {0} Col {1} ".format(line, col)
def textEdited(self, obj):
current_file = self.mainEn.file[0]
current_file = \
os.path.basename(current_file) if \
current_file and not self.isNewFile else \
"Untitled"
self.mainWindow.title = "*%s - ePad" % (current_file)
self.isSaved = False
def fileSelected(self, fs, file_selected, onStartup=False):
if not onStartup:
self.flip.go(ELM_FLIP_INTERACTION_ROTATE)
print(file_selected)
IsSave = fs.is_save_get()
if file_selected:
if IsSave:
newfile = open(file_selected, 'w')
tmp_text = self.mainEn.entry_get()
newfile.write(tmp_text)
newfile.close()
self.mainEn.file_set(file_selected, ELM_TEXT_FORMAT_PLAIN_UTF8)
self.mainEn.entry_set(tmp_text)
self.mainEn.file_save()
self.mainWindow.title_set("%s - ePad"
% os.path.basename(file_selected))
self.isSaved = True
self.isNewFile = False
else:
try:
self.mainEn.file_set(file_selected,
ELM_TEXT_FORMAT_PLAIN_UTF8)
except RuntimeError:
print("Empty file: {0}".format(file_selected))
self.mainWindow.title_set("%s - ePad"
% os.path.basename(file_selected))
def newFile(self, obj=None, ignoreSave=False):
if self.isSaved is True or ignoreSave is True:
trans = Transit()
trans.object_add(self.mainEn)
trans.auto_reverse = True
trans.effect_wipe_add(
ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE,
ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT)
trans.duration = 0.5
trans.go()
time.sleep(0.5)
self.mainWindow.title_set("Untitled - ePad")
self.mainEn.delete()
示例2: Interface
# 需要导入模块: from efl.elementary.entry import Entry [as 别名]
# 或者: from efl.elementary.entry.Entry import file_set [as 别名]
#.........这里部分代码省略.........
it.selected_set(False)
def pastePress( self, obj, it ):
self.mainEn.selection_paste()
it.selected_set(False)
def cutPress( self, obj, it ):
self.mainEn.selection_cut()
it.selected_set(False)
def selectAllPress( self, obj, it ):
self.mainEn.select_all()
it.selected_set(False)
def textEdited( self, obj ):
ourFile = self.mainEn.file_get()[0]
if ourFile and not self.isNewFile:
self.mainWindow.title_set("*%s - ePad"%self.mainEn.file_get()[0].split("/")[len(self.mainEn.file_get()[0].split("/"))-1])
else:
self.mainWindow.title_set("*Untitlted - ePad")
self.isSaved = False
def fileSelected( self, fs, file_selected, onStartup=False ):
if not onStartup:
self.flip.go(ELM_FLIP_INTERACTION_ROTATE)
print(file_selected)
IsSave = fs.is_save_get()
if file_selected:
if IsSave:
newfile = open(file_selected,'w') # creates new file
tmp_text = self.mainEn.entry_get()
newfile.write(tmp_text)
newfile.close()
self.mainEn.file_set(file_selected, ELM_TEXT_FORMAT_PLAIN_UTF8)
self.mainEn.entry_set(tmp_text)
self.mainEn.file_save()
self.mainWindow.title_set("%s - ePad" % file_selected.split("/")[len(file_selected.split("/"))-1])
self.isSaved = True
self.isNewFile = False
else:
try:
self.mainEn.file_set(file_selected, ELM_TEXT_FORMAT_PLAIN_UTF8)
except RuntimeError:
print("Empty file: {0}".format(file_selected))
self.mainWindow.title_set("%s - ePad" % file_selected.split("/")[len(file_selected.split("/"))-1])
def aboutPress( self, obj, it ):
#About popup
self.popupAbout = Popup(self.mainWindow, size_hint_weight=EXPAND_BOTH)
self.popupAbout.text = "ePad - A simple text editor written in python and elementary<br><br> " \
"By: Jeff Hoogland"
bt = Button(self.mainWindow, text="Done")
bt.callback_clicked_add(self.aboutClose)
self.popupAbout.part_content_set("button1", bt)
self.popupAbout.show()
it.selected_set(False)
def aboutClose( self, bt ):
self.popupAbout.delete()
def newFile( self , obj=None, ignoreSave=False ):
if self.isSaved == True or ignoreSave == True:
trans = Transit()
trans.object_add(self.mainEn)
trans.auto_reverse = True
示例3: Interface
# 需要导入模块: from efl.elementary.entry import Entry [as 别名]
# 或者: from efl.elementary.entry.Entry import file_set [as 别名]
#.........这里部分代码省略.........
def doSelected(self, obj):
# Something I should avoid but here I prefer a polymorphic function
if isinstance(obj, Button):
file_selected = self.fileSelector.selected_get()
else:
file_selected = obj
IsSave = self.fileSelector.is_save_get()
if file_selected:
if IsSave:
try:
newfile = open(file_selected, 'w')
except IOError as err:
print("ERROR: {0}: '{1}'".format(err.strerror,
file_selected))
if err.errno == errno.EACCES:
errorMsg = ("Permision denied: <b>'%s'</b>."
"<br><br>Operation failed !!!</br>"
% (file_selected))
errorPopup(self.mainWindow, errorMsg)
else:
errorMsg = ("ERROR: %s: '%s'"
"<br><br>Operation failed !!!</br>"
% (err.strerror, file_selected))
errorPopup(self.mainWindow, errorMsg)
return
tmp_text = self.mainEn.entry_get()
# FIXME: Why save twice?
newfile.write(tmp_text)
newfile.close()
# Suppress error message when empty file is saved
try:
self.mainEn.file_set(file_selected,
ELM_TEXT_FORMAT_PLAIN_UTF8)
except RuntimeError:
print("Empty file saved:{0}".format(file_selected))
self.mainEn.entry_set(tmp_text)
# if empty file entry.file_save destroys file :(
if len(tmp_text):
self.mainEn.file_save()
self.mainWindow.title_set("%s - ePad"
% os.path.basename(file_selected))
self.isSaved = True
self.isNewFile = False
else:
if os.path.isdir(file_selected):
print("ERROR: {0}: is a directory. "
"Could not set file.".format(file_selected))
current_file = os.path.basename(file_selected)
errorMsg = ("<b>'%s'</b> is a folder."
"<br><br>Operation failed !!!</br>"
% (current_file))
errorPopup(self.mainWindow, errorMsg)
return
# Test to see if file can be opened to catch permission errors
# as entry.file_set function does not differentiate
# different possible errors.
try:
with open(file_selected) as f:
tmp_text = f.readline()
except IOError as err:
if err.errno == errno.ENOENT:
print("Creating New file '{0}'".format(file_selected))
# self.fileSelector.current_name_set(file_selected)