Пример #1
0
 def __init__(self, parent, wid=50, hei=3):
     Text.__init__(self,
                   parent,
                   width=wid,
                   height=hei,
                   borderwidth=2,
                   font=("Calibri", 11))
Пример #2
0
 def __init__(self, parent,inhandler):
     Text.__init__(self, parent)   
     
     self.parent = parent
     self.inh = inhandler
     
     self.initUI()
Пример #3
0
    def __init__(self, parent, filename):
        "Configure tags and feed file to parser."
        Text.__init__(self, parent, wrap='word', highlightthickness=0,
                      padx=5, borderwidth=0)

        normalfont = self.findfont(['TkDefaultFont', 'arial', 'helvetica'])
        fixedfont = self.findfont(['TkFixedFont', 'monaco', 'courier'])
        self['font'] = (normalfont, 12)
        self.tag_configure('em', font=(normalfont, 12, 'italic'))
        self.tag_configure('h1', font=(normalfont, 20, 'bold'))
        self.tag_configure('h2', font=(normalfont, 18, 'bold'))
        self.tag_configure('h3', font=(normalfont, 15, 'bold'))
        self.tag_configure('pre', font=(fixedfont, 12))
        self.tag_configure('preblock', font=(fixedfont, 10), lmargin1=25,
                borderwidth=1, relief='solid', background='#eeffcc')
        self.tag_configure('l1', lmargin1=25, lmargin2=25)
        self.tag_configure('l2', lmargin1=50, lmargin2=50)
        self.tag_configure('l3', lmargin1=75, lmargin2=75)
        self.tag_configure('l4', lmargin1=100, lmargin2=100)

        self.parser = HelpParser(self)
        with open(filename, encoding='utf-8') as f:
            contents = f.read()
        self.parser.feed(contents)
        self['state'] = 'disabled'
Пример #4
0
    def __init__(self, *args, **kwargs):
        Text.__init__(self, *args, **kwargs)

        # create a proxy for the underlying widget
        self._orig = self._w + "_orig"
        self.tk.call("rename", self._w, self._orig)
        self.tk.createcommand(self._w, self._proxy)
Пример #5
0
 def __init__(self, master=None, **kw):
     self.frame = Frame(master)
     self.vbar = Scrollbar(self.frame)
     self.vbar.pack(side=RIGHT, fill=Y)
     #>>>MNC: For horizontal scrollbar 
     try:
         self.hbar = None
         if kw['wrap'] == NONE:
             self.hbar = Scrollbar(self.frame, orient=HORIZONTAL)
             self.hbar.pack(side=BOTTOM, fill=X)
             kw.update({'xscrollcommand': self.hbar.set})
     except KeyError:
         self.hbar = None
     #<<<MNC
     kw.update({'yscrollcommand': self.vbar.set})
     Text.__init__(self, self.frame, **kw)
     self.pack(side=LEFT, fill=BOTH, expand=True)
     self.vbar['command'] = self.yview
     #>>>MNC: For horizontal scrollbar 
     if self.hbar is not None:
         self.hbar['command'] = self.xview
     #<<<MNC
     # Copy geometry methods of self.frame without overriding Text
     # methods -- hack!
     text_meths = vars(Text).keys()
     methods = vars(Pack).keys() | vars(Grid).keys() | vars(Place).keys()
     methods = methods.difference(text_meths)
     for m in methods:
         if m[0] != '_' and m != 'config' and m != 'configure':
             setattr(self, m, getattr(self.frame, m))
    def __init__(self, parent, filename):
        "Configure tags and feed file to parser."
        uwide = idleConf.GetOption('main', 'EditorWindow', 'width', type='int')
        uhigh = idleConf.GetOption('main', 'EditorWindow', 'height', type='int')
        uhigh = 3 * uhigh // 4  # Lines average 4/3 of editor line height.
        Text.__init__(self, parent, wrap='word', highlightthickness=0,
                      padx=5, borderwidth=0, width=uwide, height=uhigh)

        normalfont = self.findfont(['TkDefaultFont', 'arial', 'helvetica'])
        fixedfont = self.findfont(['TkFixedFont', 'monaco', 'courier'])
        self['font'] = (normalfont, 12)
        self.tag_configure('em', font=(normalfont, 12, 'italic'))
        self.tag_configure('h1', font=(normalfont, 20, 'bold'))
        self.tag_configure('h2', font=(normalfont, 18, 'bold'))
        self.tag_configure('h3', font=(normalfont, 15, 'bold'))
        self.tag_configure('pre', font=(fixedfont, 12), background='#f6f6ff')
        self.tag_configure('preblock', font=(fixedfont, 10), lmargin1=25,
                borderwidth=1, relief='solid', background='#eeffcc')
        self.tag_configure('l1', lmargin1=25, lmargin2=25)
        self.tag_configure('l2', lmargin1=50, lmargin2=50)
        self.tag_configure('l3', lmargin1=75, lmargin2=75)
        self.tag_configure('l4', lmargin1=100, lmargin2=100)

        self.parser = HelpParser(self)
        with open(filename, encoding='utf-8') as f:
            contents = f.read()
        self.parser.feed(contents)
        self['state'] = 'disabled'
