def __init__(self, cfg): Widget.__init__(self, cfg) self.size = [0, 0] self.bg_surface = None self.trace_surface = None self.dirty_traces = True # Positional self.position = 0 self.range = 1000.0 self.zoom_range = (0, 0) # Bg colour self.colour = [0, 0, 0] # Traces dict self.traces = {} # Viewrect self.view_colour = [0, 255, 0] # Parsing check self.currently_parsing = False self.progress = 0
def __init__(self, client=None, responses=None, default=0, cancel=-1, **kwds): Widget.__init__(self, **kwds) if client or responses: rows = [] w1 = 0 w2 = 0 if client: rows.append(client) w1 = client.width if responses: buttons = Row([ Button(text, action=lambda t=text: self.dismiss(t)) for text in responses]) rows.append(buttons) w2 = buttons.width if w1 < w2: a = 'l' else: a = 'r' contents = Column(rows, align=a) m = self.margin contents.topleft = (m, m) self.add(contents) self.shrink_wrap() if responses and default is not None: self.enter_response = responses[default] if responses and cancel is not None: self.cancel_response = responses[cancel]
def __init__(self, parent, name=None): '''Initialise plotter.''' Widget.__init__(self, parent, name=name) if type(self) == NonOrthFunction: self.readDefaults() self.checker = FunctionChecker()
def __init__(self, surface): global root_widget Widget.__init__(self, surface.get_rect()) self.surface = surface root_widget = self widget.root_widget = self self.is_gl = surface.get_flags() & OPENGL <> 0
def __init__(self, cfg): Widget.__init__(self, cfg) self.size = [0, 0] self.surface = None self.line_col = cfg['globals']['colours']['cha'] self.mode = "line" # line, lines, rectangle are valid self.scale = {"x": 1.0, "y": 1.0} self.offset = {"x": 0.0, "y": 0.0} self.start = {"x": 0, "y": 0} # Pluralities for multiple traces self.offsets = {} self.scales = {} self.line_cols = {} self.sources = {} self.slots = {"colour": False, "offset": False, "order": []} self.slots['colours'] = [[255, 255, 0], [0, 255, 0], [255, 0, 0], [0, 0, 255], [255, 0, 255], [0, 255, 255], [255, 255, 255], [128, 128, 255]] self.alpha = 255 self.markers = {}
def __init__(self, cfg): Widget.__init__(self, cfg) self.size = [0, 0] self.trace_surf = None self.trace_surf_size = None # Scaling and position self.position = 0 # Where the trace starts within the ba self.range = None # Where it ends within relative pos (set in refresh) self.frequency = 100 # Background colour self.colour = [0, 0, 0] # Trace dict self.traces = {} # Grid spacing, because why not? self.grid_spacing = None # If 0, no grid, otherwise; percentage self.grid_list = [] # Only verticals, so this is just x pos's self.grid_labels = [] self.grid_label_font = None self.gutter = 0 self.need_parse = False
def __init__(self, cfg): Widget.__init__(self, cfg) self.toggle_state = True self.cache_type = "dynamic" self.colour = None self.colours = {"default": cfg['globals']['colours']['default']} self.default_colour = None self.size = [0, 0] # Minimum size is c_size * 2 self.img_proto = pygame.image.load("./image/proto.png") self.proto_pos = cfg['globals']['proto_pos']['button'] self.alt_proto_pos = cfg['globals']['proto_pos']['small_button'] self.img_proto.convert_alpha() self.internal_surface = None self.widget_surface = None self.surfaces = {} self.surf_flags = SRCALPHA self.special_flags = BLEND_RGBA_MULT self.strings = {"default": "Default"} self.alterable = True self.c_size = 10 self.alt_c_size = 4 """ STATES """ self.clicked, self.hovered, self.idle = 0, 1, 2 self.held_down = 3
def __init__(self, image_checked, image_unchecked, position=(0, 0), checked=0, callbacks=None): """Initializes the widget. Loads the icons from the passed filenamea.""" # firts call superclass constructor Widget.__init__(self, position, callbacks) # load the icons self.checked = image_checked self.unchecked = image_unchecked # store the default state self.state = checked # set the surface too, so that isInside() has something to check self.surface = self.checked # set our internal callbacks so that we can trap changes self.internal = {widget.MOUSEBUTTONUP: self.toggle} # set the original background to none, is used in the paint method self.original_background = None
def __init__(self, width, upper=None, **kwds): Widget.__init__(self, **kwds) self.set_size_for_text(width) if upper is not None: self.upper = upper self.insertion_point = None self.root = self.get_root()
def __init__(self, surface): global root_widget Widget.__init__(self, surface.get_rect()) self.surface = surface root_widget = self widget.root_widget = self self.is_gl = surface.get_flags() & OPENGL != 0 self.idle_handlers = [] self.dont = False self.shiftClicked = 0 self.shiftPlaced = -2 self.ctrlClicked = 0 self.ctrlPlaced = -2 self.altClicked = 0 self.altPlaced = -2 self.shiftAction = None self.altAction = None self.ctrlAction = None self.editor = None self.selectTool = None self.movementMath = [-1, 1, 1, -1, 1, -1] self.movementNum = [0, 0, 2, 2, 1, 1] self.notMove = [False, False, False, False, False, False] self.usedKeys = [False, False, False, False, False, False] self.cameraMath = [-1., 1., -1., 1.] self.cameraNum = [0, 0, 1, 1] self.notMoveCamera = [False, False, False, False] self.usedCameraKeys = [False, False, False, False]
def __init__(self, image, position=(0, 0), callbacks=None): """Initializes the widget. Loads the icons from the passed filename.""" # firts call superclass constructor Widget.__init__(self, position, callbacks) self.surface = image
def __init__(self, **kwargs): '''Create a slider control Keyword arguments: name -- unique widget identifier min -- minimum value max -- maximum value value -- initial value action -- callback to be invoked when the slider is moved continuous -- if true, invoke action on every movement, else invoke action only when the user releases the mouse button ''' Widget.__init__(self, **kwargs) self._min = kwargs.get('min', 0.0) self._max = kwargs.get('max', 1.0) self._value = kwargs.get('value', 0.5) self.shapes['track'] = Rectangle() self.shapes['knob'] = Rectangle() self.action = kwargs.get('action', None) self._continuous = kwargs.get('continuous', True) self._focused = False
def __init__(self, x=0, y=0, z=0, width=300, height=300, anchor_x='left', anchor_y='bottom', elements=[]): fg = (.5,.5,.5, 1) bg = (.5,.5,.5,.5) Widget.__init__(self,x,y,z,width,height,anchor_x,anchor_y) self.margin = 3 self.ropen = 0 length = len(elements) for i in range(length): elements[i].height = height / length - 2 * self.margin elements[i].width = width - 2 * self.margin elements[i].x = self.margin elements[i].y = (height - self.margin) - (i + 2) * (elements[i].height + self.margin) self._elements[i] = elements[i] self._elements[i]._hidden = True chooselabel = Label(text='...', x=self.margin, y= (height - self.margin) - ( elements[i].height + self.margin), height = height / length - 2 * self.margin, width = width - 2 * self.margin) frame = Rectangle (x=chooselabel.x, y=chooselabel.y + chooselabel.height, z=z, width=chooselabel.width, height=-chooselabel.height, radius=0, foreground=fg, background=bg, anchor_x=anchor_x, anchor_y=anchor_y) self._elements['chooselabel'] = chooselabel self._elements['frame'] = frame
def __init__(self, image, action = None, enable = None, **kwds): if isinstance(image, basestring): image = resource.get_image(image) if image: self.image = image BaseButton.__init__(self, action, enable) Widget.__init__(self, image.get_rect(), **kwds)
def __init__(self, text='Label'): ''' Creates label. ''' self._text = text self._label = cached.Label(text = self._text) Widget.__init__(self) self.style = theme.Label
def __init__(self, id, parent): Widget.__init__(self, id, parent) self._add_widget('histogram_table', HistogramTable) self._add_widget('population_picker', PopulationPicker) self._add_widget('dim_picker', Select) self._add_widget('negative_values_picker', Select) self._add_widget('apply', ApplyButton)
def __init__(self, container, x, y, frame_rate, text, size, color, type="normal", fill=True, anchor_type="topleft"): Widget.__init__(self, container, pygame.Rect(x, y, 0, 0), frame_rate) self.type = type self.lines = [] self.font = get_font(size) self.color = color self.parse_lines(text) self.size = size self.fill = fill self.anchor = (container[0] + x, container[1] + y) self.anchor_type = anchor_type if type == "tooltip": self.rect_absolute.bottomleft = (x, y) self.prepare_text_block()
def __init__(self, rows, row_spacing = 10, column_spacing = 10, **kwds): col_widths = [0] * len(rows[0]) row_heights = [0] * len(rows) for j, row in enumerate(rows): for i, widget in enumerate(row): if widget: col_widths[i] = max(col_widths[i], widget.width) row_heights[j] = max(row_heights[j], widget.height) row_top = 0 for j, row in enumerate(rows): h = row_heights[j] y = row_top + h // 2 col_left = 0 for i, widget in enumerate(row): if widget: w = col_widths[i] x = col_left widget.midleft = (x, y) col_left += w + column_spacing row_top += h + row_spacing width = max(1, col_left - column_spacing) height = max(1, row_top - row_spacing) r = Rect(0, 0, width, height) #print "albow.controls.Grid: r =", r ### #print "...col_widths =", col_widths ### #print "...row_heights =", row_heights ### Widget.__init__(self, r, **kwds) self.add(rows)
def __init__(self, rows, row_spacing=10, column_spacing=10, **kwds): col_widths = [0] * len(rows[0]) row_heights = [0] * len(rows) for j, row in enumerate(rows): for i, widget in enumerate(row): if widget: col_widths[i] = max(col_widths[i], widget.width) row_heights[j] = max(row_heights[j], widget.height) row_top = 0 for j, row in enumerate(rows): h = row_heights[j] y = row_top + h // 2 col_left = 0 for i, widget in enumerate(row): if widget: w = col_widths[i] x = col_left widget.midleft = (x, y) col_left += w + column_spacing row_top += h + row_spacing width = max(1, col_left - column_spacing) height = max(1, row_top - row_spacing) r = Rect(0, 0, width, height) #print "albow.controls.Grid: r =", r ### #print "...col_widths =", col_widths ### #print "...row_heights =", row_heights ### Widget.__init__(self, r, **kwds) self.add(rows)
def __init__(self, x=0, y=0, z=0, width=200, height=10, font_size = 10, anchor_x='left', anchor_y='bottom', value=0.50): Widget.__init__(self,x,y,z,width,height,anchor_x,anchor_y) fg = (1,1,1,1) bg = (1,1,1,.5) frame = Rectangle (x=0, y=0, z=z, width=width, height=height, radius=(height-1)/2, foreground=fg, background=bg, anchor_x=anchor_x, anchor_y=anchor_y) cursor = Ellipse (x=0, y=-.5+height/2, z=z, width=height-1, height=height-1, foreground=fg, background=fg, anchor_x='center', anchor_y='center') label = pyglet.text.Label('0', font_name='Monaco', font_size=8, x=0, y=height+2, anchor_x='center', anchor_y='bottom') self._elements['frame'] = frame self._elements['cursor'] = cursor self._elements['label'] = label self.set_cursor(value) self._is_dragging = False
def __init__(self, items, keysColumn=None, buttonsColumn=None, item_spacing=None): self.items = items self.item_spacing = item_spacing self.keysColumn = keysColumn self.buttonsColumn = buttonsColumn Widget.__init__(self) self.buildWidgets()
def __init__(self, text='Label'): ''' Creates label. ''' self._text = text self._label = cached.Label(text=self._text) Widget.__init__(self) self.style = theme.Label
def __init__(self, x, y, w, **kwargs): '''Create a text input control Keyword arguments: name -- unique widget identifier text -- intitial value action -- callback to be invoked when text is entered ''' Widget.__init__(self, x, y, w, 1, kwargs.get('name')) self.document = pyglet.text.document.UnformattedDocument(kwargs.get('text', '')) self.layout = pyglet.text.layout.IncrementalTextLayout(self.document, w-4, 1, multiline=False) font = self.document.get_font() height = font.ascent - font.descent self.layout.x, self.layout.y = 2, 2 self.caret = pyglet.text.caret.Caret(self.layout) self.elements['layout'] = self.layout self.elements['frame'] = Rectangle() self.action = kwargs.get('action', None) self._focused = False self.caret.visible = False
def __init__(self, pos, mapper, play_char=">"): Widget.__init__(self, pos, 1) self.player = None self.mapper = mapper self.text = None self.play_char = play_char # initial update self.update()
def __init__(self, id, parent): Widget.__init__(self, id, parent) self._add_widget('new_widget_select', Select) self._add_widget('apply_new_widget', ApplyButton) self._add_widget('menu', FreecellMenu) self.widgets_in_chain = [] self.widget_counter = 0
def __init__(self, id, parent): global NETWORKS Widget.__init__(self, id, parent) self._add_widget('dims', Select) self._add_widget('edge_stat', Select) self._add_widget('node_stat', Select) self._add_widget('apply', ApplyButton) self._add_widget('layout', LeftPanel)
def __init__(self, position=(0, 0), size=(1, 1), color=(0, 0, 0, 0)): """Initializes the widget. Loads the icons from the passed filename.""" # firts call superclass constructor Widget.__init__(self, position, None) # create the surface self.surface = pygame.Surface((size[0], size[1]), HWSURFACE).convert()
def __init__(self, cell_size, nrows, ncols, **kwds): """nrows, ncols are for calculating initial size of widget""" Widget.__init__(self, **kwds) self.cell_size = cell_size w, h = cell_size d = 2 * self.margin self.size = (w * ncols + d, h * nrows + d) self.cell_size = cell_size
def __init__(self, pos, idx, level_chars="01234567#"): Widget.__init__(self, pos, 4) self.idx = idx self.audio = None self.text = None self.level_chars = level_chars # first update self.update()
def __init__(self, width, upper=None, **kwds): kwds['doNotTranslate'] = kwds.get('doNotTranslate', True) Widget.__init__(self, **kwds) self.set_size_for_text(width) if upper is not None: self.upper = upper self.insertion_point = None self.root = self.get_root()
def __init__(self, id, parent): Widget.__init__(self, id, parent) self._add_widget('fcs_dir', Input) self._add_widget('fcs_files', Select) self._add_widget('combine_select', Select) self._add_widget('arcsin_factor', Input) self._add_widget('apply', ApplyButton) self.last_selected_dir = None
def __init__(self, client, border_spacing = 0, **kwds): Widget.__init__(self, **kwds) self.client = client self.margin = d = border_spacing + self.border_width w, h = client.rect.size self.rect.size = (w + 2 * d, h + 2 * d) client.rect.topleft = (d, d) self.add(client)
def __init__(self, id, parent): Widget.__init__(self, id, parent) self._add_widget('experiment_select', Select) self._add_widget('apply', ApplyButton) self._add_widget('expander', Expander) self.experiment_to_widgets = {} self.experiment = None self.data = None
def __init__(self, pos, width, text="", align=ALIGN_LEFT, stay_delay=1): Widget.__init__(self, pos, width) self.width = width self.text = text self.align = align self.stay_delay = stay_delay self.scroll = 0 self.stay = 0 self.fwd = False
def __init__(self, image=None, rect=None, **kwds): Widget.__init__(self, rect, **kwds) if image: if isinstance(image, basestring): image = resource.get_image(image) w, h = image.get_size() d = 2 * self.margin self.size = w + d, h + d self._image = image
def __init__(self, area, sprites): Widget.__init__(self, area) self.sprites = sprites self.items = [] self.color = (50, 50, 50) self.margin = 5 self.tab = 40 self.debug = False
def __init__(self, client, border_spacing = None, **kwds): Widget.__init__(self, **kwds) self.client = client if border_spacing is not None: self.margin = self.border_width + border_spacing d = self.margin w, h = client.size self.size = (w + 2 * d, h + 2 * d) client.topleft = (d, d) self.add(client)
def __init__(self, window, rows, cols, y, x, data, color=0): Widget.__init__(self, window, rows, cols, y, x, data, color) self.__cursor_idx = 0 self.__data_idx = 0 self.__page_offset = 0 # the max index that can be shown in listbox (back out borders and zero) self.__max_box_idx = self.rows - 3 self.setdata(data) # calls refresh()
def __init__(self, client, border_spacing=None, **kwds): Widget.__init__(self, **kwds) self.client = client if border_spacing is not None: self.margin = self.border_width + border_spacing d = self.margin w, h = client.size self.size = (w + 2 * d, h + 2 * d) client.topleft = (d, d) self.add(client)
def __init__(self, window, rows, cols, y, x, data, color=0): Widget.__init__(self, window, rows, cols, y, x, data, color) self.__cursor_idx = 0 self.__data_idx = 0 self.__page_offset = 0 # the max index that can be shown in listbox (back out borders and zero) self.__max_box_idx = self.rows-3 self.setdata(data) # calls refresh()
def __init__(self,caption="",selected=False): Widget.__init__(self) self.mCaption=caption self.mSelected=selected self.setFocusable(True) self.addMouseListener(self) self.addKeyListener(self) self.addFocusListener(self) self.adjustSize()
def __init__(self, image, position): self.image = image self.position = position #set width and height if self.image: self.width = self.image.get_size()[0] self.height = self.image.get_size()[1] else: self._setsize((0, 0)) Widget.__init__(self, self.position, (self.width, self.height))
def __init__(self, id, parent): global NETWORKS Widget.__init__(self, id, parent) self._add_widget('network', Select) self._add_widget('edge_stat', Select) self._add_widget('node_stat', Select) self._add_widget('apply', ApplyButton) self._add_widget('layout', LeftPanel) for network in NETWORKS: self._add_widget('graph_%s' % network, Graph) self.network_to_widget = {}