コード例 #1
0
 def print_window(self, event):
     confirm = tkMessageBox.askokcancel(title="Print",
                                        message="Print to Default Printer",
                                        default=tkMessageBox.OK,
                                        master=self.editwin)
     if not confirm:
         self.editwin.focus_set()
         return "break"
     tempfilename = None
     saved = self.get_saved()
     if saved:
         filename = self.filename
     # shell undo is reset after every prompt, looks saved, probably isn't
     if not saved or filename is None:
         (tfd, tempfilename) = tempfile.mkstemp(prefix='MRPYTHON_tmp_')
         filename = tempfilename
         os.close(tfd)
         if not self.writefile(tempfilename):
             os.unlink(tempfilename)
             return "break"
     platform = os.name
     printPlatform = True
     if platform == 'posix':  #posix platform
         command = MrPythonConf.GetOption('main', 'General',
                                          'print-command-posix')
         command = command + " 2>&1"
     elif platform == 'nt':  #win32 platform
         command = MrPythonConf.GetOption('main', 'General',
                                          'print-command-win')
     else:  #no printing for this platform
         printPlatform = False
     if printPlatform:  #we can try to print for this platform
         command = command % shlex.quote(filename)
         pipe = os.popen(command, "r")
         # things can get ugly on NT if there is no printer available.
         output = pipe.read().strip()
         status = pipe.close()
         if status:
             output = "Printing failed (exit status 0x%x)\n" % \
                      status + output
         if output:
             output = "Printing command: %s\n" % repr(command) + output
             tkMessageBox.showerror("Print status",
                                    output,
                                    master=self.editwin)
     else:  #no printing for this platform
         message = "Printing is not enabled for this platform: %s" % platform
         tkMessageBox.showinfo("Print status", message, master=self.editwin)
     if tempfilename:
         os.unlink(tempfilename)
     return "break"
コード例 #2
0
 def ResetColorizer(self):
     "Update the color theme"
     # Called from self.filename_change_hook and from configDialog.py
     self._rmcolorizer()
     self._addcolorizer()
     theme = MrPythonConf.GetOption('main','Theme','name')
     normal_colors = MrPythonConf.GetHighlight(theme, 'normal')
     cursor_color = MrPythonConf.GetHighlight(theme, 'cursor', fgBg='fg')
     select_colors = MrPythonConf.GetHighlight(theme, 'hilite')
     self.config(
         foreground=normal_colors['foreground'],
         background=normal_colors['background'],
         insertbackground=cursor_color,
         selectforeground=select_colors['foreground'],
         selectbackground=select_colors['background'],
         )
コード例 #3
0
ファイル: PyEditor.py プロジェクト: walidsadat/MrPython
 def set_notabs_indentwidth(self):
     "Update the indentwidth if changed and not using tabs in this window"
     # Called from configDialog.py
     if not self.usetabs:
         self.indentwidth = MrPythonConf.GetOption('main',
                                                   'Indent',
                                                   'num-spaces',
                                                   type='int')
コード例 #4
0
    def __init__(self, parent):
        from configHandler import MrPythonConf
        CloseableNotebook.__init__(self, parent)  #), height=500)
        self.parent = parent
        self.sizetab = 0
        self.recent_files_menu = None

        self.recent_files_path = os.path.join(MrPythonConf.GetUserCfgDir(),
                                              'recent-files.lst')
コード例 #5
0
    def LoadTagDefs(self):
        theme = MrPythonConf.GetOption('main','Theme','name')
        self.tagdefs = {
            "COMMENT": MrPythonConf.GetHighlight(theme, "comment"),
            "KEYWORD": MrPythonConf.GetHighlight(theme, "keyword"),
            "BUILTIN": MrPythonConf.GetHighlight(theme, "builtin"),
            "STRING": MrPythonConf.GetHighlight(theme, "string"),
            "DEFINITION": MrPythonConf.GetHighlight(theme, "definition"),
            "SYNC": {'background':None,'foreground':None},
            "TODO": {'background':None,'foreground':None},
            "ERROR": MrPythonConf.GetHighlight(theme, "error"),
            # The following is used by ReplaceDialog:
            "hit": MrPythonConf.GetHighlight(theme, "hit"),
            }

        if DEBUG: print('tagdefs',self.tagdefs)
