Using Qt stylesheets with Traits UI

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Using Qt stylesheets with Traits UI

Robert Kern
Recently, I wanted to customize the appearance of a table using the
TableEditor. Qt stylesheets[1] were the easiest, most convenient way
to do so. The way I did this was to modify the Qt backend's
TableEditor.init() method to do the following at the end:

  if getattr(self.factory, '_qt_stylesheet', None) is not None:
      self.control.setStyleSheet(self.factory._qt_stylesheet)

Then, in my View:

   Item('my_list', editor=TableEditor(...,
_qt_stylesheet="""QTableView { ... }""")),

Does this seem like a reasonable approach to adding this kind of
extensibility to the other editors, too? Or should we make a real
qt_stylesheet trait on all of the EditorFactories?

[1] http://doc.trolltech.com/4.6/stylesheet.html

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Using Qt stylesheets with Traits UI

bryce hendrix-2
Didn't Evan do some work to support stylesheets last summer? If not, I'd
like to see the stylesheet defined outside of the view, preferably in a
separate file.

Bryce

On 5/8/2010 6:37 PM, Robert Kern wrote:

> Recently, I wanted to customize the appearance of a table using the
> TableEditor. Qt stylesheets[1] were the easiest, most convenient way
> to do so. The way I did this was to modify the Qt backend's
> TableEditor.init() method to do the following at the end:
>
>    if getattr(self.factory, '_qt_stylesheet', None) is not None:
>        self.control.setStyleSheet(self.factory._qt_stylesheet)
>
> Then, in my View:
>
>     Item('my_list', editor=TableEditor(...,
> _qt_stylesheet="""QTableView { ... }""")),
>
> Does this seem like a reasonable approach to adding this kind of
> extensibility to the other editors, too? Or should we make a real
> qt_stylesheet trait on all of the EditorFactories?
>
> [1] http://doc.trolltech.com/4.6/stylesheet.html
>
>    

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Using Qt stylesheets with Traits UI

Robert Kern
On Sat, May 8, 2010 at 8:50 PM, Bryce Hendrix <[hidden email]> wrote:
> Didn't Evan do some work to support stylesheets last summer?

Ah, yes. enthought.traits.ui.qt4.extra.qt_view.QtView is a subclass of View
that accepts a stylesheet. Thanks!

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev