Size of controls on wxMac

Hi all,

I'm pretty sure I've seen the answer to this on this list, but no googling I've done has found it.

Is there a flag or something I can use to tell wxMac to use the smaller version of a given Window/control? In this case, I want a CheckBox that takes up less vertical space than by default.

-Chris

By the way, I'm finding that Buttons in sizers on wxMac end up being really scrunched up against things -- they really aren't getting as much space as they should. I thought this got fixed a couple versions ago, but I guess not. Is there a solution other than adding space around all my buttons just for the Mac?

···

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

Hi all,

I’m pretty sure I’ve seen the answer to this on this list, but no
googling I’ve done has found it.

Is there a flag or something I can use to tell wxMac to use the smaller
version of a given Window/control? In this case, I want a CheckBox that

takes up less vertical space than by default.

I don’t think its possible unless you roll your own checkbox that you are drawing yourself. wx nicely wraps native widgets when possible, and I don’t think the Apple controls are going to shrink gracefully; it goes against their HID.

By the way, I’m finding that Buttons in sizers on wxMac end up being
really scrunched up against things – they really aren’t getting as much

space as they should. I thought this got fixed a couple versions ago,
but I guess not. Is there a solution other than adding space around all
my buttons just for the Mac?

I’ve found a need to consistently maintain different amounts of borders around controls on our product between windows and mac. The controls are just different sizes; the mac controls have extra shadows and stuff and in the end just need a bit more room to look right on the mac platform. Stuff like…

button.SetSizerProps(border=self.__Border[platform])

or

self.sizer.Add(button, wx.ALIGN_LEFT | self.__BorderOrient[platform], self.__Border[platform])

… is not especially unusual, depending on the complexities of the UI. I usually try to set standardized borders per-control in a class attribute on the parent there as you can see. When not appropriate, button.SetSizerProps(border={“darwin”: (“all”,7), “win32”:(“all”:5)}[platform]) isn’t so difficult or ugly either.

···

On 2/23/07, Christopher Barker Chris.Barker@noaa.gov wrote:


Stephen Hansen
Development

Advanced Prepress Technology

shansen@advpubtech.com
(818) 748-9282

Hi Chris,

Hi all,

I'm pretty sure I've seen the answer to this on this list, but no googling I've done has found it.

Is there a flag or something I can use to tell wxMac to use the smaller version of a given Window/control? In this case, I want a CheckBox that takes up less vertical space than by default.

See wxWindow::SetWindowVariant

http://www.wxwidgets.org/manuals/stable/wx_wxwindow.html#wxwindowsetwindowvariant

-Chris

By the way, I'm finding that Buttons in sizers on wxMac end up being really scrunched up against things -- they really aren't getting as much space as they should. I thought this got fixed a couple versions ago, but I guess not. Is there a solution other than adding space around all my buttons just for the Mac?

Not really; this isn't a wx problem, it's that different HIGs have different spacing requirements and using the same border size on three different platforms is pretty much like setting size in pixels - it doesn't work well cross-platform. You can sort of fudge things to look halfway decent, but you can't get HIG-compliance that way. You could either write your own routines for retrieving the platform's HIG border values yourself, or use SizedControls and let it take care of all of that for you.

Regards,

Kevin

···

On Feb 23, 2007, at 2:26 PM, Christopher Barker 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

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Stephen Hansen wrote:

    Is there a flag or something I can use to tell wxMac to use the smaller
    version of a given Window/control?

I don't think its possible unless you roll your own checkbox that you are drawing yourself. wx nicely wraps native widgets when possible, and I don't think the Apple controls are going to shrink gracefully; it goes against their HID.

All true, but I have a memory that there are "small" versions of at least some of the controls, and there is a way to tell wx to use them -- I just can't remember how!

the mac controls have extra shadows and stuff and in the end just need a bit more room to look right on the mac platform.

Exactly. I'd just be happier if that was built in to wx -- that Mac buttons reported a size that reflected extra shadows and stuff. It's also odd that the CheckBoxes, for instance, seem to give themselves a lot of space, but the button don't.

   button.SetSizerProps(border=self.__Border[platform])

   self.sizer.Add(button, wx.ALIGN_LEFT | self.__BorderOrient[platform], self.__Border[platform])

attribute on the parent there as you can see. When not appropriate, button.SetSizerProps(border={"darwin": ("all",7), "win32":("all":5)}[platform]) isn't so difficult or ugly either.

Both good suggestions.

I now Kevin O. had some good ideas about how to build more of this in to the Windows or Sizers themselves. The idea was that you could easily automagically build HIG compliant layouts. I wonder what came of that?

-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

Stephen Hansen wrote:

Is there a flag or something I can use to tell wxMac to use the smaller
version of a given Window/control?

I don’t think its possible unless you roll your own checkbox that you

are drawing yourself. wx nicely wraps native widgets when possible, and
I don’t think the Apple controls are going to shrink gracefully; it goes
against their HID.

All true, but I have a memory that there are “small” versions of at

least some of the controls, and there is a way to tell wx to use them –
I just can’t remember how!

