StaticText alignment doesn't work ?

I have the following dialog :

{{{
Dialog
  Horizontal box sizer
    ListBox
    ScrollPane
      Vertical box sizer
        (
        StaticText
        TextCtlr
        StaticText <=== the target
        ) ...
      Ok & Cancel buttons ;o)
}}}

I want to display some messages in highlighted static texts , but I
need them to be right aligned . How could I ? I have tried a lot of
things e.g.

  - style=wx.RIGHT_ALIGN in initializer
  - style=wx.RIGHT_ALIGN in initializer & flag=wx.EXPAND in sizer
  - flag=wx.RIGHT_ALIGN in sizer
  - ...

but it doesn't work . I imagine it's a typo or something trivial but I
cannot find it !

Q:
  - Is it possible ?
  - How could I ?

Thnx in advance !

PS: BTW, I've also noticed that GTK implementation of ScrolledPane
seems to be buggy . Items in there do not refresh on scrolling the
client area.

Q:

  - Does anyone experiences similar behaviors in '2.8.7.1 (gtk2-unicode)'
    running in Ubuntu Hardy ? Perhaps this has been enhanced in newer
    versions and I just need to upgrade to latest . In that case ...
  - Where can I find (is ti possible) fresh DEB pkgs for latest version to be
    installed in Ubuntu Hardy ?

···

--
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Can I call a wiki-macro from another wiki-macro? | Trac | Users -
http://feedproxy.google.com/~r/TracGViz-full/~3/yiEwraF_UYc/44146

Olemis Lang wrote:

I have the following dialog :

{{{
Dialog
  Horizontal box sizer
    ListBox
    ScrollPane
      Vertical box sizer
        (
        StaticText
        TextCtlr
        StaticText <=== the target
        ) ...
      Ok & Cancel buttons ;o)
}}}

I want to display some messages in highlighted static texts , but I
need them to be right aligned . How could I ? I have tried a lot of
things e.g.

  - flag=wx.RIGHT_ALIGN in sizer

That should work.

but it doesn't work . I imagine it's a typo or something trivial but I
cannot find it !

neither can we if you don't post your code!

http://wiki.wxpython.org/MakingSampleApps

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

http://simelo.pastebin.com/m30fc98e9

···

On Mon, Dec 7, 2009 at 1:40 PM, Christopher Barker <Chris.Barker@noaa.gov> wrote:

Olemis Lang wrote:

I have the following dialog :

{{{
Dialog
Horizontal box sizer
ListBox
ScrollPane
Vertical box sizer
(
StaticText
TextCtlr
StaticText <=== the target
) ...
Ok & Cancel buttons ;o)
}}}

I want to display some messages in highlighted static texts , but I
need them to be right aligned . How could I ? I have tried a lot of
things e.g.

- flag=wx.RIGHT_ALIGN in sizer

That should work.

but it doesn't work . I imagine it's a typo or something trivial but I
cannot find it !

neither can we if you don't post your code!

--
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Can I call a wiki-macro from another wiki-macro? | Trac | Users -
http://feedproxy.google.com/~r/TracGViz-full/~3/yiEwraF_UYc/44146

Olemis Lang wrote:

neither can we if you don't post your code!

http://simelo.pastebin.com/m30fc98e9

Please read this page:

http://wiki.wxpython.org/MakingSampleApps

if it's trimmed down, and ready to run -- I can test it easily.

-CHB

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

I am also experiencing the same problem
Running ubuntu 9.10 and wxpython 2.8.10.1
also tried on ubuntu 8.10 and wx python 2.8.9.2

Code sample:
"""
import wx

class MyFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None)

        panel = wx.Panel(self)
        panel.SetBackgroundColour(wx.Colour(32,144,0))

        ctrl2 = wx.StaticText(panel, label="One", pos = wx.Point(0,0),
size=wx.Size(200, 200), style=wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE)

if __name__ == "__main__":
    app = wx.App()
    frame = MyFrame().Show()
    app.MainLoop()
"""

Alex Couper

···

On Dec 7, 7:39 pm, Christopher Barker <Chris.Bar...@noaa.gov> wrote:

Olemis Lang wrote:
>> neither can we if you don't post your code!
>http://simelo.pastebin.com/m30fc98e9

Please read this page:

MakingSampleApps - wxPyWiki

if it's trimmed down, and ready to run -- I can test it easily.

-CHB

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Bar...@noaa.gov

Olemis Lang wrote:

neither can we if you don't post your code!

http://simelo.pastebin.com/m30fc98e9

Please read this page:

MakingSampleApps - wxPyWiki

if it's trimmed down, and ready to run -- I can test it easily.

If I run this one then labels are not displayed

http://simelo.pastebin.com/m49c05392

If I run this one then it's aligned to the left

http://simelo.pastebin.com/m11c80f43

{{{

wx.version()

'2.8.7.1 (gtk2-unicode)'
}}}

Thnx !

···

On Mon, Dec 7, 2009 at 2:39 PM, Christopher Barker <Chris.Barker@noaa.gov> wrote:

--
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Can I call a wiki-macro from another wiki-macro? | Trac | Users -
http://feedproxy.google.com/~r/TracGViz-full/~3/yiEwraF_UYc/44146

If I use Fit() nothing is shown either
:-/

PS: /me not sending attachments . Hope you don't mind .

···

On Mon, Dec 7, 2009 at 3:30 PM, Olemis Lang <olemis@gmail.com> wrote:

On Mon, Dec 7, 2009 at 2:39 PM, Christopher Barker > <Chris.Barker@noaa.gov> wrote:

Olemis Lang wrote:

neither can we if you don't post your code!

http://simelo.pastebin.com/m30fc98e9

Please read this page:

MakingSampleApps - wxPyWiki

if it's trimmed down, and ready to run -- I can test it easily.

If I run this one then labels are not displayed

http://simelo.pastebin.com/m49c05392

--
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Can I call a wiki-macro from another wiki-macro? | Trac | Users -
http://feedproxy.google.com/~r/TracGViz-full/~3/yiEwraF_UYc/44146

Olemis Lang wrote:

If I run this one then labels are not displayed

http://simelo.pastebin.com/m49c05392

If I run this one then it's aligned to the left

http://simelo.pastebin.com/m11c80f43

{{{
>>> wx.version()
'2.8.7.1 (gtk2-unicode)'
}}}

Same behavior in Windows XP

{{{

wx.version()

'2.8.10.1 (msw-ansi)'
}}}

···

On Mon, Dec 7, 2009 at 3:30 PM, Olemis Lang <olemis@gmail.com> wrote:

On Mon, Dec 7, 2009 at 2:39 PM, Christopher Barker > <Chris.Barker@noaa.gov> wrote:

Thnx !

--
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Can I call a wiki-macro from another wiki-macro? | Trac | Users -
http://feedproxy.google.com/~r/TracGViz-full/~3/yiEwraF_UYc/44146

Al C wrote:

I am also experiencing the same problem
Running ubuntu 9.10 and wxpython 2.8.10.1
also tried on ubuntu 8.10 and wx python 2.8.9.2

Code sample:

Thanks -- that's a good example -- nice and small, and ready to run.

I added a line to change the background color of the statit text (which may not work on all platforms) but you'll see that (on OS-X at least), the text is right aligned, but the staticText control is left aligned in the 200x200 size control.

You really need sizers to lay this out...

import wx

class MyFrame(wx.Frame):
     def __init__(self):
         wx.Frame.__init__(self, None)

         panel = wx.Panel(self)
         panel.SetBackgroundColour(wx.Colour(32,144,0))

         self.ctrl2 = wx.StaticText(panel,
                               label="One",
                               pos = wx.Point(0,0),
                               size=wx.Size(200, 200),
                               style=wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE)
         self.ctrl2.SetBackgroundColour('White')

if __name__ == "__main__":
     app = wx.App(False)
     frame = MyFrame()
     frame.Show()
     print "size of StaticText:", frame.ctrl2.Size
     app.MainLoop()

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

And here's one aligned with a sizer:

import wx

class MyPanel(wx.Panel):
     def __init__(self, parent):
         wx.Panel.__init__(self, parent)

         self.SetBackgroundColour(wx.Colour(32,144,0))

         S = wx.BoxSizer(wx.VERTICAL)
         S.Add((200,10)) # a spacer to make sure it's big enough to see what's going on

         S.Add(wx.StaticText(self, label="left"), 0, wx.ALIGN_LEFT)
         S.Add(wx.StaticText(self, label="right"), 0, wx.ALIGN_RIGHT)

         self.SetSizerAndFit(S)

class MyFrame(wx.Frame):
     def __init__(self):
         wx.Frame.__init__(self, None)

         panel = MyPanel(self)