Пример #7
0
 def __init__(self, *args, **kwargs):
     Text.__init__(self, *args, **kwargs)
     self.redirector = WidgetRedirector(self)
     self.insert = self.redirector.register("insert",
                                            lambda *args, **kw: "break")
     self.delete = self.redirector.register("delete",
                                            lambda *args, **kw: "break")
Пример #8
0
    def __init__(self, parent, filename):
        "Configure tags and feed file to parser."
        uwide = idleConf.GetOption('main', 'EditorWindow', 'width', type='int')
        uhigh = idleConf.GetOption('main', 'EditorWindow', 'height', type='int')
        uhigh = 3 * uhigh // 4  # lines average 4/3 of editor line height
        Text.__init__(self, parent, wrap='word', highlightthickness=0,
                      padx=5, borderwidth=0, width=uwide, height=uhigh)

        normalfont = self.findfont(['TkDefaultFont', 'arial', 'helvetica'])
        fixedfont = self.findfont(['TkFixedFont', 'monaco', 'courier'])
        self['font'] = (normalfont, 12)
        self.tag_configure('em', font=(normalfont, 12, 'italic'))
        self.tag_configure('h1', font=(normalfont, 20, 'bold'))
        self.tag_configure('h2', font=(normalfont, 18, 'bold'))
        self.tag_configure('h3', font=(normalfont, 15, 'bold'))
        self.tag_configure('pre', font=(fixedfont, 12), background='#f6f6ff')
        self.tag_configure('preblock', font=(fixedfont, 10), lmargin1=25,
                borderwidth=1, relief='solid', background='#eeffcc')
        self.tag_configure('l1', lmargin1=25, lmargin2=25)
        self.tag_configure('l2', lmargin1=50, lmargin2=50)
        self.tag_configure('l3', lmargin1=75, lmargin2=75)
        self.tag_configure('l4', lmargin1=100, lmargin2=100)

        self.parser = HelpParser(self)
        with open(filename, encoding='utf-8') as f:
            contents = f.read()
        self.parser.feed(contents)
        self['state'] = 'disabled'
Пример #9
0
        def __init__(self, *a, **b):

            # Create self as a Text.
            Text.__init__(self, *a, **b)

            # Initialize the ModifiedMixin.
            self._init()
