Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #coding:utf-8
- try:
- import appuifw2
- import os
- import e32
- import powlite_fm_2
- except:
- import appuifw
- import os
- appuifw.note((ru("У вас не хватает модулей")), "error")
- os.abort()
- ru=lambda x: x.decode('utf-8')
- appuifw2.app.title = u"Redak"
- appuifw2.app.screen = "normal"
- def quit():
- if appuifw2.query(ru("Хотите выйти?"), "query") == 1: appuifw.app.set_exit()
- appuifw2.app.exit_key_handler = quit
- appuifw2.app.body = text = appuifw2.Text(move_callback=None, edit_callback=None, skinned=False,
- scrollbar=True, word_wrap=True, t9=True, indicator=True, fixed_case=False)
- def save():
- pathmanager=powlite_fm_2.manager()
- path1=pathmanager.AskUser(find="dir")
- path2=appuifw2.query(ru("Введите имя файла+расширение"), "text")
- fullpath=path1+path2
- if os.path.exists(fullpath)==1:
- rewrite=appuifw2.query(ru("Такой файл существует!Перезаписать?"), "query")
- if rewrite==1:
- f=open(fullpath, "w")
- content = text.get().replace(u"\u2029", u"\r\n")
- encontent = content.encode("UTF-8")
- f.writelines(encontent)
- f.close()
- appuifw2.note(ru("Файл сохранен!"), "conf")
- elif rewrite==0:
- appuifw2.note(ru("Файл не сохранен!"), "error")
- elif os.path.exists(fullpath)==0:
- f=open(fullpath, "w")
- content = text.get().replace(u"\u2029", u"\r\n")
- encontent = content.encode("UTF-8")
- f.writelines(encontent)
- f.close()
- appuifw2.note(ru("Файл сохранен!"), "conf")
- def clear():
- text.clear()
- def toendtext():
- a=text.len()
- text.set_pos(a)
- #Пока не робит, ну и пофиг!
- Главное что остальное робит!
- def openfile():
- open2 = text.len()
- if open2 > 0:
- rewritefile = appuifw2.query(ru("Вы уже чего то написали. Открыть новый файл?"), "query")
- if rewritefile == 1:
- text.clear()
- fileman=powlite_fm_2.manager()
- ope=fileman.AskUser()
- afn=open(str(ope))
- text.add(ru(str(afn)),)
- elif rewritefile == 0:
- pass
- fileman=powlite_fm_2.manager()
- ope=fileman.AskUser()
- afn=open(ope)
- text.add(ru(str(afn)))
- menu = [
- (ru("Открыть файл"), openfile),
- (ru("Сохранить файл"), save),
- (ru("Очистиь поле"), clear),
- (ru("В конец текста"), toendtext)]
- appuifw2.app.menu=menu
- lock = e32.Ao_lock()
- os.abort = lock.signal
- lock.wait()
Advertisement
Add Comment
Please, Sign In to add comment