Module Gnumed.pycommon.gmGuiBroker
GNUmed GUI element brokerage
This module provides wrappers for the equivalent of global variables needed for a gnumed GUI client interface
@author: Dr. Horst Herb @version: 0.2 @copyright: GPL v2 or later
Classes
class GuiBroker
-
Expand source code
class GuiBroker: "Wrapper for global objects needed by GNUMmed GUI clients" #This class wraps all global gui objects (variables)for a gnumed #application. The static (at application level)dictionary #__objects can be accessed through the method addobject #and getobject. #So, if you need to access the main window frame, you would #query an instance of GuiBroker for it. __objects:dict = {} __keycounter:int = 0 def __init__(self): pass def addobject(self, widget, key=None): "Add an object to the gnumed gui object dictionary" #An object can be anything (class, variable, widget) #The "key" is a key expression (number, text) that #allows you to retrieve the object. #Convention for keys is the widget or variable name #as a text string #If key is not passed as parameter, a unique serial #number is allocated as key and returned if not key: # create a new sequential key that doesn't exist yet key = GuiBroker.__keycounter + 1 while key in GuiBroker.__objects: key +=1 GuiBroker.__keycounter = key GuiBroker.__objects[key]=widget return key def getobject(self, key): "allows to retrieve a gnumed gui element; see addobject() regarding the key parameter" return GuiBroker.__objects[key] def has_key( self, key): return key in GuiBroker.__objects def keylist(self): " returns a list of all keys; see documentation for the dictionary data type" return list(GuiBroker.__objects) def valuelist(self): "returns a list of all values; see documentation for the dictionary data type" return GuiBroker.__objects.values() def itemlist(self): "returns a list of all key:value pairs; see documentation for the dictionary data type" return GuiBroker.__objects.items() def __getitem__(self, key): "Allows retrieving the value via value = instance[key]" return self.getobject(key) def __setitem__(self, key, object): "Allows access in the style of instance[key]=value" return self.addobject(object, key)
Wrapper for global objects needed by GNUMmed GUI clients
Methods
def addobject(self, widget, key=None)
-
Expand source code
def addobject(self, widget, key=None): "Add an object to the gnumed gui object dictionary" #An object can be anything (class, variable, widget) #The "key" is a key expression (number, text) that #allows you to retrieve the object. #Convention for keys is the widget or variable name #as a text string #If key is not passed as parameter, a unique serial #number is allocated as key and returned if not key: # create a new sequential key that doesn't exist yet key = GuiBroker.__keycounter + 1 while key in GuiBroker.__objects: key +=1 GuiBroker.__keycounter = key GuiBroker.__objects[key]=widget return key
Add an object to the gnumed gui object dictionary
def getobject(self, key)
-
Expand source code
def getobject(self, key): "allows to retrieve a gnumed gui element; see addobject() regarding the key parameter" return GuiBroker.__objects[key]
allows to retrieve a gnumed gui element; see addobject() regarding the key parameter
def has_key(self, key)
-
Expand source code
def has_key( self, key): return key in GuiBroker.__objects
def itemlist(self)
-
Expand source code
def itemlist(self): "returns a list of all key:value pairs; see documentation for the dictionary data type" return GuiBroker.__objects.items()
returns a list of all key:value pairs; see documentation for the dictionary data type
def keylist(self)
-
Expand source code
def keylist(self): " returns a list of all keys; see documentation for the dictionary data type" return list(GuiBroker.__objects)
returns a list of all keys; see documentation for the dictionary data type
def valuelist(self)
-
Expand source code
def valuelist(self): "returns a list of all values; see documentation for the dictionary data type" return GuiBroker.__objects.values()
returns a list of all values; see documentation for the dictionary data type