wxStaticText where do I find the Style Contants values?

I am trying to find the Values for the Styles listed under
wxStaticText in the wx.chm file and can't seem to find the right
search terms.

Specifically I want to create a StaticText with a fixed size,
centered, and no autosize.

You can teach me to fish or you can just give me the answer.

I can't get to the SourceForge hosted sites from work, but, I have
"Reaped" some of the material to get past the sites being blocked at
work.

I have also looked in the wxPython\docs\api area and still can't seem
to use the roght phrase or term to find the answer...

When I use the given Constant, wxST_NO_AUTORESIZE -or- wxALIGN_CENTRE
I get a global not not defined error.

style = wxST_NO_AUTORESIZE -or- style = wxALIGN_CENTRE

if I use style=3 I get the No resize... But, haven't found the
combination for centering in the oversize box.

My actual code line:

TPS_Top_Line=wxStaticText(panel, label="TPS Top Line", size=(640,50),
style=3)
TPS_Top_Line.SetFont(wx.Font(18, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0,
""))
TPS_Top_Line.SetBackgroundColour(wx.Colour(104, 100, 255))

My Frame is 640 by 480 in size... Panel fills Frame by default.

You can teach me to fish or you can just give me the answer.

only if I an catch a fish first...

When I use the given Constant, wxST_NO_AUTORESIZE -or- wxALIGN_CENTRE
I get a global not not defined error.

are you using "wx.ALIGN_CENTER" ? For the python version, everything is put in the wx namespace, and the "wx" is removed from the name -- something you need to get used to when reading the C++ docs.

style = wxST_NO_AUTORESIZE -or- style = wxALIGN_CENTRE

if I use style=3 I get the No resize... But, haven't found the
combination for centering in the oversize box.

rather than a style, you shoud be able to use a Sier to center the StaticText wherever it sits:

Sizer.Add(The_Static_Text, 0, wx.ALIGN_CENTER_HORIZONTAL)

the "0" means -- "don't stretch me"

HTH,
   -Chris

···

On 9/9/11 8:49 AM, SpiritualMadMan wrote:

--
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’m pretty sure the “not defined” problem is because you typed “wxALIGN_CENTRE” instead of “wx.ALIGN_CENTRE”. In general, all references to wxPython constants/objects/methods are in the “wx” namespace.

Things weren’t always so standardized and centralized, and there are still plenty of documentation examples on the web in deprecated formats - so if you find an example, and it doesn’t work when you try it, try putting it in the “wx.Whatever” format (or “wx.WHATEVER”, or “wx.WHAT_EVER”, or…) before you despair.

Also, what editor or IDE are you using? You’ve heard my rant on what a nasty GUI-builder wxGlade is… but there are quite a number of good Python-aware editors. A good editor or IDE can do introspection on the object/namespace/whatever you’re referencing and give you a drop-down list of available constants/methods/whatever; over the time I’ve been using wxPython, I’ve probably got at least as much help from the drop-downs as from the docs.

···

On Fri, Sep 9, 2011 at 8:49 AM, SpiritualMadMan madrucke@yahoo.com wrote:

I am trying to find the Values for the Styles listed under

wxStaticText in the wx.chm file and can’t seem to find the right

search terms.

Specifically I want to create a StaticText with a fixed size,

centered, and no autosize.

You can teach me to fish or you can just give me the answer.

I can’t get to the SourceForge hosted sites from work, but, I have

“Reaped” some of the material to get past the sites being blocked at

work.

I have also looked in the wxPython\docs\api area and still can’t seem

to use the roght phrase or term to find the answer…

When I use the given Constant, wxST_NO_AUTORESIZE -or- wxALIGN_CENTRE

I get a global not not defined error.

style = wxST_NO_AUTORESIZE -or- style = wxALIGN_CENTRE

if I use style=3 I get the No resize… But, haven’t found the

combination for centering in the oversize box.

My actual code line:

TPS_Top_Line=wxStaticText(panel, label=“TPS Top Line”, size=(640,50),

style=3)

TPS_Top_Line.SetFont(wx.Font(18, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0,

“”))

TPS_Top_Line.SetBackgroundColour(wx.Colour(104, 100, 255))

My Frame is 640 by 480 in size… Panel fills Frame by default.

Marc, Thanks! that wx. was the trick that made my day.

The working code is:

TPS_Top_Line=wxStaticText(panel, label="TPS Top Line", size=(640,50),
style=wx.ST_NO_AUTORESIZE | wx.ALIGN_CENTRE)

TPS_Top_Line.SetFont(wx.Font(18, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0,
""))

TPS_Top_Line.SetBackgroundColour(wx.Colour(104, 100, 255))

(Extra line feeds to separate lines of code de to word wrapping.)

Now I have knowledge to work with!

I am using IDLE...

I agree the wxGlade leaves a lot to be desired.

But, it has given me some example code to play with and learn from.

Chris, I am trying to avoid using Sizers for this learning
experience. :slight_smile:

I tried using Sizers for my all-in-one GUI and couldn't get wxGlade to
cooperate.

I also have BOAConstructor, but haven't made much progress with it...

As, well as wxFormbuilder...

wxGlade "seemed" to be the most Newbie Friendly and Intuitive.

For me at least :slight_smile:

Still pretty far down on the learning curve in a lot of areas.

Doc is still a problem when getting going with wxPython as there is lots out there which is out of date, or using C++ style or .....

Andrea G. a long time ago did some proof of concept, something similar will hopefully make it at some point.

But it is still useful at this point.

http://xoomer.virgilio.it/infinity77/wxPython/widgets.html
http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.StaticText.html

what you want is (I think)

  wx.ALIGN_CENTRE | wx.ST_NO_AUTORESIZE

Werner

···

On 09/09/2011 05:49 PM, SpiritualMadMan wrote:

I am trying to find the Values for the Styles listed under
wxStaticText in the wx.chm file and can't seem to find the right
search terms.

Specifically I want to create a StaticText with a fixed size,
centered, and no autosize.

You can teach me to fish or you can just give me the answer.

I can't get to the SourceForge hosted sites from work, but, I have
"Reaped" some of the material to get past the sites being blocked at
work.

I have also looked in the wxPython\docs\api area and still can't seem
to use the roght phrase or term to find the answer...

When I use the given Constant, wxST_NO_AUTORESIZE -or- wxALIGN_CENTRE

I tried using Sizers for my all-in-one GUI and couldn’t get wxGlade to
cooperate.

Boa Constructor works well with sizers, but it takes some practice. On that note…

I also have BOAConstructor, but haven’t made much progress with it…

I hope this might help:
http://showmedo.com/videotutorials/series?name=wKQrywla5

Che

Chris, I am trying to avoid using Sizers for this learning
experience. :slight_smile:

fair enough, but you really do want to learn them at some point. It is 'the way' to do layout with wx. And once you wrap your brain around them, you may actually like them.

Also, isn't wxGlade using them anyway?

-Chris

···

On 9/9/11 9:51 AM, SpiritualMadMan wrote:

I tried using Sizers for my all-in-one GUI and couldn't get wxGlade to
cooperate.

I also have BOAConstructor, but haven't made much progress with it...

As, well as wxFormbuilder...

wxGlade "seemed" to be the most Newbie Friendly and Intuitive.

For me at least :slight_smile:

Still pretty far down on the learning curve in a lot of areas.

--
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

Chris,

Yes, wxGlade uses sizers extensively.

In fact they enforce sizers even when they are not neccesary.

Remember, I am coming from VB6 and am used to laying out forms in
"Absolute" terms.

Of, course, I also am used to working with the form resize event to
adjust as required.

On forms that I allow resizing, I often have min and max limits on
form size so that the form doesn't get really ugly.

I can move button position on the resize event (in VB) and expand only
the control(s) that are the main focus of the form.

In wx I can see where maintaining evenly spaced controls would make
sizers a great benefit.

But, at the same time (at least using Glade) sizers can have
unexpected results when you are laying out a User Interface, at least
for this Newbie :).

That is why I went to learning the manual way of doing wx.

Once things slow down, if they ever slow down, I'll get to finish
reading Robin's book and the Cookbook and sizers will come a bit more
naturally to me.

Mike Sr.

Personally I think it is best to learn the toolkit *without* using a GUI builder tool. IOW, do everything by hand while learning. That will reinforce everything you learn because you are actually applying it and tweaking it and maintaining it, all in the actual source code. IMO not only will that will give you a much deeper understanding of wxPython much quicker, (which is a good thing,) but it will also force you to learn and understand sizers much sooner (which is also a good thing) because modifying and maintaining an absolute positioning layout is too painful.

