Esempio n. 1
0
    def set_children (self, children):
        """T.set_children (...) -> None

        Sets the children of the Table.

        When setting the children of the Table, keep in mind, that the
        children will be added row for row, causing the Table to fill
        the first row of itself, then the second and so on.

        Raises a ValueError, if the passed amount of children exceeds
        the cell amount of the Table.
        """
        if children != None:
            if len (children) > (self.columns * self.rows):
                raise ValueError ("children exceed the Table size.")

        # Remove all children first.
        for i in xrange (self._rows):
            for j in xrange (self._cols):
                self.grid[(i, j)] = None
        Container.set_children (self, children)
        if children == None:
            return
        
        cells = len (children)
        for i in xrange (self._rows):
            for j in xrange (self._cols):
                self.grid[(i, j)] = children[-cells]
                cells -= 1
                if cells == 0:
                    return
Esempio n. 2
0
    def _draw(self):
        if not skin.active():
            return;

        if not self.width or not self.height:
            raise TypeError, 'Not all needed variables set.'

        if not self.full:
            # catch division by zero error.
            return

        position = min((self.position * 100) / self.full, 100)
        width, height = self.get_size()

        self.surface = self.get_surface()

        self.surface.fill(self.bg_color.get_color_sdl())
        self.surface.set_alpha(self.bg_color.get_alpha())

        box = self.osd.Surface(((width * position ) / 100 , height), 0, 32)
        box.fill(self.selected_bg_color.get_color_sdl())
        box.set_alpha(self.selected_bg_color.get_alpha())

        self.surface.blit(box, (0,0))
        Container._draw(self)
Esempio n. 3
0
    def __init__(self, rows, cols):
        Container.__init__(self)
        if (type(rows) != int) or (type(cols) != int):
            raise TypeError("Arguments must be positive integers")
        if (rows <= 0) or (cols <= 0):
            raise ValueError("Arguments must be positive integers")
        self._cols = cols
        self._rows = rows

        # The grid for the children.
        self._grid = {}
        for i in xrange(self._rows):
            for j in xrange(self._cols):
                self._grid[(i, j)] = None  # None means unused, !None is used.

        # Grid for the layout.
        self._layout = {}
        for i in xrange(self._rows):
            for j in xrange(self._cols):
                self._layout[(i, j)] = ALIGN_NONE

        # Width and height grids.
        self._colwidth = {}
        self._rowheight = {}
        for i in xrange(self._cols):
            self._colwidth[i] = 0
        for i in xrange(self._rows):
            self._rowheight[i] = 0

        self.dirty = True  # Enforce creation of the internals.
Esempio n. 4
0
    def __init__ (self, rows, cols):
        Container.__init__ (self)
        if (type (rows) != int) or (type (cols) != int):
            raise TypeError ("Arguments must be positive integers")
        if (rows <= 0) or (cols <= 0):
            raise ValueError ("Arguments must be positive integers")
        self._cols = cols
        self._rows = rows

        # The grid for the children.
        self._grid = {}
        for i in xrange (self._rows):
            for j in xrange (self._cols):
                self._grid[(i, j)] = None # None means unused, !None is used.

        # Grid for the layout.
        self._layout = {}
        for i in xrange (self._rows):
            for j in xrange (self._cols):
                self._layout[(i, j)] = ALIGN_NONE

        # Width and height grids.
        self._colwidth = {}
        self._rowheight = {}
        for i in xrange (self._cols):
            self._colwidth[i] = 0
        for i in xrange (self._rows):
            self._rowheight[i] = 0

        self.dirty = True # Enforce creation of the internals.
Esempio n. 5
0
 def draw(self, surface):
     if self.visible:
         surface.blit(self.style['bg'], self.position)
         Container.draw(self, surface)
         self.drawHealth(self.player.hp * 2, surface)
         self.drawAmmo((self.player.hp - 50) * 2, surface)
         self.drawItems(surface)
