root/branch/NetworkInventory/umit/inventory/ColoredToggleButton.py @ 4252

Revision 4252, 2.0 kB (checked in by gpolo, 4 years ago)

Merged revisions 4240-4248 via svnmerge from
http://svn.umitproject.org/svnroot/umit/trunk

........

r4240 | gpolo | 2009-03-02 13:15:33 -0300 (Mon, 02 Mar 2009) | 1 line


Restructuring umit, second step. See ticket #229.

........

r4241 | gpolo | 2009-03-02 13:19:09 -0300 (Mon, 02 Mar 2009) | 1 line


Removing old directories

........

r4242 | gpolo | 2009-03-02 13:19:42 -0300 (Mon, 02 Mar 2009) | 1 line


Removed umitInterfaceEditor now

........

r4243 | gpolo | 2009-03-02 13:21:20 -0300 (Mon, 02 Mar 2009) | 1 line


Fixed some remaining old umitCore imports

........

r4244 | gpolo | 2009-03-02 15:26:14 -0300 (Mon, 02 Mar 2009) | 1 line


Renamed UMIT_CONFIG_DIR to UMIT_CFG_DIR so the unix installer doesn't replace its content when installing umit.

........

r4245 | gpolo | 2009-03-02 15:50:36 -0300 (Mon, 02 Mar 2009) | 1 line


Adjusted installers for the new structure. This concludes ticket #229.

........

r4246 | gpolo | 2009-03-02 15:59:02 -0300 (Mon, 02 Mar 2009) | 1 line


Removed unused shell scripts.

........

r4247 | gpolo | 2009-03-02 16:03:54 -0300 (Mon, 02 Mar 2009) | 1 line


Updated version_update.py and ran it.

........

r4248 | gpolo | 2009-03-02 16:06:01 -0300 (Mon, 02 Mar 2009) | 1 line


test_paths.sh has been abandoned too, gone now.

........

Line 
1# Copyright (C) 2007 Adriano Monteiro Marques
2#
3# Authors: Guilherme Polo <ggpolo@gmail.com>
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18# USA
19
20"""
21A standard ToggleButton but with an colored eventbox.
22"""
23
24import gtk
25
26class ColoredToggleButton(gtk.ToggleButton):
27
28    def __init__(self, label, color):
29        gtk.ToggleButton.__init__(self)
30
31        self.lbl = gtk.Label(label)
32        self.color_eb = gtk.EventBox()
33        self.color_eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(*color))
34
35        # XXX For some WMs the following two lines are needed in order to
36        # obtain the same results elsewhere, it is like eventbox changed
37        # its state.
38        self.color_eb.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(*color))
39        self.color_eb.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.Color(*color))
40
41        self.__set_props()
42        self.__do_layout()
43        self.show_all()
44
45
46    def __set_props(self):
47        """
48        Set eventbox width, height.
49        """
50        self.color_eb.set_size_request(12, 6)
51
52
53    def __do_layout(self):
54        """
55        Layout colored toggle button.
56        """
57        color_align = gtk.Alignment(0, 0.6, 1, 0.1)
58        color_align.add(self.color_eb)
59
60        button_box = gtk.HBox()
61        button_box.pack_start(color_align, False, False, 2)
62        button_box.add(self.lbl)
63
64        self.add(button_box)
65
Note: See TracBrowser for help on using the browser.