if __name__ == "__main__":
     app = wx.App(False)
     frame = MyFrame()
     frame.Fit()
     frame.Show()
     app.MainLoop()

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

one more note!

http://wiki.wxpython.org/Widget%20Inspection%20Tool

can help diagnose these kinds of things.

-CHB

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Al C wrote:

I am also experiencing the same problem
Running ubuntu 9.10 and wxpython 2.8.10.1
also tried on ubuntu 8.10 and wx python 2.8.9.2

Code sample:

Thanks -- that's a good example -- nice and small, and ready to run.

Seems someone has to learn
:stuck_out_tongue:
However ...

I added a line to change the background color of the statit text (which
may not work on all platforms) but you'll see that (on OS-X at least),
the text is right aligned, but the staticText control is left aligned in
the 200x200 size control.

You really need sizers to lay this out...

... there are sizers in the example I mentioned before (the last two
examples) , and only the barely minimal widgets that resemble my
scenario (since I don't know whether that is a bug with sizers,
scrollable panels, or ... ) They are :

  - A dialog
  - A panel containing Ok, Cancel buttons and ...
  - Show button because if I render the labels since the beginning it does work
    but that's not what I wanna do ;o)
  - Scrollable panel containing widgets
  - Box sizers
  - And three tiny poor little widgets

I've removed a lot of things (validators, further widgets, ...) AFAICS
there's nothing simpler than that in order to reproduce the issue ...
This been said I will be looking forward for your comments

Thnx in advance !

···

On Mon, Dec 7, 2009 at 3:57 PM, Christopher Barker <Chris.Barker@noaa.gov> wrote:

--
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Can I call a wiki-macro from another wiki-macro? | Trac | Users -
http://feedproxy.google.com/~r/TracGViz-full/~3/yiEwraF_UYc/44146

Thnx ! Let me see where are the hidden bugs
;o)

···

On Mon, Dec 7, 2009 at 4:05 PM, Christopher Barker <Chris.Barker@noaa.gov> wrote:

one more note!

http://wiki.wxpython.org/Widget%20Inspection%20Tool

can help diagnose these kinds of things.

--
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Can I call a wiki-macro from another wiki-macro? | Trac | Users -
http://feedproxy.google.com/~r/TracGViz-full/~3/yiEwraF_UYc/44146

[...]

At first sight that seems to be similar to the original issue I posted
but IMO it doesn't seem so. As I mentioned before, if I supply the
text since the beginning then *IT WORKS*.

However if I set the label afterwards (e.g. after clicking on a
button) then it doesn't work as expected (shows nothing or left
aligned ;o).

See nothing similar in your example ... CMIIW anyway

Thnx !

···

On Mon, Dec 7, 2009 at 4:04 PM, Christopher Barker <Chris.Barker@noaa.gov> wrote:

And here's one aligned with a sizer:

--
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Can I call a wiki-macro from another wiki-macro? | Trac | Users -
http://feedproxy.google.com/~r/TracGViz-full/~3/yiEwraF_UYc/44146

Hi,

... there are sizers in the example I mentioned before (the last two
examples) , and only the barely minimal widgets that resemble my
scenario (since I don't know whether that is a bug with sizers,
scrollable panels, or ... ) They are :

- A dialog
- A panel containing Ok, Cancel buttons and ...
- Show button because if I render the labels since the beginning it does work
but that's not what I wanna do ;o)
- Scrollable panel containing widgets
- Box sizers
- And three tiny poor little widgets

I've removed a lot of things (validators, further widgets, ...) AFAICS
there's nothing simpler than that in order to reproduce the issue ...
This been said I will be looking forward for your comments

Your using a GridBagSizer which creates flexable 'cells' that objects
are placed in. The objects however are still layed out in a grid
(columns/rows). For the layout your trying to achieve using some box
sizers will be much simpler.

The labels that you are adding that you want right aligned are
actually right aligned as per the client area they require, if you
want them to be right aligned as per the dialogs space you will need
to insert a strechable spacer to the left of each of them.

I made a few changes to how your layout is done to better show what I mean.

http://simelo.pastebin.com/m22d18644

Cody

···

On Mon, Dec 7, 2009 at 3:12 PM, Olemis Lang <olemis@gmail.com> wrote:

Hi,

... there are sizers in the example I mentioned before (the last two
examples) , and only the barely minimal widgets that resemble my
scenario (since I don't know whether that is a bug with sizers,
scrollable panels, or ... ) They are :