Esempio n. 6
0
    def __init__ (self, js_props={}, props={}):
        Container.__init__ (self)

        self.js_props = js_props.copy()
        self.props    = props.copy()
        self.id       = 'dialog%d'%(self.uniq_id)
        self.title    = self.js_props.pop('title', '')
        self.buttons  = []

        # Defaults
        if 'modal' not in self.js_props:
            self.js_props['modal'] = True
        if 'resizable' not in self.js_props:
            self.js_props['resizable'] = False
        if 'autoOpen' not in self.js_props:
            self.js_props['autoOpen'] = False
        if 'draggable' not in self.js_props:
            self.js_props['draggable'] = False

        # Special cases
        if not self.js_props['autoOpen']:
            if 'class' in self.js_props:
                self.js_props['class'] += ' dialog-hidden'
            else:
                self.js_props['class'] = 'dialog-hidden'

            if 'style' in self.props:
                self.props['style'] += ' display:none;'
            else:
                self.props['style'] = 'display:none;'
Esempio n. 7
0
    def set_children(self, children):
        """T.set_children (...) -> None

        Sets the children of the Table.

        When setting the children of the Table, keep in mind, that the
        children will be added row for row, causing the Table to fill
        the first row of itself, then the second and so on.

        Raises a ValueError, if the passed amount of children exceeds
        the cell amount of the Table.
        """
        if children != None:
            if len(children) > (self.columns * self.rows):
                raise ValueError("children exceed the Table size.")

        # Remove all children first.
        for i in xrange(self._rows):
            for j in xrange(self._cols):
                self.grid[(i, j)] = None
        Container.set_children(self, children)
        if children == None:
            return

        cells = len(children)
        for i in xrange(self._rows):
            for j in xrange(self._cols):
                self.grid[(i, j)] = children[-cells]
                cells -= 1
                if cells == 0:
                    return
Esempio n. 8
0
    def __init__ (self, widget=None):
        Container.__init__ (self)
        self.props = {'id': self.id}
        self._tag  = 'td'

        if widget:
            Container.__iadd__ (self, widget)
Esempio n. 9
0
File: HUD.py Progetto: hmourit/Aleph
 def draw(self, surface):
     if self.visible:
         surface.blit(self.style['bg'], self.position)
         Container.draw(self, surface)
         self.drawHealth(self.player.hp, surface)
         self.drawAmmo(self.player.shield, surface)
         self.drawItems(surface)
Esempio n. 10
0
File: HUD.py Progetto: hmourit/Aleph
 def draw(self, surface):
     if self.visible:
         surface.blit(self.style["bg"], self.position)
         Container.draw(self, surface)
         self.drawHealth(self.player.hp, surface)
         self.drawAmmo(self.player.shield, surface)
         self.drawItems(surface)
Esempio n. 11
0
    def __init__(self, widget=None):
        Container.__init__(self)
        self.props = {'id': self.id}
        self._tag = 'td'

        if widget:
            Container.__iadd__(self, widget)