Пример #10
0
    def __init__(self, master=None, change_hook=None, **kw):
        self.frame = Frame(master)
        self.vbar = Scrollbar(self.frame)
        self.vbar.pack(side=RIGHT, fill=Y)
        self.change_hook = change_hook

        self.hbar = Scrollbar(self.frame, orient=HORIZONTAL)
        self.hbar.pack(side=BOTTOM,fill=X)

        kw.update({'yscrollcommand': self.vbar.set})
        kw.update({'xscrollcommand': self.hbar.set})
        kw.update({'wrap': 'none'})
        Text.__init__(self, self.frame, **kw)
        self.pack(side=LEFT, fill=BOTH, expand=True)
        self.vbar['command'] = self.yview
        self.hbar['command'] = self.xview

        # Copy geometry methods of self.frame without overriding Text
        # methods -- hack!
        text_meths = list(vars(Text).keys())
        methods = list(vars(Pack).keys()) + list(vars(Grid).keys()) + list(vars(Place).keys())
        methods = set(methods).difference(text_meths)

        for m in methods:
            if m[0] != '_' and m != 'config' and m != 'configure':
                setattr(self, m, getattr(self.frame, m))
Пример #11
0
    def __init__(self, master=None, **kw):
        self.frame = Frame(master)

        self.vbar = Scrollbar(self.frame)
        self.vbar.pack(side=RIGHT, fill=Y)

        self.hbar = Scrollbar(self.frame, orient=HORIZONTAL)
        self.hbar.pack(side=BOTTOM, fill=X)

        kw.update({
            'yscrollcommand': self.vbar.set,
            'xscrollcommand': self.hbar.set,
            'wrap': 'none'
        })
        Text.__init__(self, self.frame, **kw)
        self.pack(side=LEFT, fill=BOTH, expand=True)
        self.vbar['command'] = self.yview
        self.hbar['command'] = self.xview

        # Copy geometry methods of self.frame without overriding Text
        # methods -- hack!
        text_meths = vars(Text).keys()
        methods = vars(Pack).keys() | vars(Grid).keys() | vars(Place).keys()
        methods = methods.difference(text_meths)

        for m in methods:
            if m[0] != '_' and m != 'config' and m != 'configure':
                setattr(self, m, getattr(self.frame, m))
Пример #12
0
    def __init__(self, *args, **kwargs) -> None:

        Text.__init__(self, *args, **kwargs)

        self._orig = self._w + "_orig"
        self.tk.call("rename", self._w, self._orig)
        self.tk.createcommand(self._w, self._proxy)
Пример #13
0
    def __init__(self, parent, filename):
        "Configure tags and feed file to parser."
        uwide = idleConf.GetOption("main", "EditorWindow", "width", type="int")
        uhigh = idleConf.GetOption("main", "EditorWindow", "height", type="int")
        uhigh = 3 * uhigh // 4  # lines average 4/3 of editor line height
        Text.__init__(self, parent, wrap="word", highlightthickness=0, padx=5, borderwidth=0, width=uwide, height=uhigh)

        normalfont = self.findfont(["TkDefaultFont", "arial", "helvetica"])
        fixedfont = self.findfont(["TkFixedFont", "monaco", "courier"])
        self["font"] = (normalfont, 12)
        self.tag_configure("em", font=(normalfont, 12, "italic"))
        self.tag_configure("h1", font=(normalfont, 20, "bold"))
        self.tag_configure("h2", font=(normalfont, 18, "bold"))
        self.tag_configure("h3", font=(normalfont, 15, "bold"))
        self.tag_configure("pre", font=(fixedfont, 12), background="#f6f6ff")
        self.tag_configure(
            "preblock", font=(fixedfont, 10), lmargin1=25, borderwidth=1, relief="solid", background="#eeffcc"
        )
        self.tag_configure("l1", lmargin1=25, lmargin2=25)
        self.tag_configure("l2", lmargin1=50, lmargin2=50)
        self.tag_configure("l3", lmargin1=75, lmargin2=75)
        self.tag_configure("l4", lmargin1=100, lmargin2=100)

        self.parser = HelpParser(self)
        with open(filename, encoding="utf-8") as f:
            contents = f.read()
        self.parser.feed(contents)
        self["state"] = "disabled"
