Question: I have a TextBlock and a Line sitting next to each other in their own exclusive StackPanel. 

I need to spread my LinearGradientBrush across the two objects, rather than shading them individually. 

My project currently looks like this: 

<http://img188.imageshack.us/img188/1268/seperategradients.png>

```
<StackPanel Orientation="Horizontal">

    <TextBlock VerticalAlignment="Bottom">
        SomeTextContent
        <TextBlock.Foreground>
            <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                <GradientStop Offset="0" Color="Blue" />
                <GradientStop Offset="1" Color="Orange" />
            </LinearGradientBrush>
        </TextBlock.Foreground>
    </TextBlock>

    <Line VerticalAlignment="Bottom" X2="100">
        <Line.Stroke>
            <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                <GradientStop Offset="0" Color="Blue" />
                <GradientStop Offset="1" Color="Orange" />
            </LinearGradientBrush>
        </Line.Stroke>
    </Line>

</StackPanel>

```

As shown, the gradient is applied to TextBlock seperately from the Line. I need to find a way to apply the gradient across the TextBlock and the Line in a single pass - as if they were the same object entirely. In this example, the text should be mostly blue and the line should be mostly orange.

Answer: 
This is very easy to do with Tkinter.

There are a couple of things that have to happen to make this work. First, you need to make sure that the standard behavior *doesn't* happen. That is, you don't want tab to both insert a tab and move focus to the next widget. By default events are processed by a specific widget prior to where the standard behavior occurs (typically in class bindings). Tk has a simple built-in mechanism to stop events from further processing. 

Second, you need to make sure you send focus to the appropriate widget. There is built-in support for determining what the next widget is.

For example:

```
def focus_next_window(event):
    event.widget.tk_focusNext().focus()
    return("break")

text_widget=Text(...)
text_widget.bind("<Tab>", focus_next_window)

```

Important points about this code:

* The method `tk_focusNext()` returns the next widget in the keyboard traversal hierarchy.
* the method `focus()` sets the focus to that widget
* returning `"break"` is critical in that it prevents the class binding from firing. It is this class binding that inserts the tab character, which you don't want.

If you want this behavior for all text widgets in an application you can use the `bind_class()` method instead of `bind()` to make this binding affect all text widgets. 

You can also have the binding send focus to a very specific widget but I recommend sticking with the default traversal order, then make sure the traversal order is correct.
It is really simple in PyQt4 simply use this one single line below and you will be able to change focus by pressing tab button:

self.textEdit.setTabChangesFocus(True)