Esempio n. 12
0
    def __init__(self, dictionary, common_objects_dictionary):
        # The message service, e.g. "Ctl"
        self.service = dictionary['service']
        # The name of the specific message, e.g. "Something"
        self.name = dictionary['name']
        # The specific message ID
        self.id = dictionary['id']

        # The type, which must always be 'Message' or 'Indication'
        self.type = dictionary['type']
        # The version info, optional
        self.version_info = dictionary['version'].split('.') if 'version' in dictionary else []
        self.static = True if 'scope' in dictionary and dictionary['scope'] == 'library-only' else False
        self.abort = True if 'abort' in dictionary and dictionary['abort'] == 'yes' else False

        # libqmi version where the message was introduced
        self.since = dictionary['since'] if 'since' in dictionary else None
        if self.since is None:
            raise ValueError('Message ' + self.name + ' requires a "since" tag specifying the major version where it was introduced')

        # The vendor id if this command is vendor specific
        self.vendor = dictionary['vendor'] if 'vendor' in dictionary else None
        if self.type == 'Indication' and self.vendor is not None:
            raise ValueError('Vendor-specific indications unsupported')

        # The message prefix
        self.prefix = 'Qmi ' + self.type

        # Create the composed full name (prefix + service + name),
        #  e.g. "Qmi Message Ctl Something"
        self.fullname = self.prefix + ' ' + self.service + ' ' + self.name

        # Create the ID enumeration name
        self.id_enum_name = utils.build_underscore_name(self.fullname).upper()

        # Build output container.
        # Every defined message will have its own output container, which
        # will generate a new Output type and public getters for each output
        # field. This applies to both Request/Response and Indications.
        # Output containers are actually optional in Indications
        self.output = Container(self.fullname,
                                'Output',
                                dictionary['output'] if 'output' in dictionary else None,
                                common_objects_dictionary,
                                self.static,
                                self.since)

        self.input = None
        if self.type == 'Message':
            # Build input container (Request/Response only).
            # Every defined message will have its own input container, which
            # will generate a new Input type and public getters for each input
            # field
            self.input = Container(self.fullname,
                                   'Input',
                                   dictionary['input'] if 'input' in dictionary else None,
                                   common_objects_dictionary,
                                   self.static,
                                   self.since)
Esempio n. 13
0
    def draw(self, surface):
        if self.visible:
            surface.blit(self.style['bg'], self.position)
            Container.draw(self, surface)

            self.printTitle(self.title, surface)
            self.printMessage(self.message, surface)
            self.printTooltip(self.tooltip, surface)
Esempio n. 14
0
    def __init__(self, left=0, top=0, width=0, height=0, bg_color=None,
                 fg_color=None, border=None, bd_color=None, bd_width=None):

        Container.__init__(self, left, top, width, height, bg_color, fg_color,
                           border, bd_color, bd_width)

        self.h_margin = 0
        self.v_margin = 0
Esempio n. 15
0
 def draw(self, surface):
     if self.visible:
         surface.blit(self.style['bg'], self.position)
         Container.draw(self, surface)
         
         self.printTitle(self.title, surface)
         self.printMessage(self.message, surface)
         self.printTooltip(self.tooltip, surface)
Esempio n. 16
0
    def __init__(
        self, left=0, top=0, width=0, height=0, bg_color=None, fg_color=None, border=None, bd_color=None, bd_width=None
    ):

        Container.__init__(self, left, top, width, height, bg_color, fg_color, border, bd_color, bd_width)

        self.h_margin = 0
        self.v_margin = 0
Esempio n. 17
0
def container(*args):
    """Returns a container object."""

    if args == ():
        container_instance = Container()
    else:
        container_instance = Container(args[0])
    return container_instance
Esempio n. 18
0
    def destroy (self):
        """F.destroy () -> None

        Destroys the Frame and removes it from its event system.
        """
        if self.widget:
            self.widget.parent = None
        Container.destroy (self)
Esempio n. 19
0
    def __init__(self, submit_url):
        Container.__init__(self)
        self.url = submit_url
        self.id = "submitter%d" % (self.uniq_id)

        # Secure submit
        srv = get_server()
        if srv.use_sec_submit:
            self.url += '?key=%s' % (srv.sec_submit)
Esempio n. 20
0
    def __init__ (self, submit_url):
        Container.__init__ (self)
        self.url = submit_url
        self.id  = "submitter%d" %(self.uniq_id)

        # Secure submit
        srv = get_server()
        if srv.use_sec_submit:
            self.url += '?key=%s' %(srv.sec_submit)