Then, once you have that very good understanding of the toolkit I think it is okay to use a GUI builder when you need to create something quickly. Since you will (or should) fully understand every line of code that is being generated, then you can use the tool as if it was an extension of the toolkit and your code editor instead of a mysterious black box that you end up being locked into using and being forced to live with its limitations (they all have some) forever.

···

On 9/9/11 12:38 PM, Michael A. Druckenmiller wrote:

Chris,

Yes, wxGlade uses sizers extensively.

In fact they enforce sizers even when they are not neccesary.

Remember, I am coming from VB6 and am used to laying out forms in
"Absolute" terms.

Of, course, I also am used to working with the form resize event to
adjust as required.

On forms that I allow resizing, I often have min and max limits on
form size so that the form doesn't get really ugly.

I can move button position on the resize event (in VB) and expand only
the control(s) that are the main focus of the form.

In wx I can see where maintaining evenly spaced controls would make
sizers a great benefit.

But, at the same time (at least using Glade) sizers can have
unexpected results when you are laying out a User Interface, at least
for this Newbie :).

That is why I went to learning the manual way of doing wx.

Once things slow down, if they ever slow down, I'll get to finish
reading Robin's book and the Cookbook and sizers will come a bit more
naturally to me.

--
Robin Dunn
Software Craftsman

I second this - third this - fourth this! When I first picked up wxPython, sizers scared the heck out of me, and I assumed that one of the automagic GUI builders would smooth my learning curve. It did exactly the opposite - wxGlade frustrated me by putting sizers in inconvenient, unpredictable places, and then generating scary spaghetti code. (I tried BoaConstructor too, but it was definitely Not Ready for Prime Time back when I tried it - it made Glade smell good. I understand it’s better now, but I can’t be bothered anymore.)

Not only do I agree with Robin that you gain a deeper understanding by learning hands-on, but I also think (given the rather sad state of wx automagic tools) that you’ll learn faster and easier without them.

