Giter Site home page Giter Site logo

lqttexteditor's Introduction

lqtTextEditor

More advanced text editor in PyQt.

demo-stylesheet.gif

Compatibility

  • Qt.py Is being used to handle compatibility between different Qt versions.
  • code can be ported to python2 if necessary, there is only type hints and super calls to change.

LinePlainTextEdit

Works well for code editing. Features :

  • line numbering in sidebar
    • range selection of lines from the sidebar
  • indentation and unindentation with custom characters
  • line hiding/showing/isolating
  • "Jump to Line" dialog on Ctrl+G
  • no big performance difference with regular QPlainTextEdit widget.
    • triggering repaint more often
    • performance hit when you have a lot of line hided at the end of the document and you scroll to the bottom
  • advanced styling with stylesheets (see below)

Note : Line numbers are visually expressed starting from 1, but starts from 0 in the code.

demo gif of using the LinenumberedTextEditor

See test_linePlainTextEdit.py for an example.

Usage

import lqtTextEditor

editor = lqtTextEditor.LinePlainTextEdit()
editor.setPlainText("Hello world !")

Here is some options you can configure

import lqtTextEditor

editor = lqtTextEditor.LinePlainTextEdit()
editor.setPlainText("Hello world !")
editor.set_tab_character("\t")
# lead to visual issue on the default Qt style when enabled
editor.set_alternating_row_colors(True)
# space between text and sidebar
editor.set_left_margin(15)

Styling

With stylesheet :

/*dark pastel theme*/
QWidget.LineSideBarWidget{
  font-family: monospace;
  color: rgb(150,150,150);
  background-color: rgb(55,55,58);
  border-right: 1px solid rgb(60,60,60);
}
/* it's possible to style each line "box" with the ::item selector */
QWidget.LineSideBarWidget::item{
    border-bottom: 1px solid rgb(60,60,60);
}
/* :hover works too */
QWidget.LineSideBarWidget::item:hover{
    background-color: rgb(65,65,70);
}
/* and also :                         */
/* ::item:first (of visible lines)    */
/* ::item:last  (of visible lines)    */
/* ::item:pressed                     */
/* ::item:selected                    */

/* works the same for the QPlainTextEdit */
QWidget.LinePlainTextEdit{
  font-family: monospace;
  color: rgb(200,200,200);
  background-color: rgb(50,50,55);
}
/*where item is the line box*/
QWidget.LinePlainTextEdit::item{
  border-bottom: 1px solid rgb(60, 60, 65);
}
/* and also :                         */
/* ::item:hover                       */
/* ::item:first (of visible lines)    */
/* ::item:last  (of visible lines)    */
/* ::item:pressed                     */
/* ::item:selected                    */
/* ::item:alternate                   */

You can find a full example in theme.dark-test.qss, loaded in test_stylesheet.py

demo-stylesheet.gif

lqttexteditor's People

Contributors

mrlixm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.