MCPcopy Index your code
hub / github.com/rawpython/remi / HBox

Class HBox

remi/gui.py:1908–1965  ·  view source on GitHub ↗

The purpose of this widget is to automatically horizontally aligning the widgets that are appended to it. Does not permit children absolute positioning. In order to add children to this container, use the append(child, key) function. The key have to be numeric and determines the

Source from the content-addressed store, hash-verified

1906
1907
1908class HBox(Container):
1909 """The purpose of this widget is to automatically horizontally aligning
1910 the widgets that are appended to it.
1911 Does not permit children absolute positioning.
1912
1913 In order to add children to this container, use the append(child, key) function.
1914 The key have to be numeric and determines the children order in the layout.
1915
1916 Note: If you would absolute positioning, use the Container instead.
1917 """
1918
1919 def __init__(self, *args, **kwargs):
1920 super(HBox, self).__init__(*args, **kwargs)
1921
1922 # fixme: support old browsers
1923 # http://stackoverflow.com/a/19031640
1924 self.style.update({'display':'flex', 'flex-direction':'row'})
1925 self.style['justify-content'] = self.style.get('justify-content', 'space-around')
1926 self.style['align-items'] = self.style.get('align-items', 'center')
1927
1928 def append(self, value, key=''):
1929 """It allows to add child widgets to this.
1930 The key allows to access the specific child in this way container.children[key].
1931 The key have to be numeric and determines the children order in the layout.
1932
1933 Args:
1934 value (Widget): Child instance to be appended.
1935 key (str): Unique identifier for the child. If key.isdigit()==True '0' '1'.. the value determines the order
1936 in the layout
1937 """
1938 if type(value) in (list, tuple, dict):
1939 if type(value)==dict:
1940 for k in value.keys():
1941 self.append(value[k], k)
1942 return value.keys()
1943 keys = []
1944 for child in value:
1945 keys.append( self.append(child) )
1946 return keys
1947
1948 key = str(key)
1949 if not isinstance(value, Widget):
1950 raise ValueError('value should be a Widget (otherwise use add_child(key,other)')
1951
1952 del value.css_left
1953 del value.css_right
1954
1955 if value.css_order == None:
1956 value.css_position = 'static'
1957 value.css_order = '-1'
1958
1959 if key.isdigit():
1960 value.css_order = key
1961
1962 key = value.identifier if key == '' else key
1963 self.add_child(key, value)
1964
1965 return key

Callers 3

add_field_with_labelMethod · 0.85
add_fieldMethod · 0.85
mainMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected