示例#1
0
	def hide(self, free=False):
		"""
		Hide the widget and all contained widgets.
		"""
		# remove this widget from the manager
		if self._added:
			get_manager().removeWidget(self)
		if self.parent is None and self._top_added:
			get_manager().removeTopWidget(self)
		# remove childs of this widget from the manager
		def _hide(hidden_widget):
			get_manager().removeWidget(hidden_widget)
		self.deepApply(_hide)
		
		if not self.isVisible() and not self.isSetVisible():
			self.adaptLayout()
			self.afterHide()
			return

		# Hide real widget to distribute a widgetHidden event.
		self.real_widget.setVisible(False)

		if free:
			if self.parent:
				self.parent.removeChild(self)
			self.removeAllChildren()

		self.adaptLayout()
		self.afterHide()
示例#2
0
    def hide(self, free=False):
        """
		Hide the widget and all contained widgets.
		"""
        # remove this widget from the manager
        if self._added:
            get_manager().removeWidget(self)
        if self.parent is None and self._top_added:
            get_manager().removeTopWidget(self)
        # remove childs of this widget from the manager
        def _hide(hidden_widget):
            get_manager().removeWidget(hidden_widget)

        self.deepApply(_hide)

        if not self.isVisible() and not self.isSetVisible():
            self.adaptLayout()
            self.afterHide()
            return

        # Hide real widget to distribute a widgetHidden event.
        self.real_widget.setVisible(False)

        if free:
            if self.parent:
                self.parent.removeChild(self)
            self.removeAllChildren()

        self.adaptLayout()
        self.afterHide()
示例#3
0
	def undockTo(self, widget):
		# Undock the Panel to the given widget.
		if self.docked and widget is not self.parent and self.dockable:
			self.parent.removeChild(self)
			# undock to main gui
			if widget is None:
				get_manager().addTopWidget(self)
			else:
				widget.addChild(self)
			self.docked = False
			self.afterUndock()
示例#4
0
 def undockTo(self, widget):
     # Undock the Panel to the given widget.
     if self.docked and widget is not self.parent and self.dockable:
         self.parent.removeChild(self)
         # undock to main gui
         if widget is None:
             get_manager().addTopWidget(self)
         else:
             widget.addChild(self)
         self.docked = False
         self.afterUndock()
示例#5
0
	def show(self):
		"""
		Show the widget and all contained widgets.
		"""
		# add this widget to the manager
		if not self._added:
			get_manager().addWidget(self)
		if self.parent is None and not self._top_added:
			get_manager().addTopWidget(self)
		# add childs of this widget to the manager
		def _show(shown_widget):
			get_manager().addWidget(shown_widget)
		self.deepApply(_show)
		
		if self.isVisible() and self.isSetVisible():
			self.beforeShow()
			self.adaptLayout()
			if self.parent is None:
				get_manager().placeWidget(self, self.position_technique)
			return

		self.beforeShow()
		# Show real widget to distribute a widgetShown event.
		self.real_widget.setVisible(True)
		self.adaptLayout()
		if self.parent is None:
			get_manager().placeWidget(self, self.position_technique)
示例#6
0
    def show(self):
        """
		Show the widget and all contained widgets.
		"""
        # add this widget to the manager
        if not self._added:
            get_manager().addWidget(self)
        if self.parent is None and not self._top_added:
            get_manager().addTopWidget(self)
        # add childs of this widget to the manager
        def _show(shown_widget):
            get_manager().addWidget(shown_widget)

        self.deepApply(_show)

        if self.isVisible() and self.isSetVisible():
            self.beforeShow()
            self.adaptLayout()
            if self.parent is None:
                get_manager().placeWidget(self, self.position_technique)
            return

        self.beforeShow()
        # Show real widget to distribute a widgetShown event.
        self.real_widget.setVisible(True)
        self.adaptLayout()
        if self.parent is None:
            get_manager().placeWidget(self, self.position_technique)
示例#7
0
	def showChild(self, child):
		# add child to the manager
		if not child._added:
			get_manager().addWidget(child)
		# add childs of child to the manager
		def _show(shown_widget):
			get_manager().addWidget(shown_widget)
		child.deepApply(_show)

		child.beforeShow()
		if not child.isVisible() or not child.isSetVisible():
			# Show real widget to distribute a widgetShown event.
			child.real_widget.setVisible(True)

		self.adaptLayout()