コード例 #6
0
    def __init__(self, text):
        '''Initialize data attributes and bind event methods.

        .text - MrPython wrapper of tk Text widget, with .bell().
        .history - source statements, possibly with multiple lines.
        .prefix - source already entered at prompt; filters history list.
        .pointer - index into history.
        .cyclic - wrap around history list (or not).
        '''
        self.text = text
        self.history = []
        self.prefix = None
        self.pointer = None
        self.cyclic = MrPythonConf.GetOption("main", "History", "cyclic", 1,
                                             "bool")
        text.bind("<<history-previous>>", self.history_prev)
        text.bind("<<history-next>>", self.history_next)
コード例 #7
0
    def __init__(self, parent, open=False, filename=None):

        Text.__init__(self,parent)
        self.scroll = scroll=Scrollbar(self)
        scroll['command'] = self.yview
        scroll.pack(side=RIGHT, fill=Y)
        self['yscrollcommand'] = scroll.set
        self.list=parent

        self.recent_files_path = os.path.join(MrPythonConf.GetUserCfgDir(), 'recent-files.lst')

        self.apply_bindings()

        try:
            sys.ps1
        except AttributeError:
            sys.ps1 = ''
            

        # usetabs true  -> literal tab characters are used by indent and
        #                  dedent cmds, possibly mixed with spaces if
        #                  indentwidth is not a multiple of tabwidth,
        #                  which will cause Tabnanny to nag!
        #         false -> tab characters are converted to spaces by indent
        #                  and dedent cmds, and ditto TAB keystrokes
        # Although use-spaces=0 can be configured manually in config-main.def,
        # configuration of tabs v. spaces is not supported in the configuration
        # dialog.  MRPYTHON promotes the preferred Python indentation: use spaces!
        usespaces = MrPythonConf.GetOption('main', 'Indent',
                                       'use-spaces', type='bool')
        self.usetabs = not usespaces
        
        # tabwidth is the display width of a literal tab character.
        # CAUTION:  telling Tk to use anything other than its default
        # tab setting causes it to use an entirely different tabbing algorithm,
        # treating tab stops as fixed distances from the left margin.
        # Nobody expects this, so for now tabwidth should never be changed.
        self.tabwidth = 8    # must remain 8 until Tk is fixed.

        # indentwidth is the number of screen characters per indent level.
        # The recommended Python indentation is four spaces.
        self.indentwidth = self.tabwidth
        self.set_notabs_indentwidth()
        
        # If context_use_ps1 is true, parsing searches back for a ps1 line;
        # else searches for a popular (if, def, ...) Python stmt.
        self.context_use_ps1 = False



        # When searching backwards for a reliable place to begin parsing,
        # first start num_context_lines[0] lines back, then
        # num_context_lines[1] lines back if that didn't work, and so on.
        # The last value should be huge (larger than the # of lines in a
        # conceivable file).
        # Making the initial values larger slows things down more often.
        self.num_context_lines = 50, 500, 5000000
        self.per = per = self.Percolator(self)
        self.undo = undo = self.UndoDelegator()
        per.insertfilter(undo)

        self.undo_block_start = undo.undo_block_start
        self.undo_block_stop = undo.undo_block_stop
        undo.set_saved_change_hook(self.saved_change_hook)

        self.io = io = self.IOBinding(self)
        io.set_filename_change_hook(self.filename_change_hook)
        
        self.color = None # initialized below in self.ResetColorizer

        self.good_load = False
        if open:
            if filename:
                if os.path.exists(filename) and not os.path.isdir(filename):
                    if io.loadfile(filename):
                        self.good_load = True
                        is_py_src = self.ispythonsource(filename)
                else:
                    io.set_filename(filename)
            else:
                self.good_load = self.io.open(editFile=filename)
        else:
            self.good_load=True

        self.ResetColorizer()
        self.saved_change_hook()
        self.askyesno = tkMessageBox.askyesno
        self.askinteger = tkSimpleDialog.askinteger

        # specific font
        self.font = nametofont(self.cget('font')).copy()
        self.configure(font=self.font)