- A dialog
- A panel containing Ok, Cancel buttons and ...
- Show button because if I render the labels since the beginning it does work
but that's not what I wanna do ;o)
- Scrollable panel containing widgets
- Box sizers
- And three tiny poor little widgets

I've removed a lot of things (validators, further widgets, ...) AFAICS
there's nothing simpler than that in order to reproduce the issue ...
This been said I will be looking forward for your comments

Your using a GridBagSizer which creates flexable 'cells' that objects
are placed in. The objects however are still layed out in a grid
(columns/rows).

GridBagSizer contains only the buttons and the scrollable panel . In
the real world example there are more widgets (e.g. listbox, further
buttons, collapsible panels ... ;o) spanning over multiple cells and
so on. That's why I used that sizer in first place. OTOH the text
controls and labels are inside a vertical box sizer [1]_

For the layout your trying to achieve using some box
sizers will be much simpler.

Your approach implies more sizers and more LOCs (just a comment, maybe
not related to the real issue
;o)

The labels that you are adding that you want right aligned are
actually right aligned as per the client area they require, if you
want them to be right aligned as per the dialogs space you will need
to insert a strechable spacer to the left of each of them.

I made a few changes to how your layout is done to better show what I mean.

http://simelo.pastebin.com/m22d18644

Thnx very much ! ... trying ! Let me see

Now it opens , connecting to the internet , user name and password,
downloading ... (just joking :stuck_out_tongue: )

:o)

Seems to work ! What should be the problem then , the use of a grid
bag sizer ? Why ?

···

On Mon, Dec 7, 2009 at 4:33 PM, Cody Precord <codyprecord@gmail.com> wrote:

On Mon, Dec 7, 2009 at 3:12 PM, Olemis Lang <olemis@gmail.com> wrote:

--
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Can I call a wiki-macro from another wiki-macro? | Trac | Users -
http://feedproxy.google.com/~r/TracGViz-full/~3/yiEwraF_UYc/44146

Hi,

The labels that you are adding that you want right aligned are
actually right aligned as per the client area they require, if you
want them to be right aligned as per the dialogs space you will need
to insert a strechable spacer to the left of each of them.

I made a few changes to how your layout is done to better show what I mean.

http://simelo.pastebin.com/m22d18644

[...]

Seems to work ! What should be the problem then , the use of a grid
bag sizer ? Why ?

NO, the spacer . Thnx !

···

On Mon, Dec 7, 2009 at 4:59 PM, Olemis Lang <olemis@gmail.com> wrote:

On Mon, Dec 7, 2009 at 4:33 PM, Cody Precord <codyprecord@gmail.com> wrote:

On Mon, Dec 7, 2009 at 3:12 PM, Olemis Lang <olemis@gmail.com> wrote:

--
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Can I call a wiki-macro from another wiki-macro? | Trac | Users -
http://feedproxy.google.com/~r/TracGViz-full/~3/yiEwraF_UYc/44146

JFYI : solved !

Well , after a deep (psycho)analysis of the code and your suggestions
I realized that my initial impression was right : * I was missing the
obvious * . The only thing that needed to be done [1]_ was to force
the box sizer to re-layout the widgets inside of it (thnx very much
Cody ! ) . Thnx everybody for the pointers

:o)

I knew I had to study the demo in detail. Excellent time to become a
missing person !

:o)

.. [1] Final solution
        (http://simelo.pastebin.com/m4ae230e2)

···

On Mon, Dec 7, 2009 at 5:02 PM, Olemis Lang <olemis@gmail.com> wrote:

On Mon, Dec 7, 2009 at 4:59 PM, Olemis Lang <olemis@gmail.com> wrote:

On Mon, Dec 7, 2009 at 4:33 PM, Cody Precord <codyprecord@gmail.com> wrote:

Hi,

On Mon, Dec 7, 2009 at 3:12 PM, Olemis Lang <olemis@gmail.com> wrote:

The labels that you are adding that you want right aligned are
actually right aligned as per the client area they require, if you
want them to be right aligned as per the dialogs space you will need
to insert a strechable spacer to the left of each of them.

I made a few changes to how your layout is done to better show what I mean.

http://simelo.pastebin.com/m22d18644

[...]

Seems to work ! What should be the problem then , the use of a grid
bag sizer ? Why ?

NO, the spacer . Thnx !

--
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Can I call a wiki-macro from another wiki-macro? | Trac | Users -
http://feedproxy.google.com/~r/TracGViz-full/~3/yiEwraF_UYc/44146