You’re right-- I never noticed those. :slight_smile: SetWindowVariant, Kevin says. Must play with and see if they’re useful to me. Hmm.

I now Kevin O. had some good ideas about how to build more of this in to

the Windows or Sizers themselves. The idea was that you could easily
automagically build HIG compliant layouts. I wonder what came of that?

Well, the Sized* controls work really well and have been a joy for more straightforward layouts since I began testing on 2.8 migration. They all know about the HID for borders and depths and such. Sometimes I still end up needing to manually nest sizers, and handle it myself; but most of my UI rewrites now use a sc.SizedPanel or sc.SizedFrame
. Did you look at the sized_controls?

import wxaddons.sized_controls as sc
class MyPanel(sc.SizedPanel):
    def __init__(self, parent):
        sc.SizedPanel.__init__(self, parent, -1, "Hola")


        self.SetSizerType("vertical")

        label = wx.StaticText(self, -1, "This is my text")
        label.SetSizerProps(expand=1, proportion=0)

        input = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE)
        input.SetSizerProps(expand=1, proportion=1)

etc. They take care of a lot of the basic borderness and stuff underneath automatically.

Of course, setting the border with the Sized controls for cases where I do want to give additional information is a pain. I never remember the format off the odd argument. I think Imma gonna make a Border function that takes Border(all=5) or Border(left=5, right=5) and turns them into (“all”, 5) and ( (“left”, 5), (“right”,5)) respectively to maintain readability and sanity.

···

On 2/23/07, Christopher Barker Chris.Barker@noaa.gov wrote:


Stephen Hansen
Development
Advanced Prepress Technology

shansen@advpubtech.com
(818) 748-9282

Hi Chris,

[snip]

I now Kevin O. had some good ideas about how to build more of this in to the Windows or Sizers themselves. The idea was that you could easily automagically build HIG compliant layouts. I wonder what came of that?

Check the "Recent Additions" section of the wxPython 2.8.1.1 demo for SizedControls. There's a demo and some preliminary docs there.

Regards,

Kevin

···

On Feb 23, 2007, at 3:26 PM, Christopher Barker wrote:

-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

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Kevin Ollivier wrote:

See wxWindow::SetWindowVariant

Bingo! I knew that was there somewhere!

Not really; this isn't a wx problem, it's that different HIGs have different spacing requirements and using the same border size on three different platforms is pretty much like setting size in pixels - it doesn't work well cross-platform.

Well, yes, but I find that almost universally, my buttons on the Mac need more space. In general, things seem to look pretty good on GTK and Windows without adding space much, but on the Mac things are crammed right up against the edges. I can't help thinking that the default sizes of controls are just too small on the Mac.

Check the "Recent Additions" section of the wxPython 2.8.1.1 demo for SizedControls. There's a demo and some preliminary docs there.

Bingo again! I'll be checking that out!

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

Hi Stephen,

Stephen Hansen wrote:

Is there a flag or something I can use to tell wxMac to use the smaller
version of a given Window/control?

I don’t think its possible unless you roll your own checkbox that you
are drawing yourself. wx nicely wraps native widgets when possible, and
I don’t think the Apple controls are going to shrink gracefully; it goes
against their HID.

All true, but I have a memory that there are “small” versions of at
least some of the controls, and there is a way to tell wx to use them –
I just can’t remember how!

You’re right-- I never noticed those. :slight_smile: SetWindowVariant, Kevin says. Must play with and see if they’re useful to me. Hmm.

I now Kevin O. had some good ideas about how to build more of this in to
the Windows or Sizers themselves. The idea was that you could easily
automagically build HIG compliant layouts. I wonder what came of that?

Well, the Sized* controls work really well and have been a joy for more straightforward layouts since I began testing on 2.8 migration. They all know about the HID for borders and depths and such.

Glad to hear you find them useful! :slight_smile:

Sometimes I still end up needing to manually nest sizers, and handle it myself; but most of my UI rewrites now use a sc.SizedPanel or sc.SizedFrame .

BTW, is there a way I can see some of the cases that SizedControls don’t handle? I know they won’t handle every case yet, but I’d like to see if there are ways I could adapt them to handle more.

Did you look at the sized_controls?

import wxaddons.sized_controls as sc
class MyPanel(sc.SizedPanel):
    def __init__(self, parent):
        sc.SizedPanel.__init__(self, parent, -1, "Hola")

        self.SetSizerType("vertical")

        label = wx.StaticText(self, -1, "This is my text")
        label.SetSizerProps(expand=1, proportion=0)

        input = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE)
        input.SetSizerProps(expand=1, proportion=1)

etc. They take care of a lot of the basic borderness and stuff underneath automatically.

Of course, setting the border with the Sized controls for cases where I do want to give additional information is a pain. I never remember the format off the odd argument. I think Imma gonna make a Border function that takes Border(all=5) or Border(left=5, right=5) and turns them into (“all”, 5) and ( (“left”, 5), (“right”,5)) respectively to maintain readability and sanity.

I considered implementing something like this, but currently it wouldn’t work like you’d expect it to. Border(left=5, right=5) will work fine, but Border(left=5, right=8) will not work as you expect - you’ll end up with both left and right borders being either 5 px or 8 px (or only one border being set), depending on how it is coded. This is because I’m just wrapping wx sizers, which only store one value for border size - it does not store separate border sizes for each direction. This is IMHO confusing and non-intuitive, but that’s how sizers work, and I haven’t had time to improve upon it yet, as it’d have to be done at the C++ level, which requires a lot more work to write and test.

Regards,

Kevin

···

On Feb 23, 2007, at 3:38 PM, Stephen Hansen wrote:

On 2/23/07, Christopher Barker Chris.Barker@noaa.gov wrote:


Stephen Hansen
Development
Advanced Prepress Technology

shansen@advpubtech.com
(818) 748-9282

Sometimes I still end up needing to manually nest sizers, and handle it myself; but most of my UI rewrites now use a sc.SizedPanel or sc.SizedFrame .

BTW, is there a way I can see some of the cases that SizedControls don’t handle? I know they won’t handle every case yet, but I’d like to see if there are ways I could adapt them to handle more.

I’ll dig through and see if I can tear out some of our Custom Stuff to make a general example or two. Our “global search” dialog is one example: it displays extremely custom search criteria for users, inspired by some configuration dialogs on the mac (like Spotlight) but customized more (and being able to OR). Its just a darn complicated window: it is scrolled, has multiple “group” panels which have a “title” panel, then any number of “Condition” panels within that can be dragged and dropped between groups and deleted independently. “Condition” panels are Field, Operator, and Value… with Value being custom so that if you’re searching on a date field, you have a date-range in the control, stuff like that.

The UI for the window has given me quite a bit of trouble :slight_smile: Attached is a screenshot to better explain what the heck is being done. In the given example, it wants to find all things in our system that EITHER matches (slug contains “this word” AND field3 matches “this pattern*”) OR (field2 is “This value”). I like the idea of the window and it mostly works, and its -completely- generic. But its a pain. :slight_smile:

And a bit of an oddity – so not using SizedControls with it seems not to be a failing of the SizedControls.

Looking over the code, I think in most cases I did a manual nested-sizes situation I could have done it differently by nesting new panels. I don’t know really if thats better, though, except to have a consistent configuration and HID considerations.

For example, on one dialog I have a long narrow bit; on the top of this bit is a FlexGridSizer for a series of labels and controls… then a toolbar, and a big ol tree control. To accomplish this, I had a master BoxSizer to which I added a FlexGridSizer first, and then to the grid all of my key/value controls, then adding the toolbar and the tree.

I could have created a sub-SizedPanel to host the key/value controls, and then add that as the first child to my main panel… and maybe should have. But SizedControls were new to me and I was used to having to do nested sizers to get things to look the way i need. :slight_smile:

Of course, setting the border with the Sized controls for cases where I do want to give additional information is a pain. I never remember the format off the odd argument. I think Imma gonna make a Border function that takes Border(all=5) or Border(left=5, right=5) and turns them into (“all”, 5) and ( (“left”, 5), (“right”,5)) respectively to maintain readability and sanity.

I considered implementing something like this, but currently it wouldn’t work like you’d expect it to. Border(left=5, right=5) will work fine, but Border(left=5, right=8) will not work as you expect - you’ll end up with both left and right borders being either 5 px or 8 px (or only one border being set), depending on how it is coded. This is because I’m just wrapping wx sizers, which only store one value for border size - it does not store separate border sizes for each direction. This is IMHO confusing and non-intuitive, but that’s how sizers work, and I haven’t had time to improve upon it yet, as it’d have to be done at the C++ level, which requires a lot more work to write and test.

Well, yes-- I wasn’t thinking when I made the example. I knew that, honest! Just… forgot :slight_smile: But the current syntax is just painful. I’ll do something to wrap it, even if its Border(5, left=True, right=True) like that. Something that doesnt’ make me have to remember the order and syntax of the tuple that comes out. In fact I like that syntax, so will probably end up using it. Something to make it appear more explicit.

–Stephen

Stephen Hansen wrote:

  Border(5, left=True, right=True)
like that. Something that doesnt' make me have to remember the order and syntax of the tuple that comes out. In fact I like that syntax, so will probably end up using it.

or maybe:

Border(5, wx.LEFT|wx.RIGHT)

less pythonic, more wx-ish.

-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

Kevin Ollivier wrote:

I considered implementing something like this, but currently it wouldn't work like you'd expect it to. Border(left=5, right=5) will work fine, but Border(left=5, right=8) will not work as you expect - you'll end up with both left and right borders being either 5 px or 8 px (or only one border being set), depending on how it is coded. This is because I'm just wrapping wx sizers, which only store one value for border size - it does not store separate border sizes for each direction. This is IMHO confusing and non-intuitive, but that's how sizers work, and I haven't had time to improve upon it yet, as it'd have to be done at the C++ level, which requires a lot more work to write and test.

Well, you could fudge it with spacers, with the obvious cost of complexity, but at least it'd be all in Python.

···

--
Don Dwiggins
Advanced Publishing Technology