Esempio n. 21
0
    def __init__(self, numboxes=7, text=None, handler=None, type=None,
                 x=None, y=None, width=None, height=None, bg_color=None,
                 fg_color=None, selected_bg_color=None, selected_fg_color=None,
                 border=None, bd_color=None, bd_width=None):

        Container.__init__(self, 'widget', x, y, width, height, bg_color,
                           fg_color, selected_bg_color, selected_fg_color,
                           border, bd_color, bd_width)

        self.h_margin  = 5
        self.v_margin  = 0
        self.h_spacing = 0
        self.v_spacing = 0

        self.text     = text
        self.type     = type
        self.boxes    = []

        self.set_layout(LetterBoxLayout(self))

        bw = 0
        for c in ('M', 'A', 'm', 'W'):
            bw = max(bw, self.content_layout.types['button'].font.stringsize(c),
                     self.content_layout.types['button selected'].font.stringsize(c))

        bw += 2

        l = 0
        h = 0

        for i in range(numboxes or 60):
            lb = LetterBox(width=bw)

            if self.type != 'password':
                if self.text and len(self.text) > i:
                    lb.set_text(self.text[i], fix_case=False)
                else:
                    lb.set_text(' ')
            l = l + lb.width
            h = max(lb.height, h)

            self.add_child(lb)
            if self.boxes:
                lb.upper_case = False
            self.boxes.append(lb)

        self.width  = min(self.width, l + self.bd_width + 2 * self.h_margin)
        self.height = h

        self.set_h_align(Align.CENTER)
        self.last_key = None

        if self.type != 'password' and self.text and len(self.text) < len(self.boxes):
            self.boxes[len(self.text)].toggle_selected()
        else:
            self.boxes[0].toggle_selected()
Esempio n. 22
0
    def __init__(self, numboxes=7, text=None, handler=None, type=None, 
                 x=None, y=None, width=None, height=None, bg_color=None, 
                 fg_color=None, selected_bg_color=None, selected_fg_color=None,
                 border=None, bd_color=None, bd_width=None):

        Container.__init__(self, 'widget', x, y, width, height, bg_color,
                           fg_color, selected_bg_color, selected_fg_color,
                           border, bd_color, bd_width)

        self.h_margin  = 5
        self.v_margin  = 0
        self.h_spacing = 0
        self.v_spacing = 0

        self.text     = text
        self.type     = type
        self.boxes    = []

        self.set_layout(LetterBoxLayout(self))

        bw = 0
        for c in ('M', 'A', 'm', 'W'):
            bw = max(bw, self.content_layout.types['button'].font.stringsize(c),
                     self.content_layout.types['button selected'].font.stringsize(c))

        bw += 2
        
        l = 0
        h = 0

        for i in range(numboxes or 60):
            lb = LetterBox(width=bw)

            if self.type != 'password': 
                if self.text and len(self.text) > i:
                    lb.set_text(self.text[i], fix_case=False)
                else:
                    lb.set_text(' ')
            l = l + lb.width
            h = max(lb.height, h)

            self.add_child(lb)
            if self.boxes:
                lb.upper_case = False
            self.boxes.append(lb)

        self.width  = min(self.width, l + self.bd_width + 2 * self.h_margin)
        self.height = h

        self.set_h_align(Align.CENTER)
        self.last_key = None
        
        if self.type != 'password' and self.text and len(self.text) < len(self.boxes):
            self.boxes[len(self.text)].toggle_selected()
        else:
            self.boxes[0].toggle_selected()
Esempio n. 23
0
    def remove_child (self, widget):
        """T.remove_widget (...) -> None

        Removes a widget from the Table.
        """
        Container.remove_child (self, widget)
        for i in xrange (self._rows):
            for j in xrange (self._cols):
                if self.grid[(i, j)] == widget:
                    self.grid[(i, j)] = None
Esempio n. 24
0
    def _draw(self):
        """
        The actual internal draw function.
        """

        rect = self.content_layout.types['button'].rectangle
        self.surface = self.get_surface()
        self.osd.drawroundbox(0, 0, self.width, self.height, rect.bgcolor, 0,
                              rect.color, 0, self.surface)
        Container._draw(self)
Esempio n. 25
0
	def __init__(self, file_name=None, abstract_relation=None):
		self.code	= Container()
		self.source	= Container()
		self.name	= Container()
		self.sample	= Container()

		self.idx_item = {}

		if file_name is not None:
			self.load(file_name, abstract_relation)
Esempio n. 26
0
    def remove_child(self, widget):
        """T.remove_widget (...) -> None

        Removes a widget from the Table.
        """
        Container.remove_child(self, widget)
        for i in xrange(self._rows):
            for j in xrange(self._cols):
                if self.grid[(i, j)] == widget:
                    self.grid[(i, j)] = None
Esempio n. 27
0
    def draw (self):
        """B.draw () -> None

        Draws the Box surface and places its children on it.
        """
        Container.draw (self)

        blit = self.image.blit
        for widget in self.children:
            blit (widget.image, widget.rect)
Esempio n. 28
0
    def __init__(self, window, **kwargs):
        Container.__init__(self, **kwargs)

        self._window = window
        self._transition_position = 1.0
        self._exiting = False
        self._state = SCREEN_STATES.TRANSITION_ON

        self.TransitionOnTime = 0.0
        self.TransitionOffTime = 0.0
Esempio n. 29
0
    def draw(self):
        """B.draw () -> None

        Draws the Box surface and places its children on it.
        """
        Container.draw(self)

        blit = self.image.blit
        for widget in self.children:
            blit(widget.image, widget.rect)
Esempio n. 30
0
    def __init__ (self, href, content=None, props={}):
        Container.__init__ (self)
        self.href  = href[:]
        self.props = props.copy()

        if 'id' in self.props:
            self.id = self.props.pop('id')

        if content:
            self += content
Esempio n. 31
0
    def _draw(self):
        """
        The actual internal draw function.
        """

        rect = self.content_layout.types['button'].rectangle
        self.surface = self.get_surface()
        self.osd.drawroundbox(0, 0, self.width, self.height, rect.bgcolor, 0, rect.color,
                              0, self.surface)
        Container._draw(self)
Esempio n. 32
0
 def __init__(self, window, **kwargs):
     Container.__init__(self, **kwargs)
     
     self._window = window
     self._transition_position = 1.0
     self._exiting = False
     self._state = SCREEN_STATES.TRANSITION_ON
     
     self.TransitionOnTime = 0.0
     self.TransitionOffTime = 0.0
Esempio n. 33
0
 def __init__(self, filename = '', name = '', template = '', highres_template = '', slideshow_template = '', style_directory = '',
              menu_id = '', title = '', subtitle = '', html_location = '', supplemental_dir = '', description=''):
     CustomContentReference.__init__(self, name, menu_id, title, subtitle, html_location, supplemental_dir, description)
     Container.__init__(self)
     Modifyable.__init__(self)
     self.__filename = filename
     self.__top_level_indexes = []
     self.__xhtml_template = template
     self.__highres_xhtml_template = highres_template
     self.__slideshow_xhtml_template = slideshow_template
     self.__style_directory = style_directory
Esempio n. 34
0
 def __init__(self, director, position, style, visible):
     Container.__init__(self, director, position, style, visible)
     self.button = ImageButton.ImageButton(self.director, (14, 248), style)
     Container.addWidget(self, self.button)
     self.title = 'Title'
     self.message = 'Message'
     self.tooltip = 'Tooltip'
     fullname = os.path.join(Constants.FONTS_DIR, 'neuropolitical.ttf')
     self.titleFont = pygame.font.Font(fullname, 19)
     self.textFont = pygame.font.Font(fullname, 16)
     self.tooltipFont = pygame.font.Font(fullname, 14)
Esempio n. 35
0
    def destroy(self):
        """T.destroy () -> None

        Destroys the Table and all its children and shedules them for
        deletion by the renderer.
        """
        Container.destroy(self)
        del self._grid
        del self._layout
        del self._colwidth
        del self._rowheight
Esempio n. 36
0
 def __init__(self, director, position, style, visible):
     Container.__init__(self, director, position, style, visible)
     self.button = ImageButton.ImageButton(self.director, (14, 248), style)
     Container.addWidget(self, self.button)
     self.title = 'Title'
     self.message = 'Message'
     self.tooltip = 'Tooltip'
     fullname = os.path.join(Constants.FONTS_DIR , 'neuropolitical.ttf')
     self.titleFont = pygame.font.Font(fullname, 19)
     self.textFont = pygame.font.Font(fullname, 16)
     self.tooltipFont = pygame.font.Font(fullname, 14)
Esempio n. 37
0
    def destroy (self):
        """T.destroy () -> None

        Destroys the Table and all its children and shedules them for
        deletion by the renderer.
        """
        Container.destroy (self)
        del self._grid
        del self._layout
        del self._colwidth
        del self._rowheight
Esempio n. 38
0
    def Add (self, widget, props={}):
        assert isinstance(widget, Widget) or widget is None or type(widget) is list

        entry = ListEntry (props.copy())
        if widget:
            if type(widget) == list:
                for w in widget:
                    entry += w
            else:
                entry += widget

        Container.__iadd__ (self, entry)
Esempio n. 39
0
    def draw (self):
        """T.draw () -> None

        Draws the Table surface and places its children on it.
        """
        Container.draw (self)

        # Draw all children.
        self.dispose_widgets ()
        blit = self.image.blit
        for widget in self.children:
            blit (widget.image, widget.rect)
Esempio n. 40
0
    def draw(self):
        """T.draw () -> None

        Draws the Table surface and places its children on it.
        """
        Container.draw(self)

        # Draw all children.
        self.dispose_widgets()
        blit = self.image.blit
        for widget in self.children:
            blit(widget.image, widget.rect)
Esempio n. 41
0
    def __init__(self, name, x, y, doc = 'A linear combination of several variables', *args, **kwds):
        self.x = x
        self.y = y
        self.N = len(self.x)

        if not len(self.y)==len(self.x):
            raise ValueError, 'Arguments x and y must be same length.'

        def eval_fun(x, y):
            out = np.dot(x[0], y[0])
            for i in xrange(1,len(x)):
                out = out + np.dot(x[i], y[i])
            return np.asarray(out).squeeze()

        pm.Deterministic.__init__(self,
                                eval=eval_fun,
                                doc=doc,
                                name = name,
                                parents = {'x':x, 'y':y},
                                *args, **kwds)

        # Tabulate coefficients and offsets of each constituent Stochastic.
        self.coefs = {}
        self.sides = {}

        for s in self.parents.stochastics | self.parents.observed_stochastics:
            self.coefs[s] = []
            self.sides[s] = []

        for i in xrange(self.N):

            stochastic_elem = None

            if isinstance(x[i], pm.Stochastic):

                if x[i] is y[i]:
                    raise ValueError, 'Stochastic %s multiplied by itself in LinearCombination %s.' %(x[i], self)

                stochastic_elem = x[i]
                self.sides[stochastic_elem].append('L')
                this_coef = Lambda('%s_coef'%stochastic_elem, lambda c=y[i]: np.asarray(c))
                self.coefs[stochastic_elem].append(this_coef)

            if isinstance(y[i], pm.Stochastic):

                stochastic_elem = y[i]
                self.sides[stochastic_elem].append('R')
                this_coef = Lambda('%s_coef'%stochastic_elem, lambda c=x[i]: np.asarray(c))
                self.coefs[stochastic_elem].append(this_coef)


        self.sides = Container(self.sides)
        self.coefs = Container(self.coefs)
Esempio n. 42
0
    def __init__(self, **kwargs):
        Identity.__init__(self)
        Container.__init__(self)
        NodeGraph.__init__(self)
        Position.__init__(self)

        self.NumTNode = kwargs.get('NumTNode')
        self.pass_counter = 1

        attr = SharedCounter.Counter
        for _ in range(attr, self.NumTNode + 1):  # For all tensors
            newTensor = TNode(layer=self)  # Create a new instance of tensor
            self.add(newTensor)  # add tensor in Container