I like to make a quick sketch of the layout - a box for the outside, and smaller boxes inside to hold groups of controls. I give the boxes names, and decide how they’re aligned and how they’ll grow. Those are my sizers; I create them at the top of my Frame.init(), and .Add each of them to the outermost sizer at the end of it (and set that outermost sizer as the sizer for the Panel. In between I have to remember to add each control to its appropriate sizer after I create it… but that’s it. Four or five minutes of prep at the beginning of the project, and sizers practically manage themselves.

One other thing: the Inspection Tool is AWESOME! Add “import wx.lib.inspection” to the top of your code, and “wx.lib.inspection.InspectionTool().Show()” just before MainLoop(), and prepare to have your horizons broadened. (Don’t forget to comment it out before going into production; your users may prefer their horizons unbroadened.)

···

On Fri, Sep 9, 2011 at 12:50 PM, Robin Dunn robin@alldunn.com wrote:

On 9/9/11 12:38 PM, Michael A. Druckenmiller wrote:

That is why I went to learning the manual way of doing wx.

Once things slow down, if they ever slow down, I’ll get to finish

reading Robin’s book and the Cookbook and sizers will come a bit more

naturally to me.

Personally I think it is best to learn the toolkit without using a GUI builder tool. IOW, do everything by hand while learning. That will reinforce everything you learn because you are actually applying it and tweaking it and maintaining it, all in the actual source code. IMO not only will that will give you a much deeper understanding of wxPython much quicker, (which is a good thing,) but it will also force you to learn and understand sizers much sooner (which is also a good thing) because modifying and maintaining an absolute positioning layout is too painful.

Now I have knowledge to work with!

I am using IDLE...

IIRC, IDLE and wxPython don't play well with each other as it is written in TKinter

Boa (pity that it hasn't seen an update for a long time) or Editra (especially with the Studio plug-in) are in my view much better. Both have pretty good editors and debugging tools.

There are many more wxPythonPit Apps - wxPyWiki and I see that you already got a few.

I agree the wxGlade leaves a lot to be desired.

But, it has given me some example code to play with and learn from.

Chris, I am trying to avoid using Sizers for this learning
experience. :slight_smile:

But I won't wait to long to get into sizers, they are a p.... to learn but I think they are well worse the effort.

I just recently started to use/try out the sized_controls - check out the wxPython demo

Werner

···

On 09/09/2011 06:51 PM, SpiritualMadMan wrote:

Marc,

One other thing: the Inspection Tool is AWESOME! Add "import wx.lib.inspection" to the top of your code, and "wx.lib.inspection.InspectionTool().Show()" just before MainLoop(), and prepare to have your horizons broadened. (Don't forget to comment it out before going into production; your users may prefer their horizons unbroadened.)

WIT has helped me a lot too.

Instead of doing wx.lib.inspection.InspectionTool().Show() I mix it in with the app.

from wx.lib.mixins.inspection import InspectionMixin

class BaseApp(wx.App, InspectionMixin):
     def OnInit(self):
         self.Init() # InspectionMixin

Then when you need it press ctrl-alt-i (default, can be mapped differently).

Werner

···

On 09/09/2011 11:45 PM, Marc Tompkins wrote:

First I’d heard of the Inspection mixin - I’ll definitely have to try that out! Thanks!

···

On Sat, Sep 10, 2011 at 1:33 AM, werner wbruhin@free.fr wrote:

Marc,

On 09/09/2011 11:45 PM, Marc Tompkins wrote:

One other thing: the Inspection Tool is AWESOME! Add “import wx.lib.inspection” to the top of your code, and “wx.lib.inspection.InspectionTool().Show()” just before MainLoop(), and prepare to have your horizons broadened. (Don’t forget to comment it out before going into production; your users may prefer their horizons unbroadened.)

WIT has helped me a lot too.

Instead of doing wx.lib.inspection.InspectionTool().Show() I mix it in with the app.

from wx.lib.mixins.inspection import InspectionMixin

class BaseApp(wx.App, InspectionMixin):

def OnInit(self):

    self.Init() # InspectionMixin

Then when you need it press ctrl-alt-i (default, can be mapped differently).


I am trying to find the Values for the Styles listed under
wxStaticText in the wx.chm file and can't seem to find the right
search terms.
Specifically I want to create a StaticText with a fixed size,
centered, and no autosize.
You can teach me to fish or you can just give me the answer.

My way of fishing for something like this:
1) Take a look at StaticText in the wxPython demo for some hints:
2) Try the built in documentation:
python
>>> import wx
>>> st=wx.StaticText
>>> dir(st)

*see if I can spot anything useful*, *      Create looks like it

might have some information so*

>>> help(st.Create)

*see if I can spot anything useful*
Help on method Create in module wx._controls:

Create(*args, **kwargs) unbound wx._controls.StaticText method
    Create(self, Window parent, int id=-1, String label=EmptyString,
        Point pos=DefaultPosition, Size size=DefaultSize,
        long style=0, String name=StaticTextNameStr) -> bool

*      So I can pass it a size at creation time, now since I know I am

looking for ALIGN items:*
>>> wxd=dir(wx)
>>> for n in wxd:
… if n.startswith(‘ALIGN’):
… print n

ALIGN_BOTTOM
ALIGN_CENTER
ALIGN_CENTER_HORIZONTAL
ALIGN_CENTER_VERTICAL
ALIGN_CENTRE
ALIGN_CENTRE_HORIZONTAL
ALIGN_CENTRE_VERTICAL
ALIGN_LEFT
ALIGN_MASK
ALIGN_NOT
ALIGN_RIGHT
ALIGN_TOP
ALIGN_CENTER looks hopeful
>>> for n in wxd:
… if n.find(‘SIZE’) > 0:
… print(n)

ADJUST_MINSIZE
CONTROL_SIZEGRIP
CP_NO_TLW_RESIZE
CURSOR_SIZENESW
CURSOR_SIZENS
CURSOR_SIZENWSE
CURSOR_SIZEWE
EVT_SIZE
FIXED_MINSIZE
FULL_REPAINT_ON_RESIZE
ID_VIEW_SORTSIZE
LIST_AUTOSIZE
LIST_AUTOSIZE_USEHEADER
NO_FULL_REPAINT_ON_RESIZE
RESIZE_BORDER
RESIZE_BOX
ST_NO_AUTORESIZE
ST_SIZEGRIP
SYS_FRAMESIZE_X
SYS_FRAMESIZE_Y
TEXT_ATTR_FONT_SIZE
wxEVT_SIZE
>>>
ST_NO_AUTORESIZE looks likely.

Next try either modifying the code in the wxPython Demo to see if I

can get what I need or knock up a quick test script to see if I can
do it.

Gadget/Steve
···

On 09/09/2011 4:49 PM, SpiritualMadMan wrote: