Thanks for the existence of this group where we can find help, that’s nice and great!
I’m trying to configure a StyledTextCtrl (from the wx.stc) and I can’t manage to control the width of the element on the left where lines numbers are displayed. I’ve tried many things, looked for help on Google, but nothing I did gave me the answer…
Here a screenshot:
As you can see, the space for numbers is too narrow, and when there’s many line in the control numbers are hidden on the left behind the border…
I also attach my entire file for you to see the code in context! And by the way, while you may read and inspect my script, I need help for another problem: despite what I wrote in my code the indentation guides don’t appear… Can you tell me how to fix that?
Your help we’ll be greatly appreciated as I’m struggling since yesterday with these problems… Big thanks in advance!
if your post runnable samples you will get tested suggestions.
HTH
Niki
···
On 13.07.2016 13:02, stephane catalanotto wrote:
*Hi everyone!*
Thanks for the existence of this group where we can find help, that's
nice and great!
I'm trying to configure a StyledTextCtrl (from the wx.stc) and I can't
manage to control the width of the element on the left where lines
numbers are displayed. I've tried many things, looked for help on
Google, but nothing I did gave me the answer...
I am also trying to update it in a dynamic way something like catching text changed event and binding to a function to set line number margin with again.
But if you want to make it wider and not change it again you can try changing the line in your code runnable_sample.py below
from
self.SetMarginWidth(2, 12)
to
self.SetMarginWidth(1, 50)
and if you make it
self.SetMarginWidth(1, 100) you will get a wider line number area
<details class='elided'>
<summary title='Show trimmed content'>···</summary>
On Thursday, July 14, 2016 at 5:01:33 PM UTC+1, stephane catalanotto wrote:
>
> Le jeudi 14 juillet 2016 09:33:59 UTC+2, niki a écrit :
> > try (untested):
> >
> >
> >
> > self.SetMarginWidth(1, 25)
> >
> >
> >
> > if your post runnable samples you will get tested suggestions.
> >
> >
> >
> > HTH
> >
> >
> >
> > Niki
> >
>
>
> Hi Niki, thanks for the reply! :)
>
> I've tried what you propose, but it doesn't change a thing...
>
> Iattach a runnable sample as you have suggested to me!
>
> I've forgot to mention that I use wxPython 3 (with Python 2.7).
>
> Thanks again!!
</details>
I’m gonna try what you suggested to me, it sounds good!
I’ll try and I’ll be back to tell how it works for me. But I’ll do it later, because for the moment I don’t have really the motivation to do coding; let me explain: I’m french and as you may have heard it, we have been hit by another attack. It happened during national day, july the 14th, in city of Nice (southern France, near where I live). My mind and my heart are not totally at coding for the moment, I need 3 or 4 days to wail…
self.SetMarginWidth(1, 50) # set the width for line number
self.SetMarginWidth(2, 12) # set the width for folding control
``
In fact I didn’t realised that the 1st param of SetMarginWidth designates the column concerned by the 2nd param… First one is the line numbers column, and the second is for the folding controls.
Now everything works the way it has to…
As Emre raised the question of dynamic width, I will probably modify the code so that the line numbers adapts itself according to number of lines, indeed there’s no need to have a width of 50px when there’s only a few lines.
Long live wxPython, and long live WxPython users! (yes I’m happy, some may say it doesn’t take much to make me happy…).