Пример #14
0
    def __init__(self, *args, **kwords):
        Text.__init__(self, *args, **kwords)
        if not ROText.tagInit:
            self.init_tag()

        bindTags = tuple(tag if tag != "Text" else "ROText" for tag in self.bindtags())
        self.bindtags(bindTags)
Пример #15
0
 def __init__(self, master):
     """
     Initialise main message panel.
     Its master must be the root element.
     """
     Text.__init__(self, master, width=50, wrap=CHAR)
     self.insert(END, '')
     self._set_state(DISABLED)
 def __init__(self, *args, **kwords):
     Text.__init__(self, *args, **kwords)
     if not ROText.tagInit:
         self.init_tag()
     # Create a new binding table list, replace the default Text binding table by the ROText one
     bind_tags = tuple(tag if tag != "Text" else "ROText"
                       for tag in self.bindtags())
     self.bindtags(bind_tags)
Пример #17
0
 def __init__(self, master, **options):
     Text.__init__(self, master, **options)
     self.queue = queue.Queue()
     self.encoding = "utf-8"
     self.gui = True
     self.initial_width = 85
     self.width = self.initial_width
     self.update_me()
Пример #18
0
 def __init__(self, *args, **kwargs):
     """
 initialize our specialized tkinter Text widget
 """
     Text.__init__(self, *args, **kwargs)
     self.known_tags = set([])
     # register a default color tag
     self.register_tag("30", "White", "Black")
     self.reset_to_default_attribs()
Пример #19
0
 def __init__(self, master, **kwargs):
     self.master = Frame(master)
     self.font = Font(family="Helvetica", size=DEFAULT_FONT_SIZE)
     self.font_bold = Font(family="Helvetica", size=DEFAULT_FONT_SIZE, weight=BOLD)
     Text.__init__(self, self.master, font=self.font, state=DISABLED, **kwargs)
     self.scrollbar = Scrollbar(self.master, orient=VERTICAL, command=self.yview)
     self.search_frame = SearchFrame(self.master)
     self.configure(yscrollcommand=self.scrollbar.set)
     self.images: dict = {}
     self.declare_tags()
Пример #20
0
    def __init__(self, magus_gui):
        """
        Initialise main message panel.

        Its master must be the root element.
        """
        Text.__init__(self, magus_gui, bg=MESSAGE_BOX_COLOUR,
                      width=TAB_PANEL_WIDTH)
        self.insert(END, TEXT_START)
        self._set_state(DISABLED)
Пример #21
0
 def __init__(self, *args, **kwargs):
     Text.__init__(self, *args, **kwargs)
     self.redirector = WidgetRedirector(self)
     self.insert = self.redirector.register("insert",
                                            lambda *args, **kw: "break")
     self.delete = self.redirector.register("delete",
                                            lambda *args, **kw: "break")
     self.configure(highlightthickness=0,
                    insertwidth=0,
                    takefocus=0,
                    wrap="word")
Пример #22
0
 def __init__(self, *args, **kwargs):
     # Widgets
     self.frame = Frame(*args)
     self.scrollbar = AutoScrollbar(self.frame, command=self.yview)
     # Init
     kwargs["yscrollcommand"] = self.scrollbar.set
     Text.__init__(self, self.frame, **kwargs)
     # Layout
     self.frame.columnconfigure(0, weight=1)
     self.frame.rowconfigure(0, weight=1)
     Text.grid(self, column=0, row=0, sticky="NSEW")
     self.scrollbar.grid(column=1, row=0, sticky="NSEW")