示例#8
0
	def getDockArea(self):
		if not self.docked:
			dockAreas = []
			# all top widgets are used for the search
			if not self.parent:
				topWidgets = get_manager().allTopHierachyWidgets
				for t in topWidgets:
					dockAreas.extend(t.findChildren(__class__=DockArea))
			else:
				# only all childs are used for the search
				dockAreas = self.parent.findChildren(__class__=DockArea)
			# reverse order so inner/deeper Areas are preferred
			dockAreas.reverse()
			# try to find an intersecting and active DockArea
			dim = fife.Rect(0, 0, self.width, self.height)
			dim.x, dim.y = self.getAbsolutePos()
			for d in dockAreas:
				if d.real_widget.isActiveDockArea():
					ddim = fife.Rect(0, 0, d.width, d.height)
					ddim.x, ddim.y = d.getAbsolutePos()
					if dim.intersects(ddim):
						return d
			return None
		else:
			return self.parent
示例#9
0
    def collectData(self, *widgetNames):
        """
		Collect data from a widget hierachy by names.
		This can only handle UNIQUE widget names (in the hierachy)
		and will raise a RuntimeError if the number of matching widgets
		is not equal to one.

		This function takes an arbitrary number of widget names and
		returns a list of the collected data in the same order.

		In case only one argument is given, it will return just the
		data, with out putting it into a list.

		Usage::
		  # Multiple element extraction:
		  text, selected = guiElement.collectData('myTextField','myListBox')
		  print "You entered:",text," and selected item nr",selected
		  # Single elements are handled gracefully, too:
		  test = guiElement.collectData('testElement')

		"""
        children = self.getNamedChildren(include_unnamed=True)
        dataList = []
        for name in widgetNames:
            widgetList = children.get(name, [])
            if len(widgetList) != 1:
                if get_manager().debug:
                    self.listNamedWidgets()
                raise RuntimeError(
                    "CollectData can only handle widgets with unique names.")
            dataList.append(widgetList[0].getData())
        if len(dataList) == 1:
            return dataList[0]
        return dataList
示例#10
0
	def collectData(self,*widgetNames):
		"""
		Collect data from a widget hierachy by names.
		This can only handle UNIQUE widget names (in the hierachy)
		and will raise a RuntimeError if the number of matching widgets
		is not equal to one.

		This function takes an arbitrary number of widget names and
		returns a list of the collected data in the same order.

		In case only one argument is given, it will return just the
		data, with out putting it into a list.

		Usage::
		  # Multiple element extraction:
		  text, selected = guiElement.collectData('myTextField','myListBox')
		  print "You entered:",text," and selected item nr",selected
		  # Single elements are handled gracefully, too:
		  test = guiElement.collectData('testElement')

		"""
		children = self.getNamedChildren(include_unnamed=True)
		dataList = []
		for name in widgetNames:
			widgetList = children.get(name,[])
			if len(widgetList) != 1:
				if get_manager().debug:
					self.listNamedWidgets()
				raise RuntimeError("CollectData can only handle widgets with unique names.")
			dataList.append( widgetList[0].getData() )
		if len(dataList) == 1:
			return dataList[0]
		return dataList
示例#11
0
 def getDockArea(self):
     if not self.docked:
         dockAreas = []
         # all top widgets are used for the search
         if not self.parent:
             topWidgets = get_manager().allTopHierachyWidgets
             for t in topWidgets:
                 dockAreas.extend(t.findChildren(__class__=DockArea))
         else:
             # only all childs are used for the search
             dockAreas = self.parent.findChildren(__class__=DockArea)
         # reverse order so inner/deeper Areas are preferred
         dockAreas.reverse()
         # try to find an intersecting and active DockArea
         dim = fife.Rect(0, 0, self.width, self.height)
         dim.x, dim.y = self.getAbsolutePos()
         for d in dockAreas:
             if d.real_widget.isActiveDockArea():
                 ddim = fife.Rect(0, 0, d.width, d.height)
                 ddim.x, ddim.y = d.getAbsolutePos()
                 if dim.intersects(ddim):
                     return d
         return None
     else:
         return self.parent
示例#12
0
    def showChild(self, child):
        # add child to the manager
        if not child._added:
            get_manager().addWidget(child)
        # add childs of child to the manager
        def _show(shown_widget):
            get_manager().addWidget(shown_widget)

        child.deepApply(_show)

        child.beforeShow()
        if not child.isVisible() or not child.isSetVisible():
            # Show real widget to distribute a widgetShown event.
            child.real_widget.setVisible(True)

        self.adaptLayout()
