However, the output on TextCtrl is not left aligned in columns. it is
as follows.
[system] -> standard sys
[back] -> xxxx xxxxxx
[utilities] -> commands
[arbi] -> yyy
[code] -> code
I thought I should get the exactly the same output format. So what is
happening? what should I do to make the output aligned in columns?
On Mon, Feb 7, 2011 at 8:12 AM, pploo <beilushao@gmail.com> wrote:
I thought I should get the exactly the same output format. So what is
happening? what should I do to make the output aligned in columns?
Your terminal is using a fixed width font. The default font used by
most gui components (including the TextCtrl) is a proportional font
(meaning each character is a different width). Try changing the
TextCtrl's Font to a fixed width one like Courier New and it should
line up the same as in the terminal.
hi, Cody, thank you for your answer. But where can I change this for
the TextCtrl?
Can you share more details or some examples? Thanks in advance.
···
On Feb 7, 3:37 pm, Cody Precord <codyprec...@gmail.com> wrote:
Hi,
On Mon, Feb 7, 2011 at 8:12 AM, pploo <beilus...@gmail.com> wrote:
> I thought I should get the exactly the same output format. So what is
> happening? what should I do to make the output aligned in columns?
Your terminal is using a fixed width font. The default font used by
most gui components (including the TextCtrl) is a proportional font
(meaning each character is a different width). Try changing the
TextCtrl's Font to a fixed width one like Courier New and it should
line up the same as in the terminal.
Thank you Cody. It works.
I tried with the following code.
font1 = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL, False, u'Courier
New')
self.textctrl.SetFont(font1)
But the font style (I use as your case Courier New) is different from
the print on the bash.
How can I get to know what font the application uses, or preferrably
how can I set the font as fixed width without changing the size and
style?
Thanks a lot!
···
On Feb 7, 3:52 pm, Cody Precord <codyprec...@gmail.com> wrote:
Hi,
On Mon, Feb 7, 2011 at 8:47 AM, pploo <beilus...@gmail.com> wrote:
> hi, Cody, thank you for your answer. But where can I change this for
> the TextCtrl?
> Can you share more details or some examples? Thanks in advance.
The wxPython demo and google have plenty of examples.
Thank you Cody. It works.
I tried with the following code.
font1 = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL, False, u'Courier
New')
self.textctrl.SetFont(font1)
But the font style (I use as your case Courier New) is different from
the print on the bash.
How can I get to know what font the application uses, or preferrably
how can I set the font as fixed width without changing the size and
style?
Sorry, not sure I completely understand what your asking. If you want
to keep the same size you can just do something like this to produce a
fixed width font.
font = self.textctrl.GetFont()
newFont = wx.Font(font.PointSize, wx.FONTFAMILY_MODERN,
wx.FONTSTYLE_NORMAL,
wx.FONTWEIGHT_NORMAL)
self.textctrl.SetFont()
Also see the SystemSettings demo in the wxPython Demo application if
you want to retrieve the default system fixed width font.
It works very well!!
Thanks a lot, Cody, you are my hero!
···
On Feb 7, 4:23 pm, Cody Precord <codyprec...@gmail.com> wrote:
Sorry, not sure I completely understand what your asking. If you want
to keep the same size you can just do something like this to produce a
fixed width font.
font = self.textctrl.GetFont()
newFont = wx.Font(font.PointSize, wx.FONTFAMILY_MODERN,
wx.FONTSTYLE_NORMAL,
wx.FONTWEIGHT_NORMAL)
self.textctrl.SetFont()
wx.FONTFAMILY_TELETYPE would be a better choice. The _MODERN family may or may not be a monospaced font, depending on platform.
···
On 2/7/11 7:23 AM, Cody Precord wrote:
Hi,
On Mon, Feb 7, 2011 at 9:11 AM, pploo<beilushao@gmail.com> wrote:
Thank you Cody. It works.
I tried with the following code.
font1 = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL, False, u'Courier
New')
self.textctrl.SetFont(font1)
But the font style (I use as your case Courier New) is different from
the print on the bash.
How can I get to know what font the application uses, or preferrably
how can I set the font as fixed width without changing the size and
style?
Sorry, not sure I completely understand what your asking. If you want
to keep the same size you can just do something like this to produce a
fixed width font.
font = self.textctrl.GetFont()
newFont = wx.Font(font.PointSize, wx.FONTFAMILY_MODERN,
wx.FONTSTYLE_NORMAL,
wx.FONTWEIGHT_NORMAL)
self.textctrl.SetFont()