Пример #23
0
 def __init__(self, api, text='', id=None):
     self.master = Tk()
     self.id = id
     self.api = api
     Text.__init__(self, self.master, bg='#f9f3a9', wrap='word', undo=True)
     self.bind('<Control-n>', self.create)
     self.bind('<Control-s>', self.save)
     if id:
         self.master.title('#%d' % id)
     self.delete('1.0', 'end')
     self.insert('1.0', text)
     self.master.geometry('220x235')
     self.pack(fill='both', expand=1)
Пример #24
0
 def __init__(self, master=None, **kw):
     self.frame = Frame(master)
     self.vbar = Scrollbar(self.frame)
     self.vbar.pack(side=RIGHT, fill=Y)
     kw.update({'yscrollcommand': self.vbar.set})
     Text.__init__(self, self.frame, **kw)
     self.pack(side=LEFT, fill=BOTH, expand=True)
     self.vbar['command'] = self.yview
     text_meths = vars(Text).keys()
     methods = vars(Pack).keys() | vars(Grid).keys() | vars(Place).keys()
     methods = methods.difference(text_meths)
     for m in methods:
         if m[0] != '_' and m != 'config' and m != 'configure':
             setattr(self, m, getattr(self.frame, m))
Пример #25
0
    def __init__(self, master=None, cnf={}, **kw):
        self.__debug = False
        """See the __init__ for Tkinter.Text for most of this stuff."""

        Text.__init__(self, master, cnf, **kw)

        self.started = False
        self.write_lock = threading.Lock()

        self.tag_configure('STDOUT',background='black',foreground='white')
        self.tag_configure('STDERR',background='black',foreground='red')

        self.config(state=NORMAL)
        self.bind('<Key>',lambda e: 'break') #ignore all key presses
Пример #26
0
 def __init__(self,
              frame,
              string="",
              font=mediumtext,
              foreground=primary_text_color,
              background=primary_color):
     Text.__init__(self,
                   frame,
                   wrap="word",
                   font=font,
                   foreground=foreground,
                   background=background,
                   borderwidth=0,
                   highlightthickness=0)
     self.set(string)
    def __init__(self, master=None, **kw):
        self.frame = Frame(master)
        self.vbar = Scrollbar(self.frame)
        self.vbar.pack(side=RIGHT, fill=Y)

        kw.update({'yscrollcommand': self.vbar.set})
        Text.__init__(self, self.frame, **kw)
        self.pack(side=LEFT, fill=BOTH, expand=True)
        self.vbar['command'] = self.yview

        # Copy geometry methods of self.frame -- hack!
        methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys()

        for m in methods:
            if m[0] != '_' and m != 'config' and m != 'configure':
                setattr(self, m, getattr(self.frame, m))
Пример #28
0
    def __init__(self, master=None, **kw):
        self.frame = Frame(master)
        self.vbar = Scrollbar(self.frame)
        self.vbar.pack(side=RIGHT, fill=Y)

        kw.update({'yscrollcommand': self.vbar.set})
        Text.__init__(self, self.frame, **kw)
        self.pack(side=LEFT, fill=BOTH, expand=True)
        self.vbar['command'] = self.yview

        # Copy geometry methods of self.frame -- hack!
        methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys()

        for m in methods:
            if m[0] != '_' and m != 'config' and m != 'configure':
                setattr(self, m, getattr(self.frame, m))
Пример #29
0
 def __init__(self,
              master,
              username: str,
              fragments: dict,
              color: str,
              font: Font,
              autoscroll: bool = True):
     Text.__init__(self, master, height=1, font=font, wrap=WORD)
     self.username: str = username
     self.fragments: dict = fragments
     self.font: Font = font
     self.font_bold: Font = font.copy()
     self.font_bold.configure(weight=BOLD)
     self.color = color
     self.autoscroll = autoscroll
     self.images: list = []
