本文整理汇总了Python中efl.elementary.entry.Entry.file_get方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.file_get方法的具体用法?Python Entry.file_get怎么用?Python Entry.file_get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类efl.elementary.entry.Entry
的用法示例。
在下文中一共展示了Entry.file_get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Interface
# 需要导入模块: from efl.elementary.entry import Entry [as 别名]
# 或者: from efl.elementary.entry.Entry import file_get [as 别名]
#.........这里部分代码省略.........
self.confirmSave(self.newFile)
def openFile(self, obj=None, ignoreSave=False):
if self.isSaved is True or ignoreSave is True:
self.fileSelector.is_save_set(False)
self.fileLabel.text = "<b>Select a text file to open:</b>"
self.flip.go(ELM_FLIP_ROTATE_YZ_CENTER_AXIS)
elif self.confirmPopup is None:
self.confirmSave(self.openFile)
def confirmSave(self, ourCallback=None):
self.confirmPopup = Popup(self.mainWindow,
size_hint_weight=EXPAND_BOTH)
self.confirmPopup.part_text_set("title,text", "File Unsaved")
current_file = self.mainEn.file[0]
current_file = \
os.path.basename(current_file) if current_file else "Untitled"
self.confirmPopup.text = "Save changes to '%s'?" % (current_file)
# Close without saving button
no_btt = Button(self.mainWindow)
no_btt.text = "No"
no_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
if ourCallback is not None:
no_btt.callback_clicked_add(ourCallback, True)
no_btt.show()
# cancel close request
cancel_btt = Button(self.mainWindow)
cancel_btt.text = "Cancel"
cancel_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
cancel_btt.show()
# Save the file and then close button
sav_btt = Button(self.mainWindow)
sav_btt.text = "Yes"
sav_btt.callback_clicked_add(self.saveFile)
sav_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
sav_btt.show()
# add buttons to popup
self.confirmPopup.part_content_set("button1", no_btt)
self.confirmPopup.part_content_set("button2", cancel_btt)
self.confirmPopup.part_content_set("button3", sav_btt)
self.confirmPopup.show()
def saveAs(self):
self.fileSelector.is_save_set(True)
self.fileLabel.text = "<b>Save new file to where:</b>"
self.flip.go(ELM_FLIP_ROTATE_XZ_CENTER_AXIS)
def saveFile(self, obj=False):
if self.mainEn.file_get()[0] is None or self.isNewFile:
self.saveAs()
else:
self.mainEn.file_save()
self.mainWindow.title_set("%s - ePad"
% os.path.basename(self.mainEn.file[0]))
self.isSaved = True
def closeChecks(self, obj):
print(self.isSaved)
if self.isSaved is False and self.confirmPopup is None:
self.confirmSave(self.closeApp)
else:
self.closeApp()
def closePopup(self, bt, confirmPopup):
self.confirmPopup.delete()
self.confirmPopup = None
def closeApp(self, obj=False, trash=False):
elementary.exit()
def eventsCb(self, obj, src, event_type, event):
if event.modifier_is_set("Control"):
if event.key.lower() == "n":
self.newFile()
elif event.key.lower() == "s" and event.modifier_is_set("Shift"):
self.saveAs()
elif event.key.lower() == "s":
self.saveFile()
elif event.key.lower() == "o":
self.openFile()
# Legacy hack no longer needed
# there was an issue in elementary entry where it would
# accept those character controls
# def textFilter( self, obj, theText, data ):
# # Block ctrl+hot keys used in eventsCb
# #
# # Ctrl O Ctrl N Ctrl S
# ctrl_block = [chr(14), chr(15), chr(19)]
# if theText in ctrl_block:
# return None
# else:
# return theText
def launch(self, startingFile=False):
if startingFile:
self.fileSelected(self.fileSelector, startingFile, True)
self.mainWindow.show()
示例2: Interface
# 需要导入模块: from efl.elementary.entry import Entry [as 别名]
# 或者: from efl.elementary.entry.Entry import file_get [as 别名]
#.........这里部分代码省略.........
def openPress( self, obj, it ):
self.openFile()
it.selected_set(False)
def savePress( self, obj, it ):
self.saveFile()
it.selected_set(False)
def saveAsPress( self, obj, it ):
self.saveAs()
it.selected_set(False)
def optionsPress( self, obj, it ):
it.selected_set(False)
def copyPress( self, obj, it ):
self.mainEn.selection_copy()
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
示例3: Interface
# 需要导入模块: from efl.elementary.entry import Entry [as 别名]
# 或者: from efl.elementary.entry.Entry import file_get [as 别名]
#.........这里部分代码省略.........
os.path.basename(current_file) if current_file else "Untitled"
self.confirmPopup.text = "Save changes to '%s'?" % (current_file)
# Close without saving button
no_btt = Button(self.mainWindow)
no_btt.text = "No"
no_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
if ourCallback is not None:
no_btt.callback_clicked_add(ourCallback, True)
no_btt.show()
# cancel close request
cancel_btt = Button(self.mainWindow)
cancel_btt.text = "Cancel"
cancel_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
cancel_btt.show()
# Save the file and then close button
sav_btt = Button(self.mainWindow)
sav_btt.text = "Yes"
sav_btt.callback_clicked_add(self.saveFile)
sav_btt.callback_clicked_add(self.closePopup, self.confirmPopup)
sav_btt.show()
# add buttons to popup
self.confirmPopup.part_content_set("button1", no_btt)
self.confirmPopup.part_content_set("button2", cancel_btt)
self.confirmPopup.part_content_set("button3", sav_btt)
self.confirmPopup.show()
def saveAs(self):
self.fileSelector.is_save_set(True)
self.fileLabel.text = "<b>Save new file to where:</b>"
self.flip.go(ELM_FLIP_ROTATE_XZ_CENTER_AXIS)
def saveFile(self, obj=False):
if self.mainEn.file_get()[0] is None or self.isNewFile:
self.saveAs()
else:
file_selected = self.mainEn.file_get()[0]
# Detect save errors as entry.file_save currently returns no errors
# even in the case where the file fails to save :(
try:
newfile = open(file_selected, 'w')
except IOError as err:
if err.errno == errno.EACCES:
errorMsg = ("Permision denied: <b>'%s'</b>."
"<br><br>Operation failed !!!"
% (file_selected))
errorPopup(self.mainWindow, errorMsg)
else:
errorMsg = ("ERROR: %s: '%s'"
"<br><br>Operation failed !!!"
% (err.strerror, file_selected))
errorPopup(self.mainWindow, errorMsg)
return
newfile.close()
# if entry is empty and the file does not exists then
# entry.file_save will destroy the file created about by the
# open statement above for some odd reason ...
if not self.mainEn.is_empty:
self.mainEn.file_save()
self.mainWindow.title_set("%s - ePad"
% os.path.basename(self.mainEn.file[0]))
self.isSaved = True
def doSelected(self, obj):
# Something I should avoid but here I prefer a polymorphic function