PyQT - How to implement Syntax Highlighting? - python

I want to write a little IDE for Cython using PyQT, but I don't have any idea how to implement Syntax Highlighting.
I know how to parse the Python-source, but I don't know how I can set the color for different words within the Textfield in PyQT.
I could use HTML for this, but how does it work in realtime ? I mean when the user edits the text I need to be able to immediately change the text's format, etc.
Do you know how I can achieve this ?

Have you considered using QScintilla?
"As well as features found in standard text editing components, QScintilla includes features especially useful when editing and debugging source code. These include support for syntax styling, error indicators, code completion and call tips."

I would recommend checking out the code in KhtEditor which is written in Python using PyQt. I believe the author is also working on a port from QWidget to QML.

Related

Python GTK3 Basic Text Editor Like MS Office, LibreOffice

I want to create text editor that have coloring feature, Bold,Italic, ... and too many basically Office Program feature for users of my program. but creating this will take too much of my time. so is there a module, package or code for this ?
Thanks.
Gtk3 already has Gtk.TextView and Gtk.TextBuffer which has the requirements you mention (though might be missing some of the more sophisticated ones of a real Office suite). It can also insert images, and do many other tricks. Of course, you have to provide the commands to do steer the widget into executing each of them.
Another possibility is using a web-based editor, and include webkit in your project.

Code hiding and line numbers IDLE

Is there any way to enable code hiding (hides the details of a class or a function just shows the definition) and line numbers in IDLE ?
Don't think so. It was discussed briefly on the mailing lists, but I don't believe anything's come out of it since.
If you're interested in code folding, look into slightly more powerful editors - Geany (GTK) and Sublime Text both support code folding.
A code/line folding feature was asked before in that Python Issue. It was closed and rejected but with good reasons.
If you know this features of IDLE you maybe do not need code folding anymore.
Module Browser:
To get an outline view of a file's classes and functions, use File => Module Browser (ALT+C).
Code Context:
To get a dynamic view of nested compound statement headers with Options => Code Context.

How to adjust delay of suggestion list in Python 3.3.2

In python 3.3.2, how you adjust the time it takes for the suggestion box to appear just after typing a '.'. For example, say I import wxPython and type wx. after 3 seconds a list box would appear showing the available options. Is there any way to set this to appear instantly or in a very short time? Sort of like Visual Studio's intellisense feature which appears instantly.
Thanks in advance :)
I think you are referring to your IDE, the editor you are using to write your code. If this is the case, that would depend on your editor, which one are you using?
If you are using the built-in editor IDLE, then what you are looking to do is not an available option.
If you are trying to do this within your own code using wxPython (as
SexySaxMan suggested), please provide an example of your code so we can get a better idea of what you are trying to do.
I believe what you're looking for is something like time.sleep
http://docs.python.org/2/library/time.html#time.sleep
EDIT: I haven't really used wxPython, but I have used Tkinter and Tkinter.after does exactly what you're asking for. Try looking for a parallel in wxPython.

QScintilla in PySide

I like PySide, and have used it for a while now, but in the program I am working on at the moment, I need an advanced code editor.
I have found QScintilla, but that is for PyQt. Is that compatible with PySide and if so, how would I go about using it?
I have also looked at PySide-QScintilla, but all that is is a couple of .h files and an __init.py__ and the __init__.py doesn't even have anything relating to the .h files! Has anyone used that? How do you include it in a program?
I also saw qutepart but it seems to be mush too basic for what I need.
I would accept solutions other than QScintilla, but they have to have:
Error Highlighting
Syntax Highlighting
Code Suggestion (a drop down menu while typing)
Line Numbers
Custom Colors
Must be at least GPL (LGPL would be nice)
Any other features are great.
Doing a quick Google search brought up the following:
http://gitorious.org/pyside-qscintilla
https://github.com/LuaDist/scintilla/tree/master/qt/ScintillaEditPy
I suspect the first one is a direct port, whereas the second is some kind of Scintilla wrapper instead of a QScintilla port.

How can I get Geany to show me the methods a library has when I press the '.' key?

In visual studio, I could just press ctrl+spacekey and the methods appeared. In Geany is there a way for me to get this functionality?
No, because is Python is dynamically typed language and quite hard to achieve that. Python plugins for netbeans do that partially, but I believe such plugin is not in geany developers plans. There are different things to be done ;-)
However, geany provides some completions support. First, it analyzes your imports in a file and uses it in completions; furthermore it completes functions from the std library. It also analyzes all you open files for suggestions, although you may need to apply it in preferences. Also you can get call tips, when you hit Ctrl+Shift+Space, which not everyone know about. They are quite good, because they appear in form <Class>.<method>(<args>), which is very helpful.
shortcut ctrl+space works for me. also, you can setup autocomplete suggestion length (ie how many letters you must type before the autocomplete tooltip pops up automatically - http://www.geany.org/manual/current/#editor-completions-preferences ).
this works only for method names. if i want to see the options for method parameters, i must type bracket ( after the method full name.

Categories

Resources