36 |
37 |
37 def setMenu(self, menu): |
38 def setMenu(self, menu): |
38 """ |
39 """ |
39 Public method to set the button menu. |
40 Public method to set the button menu. |
40 |
41 |
41 @param menu reference to the menu (QMenu) |
42 @param menu reference to the menu |
|
43 @type QMenu |
42 """ |
44 """ |
43 self.__menu = menu |
45 self.__menu = menu |
44 self.update() |
46 self.update() |
45 |
47 |
46 def menu(self): |
48 def menu(self): |
47 """ |
49 """ |
48 Public method to get a reference to the menu. |
50 Public method to get a reference to the menu. |
49 |
51 |
50 @return reference to the associated menu (QMenu) |
52 @return reference to the associated menu |
|
53 @rtype QMenu |
51 """ |
54 """ |
52 return self.__menu |
55 return self.__menu |
53 |
56 |
54 def setIcon(self, icon): |
57 def setIcon(self, icon): |
55 """ |
58 """ |
56 Public method to set the button icon. |
59 Public method to set the button icon. |
57 |
60 |
58 @param icon icon to be set (QIcon) |
61 @param icon icon to be set |
|
62 @type QIcon |
59 """ |
63 """ |
60 if icon.isNull(): |
64 if icon.isNull(): |
61 self.__image = None |
65 self.__image = None |
62 else: |
66 else: |
63 self.__image = icon.pixmap(16, 16).toImage() |
67 self.__image = icon.pixmap(16, 16).toImage() |
73 |
77 |
74 def paintEvent(self, evt): |
78 def paintEvent(self, evt): |
75 """ |
79 """ |
76 Protected method handling a paint event. |
80 Protected method handling a paint event. |
77 |
81 |
78 @param evt reference to the paint event (QPaintEvent) |
82 @param evt reference to the paint event |
|
83 @type QPaintEvent |
79 """ |
84 """ |
80 painter = QPainter(self) |
85 painter = QPainter(self) |
81 |
86 |
82 if self.__image is not None and not self.__image.isNull(): |
87 if self.__image is not None and not self.__image.isNull(): |
83 x = (self.width() - self.__image.width()) // 2 - 1 |
88 x = (self.width() - self.__image.width()) // 2 - 1 |