コード例 #8
0
        None,
        ('_Find...', '<<find>>'),
        ('Find A_gain', '<<find-again>>'),
        ('Find _Selection', '<<find-selection>>'),
        ('Find in Files...', '<<find-in-files>>'),
        ('R_eplace...', '<<replace>>'),
        ('Go to _Line', '<<goto-line>>'),
    ]),
    ('format', [('_Indent Region', '<<indent-region>>'),
                ('_Dedent Region', '<<dedent-region>>'), None,
                ('Comment _Out Region', '<<comment-region>>'),
                ('U_ncomment Region', '<<uncomment-region>>')]),
    ('command', [
        ('Select language...', '<<select-language>>'),
        None,
        ('Check Module', '<<check-module>>'),
        ('Run Module', '<<run-module>>'),
    ]),
    ('help', [
        ('_About MrPython', '<<about-mrpython>>'),
        None,
        ('_MrPython Help', '<<help>>'),
        ('Python _Docs', '<<python-docs>>'),
    ]),
]

#if find_spec('turtledemo'):
#   menudefs[-1][1].append(('Turtle Demo', '<<open-turtle-demo>>'))

default_keydefs = MrPythonConf.GetCurrentKeySet()
コード例 #9
0
"""
Contains and modify MrPython behaviour, filepaths for input/output, LRS properties,
xAPI verbs and activities, error categories and mapping function_names->exercise
"""
from tincan import Verb, Activity, LanguageMap, ActivityDefinition
from configHandler import MrPythonConf
import os

# MrPython behaviour and filepaths

send_to_LRS = True  # Send the created statements to the LRS
debug_log_print = True  # Keep a record of all statements produced in debug_filepath / Print messages related to tracing
backup_filepath =  os.path.join(MrPythonConf.GetUserCfgDir(), 'tracing_backup_stack.txt')
debug_filepath = os.path.join(MrPythonConf.GetUserCfgDir(), 'tracing_debug.txt')
session_filepath = os.path.join(MrPythonConf.GetUserCfgDir(), 'tracing_session.txt')

# LRS properties

lrs_endpoint = "https://lrsmocah.lip6.fr/data/xAPI"
lrs_version = "1.0.1" # 1.0.1 | 1.0.0 | 0.95 | 0.9
lrs_username = "******"
lrs_password = "******"
proxy_name = ""
proxy_port = 0

# xAPI verbs and activites

verbs = {
    "opened": Verb(
        id="http://activitystrea.ms/schema/1.0/open", display=LanguageMap({'en-US': 'opened'})),
    "closed": Verb(
コード例 #10
0
xAPI verbs and activities, error categories and mapping function_names->exercise
"""
from tincan import (
    Verb,
    Activity,
    LanguageMap,
    ActivityDefinition,
)
from configHandler import MrPythonConf
import os

# MrPython behaviour and filepaths

send_to_LRS = True  # Send the created statements to the LRS
debug_log_print = True  # Keep a record of all statements produced in debug_filepath / Print messages related to tracing
backup_filepath = os.path.join(MrPythonConf.GetUserCfgDir(),
                               'tracing_backup_stack.txt')
debug_filepath = os.path.join(MrPythonConf.GetUserCfgDir(),
                              'tracing_debug.txt')
session_filepath = os.path.join(MrPythonConf.GetUserCfgDir(),
                                'tracing_session.txt')

# LRS properties

lrs_endpoint = "https://lrsmocah.lip6.fr/data/xAPI"
lrs_version = "1.0.1"  # 1.0.1 | 1.0.0 | 0.95 | 0.9
lrs_username = "******"
lrs_password = "******"

# xAPI verbs and activites