示例#13
0
	def dockTo(self, widget):
		# Dock the Panel to the given widget.
		if not self.docked and widget is not self.parent and self.dockable:
			widget.real_widget.setHighlighted(False)
			# map coordinates to new parent and remove it from old parent
			if self.parent:
				self.x = (self.x // (self.parent.width // 100)) * (widget.width // 100)
				self.y = (self.y // (self.parent.height // 100)) * (widget.height // 100)
				self.parent.removeChild(self)
			else:
				self.x = (self.x // (get_manager().hook.screen_width // 100)) * (widget.width // 100)
				self.y = (self.y // (get_manager().hook.screen_height // 100)) * (widget.height // 100)
				get_manager().removeTopWidget(self)
			# dock it to new parent
			widget.addChild(self)
			self.docked = True
			self.afterDock()
示例#14
0
	def show(self):
		"""
		Show the widget and all contained widgets.
		"""
		if self._visible and self.isSetVisible(): return

		self.beforeShow()
		self._visible = True
		if self.parent:
			self.parent.showChild(self)
		else:
			self.adaptLayout()
			get_manager().show(self)
		#update the states of the child widgets
		def _show(shown_widget):
			shown_widget._visible = True
		self.deepApply(_show, shown_only=True)
示例#15
0
	def hide(self):
		"""
		Hide the widget and all contained widgets.
		"""
		if not self._visible and not self.isSetVisible(): return

		self._visible = False
		if self.parent:
			self.parent.hideChild(self)
		else:
			get_manager().hide(self)
		#update the states of the child widgets
		def _hide(hidden_widget):
			hidden_widget._visible = False
		self.deepApply(_hide)
		
		self.afterHide()
示例#16
0
 def _setCursors(self, cursors):
     if cursors is not None:
         i = 0
         for c in cursors:
             if isinstance(c, str):
                 # we need a fife image
                 c = get_manager().loadImage(c, gui=False)
             self.real_widget.set(self.DIRECTION_LIST[i], c)
             i += 1
示例#17
0
	def _setCursors(self, cursors):
		if cursors is not None:
			i = 0
			for c in cursors:
				if isinstance(c, str):
					# we need a fife image
					c = get_manager().loadImage(c, gui=False)
				self.real_widget.set(self.DIRECTION_LIST[i], c)
				i += 1
示例#18
0
	def hideChild(self, child, free=False):
		# remove child from the manager
		if child._added:
			get_manager().removeWidget(child)
		if child._top_added:
			get_manager().removeTopWidget(child)
		# remove childs of the child from the manager
		def _hide(hidden_widget):
			get_manager().removeWidget(hidden_widget)
		child.deepApply(_hide)
		
		if child.isVisible() or child.isSetVisible():
			# Hide real widget to distribute a widgetHidden event.
			child.real_widget.setVisible(False)
			
		if free:
			self.removeChild(child)
		self.adaptLayout()
		self.afterHide()
示例#19
0
    def execute(self, bind, focus=None):
        """
		Execute a dialog synchronously.

		As argument a dictionary mapping widget names to return values
		is expected. Events from these widgets will cause this function
		to return with the associated return value.

		This function will not return until such an event occurs.
		The widget will be shown before execution and hidden afterwards.
		You can only execute root widgets.

		@param focus: name of child widget which should have focus. Defaults to main widget.

		Note: This feature is not tested well, and the API will probably
		change. Otherwise have fun::
		  # Okay this a very condensed example :-)
		  return pychan.loadXML("contents/gui/dialog.xml").execute({ 'okButton' : True, 'closeButton' : False })

		"""
        if not get_manager().can_execute:
            raise RuntimeError("Synchronous execution is not set up!")
        if self.__parent:
            raise RuntimeError("You can only 'execute' root widgets, not %s!" %
                               str(self))

        for name, returnValue in bind.items():

            def _quitThisDialog(returnValue=returnValue):
                get_manager().breakFromMainLoop(returnValue)
                self.hide()

            self.findChild(name=name).capture(_quitThisDialog,
                                              group_name="__execute__")
        self.show()
        if focus and self.findChild(name=focus):
            self.findChild(name=focus).is_focusable = True
            self.findChild(name=focus).requestFocus()
        else:
            self.is_focusable = True
            self.requestFocus()
        return get_manager().mainLoop()
示例#20
0
    def hideChild(self, child, free=False):
        # remove child from the manager
        if child._added:
            get_manager().removeWidget(child)
        if child._top_added:
            get_manager().removeTopWidget(child)
        # remove childs of the child from the manager
        def _hide(hidden_widget):
            get_manager().removeWidget(hidden_widget)

        child.deepApply(_hide)

        if child.isVisible() or child.isSetVisible():
            # Hide real widget to distribute a widgetHidden event.
            child.real_widget.setVisible(False)

        if free:
            self.removeChild(child)
        self.adaptLayout()
        self.afterHide()
示例#21
0
	def setBackgroundImage(self,image):
		self._background = getattr(self,'_background',None)
		if image is None:
			self._background_image = None
			map(self.real_widget.remove,self._background)
			self._background = []
			return
		# Background generation is done in _resetTiling

		if not isinstance(image, fife.GuiImage):
			image = get_manager().loadImage(image)
		self._background_image = image
示例#22
0
    def setBackgroundImage(self, image):
        self._background = getattr(self, '_background', None)
        if image is None:
            self._background_image = None
            map(self.real_widget.remove, self._background)
            self._background = []
            return
        # Background generation is done in _resetTiling

        if not isinstance(image, fife.GuiImage):
            image = get_manager().loadImage(image)
        self._background_image = image
示例#23
0
	def execute(self, bind, focus=None):
		"""
		Execute a dialog synchronously.

		As argument a dictionary mapping widget names to return values
		is expected. Events from these widgets will cause this function
		to return with the associated return value.

		This function will not return until such an event occurs.
		The widget will be shown before execution and hidden afterwards.
		You can only execute root widgets.

		@param focus: name of child widget which should have focus. Defaults to main widget.

		Note: This feature is not tested well, and the API will probably
		change. Otherwise have fun::
		  # Okay this a very condensed example :-)
		  return pychan.loadXML("contents/gui/dialog.xml").execute({ 'okButton' : True, 'closeButton' : False })

		"""
		if not get_manager().can_execute:
			raise RuntimeError("Synchronous execution is not set up!")
		if self.__parent:
			raise RuntimeError("You can only 'execute' root widgets, not %s!" % str(self))

		for name,returnValue in bind.items():
			def _quitThisDialog(returnValue = returnValue ):
				get_manager().breakFromMainLoop( returnValue )
				self.hide()
			self.findChild(name=name).capture( _quitThisDialog , group_name = "__execute__" )
		self.show()
		if focus and self.findChild(name=focus):
			self.findChild(name=focus).is_focusable = True
			self.findChild(name=focus).requestFocus()
		else:
			self.is_focusable = True
			self.requestFocus()
		return get_manager().mainLoop()
示例#24
0
 def dockTo(self, widget):
     # Dock the Panel to the given widget.
     if not self.docked and widget is not self.parent and self.dockable:
         widget.real_widget.setHighlighted(False)
         # map coordinates to new parent and remove it from old parent
         if self.parent:
             self.x = (self.x //
                       (self.parent.width // 100)) * (widget.width // 100)
             self.y = (self.y //
                       (self.parent.height // 100)) * (widget.height // 100)
             self.parent.removeChild(self)
         else:
             self.x = (self.x //
                       (get_manager().hook.screen_width // 100)) * (
                           widget.width // 100)
             self.y = (self.y //
                       (get_manager().hook.screen_height // 100)) * (
                           widget.height // 100)
             get_manager().removeTopWidget(self)
         # dock it to new parent
         widget.addChild(self)
         self.docked = True
         self.afterDock()
示例#25
0
	def hide(self):
		"""
		Hide the widget and all contained widgets.
		"""
		if not self._visible: return
		
		if self.parent:
			self.parent.hideChild(self)
			self.parent.adaptLayout()
		else:
			get_manager().hide(self)

		self.afterHide()
		self._visible = False
		
	    #Hide real widget to distribute a widgetHidden event.
		self.real_widget.setVisible(False)		
				
		
		def _hide(widget):
			widget._visible = False
			
		self.deepApply(_hide, shown_only=True)
示例#26
0
	def show(self):
		"""
		Show the widget and all contained widgets.
		"""
		if self._visible: return
		
		if self.parent:
			self.beforeShow()
			self.parent.showChild(self)
			self.parent.adaptLayout()
			self._visible = True
		else:
			self.adaptLayout()
			self.beforeShow()
			get_manager().show(self)
			self._visible = True	

		#show real widget to distribute a widgetShown event.
		self.real_widget.setVisible(True)	
						
		def _show(widget):
			widget._visible = True
				
		self.deepApply(_show, shown_only=True)
示例#27
0
	def distributeData(self,dataMap):
		"""
		Distribute data from a dictionary over the widgets in the hierachy
		using the keys as names and the values as the data (which is set via L{setData}).
		This will only accept unique matches.

		Use it like this::
		  guiElement.distributeData({
		       'myTextField' : 'Hello World!',
		       'myListBox' : ["1","2","3"]
		  })

		"""
		children = self.getNamedChildren(include_unnamed=True)
		for name,data in dataMap.items():
			widgetList = children.get(name,[])
			if len(widgetList) != 1:
				if get_manager().debug:
					self.listNamedWidgets()
				raise RuntimeError("DistributeData can only handle widgets with unique names.")
			widgetList[0].setData(data)
示例#28
0
    def distributeData(self, dataMap):
        """
		Distribute data from a dictionary over the widgets in the hierachy
		using the keys as names and the values as the data (which is set via L{setData}).
		This will only accept unique matches.

		Use it like this::
		  guiElement.distributeData({
		       'myTextField' : 'Hello World!',
		       'myListBox' : ["1","2","3"]
		  })

		"""
        children = self.getNamedChildren(include_unnamed=True)
        for name, data in dataMap.items():
            widgetList = children.get(name, [])
            if len(widgetList) != 1:
                if get_manager().debug:
                    self.listNamedWidgets()
                raise RuntimeError(
                    "DistributeData can only handle widgets with unique names."
                )
            widgetList[0].setData(data)
示例#29
0
	def collectDataAsDict(self,widgetNames):
		"""
		Collect data from a widget hierachy by names into a dictionary.
		This can only handle UNIQUE widget names (in the hierachy)
		and will raise a RuntimeError if the number of matching widgets
		is not equal to one.

		Usage::
		  data = guiElement.collectDataAsDict(['myTextField','myListBox'])
		  print "You entered:",data['myTextField']," and selected ",data['myListBox']

		"""
		children = self.getNamedChildren(include_unnamed=True)
		dataMap = {}
		for name in widgetNames:
			widgetList = children.get(name,[])
			if len(widgetList) != 1:
				if get_manager().debug:
					self.listNamedWidgets()
				raise RuntimeError("CollectData can only handle widgets with unique names.")

			dataMap[name] = widgetList[0].getData()
		return dataMap
示例#30
0
    def collectDataAsDict(self, widgetNames):
        """
		Collect data from a widget hierachy by names into a dictionary.
		This can only handle UNIQUE widget names (in the hierachy)
		and will raise a RuntimeError if the number of matching widgets
		is not equal to one.

		Usage::
		  data = guiElement.collectDataAsDict(['myTextField','myListBox'])
		  print "You entered:",data['myTextField']," and selected ",data['myListBox']

		"""
        children = self.getNamedChildren(include_unnamed=True)
        dataMap = {}
        for name in widgetNames:
            widgetList = children.get(name, [])
            if len(widgetList) != 1:
                if get_manager().debug:
                    self.listNamedWidgets()
                raise RuntimeError(
                    "CollectData can only handle widgets with unique names.")

            dataMap[name] = widgetList[0].getData()
        return dataMap
示例#31
0
 def _add(added_widget):
     if not added_widget._added:
         get_manager().addWidget(added_widget)
     if added_widget._top_added:
         get_manager().removeTopWidget(added_widget)
示例#32
0
 def _remove(removed_widget):
     if removed_widget._added:
         get_manager().removeWidget(removed_widget)
     if removed_widget._top_added:
         get_manager().removeTopWidget(removed_widget)
示例#33
0
			def _quitThisDialog(returnValue = returnValue ):
				get_manager().breakFromMainLoop( returnValue )
				self.hide()
示例#34
0
 def _setFont(self, font):
     self._font = font
     self.real_font = get_manager().getFont(font)
     self.real_widget.setFont(self.real_font)
示例#35
0
	def __init__(self,
				 parent = None, 
				 name = None,
				 size = None,
				 min_size = None, 
				 max_size = None, 
				 helptext = None, 
				 position = None, 
				 style = None, 
				 hexpand = None,
				 vexpand = None,
				 font = None,
				 base_color = None,
				 background_color = None,
				 foreground_color = None,
				 selection_color = None,
				 border_size = None,
				 position_technique = None,
				 is_focusable = None,
				 comment = None):
		
		# Make sure the real_widget has been created
		assert( hasattr(self,'real_widget') )
		
		self.event_mapper = events.EventMapper(self)
		
		self._visible = False
		self._extra_border = (0,0)

		# Data distribution & retrieval settings
		self.accepts_data = False
		self.accepts_initial_data = False
		
		#set all defaults
		if get_manager().compat_layout:
			self.hexpand, self.vexpand = 0,0
		else:
			self.hexpand = self.DEFAULT_HEXPAND
			self.vexpand = self.DEFAULT_VEXPAND 		

		self.name = self.DEFAULT_NAME
		self.has_name = False
		self.position = self.DEFAULT_POSITION
		self.position_technique = self.DEFAULT_POSITION_TECHNIQUE
		self.font = self.DEFAULT_FONT
		self.min_size = self.DEFAULT_MIN_SIZE
		self.max_size = self.DEFAULT_MAX_SIZE
		self.size = self.DEFAULT_SIZE
		self.border_size = self.DEFAULT_BORDER_SIZE
		self.helptext = self.DEFAULT_HELPTEXT
		self.comment = self.DEFAULT_COMMENT
		self._usedPrefixes = []
	
		# Parent attribute makes sure we only have one parent,
		# that tests self.__parent - so make sure we have the attr here.
		self.__parent = None
		self.parent = parent

		# Inherit and apply style
		if style is None and parent:
			style = parent.style
		self.style = style or "default"
		
		# override everything style has set
		if vexpand is not None:	self.vexpand = vexpand
		if hexpand is not None: self.hexpand = hexpand
		if name is not None: 
			self.name = name
			self.has_name = True

		if position is not None: self.position = position
		if position_technique is not None: self.position_technique = position_technique
		if font is not None: self.font = font
		
		# only set this if it's provided
		if is_focusable is not None: self.is_focusable = is_focusable
		
		if min_size is not None: self.min_size = min_size
		if max_size is not None: self.max_size = max_size
		if size is not None: self.size = size
		if border_size is not None: self.border_size = border_size
		
		if helptext is not None: self.helptext = helptext
		if comment is not None: self.comment = comment

		# these are set in the default style
		#if base_color is not None: self.base_color = base_color
		if background_color is not None: self.background_color = background_color
		if foreground_color is not None: self.foreground_color = foreground_color
		if selection_color is not None: self.selection_color = selection_color
示例#36
0
 def _setStyle(self, style):
     self._style = style
     get_manager().stylize(self, style)
示例#37
0
 def _hide(hidden_widget):
     get_manager().removeWidget(hidden_widget)
示例#38
0
    def __init__(self,
                 parent=None,
                 name=None,
                 size=None,
                 min_size=None,
                 max_size=None,
                 helptext=None,
                 position=None,
                 style=None,
                 hexpand=None,
                 vexpand=None,
                 font=None,
                 base_color=None,
                 background_color=None,
                 foreground_color=None,
                 selection_color=None,
                 border_size=None,
                 position_technique=None,
                 is_focusable=None,
                 comment=None):

        # Make sure the real_widget has been created
        assert (hasattr(self, 'real_widget'))

        self.event_mapper = events.EventMapper(self)

        # Flag to indicate if the Widget is added to the Manager
        self._added = False
        # Flag to indicate if the Widget is added to
        # the top Widget list of the Manager
        self._top_added = False
        self._extra_border = (0, 0)

        # Data distribution & retrieval settings
        self.accepts_data = False
        self.accepts_initial_data = False

        #set all defaults
        if get_manager().compat_layout:
            self.hexpand, self.vexpand = 0, 0
        else:
            self.hexpand = self.DEFAULT_HEXPAND
            self.vexpand = self.DEFAULT_VEXPAND

        self.name = self.DEFAULT_NAME
        self.has_name = False
        self.position = self.DEFAULT_POSITION
        self.position_technique = self.DEFAULT_POSITION_TECHNIQUE
        self.font = self.DEFAULT_FONT
        self.min_size = self.DEFAULT_MIN_SIZE
        self.max_size = self.DEFAULT_MAX_SIZE
        self.size = self.DEFAULT_SIZE
        self.border_size = self.DEFAULT_BORDER_SIZE
        self.helptext = self.DEFAULT_HELPTEXT
        self.comment = self.DEFAULT_COMMENT
        self._usedPrefixes = []

        # Parent attribute makes sure we only have one parent,
        # that tests self.__parent - so make sure we have the attr here.
        self.__parent = None
        self.parent = parent

        # Inherit and apply style
        if style is None and parent:
            style = parent.style
        self.style = style or "default"

        # override everything style has set
        if vexpand is not None: self.vexpand = vexpand
        if hexpand is not None: self.hexpand = hexpand
        if name is not None:
            self.name = name
            self.has_name = True

        if position is not None: self.position = position
        if position_technique is not None:
            self.position_technique = position_technique
        if font is not None: self.font = font

        # only set this if it's provided
        if is_focusable is not None: self.is_focusable = is_focusable

        if min_size is not None: self.min_size = min_size
        if max_size is not None: self.max_size = max_size
        if size is not None: self.size = size
        if border_size is not None: self.border_size = border_size

        if helptext is not None: self.helptext = helptext
        if comment is not None: self.comment = comment

        # these are set in the default style
        if base_color is not None: self.base_color = base_color
        if background_color is not None:
            self.background_color = background_color
        if foreground_color is not None:
            self.foreground_color = foreground_color
        if selection_color is not None: self.selection_color = selection_color
        # add this widget to the manager
        get_manager().addWidget(self)
示例#39
0
		def _hide(hidden_widget):
			get_manager().removeWidget(hidden_widget)
示例#40
0
	def _setFont(self, font):
		self._font = font
		self.real_font = get_manager().getFont(font)
		self.real_widget.setFont(self.real_font)
示例#41
0
		def _remove(removed_widget):
			if removed_widget._added:
				get_manager().removeWidget(removed_widget)
			if removed_widget._top_added:
				get_manager().removeTopWidget(removed_widget)
示例#42
0
		def _add(added_widget):
			if not added_widget._added:
				get_manager().addWidget(added_widget)
			if added_widget._top_added:
				get_manager().removeTopWidget(added_widget)
示例#43
0
 def _restyle(widget):
     get_manager().stylize(widget, style, **kwargs)
示例#44
0
	def __init__(self,
				 parent = None, 
				 name = None,
				 size = None,
				 min_size = None, 
				 max_size = None,
				 fixed_size = None,
				 margins = None,
				 padding = None,
				 helptext = None, 
				 position = None, 
				 style = None, 
				 hexpand = None,
				 vexpand = None,
				 font = None,
				 base_color = None,
				 background_color = None,
				 foreground_color = None,
				 selection_color = None,
				 border_color = None,
				 outline_color = None,
				 border_size = None,
				 outline_size = None,
				 position_technique = None,
				 is_focusable = None,
				 comment = None):
		
		# Make sure the real_widget has been created
		assert( hasattr(self,'real_widget') )

		self.event_mapper = events.EventMapper(self)

		# Flag to indicate if the Widget is added to the Manager
		self._added = False
		# Flag to indicate if the Widget is added to
		# the top Widget list of the Manager
		self._top_added = False
		# Only needed for tabs
		self.tab = None
		
		# Data distribution & retrieval settings
		self.accepts_data = False
		self.accepts_initial_data = False
		
		#set all defaults
		if get_manager().compat_layout:
			self.hexpand, self.vexpand = 0,0
		else:
			self.hexpand = self.DEFAULT_HEXPAND
			self.vexpand = self.DEFAULT_VEXPAND 		

		self.name = self.DEFAULT_NAME
		self.has_name = False
		self.position = self.DEFAULT_POSITION
		self.position_technique = self.DEFAULT_POSITION_TECHNIQUE
		self.font = self.DEFAULT_FONT
		self.min_size = self.DEFAULT_MIN_SIZE
		self.max_size = self.DEFAULT_MAX_SIZE
		self.size = self.DEFAULT_SIZE
		self.margins = self.DEFAULT_MARGINS
		self.padding = self.DEFAULT_PADDING
		self.border_size = self.DEFAULT_BORDER_SIZE
		self.outline_size = self.DEFAULT_OUTLINE_SIZE
		self.helptext = self.DEFAULT_HELPTEXT
		self.comment = self.DEFAULT_COMMENT
		self._usedPrefixes = []
	
		# Parent attribute makes sure we only have one parent,
		# that tests self.__parent - so make sure we have the attr here.
		self.__parent = None
		self.parent = parent

		# Inherit and apply style
		if style is None and parent:
			style = parent.style
		self.style = style or "default"
		
		# override everything style has set
		if vexpand is not None:	self.vexpand = vexpand
		if hexpand is not None: self.hexpand = hexpand
		if name is not None: 
			self.name = name
			self.has_name = True

		if position is not None: self.position = position
		if position_technique is not None: self.position_technique = position_technique
		if font is not None: self.font = font
		
		# only set this if it's provided
		if is_focusable is not None: self.is_focusable = is_focusable
		
		if min_size is not None: self.min_size = min_size
		if max_size is not None: self.max_size = max_size
		if size is not None: self.size = size
		if fixed_size is not None: self.fixed_size = fixed_size
		if margins is not None: self.margins = margins
		if padding is not None: self.padding = padding
		if border_size is not None: self.border_size = border_size
		if outline_size is not None: self.outline_size = outline_size
		
		if helptext is not None: self.helptext = helptext
		if comment is not None: self.comment = comment

		# these are set in the default style
		if base_color is not None: self.base_color = base_color
		if background_color is not None: self.background_color = background_color
		if foreground_color is not None: self.foreground_color = foreground_color
		if selection_color is not None: self.selection_color = selection_color
		if border_color is not None: self.border_color = border_color
		if outline_color is not None: self.outline_color = outline_color
		# add this widget to the manager
		get_manager().addWidget(self)
示例#45
0
 def _quitThisDialog(returnValue=returnValue):
     get_manager().breakFromMainLoop(returnValue)
     self.hide()
示例#46
0
		def _show(shown_widget):
			get_manager().addWidget(shown_widget)
示例#47
0
		def _restyle(widget):
			get_manager().stylize(widget,style,**kwargs)
示例#48
0
 def _show(shown_widget):
     get_manager().addWidget(shown_widget)
示例#49
0
	def _setStyle(self,style):
		self._style = style
		get_manager().stylize(self,style)
示例#50
0
	def __init__(self, 
				 parent = None,
				 name = None,
				 size = None,
				 min_size = None,
				 max_size = None,
				 fixed_size = None,
				 margins = None,
				 padding = None,
				 helptext = None,
				 position = None,
				 style = None,
				 hexpand = None,
				 vexpand = None,
				 font = None,
				 base_color = None,
				 background_color = None,
				 foreground_color = None,
				 selection_color = None,
				 border_color = None,
				 outline_color = None,
				 border_size = None,
				 outline_size = None,
				 position_technique = None,
				 is_focusable = None,
				 comment = None,
				 image = None,
				 scale = None,
				 tile = None,
				 opaque = None):
				 
		self.real_widget = fifechan.Icon(None)
		
		super(Icon,self).__init__(parent=parent,
								  name=name,
								  size=size,
								  min_size=min_size,
								  max_size=max_size,
								  fixed_size=fixed_size,
								  margins=margins,
								  padding=padding,
								  helptext=helptext,
								  position=position,
								  style=style,
								  hexpand=hexpand,
								  vexpand=vexpand,
								  font=font,
								  base_color=base_color,
								  background_color=background_color,
								  foreground_color=foreground_color,
								  selection_color=selection_color,
								  border_color=border_color,
								  outline_color=outline_color,
								  border_size=border_size,
								  outline_size=outline_size,
								  position_technique=position_technique,
								  is_focusable=is_focusable,
								  comment=comment)

		# set provided attributes or defaults
		if scale is not None: self.scale = scale
		else: self.scale = self.DEFAULT_SCALE

		if tile is not None: self.tile = tile
		else: self.tile = self.DEFAULT_TILE

		if opaque is not None: self.opaque = opaque
		else: self.opaque = self.DEFAULT_OPAQUE

		# for the case that image can not be found, e.g. invalid path
		# the Icon is removed from the manager
		try:
			self.image = image
		except Exception:
			get_manager().removeWidget(self)
			raise
		
		#if the size parameter is specified set it (again) to override
		#the icons size. That works only without layouting.
		if size is not None: self.size = size