source: trunk/engine/python/fife/extensions/pychan/widgets/icon.py @ 3786

Revision 3786, 2.9 KB checked in by prock, 2 years ago (diff)

This should conclude my work on tickets fixes[t:520] and fixes[t:576]. All widgets should now take all configurable properties in their constructor. All clients should used named parameters when passing in values to the constructor.

I have added a "comment" attribute to all widgets. This should allow clients to easily store a bit of extra information about a widget for their own use.

I also changed Slider and PercentageBar? to conform to the pychan standard. To get and set values to them you can use their "value" property. I had to change some code in the PychanDemo? so chances are if you are using these widgets you'll need to do the same.

Fixed the editor and all demo's to work with these changes. Hopefully I got everything.

Some notes to clients: This commit MAY change some functionality of pychan depending on how you are using it. Any parameters passed to the constructors will override any attributes set in the style even if you specify a style in the constructor. Keep this in mind! Other than that it should be exactly the same.

  • Property svn:eol-style set to native
Line 
1# -*- coding: utf-8 -*-
2
3# ####################################################################
4#  Copyright (C) 2005-2011 by the FIFE team
5#  http://www.fifengine.net
6#  This file is part of FIFE.
7#
8#  FIFE is free software; you can redistribute it and/or
9#  modify it under the terms of the GNU Lesser General Public
10#  License as published by the Free Software Foundation; either
11#  version 2.1 of the License, or (at your option) any later version.
12#
13#  This library is distributed in the hope that it will be useful,
14#  but WITHOUT ANY WARRANTY; without even the implied warranty of
15#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16#  Lesser General Public License for more details.
17#
18#  You should have received a copy of the GNU Lesser General Public
19#  License along with this library; if not, write to the
20#  Free Software Foundation, Inc.,
21#  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22# ####################################################################
23
24from common import *
25from widget import Widget
26from fife.extensions.pychan.properties import ImageProperty
27
28class Icon(Widget):
29   """
30   An image icon.
31
32   New Attributes
33   ==============
34
35     - image: String or GuiImage: The source location of the Image or a direct GuiImage
36   """
37   ATTRIBUTES = Widget.ATTRIBUTES + [ Attr('image') ]
38
39   def __init__(self, 
40             parent = None, 
41             name = None,
42             size = None,
43             min_size = None, 
44             max_size = None, 
45             helptext = None, 
46             position = None, 
47             style = None, 
48             hexpand = None,
49             vexpand = None,
50             font = None,
51             base_color = None,
52             background_color = None,
53             foreground_color = None,
54             selection_color = None,
55             border_size = None,
56             position_technique = None,
57             is_focusable = None,
58             comment = None,
59             image = None):
60             
61      self.real_widget = fife.Icon(None)
62      super(Icon,self).__init__(parent=parent, 
63                          name=name, 
64                          size=size, 
65                          min_size=min_size, 
66                          max_size=max_size,
67                          helptext=helptext, 
68                          position=position,
69                          style=style, 
70                          hexpand=hexpand, 
71                          vexpand=vexpand,
72                          font=font,
73                          base_color=base_color,
74                          background_color=background_color,
75                          foreground_color=foreground_color,
76                          selection_color=selection_color,
77                          border_size=border_size,
78                          position_technique=position_technique,
79                          is_focusable=is_focusable,
80                          comment=comment)
81      self.image = image
82
83   _image = ImageProperty("Image")
84
85   def _setImage(self,source):
86      self._image = source
87      # This is a bit odd.
88      # ... not sure whether to leave the sizes alone, but that might
89      # break layouts. yikes.
90      self.min_size = self.real_widget.getWidth(),self.real_widget.getHeight()
91      self.max_size = self.min_size
92      self.size  = self.min_size
93      #print self._image, self.min_size, self.max_size
94
95   def _getImage(self):
96      return self._image
97   image = property(_getImage,_setImage)
Note: See TracBrowser for help on using the repository browser.