generating line numbers in a qt text object

edited August 2015 in Ruby Scripting
What is the best method to generate a Qt text object with line numbers through klayout's ruby scripting?



One example I have found outside of klayout involves creating sub-classes from QPlainTextEdit and QWidget. In this c++ example, the line number area [QWidget] is painted and controlled by events in the text object [QPlainTextEdit]. However, I am not sure how to go about doing something similar through klayout.

Is there another method to use?

Comments

  • edited November -1

    Hi,

    well, you can basically convert the sample into Ruby, but I doubt that you would like to do this. It's a big effort and frankly I have some doubts whether that will be successful in terms of functionality required and performance.

    I had a similar topic for the macro editor. The solution there is to use a separate panel next to the text widget which shows the line numbers and synchronize both by means of signals. You'll find the sources for the side panel widget in layMacroEditorPage.cc. The class of the side panel widget is MacroEditorSidePanel.

    Another option is not to show line numbers in the text edit widget but to show the current line in a label below or beside the edit widget. That's fairly simple to implement with signals/events and serves the purpose of showing the current location.

    Matthias

  • edited November -1
    I managed to translate and use the same methodology that was used in the C++ and similar python code and it worked. thanks!
  • edited November -1

    jnopaja,

    I'm interested in doing a similar thing. Could you please paste your code?

    Thanks,

    David

Sign In or Register to comment.