Do not repeat, as Brian Oakley has already answered this, but yes. And he is right. The text widget is extremely powerful. I have never seen another text widget that matches its breadth of possibilities.
Tkinter is the most convenient GUI library I've ever found to create a text editor. In fact, I have been doing this, myself, for a while. Are you interested in making one or looking for one already made with Tkinter?
For me, syntax highlighting and auto-completion are not the most important functions of a text editor. I like quick / easy access to files / projects, launching / compiling / launching programs, Unicode or special character input, color widget layouts, navigation key bindings, tabs and having all the shortcuts for various wild tools that I like make my life easier (and more fun). So, I'm actually starting to highlight the syntax now (after I have already done most of the other things). But yes, syntax highlighting can be done in Tkinter.
Indeed, many of the functions that a text editor may require do not even require much for the GUI library. For example, to find out which file you are editing, you can run the file using the correct program (or compile it using the correct compiler). It really has little to do with Tkinter.
Let me know if you want to chat in real time with text editors.
The IDE that ships with Python, IDLE, is also written using Tkinter. Looking at the source code is sometimes useful, but they tend to do things differently than I personally recommend, although I'm sure some people like it more than I like.
There are several flaws of Tkinter, but they are better than the flaws that I saw with other GUI libraries for my purposes. Some things require more work, but most also seem to offer more flexibility. Some things require less work. Impressively, Tkinter does not seem to have many errors, and most of them that exist can be programmed. This is pretty cool. Sometimes he gets a bad rap for not having native widgets, and not for making fonts in a certain way, but not listening to people. Widgets are in order, regardless of whether they are native, and the fonts look great. If ever there was a problem with fonts, I think they fixed it. Tell me if I'm wrong. Mine looks great (exactly the same as in LibreOffice, if not better). In addition, you should not forget about the privileges of Tkinter. Tkinter is awesome.
The python help () method will be your friend. Use it on classes and modules.
One of the best things about Tkinter is that it is mostly Python. Thus, unlike WxPython (which is not even on 3.x, although they do something for it with a different name), Tkinter will most likely be automatically supported for all future releases of Python (as long as / if they replace it with something else - and I donβt know what they will do if they do not find something absolutely amazing). Also, this is not a huge load.
In any case, to get started, you'll want to learn about methods (especially built-in ones) and tags. Most likely, you will use them for many things. They are important for accessing specific areas of text in your widget and for them.
INSERT is a string, 'insert' . But this is also a sign. Signs are variable indices for position marking. The 'insert' icon represents the index in your text widget where your text insert is. The beginning of your document is the index "1.0" not "0.0" . 1 - line 1. 0 - character 0. I do not believe that there is a mark for a start. You just use the index. The end sign is END (this is a string, 'end' ). "sel.first" and "sel.last" represent the indices at the beginning and end of the selected text. SEL (or 'sel' ) - this tag. Tags are similar to HTML tags in which they mark the beginning and end of things (and all the text between them). You can create your own tags to add text styles (for example, bold or italics or just highlighting, which can be useful for syntax highlighting). You can check the range of text to see if it has a specific tag. For instance,
SEL in self.myTextWidget.tag_names(INSERT)
Will return True if the character is selected immediately after (that is, in) text insertion.
For labels, you can use convenient notation to get convenient index locations. For example, "insert wordstart" will provide you with an index for the beginning of any word that has the label 'insert' . "insert+2c" will give you the position of the two characters after the insert. In any case, there are a lot of things.
If you are creating a cross-platform application, you need to know that some events are different on different platforms. So check and make sure that they all work.
You will also want to understand that although some standard keyboard shortcuts in a text widget do not work (for example, Control-a does not select everything), there are actually shortcuts. These are just different shortcuts. However, you can override them and make your own quite easily:
β¦