Esempio n. 43
0
    def __init__ (self, klass='information', content=None, props={}):
        Container.__init__ (self)

        assert klass in NOTICE_TYPES
        self.props = props.copy()

        if 'class' in self.props:
            self.props['class'] = 'dialog-%s %s'%(klass, self.props['class'])
        else:
            self.props['class'] = 'dialog-%s' %(klass)

        if content:
            self += content
Esempio n. 44
0
    def __init__(self, href=None, content=None, props={}):
        Container.__init__(self)
        if href:
            self.href = href[:]
        else:
            self.href = None
        self.props = props.copy()

        if "id" in self.props:
            self.id = self.props.pop("id")

        if content:
            self += content
Esempio n. 45
0
    def __init__(self, href=None, content=None, props={}):
        Container.__init__(self)
        if href:
            self.href = href[:]
        else:
            self.href = None
        self.props = props.copy()

        if 'id' in self.props:
            self.id = self.props.pop('id')

        if content:
            self += content
Esempio n. 46
0
    def __init__(self, x=None, y=None, width=70, height=25, bg_color=None,
                 border=None, bd_color=None, bd_width=None, full=0):

        Container.__init__(self, 'widget', x, y, width, height, bg_color,
                           0, 0, 0, border, bd_color, bd_width)

        self.h_margin = 2
        self.v_margin = 2
        self.position = 0
        self.full     = full

        self.set_v_align(Align.BOTTOM)
        self.set_h_align(Align.CENTER)
Esempio n. 47
0
    def __init__(self, klass='information', content=None, props={}):
        Container.__init__(self)

        assert klass in NOTICE_TYPES
        self.props = props.copy()

        if 'class' in self.props:
            self.props['class'] = 'dialog-%s %s' % (klass, self.props['class'])
        else:
            self.props['class'] = 'dialog-%s' % (klass)

        if content:
            self += content
Esempio n. 48
0
    def __init__(self, klass="information", content=None, props={}):
        Container.__init__(self)

        assert klass in NOTICE_TYPES
        self.props = props.copy()

        if "class" in self.props:
            self.props["class"] = "dialog-%s %s" % (klass, self.props["class"])
        else:
            self.props["class"] = "dialog-%s" % (klass)

        if content:
            self += content
Esempio n. 49
0
    def Add(self, widget, props={}):
        assert isinstance(widget,
                          Widget) or widget is None or type(widget) is list

        entry = ListEntry(props.copy())
        if widget:
            if type(widget) == list:
                for w in widget:
                    entry += w
            else:
                entry += widget

        Container.__iadd__(self, entry)
def setup_containers(network_name):
    containers = []

    # create some containers with differing attributes

    # alpine is a Linux distribution based on busybox
    alpi = Container('alpi', 'alpine', None,
                     network_name)  # stripped container, no options
    alpi.run([])
    containers.append(alpi)

    alpidetached = Container('alpidetached', 'alpine', None,
                             network_name)  # detached container, no program
    alpidetached.run(['--detach'])
    containers.append(alpidetached)

    alpidetachedtty = Container(
        'alpidetachedtty', 'alpine', None,
        network_name)  # detached container, with tty ssh
    alpidetachedtty.run(['--detach', '-t'])
    containers.append(alpidetachedtty)

    # centos is a Linux distribution based on RedHat
    centosdetached = Container(
        'centosdetached', 'centos', '/bin/bash',
        network_name)  # detached container, running bash
    centosdetached.run(['--detach'])
    containers.append(centosdetached)

    # hello-world is a docker image that just prints hello world
    hw = Container('hw', 'hello-world', None,
                   network_name)  # simple container, runs 'hello-world'
    hw.run([])
    containers.append(hw)

    # nginx is a reverse proxy server
    nginxdetached = Container('nginx', 'nginx', None,
                              network_name)  # opens a proxy
    nginxdetached.run(['--detach'])
    containers.append(nginxdetached)

    # splunk is a fully functional splunk setup (with a web server)
    splunkdetached = Container('splunk', 'splunk/splunk', None,
                               network_name)  # starts a web server
    splunkdetached.run([
        '--detach', '-e', 'SPLUNK_START_ARGS=--accept-license', '-e',
        'SPLUNK_PASSWORD=changeme'
    ])
    containers.append(splunkdetached)

    Container.list_all()
    time.sleep(10)

    return containers
