I’m having trouble getting text to align anywhere other than to the left. Just to make sure I wasn’t doing something stupid, I pulled down the following small test program. Unfortunately this one doesn’t work for me either.
In the following test program two static text controls should show text, one line aligned left and the other right. Both come out left aligned for me. Also, while the white text shows as white, its background is not black, but stays the same gray as the rest of the background.
On Sat, Dec 12, 2009 at 5:28 PM, Thomas M Wetherbee tom@wetherbees.com wrote:
I’m having trouble getting text to align anywhere other than to the left. Just to make sure I wasn’t doing something stupid, I pulled down the following small test program. Unfortunately this one doesn’t work for me either.
In the following test program two static text controls should show text, one line aligned left and the other right. Both come out left aligned for me. Also, while the white text shows as white, its background is not black, but stays the same gray as the rest of the background.
This code works for me on Windows XP, python 2.5, wxPython 2.8.10.1 (unicode). I’ve attached a screenshot. You may need to upgrade your wxPython or Linux just works differently.
This happens on Ubuntu 9.10 as well
Python: 2.6.4 (r264:75706, Nov 2 2009, 14:38:03)
[GCC 4.4.1]
wxPython Version: 2.8.10.1
Platform: Linux-2.6.31-14-generic-i686-with-debian-squeeze-sid
···
On Sat, Dec 12, 2009 at 4:28 PM, Thomas M Wetherbee <tom@wetherbees.com> wrote:
In the following test program two static text controls should show text, one
line aligned left and the other right. Both come out left aligned for me.
Also, while the white text shows as white, its background is *not* black,
but stays the same gray as the rest of the background.
Thanks for the feedback. I hadn’t intended to run this as an older version of wx.python, but my system defaults got me. I tried it again with version 2.8.10.1-1 (unicode) and it still fails to format properly. This is true with both Compiz and Metacity. It looks like the Linux version of wx has a bug in this area, which was also confirmed by another user for Ubuntu 9.10 as well. Do I need to file some sort of official bug report, or does this mailing list take care of it?
The whole wx version issue brings up a few additional questions. I should know the answers to these, since I have been using wx for awhile, but I don’t. Searching the Internet helped a bit, but mostly left me with more questions. Keep in mind that these questions are for a Ubuntu installation of Python and wxPython:
How do you display the current version of wx? I assume there is some sort of wx.version(), but I don’t know what it is.
My sys.path shows two versions of wx.python (/usr/lib/python2.6/dist-packages/wx-2.6-gtk2-unicode and /usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode). I assume these get added by one or more *.pth files. Sorting through the tangled *.pth files doesn’t look like much fun. Is there an easy way to see how and where directories are added to sys.path?
The following lines are the content of /var/lib/dpkg/alternatives/wx2.6.pth. What do these do?
auto
/usr/lib/python2.6/dist-packages/wx.pth
/usr/lib/wx/python/wx2.6.pth
26
/usr/lib/wx/python/wx2.8.pth
28
Likewise, what is going on with /usr/local/lib/python2.6/dist-packages/easy-install.pth:
import sys; sys.__plen = len(sys.path)
./pyserial-2.4-py2.6.egg
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,‘__egginsert’,0); sys.path[p:p]=new; sys.__egginsert = p+len(new)
I assume all this is explained somewhere in a wiki, but I haven’t been able to find it. Any help is greatly appreciated.
Thanks,
Tom
···
On Sat, 2009-12-12 at 18:49 -0600, Mike Driscoll wrote:
Hi,
On Sat, Dec 12, 2009 at 5:28 PM, Thomas M Wetherbee tom@wetherbees.com wrote:
I’m having trouble getting text to align anywhere other than to the left. Just to make sure I wasn’t doing something stupid, I pulled down the following small test program. Unfortunately this one doesn’t work for me either.
In the following test program two static text controls should show text, one line aligned left and the other right. Both come out left aligned for me. Also, while the white text shows as white, its background is *not* black, but stays the same gray as the rest of the background.
Configuration:
Ubuntu Linux 9.04
Python 2.6.2
wxPythonon 2.6.3.2
BoaConstructor 0.6.1
Thanks,
Tom
Code: ************************************************
#!/usr/bin/env python
#Boa:PyApp:main
import wx
modules ={}
class StaticTextFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, 'Static Text Example', size=(400, 300))
panel = wx.Panel(self, -1)
wx.StaticText(panel, -1, "This is an example of static text", (100, 10))
right = wx.StaticText(panel, -1, "align right", (100, 70), (160, -1), wx.ALIGN_RIGHT)
right.SetForegroundColour('white')
right.SetBackgroundColour('black')
app = wx.PySimpleApp()
frame = StaticTextFrame()
frame.Show()
app.MainLoop()
–
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit [http://groups.google.com/group/wxPython-users?hl=en](http://groups.google.com/group/wxPython-users?hl=en)
This code works for me on Windows XP, python 2.5, wxPython 2.8.10.1 (unicode). I've attached a screenshot. You may need to upgrade your wxPython or Linux just works differently.
-------------------
Mike Driscoll
Blog: [http://blog.pythonlibrary.org](http://blog.pythonlibrary.org)
--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit [http://groups.google.com/group/wxPython-users?hl=en](http://groups.google.com/group/wxPython-users?hl=en)
Thanks for the feedback. I hadn’t intended to run this as an older version of wx.python, but my system defaults got me. I tried it again with version 2.8.10.1-1 (unicode) and it still fails to format properly. This is true with both Compiz and Metacity. It looks like the Linux version of wx has a bug in this area, which was also confirmed by another user for Ubuntu 9.10 as well. Do I need to file some sort of official bug report, or does this mailing list take care of it?
The whole wx version issue brings up a few additional questions. I should know the answers to these, since I have been using wx for awhile, but I don’t. Searching the Internet helped a bit, but mostly left me with more questions. Keep in mind that these questions are for a Ubuntu installation of Python and wxPython:
How do you display the current version of wx? I assume there is some sort of wx.version(), but I don’t know what it is.
You are correct. Import wx in the python shell, then type wx.version() and it will print whatever is set as the default.
My sys.path shows two versions of wx.python (/usr/lib/python2.6/dist-packages/wx-2.6-gtk2-unicode and /usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode). I assume these get added by one or more *.pth files. Sorting through the tangled *.pth files doesn’t look like much fun. Is there an easy way to see how and where directories are added to sys.path?
Thanks for the feedback. I hadn’t intended to run this as an older version of wx.python, but my system defaults got me. I tried it again with version 2.8.10.1-1 (unicode) and it still fails to format properly. This is true with both Compiz and Metacity. It looks like the Linux version of wx has a bug in this area, which was also confirmed by another user for Ubuntu 9.10 as well. Do I need to file some sort of official bug report, or does this mailing list take care of it?
The whole wx version issue brings up a few additional questions. I *should* know the answers to these, since I have been using wx for awhile, but I don't. Searching the Internet helped a bit, but mostly left me with more questions. Keep in mind that these questions are for a Ubuntu installation of Python and wxPython:
1) How do you display the current version of wx? I assume there is some sort of wx.version(), but I don't know what it is.
You are correct. Import wx in the python shell, then type wx.version() and it will print whatever is set as the default.
2) My sys.path shows two versions of wx.python (/usr/lib/python2.6/dist-packages/wx-2.6-gtk2-unicode and /usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode). I assume these get added by one or more *.pth files. Sorting through the tangled *.pth files doesn't look like much fun. Is there an easy way to see how and where directories are added to sys.path?
The wiki tells all about this subject: [http://wiki.wxpython.org/MultiVersionInstalls](http://wiki.wxpython.org/MultiVersionInstalls)
3) The following lines are the content of /var/lib/dpkg/alternatives/wx2.6.pth. What do these do?
auto
/usr/lib/python2.6/dist-packages/wx.pth
/usr/lib/wx/python/wx2.6.pth
26
/usr/lib/wx/python/wx2.8.pth
28
4) Likewise, what is going on with /usr/local/lib/python2.6/dist-packages/easy-install.pth:
import sys; sys.__plen = len(sys.path)
./pyserial-2.4-py2.6.egg
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)
I assume all this is explained somewhere in a wiki, but I haven't been able to find it. Any help is greatly appreciated.
Thanks,
Tom
I'll let someone else tell you about the answers to those other two since I don't know.
Mike Driscoll
Blog: [http://blog.pythonlibrary.org](http://blog.pythonlibrary.org)
--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit [http://groups.google.com/group/wxPython-users?hl=en](http://groups.google.com/group/wxPython-users?hl=en)
Thanks for the feedback. I hadn't intended to run this as an older
version of wx.python, but my system defaults got me. I tried it again
with version 2.8.10.1-1 (unicode) and it still fails to format properly.
This is true with both Compiz and Metacity. It looks like the Linux
version of wx has a bug in this area, which was also confirmed by
another user for Ubuntu 9.10 as well. Do I need to file some sort of
official bug report, or does this mailing list take care of it?
Since the problem happens both with an old version of wx and a newer one, then I'm guessing that something has changed with GTK and that wx needs to be updated to deal with it. Please create a bug ticket at trac.wxwidgets.org and set it to the wxGTK component.
In the meantime, there is a generic static text class in the wx.lib.stattext module that can be used instead.
1) How do you display the current version of wx? I assume there is some sort of wx.version(), but I don't know what it is.
In addition to wx.version() there is also wx.VERSION, wx.VERSION_STR and wx.__version__.
3) The following lines are the content of
/var/lib/dpkg/alternatives/wx2.6.pth. What do these do?
auto
/usr/lib/python2.6/dist-packages/wx.pth
/usr/lib/wx/python/wx2.6.pth
26
/usr/lib/wx/python/wx2.8.pth
28
The wx.pth file is setup on debian/ubuntu systems such that the standard update-alternatives tool can be used to switch the defaults. I don't remember the magic incantation off the top of my head, but it should be in the archives of this list.
4) Likewise, what is going on with
/usr/local/lib/python2.6/dist-packages/easy-install.pth:
This file is maintained by the easy_install tool from the setuptools package, and is how the contents of python eggs are added to the sys.path.
On Sun, 2009-12-13 at 16:33 -0700, Dj Gilcrease wrote:
On Sun, Dec 13, 2009 at 3:41 PM, Thomas M Wetherbee > <wxpython-users@wetherbees.com > > > wrote:
> Perhaps, but here is what happens when I try to get the version:
>
>>>> import wx
>>>> wx.version()
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> AttributeError: 'module' object has no attribute 'version'
>>>>
import wx
print wx.__version__
The StaticText alignment issue for GTK is a known bug. It appears to be a regression. I haven’t tried this, but supposedly it works okay if any of the Ellipses flags are set.
I was being stupid in my use of the StaticText widget and didn’t really need or want alignment. By default, the widget changes its size to exactly fit the contained text when SetLabel(‘text’) is called, which means that there is no need for alignment. I had foolishly set a size, which overrode the automatic sizing.
I hope this helps someone else.
Tom
···
On Sun, 2009-12-13 at 16:36 -0800, Robin Dunn wrote:
On 12/13/09 9:19 AM, Thomas M Wetherbee wrote:
> Thanks for the feedback. I hadn't intended to run this as an older
> version of wx.python, but my system defaults got me. I tried it again
> with version 2.8.10.1-1 (unicode) and it still fails to format properly.
> This is true with both Compiz and Metacity. It looks like the Linux
> version of wx has a bug in this area, which was also confirmed by
> another user for Ubuntu 9.10 as well. Do I need to file some sort of
> official bug report, or does this mailing list take care of it?
Since the problem happens both with an old version of wx and a newer one, then I'm guessing that something has changed with GTK and that wx needs to be updated to deal with it. Please create a bug ticket at trac.wxwidgets.org and set it to the wxGTK component.
In the meantime, there is a generic static text class in the wx.lib.stattext module that can be used instead.
> 1) How do you display the current version of wx? I assume there is some sort of wx.version(), but I don't know what it is.
>
In addition to wx.version() there is also wx.VERSION, wx.VERSION_STR and wx.__version__.
> 3) The following lines are the content of
> /var/lib/dpkg/alternatives/wx2.6.pth. What do these do?
>
> auto
> /usr/lib/python2.6/dist-packages/wx.pth
> /usr/lib/wx/python/wx2.6.pth
> 26
> /usr/lib/wx/python/wx2.8.pth
> 28
>
The wx.pth file is setup on debian/ubuntu systems such that the standard update-alternatives tool can be used to switch the defaults. I don't remember the magic incantation off the top of my head, but it should be in the archives of this list.
> 4) Likewise, what is going on with
> /usr/local/lib/python2.6/dist-packages/easy-install.pth:
>
This file is maintained by the easy_install tool from the setuptools package, and is how the contents of python eggs are added to the sys.path.
-- Robin Dunn
Software Craftsman
[http://wxPython.org](http://wxPython.org)