예제 #1
0
파일: panel.py 프로젝트: zwadar/pyqode.core
"""
Show how decoding errors can be automatically handled using the EncodingPanel.
"""
import sys
from pyqode.qt import QtWidgets
from pyqode.core import api, panels
from common import setup_editor, get_file_path

app = QtWidgets.QApplication(sys.argv)
editor = setup_editor(
    panels=[(panels.EncodingPanel(), api.Panel.Position.TOP)])
editor.file.open(get_file_path(), use_cached_encoding=False)
app.exec_()
예제 #2
0
"""
Use the encoding choice dialog to reload file in case of error.
"""
import sys
from common import setup_editor, get_file_path
from pyqode.qt import QtWidgets
from pyqode.core import dialogs

app = QtWidgets.QApplication(sys.argv)
success = False
editor = setup_editor()
pth = get_file_path()
success = False
encoding = 'utf-8'
while not success:
    try:
        editor.file.open(pth, encoding=encoding, use_cached_encoding=False)
    except UnicodeDecodeError:
        encoding = dialogs.DlgEncodingsChoice.choose_encoding(
            editor, pth, encoding)
    else:
        success = True
app.exec_()
예제 #3
0
"""
Use the encoding choice dialog to reload file in case of error.
"""
import sys
from pyqode.qt import QtWidgets
from pyqode.core import dialogs
from common import setup_editor, get_file_path

app = QtWidgets.QApplication(sys.argv)
success = False
editor = setup_editor()
pth = get_file_path()
success = False
encoding = "utf-8"
while not success:
    try:
        editor.file.open(pth, encoding=encoding, use_cached_encoding=False)
    except UnicodeDecodeError:
        encoding = dialogs.DlgEncodingsChoice.choose_encoding(editor, pth, encoding)
    else:
        success = True
app.exec_()