Esempio n. 51
0
 def click_add_dev(self, init=False):
     if not init:
         chosen = self.dev_chosen.get()
         if chosen in self.vsframe.interior.dev_online:
             messagebox.showinfo(title="提示", message='该设备的面板已存在!')
         elif chosen == "请选择要添加的设备":
             messagebox.showinfo(title="提示", message="请选择要添加的设备")
         else:
             Container(self.vsframe.interior, chosen,
                       50).time_chosen.current(0)
             messagebox.showinfo(title="提示", message="成功添加设备: %s" % chosen)
     else:  # when init
         for i in range(len(self.dev_list)):
             Container(self.vsframe.interior, self.dev_list[i],
                       50).time_chosen.current(0)
Esempio n. 52
0
    def __init__(self, **kwargs):
        '''Pass NumLayer=?,NumTensor=?'''

        Identity.__init__(self)
        Container.__init__(self)
        Position.__init__(self)

        self.NumLayers = kwargs.get('NumLayer')
        self.NumTensor = kwargs.get('NumTensor')
        self._Data = None
        # Model Initilization by private functions
        self.__InitLayers()
        self.__ConnectLayers()
        self.__ConnectTensors()
        self.__ConnectWeightsOfTensor()
Esempio n. 53
0
    def _expand(self, value):
        if isinstance(value, basestring):
            if value.startswith('@'):
                # Service
                return self.get_service(value[1:])
            else:
                return Container._expand_parameters(self, value)
        # elif isinstance(value, basestring) and value.startswith('%'):
            # # Parameter
            # return self.get_param(value[1:])
        elif isinstance(value, list):
            # List
            res = []
            for item in value:
                res.append(self._expand(item))
            return res
        elif isinstance(value, dict):
            # Dictionnary
            res = {}
            for key in value:
                res[key] = self._expand(value[key])
            return res

        # Normal value, replace parameters
        return value
Esempio n. 54
0
    def add_child (self, row, col, widget):
        """T.add_child (...) -> None

        Adds a widget into the cell located at (row, col) of the Table.

        Raises a ValueError, if the passed row and col arguments are not
        within the cell range of the Table.
        Raises an Exception, if the cell at the passed row and col
        coordinates is already occupied.
        """
        if (row, col) not in self.grid:
            raise ValueError ("Cell (%d, %d) out of range" % (row, col))
        if self.grid[(row, col)] != None:
            raise Exception ("Cell (%d, %d) already occupied" % (row, col))

        self.grid[(row, col)] = widget
        Container.add_child (self, widget)
Esempio n. 55
0
    def __init__ (self, template=None, headers=None, helps=[], **kwargs):
        Container.__init__ (self, **kwargs)
        self.js_header_end = True

        if headers:
            self._headers = HEADERS + headers
        else:
            self._headers = HEADERS

        if template:
            self._template = template
        else:
            self._template = Template (content = PAGE_TEMPLATE_DEFAULT)

        self._helps = []
        for entry in helps:
            self._helps.append (HelpEntry (entry[1], entry[0]))
Esempio n. 56
0
File: Box.py Progetto: BeQ/webserver
    def __init__ (self, props={}, content=None, embed_javascript=False):
        Container.__init__ (self)
        self.props = props.copy()
        self.embed_javascript = embed_javascript

        # Object ID
        if 'id' in self.props:
            self.id = self.props.pop('id')

        # Initial value
        if content:
            if isinstance (content, Widget):
                self += content
            elif type(content) in (list, type):
                for o in content:
                    self += o
            else:
                raise TypeError, 'Unknown type: "%s"' %(type(content))