This is kind of a follow-up to my previous email about the Tree
control resizing.
Please see/execute attached code. In the displayed interface, there is
a panel in the top part of the frame, followed by the tree control.
Now the top panel must:
1. Have a gradient fill
2. The option button must be right aligned on the panel.
Q1: I have gradient filled the panel itself. How do I make StaticText
inherit its background color from the parent panel in which it is
created? Is that even possible?
Q2: The options button "sticks" right next to the StaticText; I
expected the sizer to align it to the right using wx.ALIGN_RIGHT. Can
someone explain what I am doing wrong in my code?
I tried another way which solves my button positioning problem but
with that method I believe I can not have a gradient filled static
panel header like I want. That method was to use two sizers - a
horizontal sizer to position the static text and button and a vertical
sizer to position the horizontal box and the tree control in it. This
worked well for the button position.
If I have to change my entire approach, kindly let me know that too.
This is kind of a follow-up to my previous email about the Tree
control resizing.
Please see/execute attached code. In the displayed interface, there is
a panel in the top part of the frame, followed by the tree control.
Now the top panel must:
1. Have a gradient fill
2. The option button must be right aligned on the panel.
Q1: I have gradient filled the panel itself. How do I make StaticText
inherit its background color from the parent panel in which it is
created? Is that even possible?
Doing things like that with the native widgets is not suported, but you can do whatever you want with a generic widget (see wx.lib.stattext) or you can even just draw the text yourself in the EVT_PAINT handler and not use a wx.StaticText.
Q2: The options button "sticks" right next to the StaticText; I
expected the sizer to align it to the right using wx.ALIGN_RIGHT. Can
someone explain what I am doing wrong in my code?
The sizer alignment flags specify how the item is aligned within the space that is given to is by the sizer, they don't cause that space to be changed in any way. One way you can do what you want there is to add a space before the button and set it to take all the remaining space, and then add the button. That will give a big empty space between the controls and the button will be pushed to the right.
hbox.Add((5,5), 1)
You also have a problem in how you use hbox. You should be assigning it (with SetSizer) to the TitlePanel, and then in the WidgetContainer's sizer you should just add tp, not tp.hbox.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
As always, thanks for your input! The button now floats to the right
of the panel.
About the custom text, I had done what you described using EVT_PAINT
but later changed it to the version I sent. The issue I encountered
using EVT_PAINT to write the text in the panel was that when I dragged
the right border of the window frame all the way to the left, the
button moved on top of my text. Considering my limited knowledge of
sizers, I did not know to deal with that :-).
I will gladly revert back to using EVT_PAINT in TitlePanel to write my
text, which I found to be more elegant when it came to coping with the
gradient background, if I am able to prevent the options button from
moving on top of the text.
I certainly appreciate your help!
-Kartic
···
On 6/15/05, Robin Dunn <robin@alldunn.com> wrote:
K K wrote:
> Hi All,
>
> This is kind of a follow-up to my previous email about the Tree
> control resizing.
>
> Please see/execute attached code. In the displayed interface, there is
> a panel in the top part of the frame, followed by the tree control.
> Now the top panel must:
> 1. Have a gradient fill
> 2. The option button must be right aligned on the panel.
>
> Q1: I have gradient filled the panel itself. How do I make StaticText
> inherit its background color from the parent panel in which it is
> created? Is that even possible?
Doing things like that with the native widgets is not suported, but you
can do whatever you want with a generic widget (see wx.lib.stattext) or
you can even just draw the text yourself in the EVT_PAINT handler and
not use a wx.StaticText.
>
> Q2: The options button "sticks" right next to the StaticText; I
> expected the sizer to align it to the right using wx.ALIGN_RIGHT. Can
> someone explain what I am doing wrong in my code?
The sizer alignment flags specify how the item is aligned within the
space that is given to is by the sizer, they don't cause that space to
be changed in any way. One way you can do what you want there is to add
a space before the button and set it to take all the remaining space,
and then add the button. That will give a big empty space between the
controls and the button will be pushed to the right.
hbox.Add((5,5), 1)
You also have a problem in how you use hbox. You should be assigning it
(with SetSizer) to the TitlePanel, and then in the WidgetContainer's
sizer you should just add tp, not tp.hbox.
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
I'd like to put a little image there similar to the
one used in mozilla-mail's message grid to enable
selection of columns to display.
I already have a working pop-up menu (very similar
to mozilla's) that lets you select what columns to
display, and right now it's activated by
right-clicking on the (0,0) label, but that's not
very obvious to the user, so I'd like to put an
image or button there.
The issue I encountered
using EVT_PAINT to write the text in the panel was that when I dragged
the right border of the window frame all the way to the left, the
button moved on top of my text. Considering my limited knowledge of
sizers, I did not know to deal with that :-).
I will gladly revert back to using EVT_PAINT in TitlePanel to write my
text, which I found to be more elegant when it came to coping with the
gradient background, if I am able to prevent the options button from
moving on top of the text.
combining layout between your own drawn stuff and Sizers is a bot of a trick. I see two options:
1) use a generic control instead, it may provide some of the layout for you
2) whenever there is an EVT_SIZE, query the button for where it is, then re-draw your text aligned with it. Perhaps you should put a spacer in the sizer to fill the space that you are going to draw your text on. It may be a bit of a trick to figure out how to get the location of the button after all the sizing has occurred, but I'll be tit can work. See a recent message by Robin about how to make the background of a widget in a Gridsizer a certain color, the technique will be similar.
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
The issue I encountered
using EVT_PAINT to write the text in the panel was that when I dragged
the right border of the window frame all the way to the left, the
button moved on top of my text. Considering my limited knowledge of
sizers, I did not know to deal with that :-).
I will gladly revert back to using EVT_PAINT in TitlePanel to write my
text, which I found to be more elegant when it came to coping with the
gradient background, if I am able to prevent the options button from
moving on top of the text.
Perhaps you should put a spacer in the sizer to fill the space that you are going to draw your text on. It may be a bit of a trick to figure out how to get the location of the button after all the sizing has occurred, but I'll be tit can work. See a recent message by Robin about how to make the background of a widget in a Gridsizer a certain color, the technique will be similar.
Yep. Just add a spacer to the sizer that is the same size as the text you are going to draw (use GetTextExtent to find out how big it is.) and then when you add that spacer to the sizer keep track of the item returned from the sizer.Add. Then in your paint handler use that item's GetRect method to find out where to draw the text.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
I'd like to put a little image there similar to the
one used in mozilla-mail's message grid to enable
selection of columns to display.
I already have a working pop-up menu (very similar
to mozilla's) that lets you select what columns to
display, and right now it's activated by
right-clicking on the (0,0) label, but that's not
very obvious to the user, so I'd like to put an
image or button there.
What's the easiest way?
You can use grid.GetGridCornerLabelWindow() to get a reference to the window that implements that spot on the grid. Then you can do whatever you want with that window, use it as the parent of a wx.StaticBitmap, or bind a EVT_PAINT handler to it, or etc.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Yep. Just add a spacer to the sizer that is the same size as the text
you are going to draw (use GetTextExtent to find out how big it is.) and
then when you add that spacer to the sizer keep track of the item
returned from the sizer.Add. Then in your paint handler use that item's
GetRect method to find out where to draw the text.