Пример #30
0
 def __init__( self, master=None, prompt = "> ", width=80, fg='white', bg='black') :
     Text.__init__( self, master, width=width, fg=fg, bg=bg, insertbackground=fg)
     self.prompt = prompt
     self.bind( "<BackSpace>", self.backspace)
     self.bind( "<Key-Return>",self.execute)
     self.bind( "<Key-Left>", self.left)
     self.bind( "<Key-Up>", self.rappelerLigne)
     self.bind( "<Key-Down>", self.rappelerLigne)
     self.bind( "<1>", self.button_1)
     self.bind( "<B1-Motion>", self.button_1)
     self.bind( "<B1-Leave>", lambda event : "break")
     self.bind( "<Double-1>", lambda event : "break") 
     self.bind( "<Triple-1>", lambda event : "break")
     self.bind( "<<Paste>>", self.insert_commande)
     self.insert( "end", self.prompt )
     self.start_commande = '1.0 + %d chars' % len( self.prompt )
     self.lignes = []
     self.numeroligne = 0
Пример #31
0
    def __init__(self, parent, spell=None, **kw):
        Text.__init__(self, parent, wrap="word",
                      font="Times 14", takefocus=True, **kw)
        self.tg_regexp = re.compile("<[^>]*>")
        self.bind("<Control-c>", self.copy)
        self.bind("<Control-x>", self.cut)
        self.bind("<Return>", self.newline)
        self.tag_configure("h1", font="Times 16 bold", relief="raised")
        self.tag_configure("highlight", background="yellow", relief="raised")
        self.tag_configure("html_tag", foreground="blue")
        if spell:
            r, self.wd = pipe()
            self.rd, w = pipe()
            args = spell.split()
            self.sp = Popen(args, stdin=r, stdout=w)

            self.tag_configure("misspelled", foreground="red", underline=True)
            self.bind("<space>", self.Spellcheck)
        self.percolator = Percolator(self)
        self.percolator.insertfilter(HtmlColorDelegator())
Пример #32
0
    def __init__(self, *a, **b):

        try:
            self.master = a[0]
        except IndexError:
            raise TypeError("Must be a tk for first args")
        # Create self as a Text.
        Text.__init__(self, *a, **b)
        self.textlen = 0

        # Initialize the ModifiedMixin.
        self._init()

        #Initialize the tags
        self.tag_config("pap_funcs_name",
                        foreground="#ff0000",
                        fg="gray75",
                        wrap=NONE)
        self.tag_config("built_in_funcs_name", foreground="blue", wrap=NONE)
        self.tag_config("key_words_name", foreground="green", wrap=NONE)
Пример #33
0
    def __init__(self, default_filename, *args, **kwargs):
        """
        This class receives all Text widget arguments
        and one named default_filename which means
        the filename that is saved when no filename
        is specified.

        default_filename:   
        The default path file where contents are saved.        
        """

        Text.__init__(self, *args, **kwargs)
        DataEvent.__init__(self, self)
        IdleEvent.__init__(self, self)

        self.setup = dict()

        # Maybe it should be?
        # abspath(default_filename)
        self.default_filename = default_filename

        # The file's path and name.
        self.filename  = default_filename
        self.extension = os.path.splitext(self.filename)

        self.mark_set('(CURSOR_LAST_COL)', '1.0')

        self.charset  = 'utf-8'
        self.map      = {}
        self.db       = {}
        self.project  = ''
        self.assoc_c  = 0

        # The character used for indentation.
        self.tabchar = ' '
        self.tabsize = 4

        def set_input(e):
            AreaVi.INPUT = e.widget
        self.hook('AreaVi', '-1', '<FocusIn>', set_input)
Пример #34
0
    def __init__(self, qp, master=None, log=None, **kw):
        self.qp = qp
        self.log = log
        self.frame = Frame(master)
        self.vbar = Scrollbar(self.frame)
        self.vbar.pack(side=RIGHT, fill=Y)

        kw.update({'yscrollcommand': self.vbar.set})
        Text.__init__(self, self.frame, **kw)
        self.pack(side=LEFT, fill=BOTH, expand=True)
        self.vbar['command'] = self.yview
        self.values = {}

        # Copy geometry methods of self.frame without overriding Text
        # methods -- hack!
        text_meths = vars(Text).keys()
        methods = vars(Pack).keys() | vars(Grid).keys() | vars(Place).keys()
        methods = methods.difference(text_meths)

        for m in methods:
            if m[0] != '_' and m != 'config' and m != 'configure':
                setattr(self, m, getattr(self.frame, m))
Пример #35
0
    def __init__(self, master, **kw):
        kw.setdefault('width', 50)
        kw.setdefault('wrap', 'word')
        kw.setdefault('prompt1', '>>> ')
        kw.setdefault('prompt2', '    ')
        banner = kw.pop('banner', 'Python %s\n' % sys.version)
        self._prompt1 = kw.pop('prompt1')
        self._prompt2 = kw.pop('prompt2')
        ColorText.__init__(self, master, **kw)
        # --- history
        self.history = History()
        self._hist_item = 0
        self._hist_match = ''

        # --- initialization
        self._console = InteractiveConsole(
        )  # python console to execute commands
        sys.stdin = Pipe()
        self.insert('end', banner, 'banner')
        self.prompt()
        self.mark_set('input', 'insert')
        self.mark_gravity('input', 'left')

        # --- bindings
        self.bind('<Control-Return>', self.on_ctrl_return)
        self.bind('<Shift-Return>', self.on_shift_return)
        self.bind('<KeyPress>', self.on_key_press)
        self.bind('<KeyRelease>', self.on_key_release)
        self.bind('<Tab>', self.on_tab)
        self.bind('<Down>', self.on_down)
        self.bind('<Up>', self.on_up)
        self.bind('<Return>', self.on_return)
        self.bind('<BackSpace>', self.on_backspace)
        self.bind('<Control-c>', self.on_ctrl_c)
        self.bind('<<Paste>>', self.on_paste)
        self.unbind('<Control-Shift-Home>')
        self.unbind('<Control-Shift-End>')
Пример #36
0
    def __init__(self, master=None, **kw):
        self.frame = Frame(master)
        self.vbar = AutoScrollbar(self.frame, orient="vertical")
        self.vbar.grid(row=0, column=1, sticky="ns")
        self.frame.grid_columnconfigure(0, weight=1)
        self.frame.grid_columnconfigure(1, weight=0)
        self.frame.grid_rowconfigure(0, weight=1)

        kw.update({'yscrollcommand': self.vbar.set})
        Text.__init__(self, self.frame, **kw)
        self.vbar['command'] = self.yview
        Text.grid(self, row=0, column=0, sticky="news")

        # Copy geometry methods of self.frame without overriding Text
        # methods -- hack!
        text_meths = vars(Text).keys()
        methods = vars(Pack).keys() | vars(Grid).keys() | vars(Place).keys()
        methods = methods.difference(text_meths)

        for m in methods:
            if m[0] != '_' and m != 'config' and m != 'configure' and m not in [
                    "grid", "pack"
            ]:
                setattr(self, m, getattr(self.frame, m))
Пример #37
0
 def __init__(self, master, **kw):
     Text.__init__(self, master, **kw)
     self.config(state="disabled")
     self.rollFlag = BooleanVar()
     self.rollFlag.set(True)
Пример #38
0
 def __init__(self, *args, **kwargs):
     Text.__init__(self, *args, **kwargs)
     self.redirector = WidgetRedirector(self)
     self.insert = self.redirector.register("insert", lambda *args, **kw: "break")
     self.delete = self.redirector.register("delete", lambda *args, **kw: "break")
     
Пример #39
0
    def __init__(self, parent, file=None):
        Text.__init__(self, parent, wrap=NONE, undo=True, maxundo=-1, borderwidth='0p')
        self.vbar = Scrollbar(parent, name='vbar_tiborcim')
        self.xbar = Scrollbar(parent, name='xbar_tiborcim', orient="horizontal")
        self.bind('<Button-3>',CimEditMenu, add='')
        self.vbar['command'] = self.yview
        self.vbar.pack(side="right", fill=Y)
        self['yscrollcommand'] = self.vbar.set
        self.xbar['command'] = self.xview
        self.xbar.pack(side="bottom", fill=X)
        self['xscrollcommand'] = self.xbar.set
        self.pack(expand=1, fill="both")
        self.tag_configure("keyword", foreground="#ff0000")
        self.tag_configure("string", foreground="#28a030")
        self.tag_configure("block", foreground="#0000ff")
        self.tag_configure("builtin", foreground="#9228a0")
        self.tag_configure("comment", foreground="#74787f")

        def text_changed(evt):
            if file is not None:
                file.saved = False
            line, col = self.index('insert').split('.')
            txt = self.get('%s.0' % line, '%s.end' % line)
            blocks = [
                "WHILE", "WEND",                        # WHILE loop
                "SUB", "END SUB",                       # SUBs
                "IF", "ELSEIF", "ELSE", "END IF", "THEN",# IF control
                "FOR", "TO", "NEXT",                    # FOR loop
                "PYTHON", "END PYTHON"                  # PYTHON block
            ]
            builtins = [
                "INT",
                "RND",
                "SHAKEN",
                "NOT", "AND", "OR"                      # Not implemented
            ]
            builtinvars = [
                "STR\$",
                "INKEY\$",
                "RECEIVE\$"
            ]
            keywords = [
                "SCREEN", "PSET",                       # Leds
                "RADIO\W(ON|OFF)", "BROADCAST",         # Radio communications
                "PRINT",
                "SHOW",
                "IMAGE",
                "SLEEP"
            ]
            strings = [
                "\"(.*?)\"",
                "'(.*?)'"
            ]
            self.tag_remove('builtin', '1.0', 'end')
            self.tag_remove('keyword', '1.0', 'end')
            self.tag_remove('string', '1.0', 'end')
            self.tag_remove('block', '1.0', 'end')
            for builtin in builtins:
                self.highlight_pattern("\y" + builtin + "\y(?=([^\"]*\"[^\"]*\")*[^\"]*$)", "builtin", '1.0', 'end', True)
            for builtinvar in builtinvars:
                self.highlight_pattern("\y" + builtinvar + "(?=([^\"]*\"[^\"]*\")*[^\"]*$)", "builtin", '1.0', 'end', True)
            for keyword in keywords:
                self.highlight_pattern("\y" + keyword + "\y(?=([^\"]*\"[^\"]*\")*[^\"]*$)", "keyword", '1.0', 'end', True)
            for string in strings:
                self.highlight_pattern(string + "(?=([^\"]*\"[^\"]*\")*[^\"]*$)", "string", '1.0', 'end', True)
            for block in blocks:
                self.highlight_pattern("\y" + block + "\y(?=([^\"]*\"[^\"]*\")*[^\"]*$)", "block", '1.0', 'end', True)
            self.highlight_pattern("^\'(.*?)$", "comment", '1.0', 'end', True)
            self.edit_modified(False)

        self.bind('<<Modified>>', text_changed)
Пример #40
0
 def __init__(self, *args, **kwargs):
     Text.__init__(self, *args, **kwargs)
Пример #41
0
 def __init__(self, *args, **kwargs):
     Text.__init__(self, *args, **kwargs)
Пример #42
0
    def __init__(self, parent, scrollbar, list_model_factory):
        Text.__init__(self, parent, yscrollcommand=scrollbar.set)

        self._list_model_factory = list_model_factory
        self._list_model = list_model_factory.get_list_model()
        self._list_model.add_listener(self._list_items_changed)
Пример #43
0
 def __init__(self, parent):
     Text.__init__(self, parent)
     self.parent = parent