def __init__(self, url="", Element=None, **kwargs): if Element is None: Element = DOM.createIFrame() if url: kwargs['Url'] = url self.setElement(Element) Widget.__init__(self, **kwargs)
def __init__(self, pos, text, font, width, center = 0): self.lines = [] words = text.split(' ') start = 0 stop = 0 height = font.get_height() while start < len(words): while (get_item_width(' '.join(words[start:stop]), font) < width and stop < len(words) + 1): stop += 1 l = ' '.join(words[start:stop - 1]) self.lines.append\ (TextLine((pos[0], pos[1] + len(self.lines) * (height + 1)), l, font, Borders(), width, center)) start = stop - 1 Widget.__init__(self, pos, (width, len(self.lines) * (height + 1)))
def __init__(self, titulo="Video"): Widget.__init__(self, titulo) self._html = """ <b class='titulo'>{}</b> <p>{}</p> <div class='visor'> <p>{}</p> <img src='{}' class='hidden'> </div> <div class='btns'> <button class='btn2'>{}</button> </div> """ self.img = "" self.descripcion = """ Sube tu vÃdeo en formato .mp4 y minimiza su tamaño de archivo para obtener mejores resultados. Tu tema recomienda unas dimensiones de 2000 × 1200 pixeles. """ self.btn = "Seleccione vÃdeo" self.btn2 = "Cambiar vÃdeo" self.btn1 = "Eliminar vÃdeo" self.placeholder = "No has seleccionado ningún vÃdeo" self.value = None
def __init__ (self, props=None, content=''): Widget.__init__ (self) self.props = props self.content = content if 'id' in props: self.id = self.props.pop('id')
def __init__(self, element, **kwargs): self.setElement(element) Widget.__init__(self, **kwargs) FocusHandler.__init__(self) KeyboardHandler.__init__(self) ClickHandler.__init__(self) MouseHandler.__init__(self)
def __init__(self, pbuf=None): self.__pbuf = pbuf Widget.__init__(self) if (self.__pbuf): self.set_image(self.__pbuf)
def __init__(self, text, disclosurePanel): Widget.__init__(self) self.disclosurePanel = disclosurePanel self.imageBase = pygwt.getModuleBaseURL() self.root = DOM.createTable() self.tbody = DOM.createTBody() self.tr = DOM.createTR() self.imageTD = DOM.createTD() self.labelTD = DOM.createTD() self.imgElem = DOM.createImg() self.updateState() self.setElement(self.root) DOM.appendChild(self.root, self.tbody) DOM.appendChild(self.tbody, self.tr) DOM.appendChild(self.tr, self.imageTD) DOM.appendChild(self.tr, self.labelTD) DOM.appendChild(self.imageTD, self.imgElem) self.setText(text) disclosurePanel.addEventHandler(self) self.updateState()
def __init__(self, titulo): Widget.__init__(self, titulo) self._html = """ <div> <div class='text'> <span class='help'>?</span> <p>Estas personalizando</p> <h3>{}</h3> <div class='pro'> </div> </div> <div class='info' > <p>{}</p> </div> </div> """ self._help = """ El personalizador te permite tener una vista previa de los cambios de tu sitio antes de publicarlos. Puedes navegar a traves de las distintas páginas de tu sitio sin salir de la vista previa. Se muestran enlaces de editar a algunos elementos que lo apliquen.""" self.proButton = None
def __init__(self, pos, text, font, width, center=0): self.lines = [] words = text.split(' ') start = 0 stop = 0 height = font.get_height() while start < len(words): while (get_item_width(' '.join(words[start:stop]), font) < width and stop < len(words) + 1): stop += 1 l = ' '.join(words[start:stop - 1]) self.lines.append\ (TextLine((pos[0], pos[1] + len(self.lines) * (height + 1)), l, font, Borders(), width, center)) start = stop - 1 Widget.__init__(self, pos, (width, len(self.lines) * (height + 1)))
def __init__(self, titulo="", tabs=3): Widget.__init__(self, titulo) self._html = "" self.target.html("<b class='titulo'></b><div></div>") self.ntabs = tabs self.tabs = [s("<div class='tab'></div>") for i in range(tabs)] self.onlyActiveVisible = True for k, elem in enumerate(self.tabs): s(self.target).find(">div").append(elem) self.tabWidth = 300 self.width = self.tabWidth * tabs self.tabCurrent = 0 self.__titulo = s(self.target).find(">.titulo") self.content = lambda self, k: self.tabs[k] self.__tabs = s(self.target).find(">div").find(">.tab") self.target.find(">.titulo") self.controles = False self.paginacion = False self.height = 500 self.movimiento = 0 self.btn_left = config.base_url + "static/imgs/iconos/arrow-2_blanco.png" self.btn_right = config.base_url + "static/imgs/iconos/arrow_blanco.png" self.clones = 3 self._loop = False self.i = 0
def __init__(self, titulo="tab", descripcion=""): Widget.__init__(self, titulo) self._html = """ <span> <b class='titulo'>{}</b> <span> <span class='descripcion'>{}</span> <span class='switch'> </span> </span> </span> <div class='content'> </div> """ self.img = "" self.descripcion = descripcion self.btn = config.base_url + "static/imgs/iconos/arrow-4.png" self._btn = config.base_url + "static/imgs/iconos/arrow-3.png" self.placeholder = "No se ha elegido una imagen" self.value = {} self.open = False self.height = 0 self.activador = None self.content = lambda self: self.target.find(">.content")
def __init__(self, titulo="Presionar"): Widget.__init__(self, titulo) self.target.html( "<h2 class='titulo'></h2><div class='content'></div><span class='close'>x</span>" ) self.__button = self.target.find(">button") self._html = ""
def __init__(self, titulo=""): Widget.__init__(self,titulo) self._html_tablet=""" <div class='tablet'> <span class='camara'></span> <iframe src='' name=''></iframe> <div class='btns'> <span class='atras'></span> <span class='home'></span> <span class='menu'></span> </div> </div> """ self._html_phone=""" <div class='phone'> <span class='bocina'></span><span class='camara'></span> <iframe src='' name=''></iframe> <div class='btns'> <span class='atras'></span> <span class='home'></span> <span class='menu'></span> </div> </div> """ self.target.html(self._html) self._html="" self.name=self.titulo self.source="" self.primitivo=lambda self:self.target.find("iframe") self.__iframe=self.target.find(">iframe")
def __init__(self, titulo="Arrastra archivos a cualquier lugar para subirlos"): Widget.__init__(self, titulo) self._html = """ <div> <form method='post' enctype='multipart/form-data' action='{}'> <h3>{}</h3> <div>o</div> <input type='file' name='archivo'> {} </form> <iframe name='fileupload' class='hidden'></iframe> </div> """ self.restricciones = """ <p>Tamaño máximo de archivo: 128 MB.</p> <p>Dimensiones de imagen sugeridas: 150 por 150 pÃxeles.</p> """ self.avanzado = False self.activador = True self.automatico = False self.action = "" self.categorias = [] self.tipos = [] self.iframe = ""
def __init__(self, titulo="Barra deslizante"): Widget.__init__(self, titulo) self.orientacion = "horizontal" self.target.html(""" <span class='titulo'></span> <div> <div class='frames'> </div> <div> <div class='barra'> <button class='guia'> </button> </div> </div> </div>""") self.grosor = 10 self.range = [0, 100] self.frames = 10 self.largo = 300 self.presionado = False self.value = 0 self.posInicial = 0 self.__barra = None self.__guia = None self.grosorFrames = 30 self.largo_guia = 20 self.colores = [(43, 118, 255), (0, 255, 30), (255, 0, 0)]
def __init__(self,titulo="Logo"): Widget.__init__(self,titulo) self._html=""" <b class='titulo'>{}</b> <div class='content'> </div> <div class='btns'> <span class='reordenar'>{}</span> <button class='add'>{}</button> </div> <span class='borrar'>{}</span> """ self.img="" self.descripcion="" self.placeholder="No se ha elegido una imagen" self.value={} self.open=False self.height=0 self.children=[] self.backgroundContents="#999" self.content=lambda self: self.target.find(">.content") self.span="Reordenar" self.btn="Añadir items" self.borrar="Borrar"
def setSize(self, size, resetOrigin=True): radius = min(size.x, size.y) self.radius = radius/2 Widget.setSize(self, size, resetOrigin) if radius != 0: self._bigCircle.ratio = (size/sf.Vector2(radius, radius)) self._smallCircle.ratio = (size/sf.Vector2(radius, radius))
def __init__(self, titulo=""): Widget.__init__(self, titulo) self.descripcion = "" self._html = "<b class='titulo'>{}</b><p class='descripcion'>{}</p><textarea></textarea><p class='postdescripcion'></p>" self.postdescripcion s(self.target).css({"display": "inline-block"}) self.value = None
def __init__(self, button_pbuf): """ Creates a new slider with the given pixbuf for the slider. @param button_pbuf: pixbuf for the slider """ # background pbuf self.__background = None # offscreen buffer self.__buffer = None self.__mode = self.HORIZONTAL self.__value = 0.0 self.__button_pbuf = button_pbuf self.__is_dragging = False self.__grab_point = 0 self.__previous_pos = 0 self.__is_active = True # time of last motion self.__last_motion_time = 0 Widget.__init__(self) self.connect_button_pressed(self.__on_press) self.connect_button_released(self.__on_release) self.connect_pointer_moved(self.__on_motion)
def __init__(self,titulo="Gestor de Archivos"): Widget.__init__(self,titulo) self._html=""" <div><b class='titulo'>{}</b><span class='close'>x</span></div> <div class='botonera'> <span class='btn'>{}</span> <span class='btn'>{}</span> </div> <div class='content'> </div> <div> <button class='elegir'>{}</button> </div> """ self.tabsManger=BasicTabs() self.btn1="Subir archivos" self.btn2="Biblioteca Multimedia" self.btn3="Elegir" self.css_selected={"color":"gray", "border":"solid", "border-width":"1px", "border-radius":"12px 12px 0px 0px"} self.css_deselected={"color":"blue","border":"none"} self.url=config.base_url+settings.app+"/admin/Archivos/action=ver" self.archivos=[] self.biblioteca=Biblioteca() self.biblioteca.Media=self self.biblioteca.url=self.url self.activador=None self.value=[]
def __init__(self): # background pixmap self.__bg_pmap = None # progress pixmap self.__progress_pmap = None # list of bookmarks. a bookmark is a position between 0.0 and 1.0 self.__bookmarks = [] # whether the user is currently dragging self.__is_dragging = False # the index of the currently dragged bookmark or -1 self.__dragged_bookmark = -1 self.__dragged_bookmark_pos = 0.0 self.__is_dragging_bookmark = False # the current progress as a value between 0.0 and 1.0 self.__progress = 0 # the current amount, if any self.__amount = 0.0 # the current message if any self.__current_message = "" Widget.__init__(self) self.set_size(180, 64) self.connect_button_pressed(self.__on_button_press) self.connect_button_released(self.__on_button_release) self.connect_pointer_moved(self.__on_motion)
def __init__ (self, name, group=[]): Widget.__init__ (self) self.name = name self.entries = [] for entry in group: self += entry
def __init__(self, titulo="Presionar"): Widget.__init__(self, titulo="Builder-Z") self._html = """ <div class='header'> <div> <b class='titulo'></b> <div> <span class='minimizar'></span> </div> </div> <div class='btns'> <div class='btns-left'> <span class='save'>Guardar libreria</span> <span class='load'>Cargar libreria</span> <span class='clear'>Limpiar layout</span> </div> <div class='btns-right'> <span class='deshacer'></span> <span class='rehacer'></span> <span class='historial'></span> </div> </div> </div> <div class='content'> <span class='add'> Añadir </span> </div> <div class='window'></div> """ self._rows = [] self.window = Window() self.window.Builder = self
def __init__(self, name, group=[]): Widget.__init__(self) self.name = name self.entries = [] for entry in group: self += entry
def __init__(self, titulo=""): Widget.__init__(self,titulo) self._descripcion="" self._html="<b>{}</b><p>{}</p><input>" s(self.target).css({"display":"inline-block"}) self.value=None self.content=None
def __init__(self, props=None, content=''): Widget.__init__(self) self.props = props self.content = content if 'id' in props: self.id = self.props.pop('id')
def __init__(self): self.__title = "" self.__mode = self.MODE_NORMAL Widget.__init__(self) self.connect_clicked(lambda *a:self.emit_event(self.EVENT_MENU)) self.__btn_switch = ImageButton(theme.btn_window_switch_1, theme.btn_window_switch_2) self.__btn_switch.connect_clicked( lambda *a:self.emit_event(self.EVENT_SWITCH)) self.add(self.__btn_switch) self.__btn_close = ImageButton(theme.btn_window_close_1, theme.btn_window_close_2) self.__btn_close.connect_clicked( lambda *a:self.emit_event(self.EVENT_CLOSE)) self.add(self.__btn_close) self.__btn_back = ImageButton(theme.btn_window_back_1, theme.btn_window_back_2) self.__btn_back.connect_clicked( lambda *a:self.emit_event(self.EVENT_CLOSE)) self.add(self.__btn_back) self.__btn_back.set_visible(False)
def __init__(self, titulo): Widget.__init__(self, titulo) self._html = """ <div class='header-top'> <span class='close'> X </span><button name='save'>{}</button> </div> <div class='content'> </div> <div class='footer-bottom'> <span class='ocultar'> <span class='icon'></span> <span class='text'>{}</span> </span> <div class='responsive'> <span class='desktop'></span> <span class='tablet'></span> <span class='phone'></span> </div> </div> """ self.content = lambda self=self: self.target.find(">.content") self.btn_save = "Guardar" self.btn_desing = "Ocultar" self.btn_desktop = config.base_url + "static/imgs/iconos/desktop.png" self.btn_tablet = config.base_url + "static/imgs/iconos/tablet.png" self.btn_phone = config.base_url + "static/imgs/iconos/smartphone.png"
def __init__(self, vertical=False, **kwargs): if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-MenuBar" self.body = None self.items = [] self.parentMenu = None self.popup = None self.selectedItem = None self.shownChildMenu = None self.vertical = False self.autoOpen = False if kwargs.has_key('Element'): table = kwargs.pop('Element') fc = DOM.getFirstChild(table) if fc: self.body = fc else: self.body = DOM.createTBody() DOM.appendChild(table, self.body) else: table = DOM.createTable() self.body = DOM.createTBody() DOM.appendChild(table, self.body) if not vertical: tr = DOM.createTR() DOM.appendChild(self.body, tr) self.vertical = vertical outer = DOM.createDiv() DOM.appendChild(outer, table) self.setElement(outer) Widget.__init__(self, **kwargs)
def __init__(self, titulo=""): Widget.__init__(self, titulo) self._html = """ <div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls blueimp-gallery-display" style="display: block;"> <!-- The container for the modal slides --> <div class="slides" style="width: 15912px;"><div class="slide" data-index="0" style="width: 1326px; left: 0px; transition-duration: 400ms; transform: translate(1326px, 0px) translateZ(0px);"></div><div class="slide" data-index="1" style="width: 1326px; left: -1326px; transition-duration: 400ms; transform: translate(1326px, 0px) translateZ(0px);"></div><div class="slide" data-index="2" style="width: 1326px; left: -2652px; transition-duration: 400ms; transform: translate(1326px, 0px) translateZ(0px);"></div><div class="slide" data-index="3" style="width: 1326px; left: -3978px; transition-duration: 400ms; transform: translate(1326px, 0px) translateZ(0px);"></div><div class="slide" data-index="4" style="width: 1326px; left: -5304px; transition-duration: 0ms; transform: translate(1326px, 0px) translateZ(0px);"><img draggable="false" title="1" src="http://localhost:8000/PTC/apps/occoa/user/static/images/portfolio/5.jpg" class="slide-content"></div><div class="slide" data-index="5" style="width: 1326px; left: -6630px; transition-duration: 0ms; transform: translate(-1326px, 0px) translateZ(0px);"><img draggable="false" title="1" src="http://localhost:8000/PTC/apps/occoa/user/static/images/portfolio/6.jpg" class="slide-content"></div><div class="slide" data-index="6" style="width: 1326px; left: -7956px; transition-duration: 400ms; transform: translate(0px, 0px) translateZ(0px);"><img draggable="false" title="1" src="http://localhost:8000/PTC/apps/occoa/user/static/images/portfolio/7.jpg" class="slide-content"></div><div class="slide" data-index="7" style="width: 1326px; left: -9282px; transition-duration: 400ms; transform: translate(1326px, 0px) translateZ(0px);"><img draggable="false" title="1" src="http://localhost:8000/PTC/apps/occoa/user/static/images/portfolio/8.jpg" class="slide-content"></div><div class="slide" data-index="8" style="width: 1326px; left: -10608px; transition-duration: 400ms; transform: translate(1326px, 0px) translateZ(0px);"><img draggable="false" title="1" src="http://localhost:8000/PTC/apps/occoa/user/static/images/portfolio/9.jpg" class="slide-content"></div><div class="slide" data-index="9" style="width: 1326px; left: -11934px; transition-duration: 400ms; transform: translate(1326px, 0px) translateZ(0px);"></div><div class="slide" data-index="10" style="width: 1326px; left: -13260px; transition-duration: 400ms; transform: translate(1326px, 0px) translateZ(0px);"></div><div class="slide" data-index="11" style="width: 1326px; left: -14586px; transition-duration: 400ms; transform: translate(1326px, 0px) translateZ(0px);"></div></div> <!-- Controls for the borderless lightbox --> <h3 class="title">1</h3> <a class="prev">‹</a> <a class="next">›</a> <a class="close">×</a> <!-- The modal dialog, which will be used to wrap the lightbox content --> </div> """ self._img = config.base_url + "apps/" + settings.app + "/user/static/images/portfolio/1.jpg" self.target.html(self._html) self._html = "" self._enlace = config.base_url + "apps/" + settings.app + "/user/static/images/portfolio/1.jpg"
def __init__(self, is_checked = False): self.__is_checked = is_checked self.__user_may_uncheck = True Widget.__init__(self) self.connect_clicked(self.__on_click)
def __init__(self, key, modules, **kwargs): def key_to_url(key): return ''.join([('_', c)[c in string.letters + string.digits] for c in key]) Widget.__init__(self) # Properties self._key = key self._mods = modules active_name = cfg.get_val(self._key) # URL self._url = '/plugin_content_%s' % (key_to_url(key)) srv = get_server() if srv.use_sec_submit: self._url += '?key=%s' % (srv.sec_submit) # Widgets self.selector_widget = ComboCfg(key, modules) self.plugin = instance_plugin(active_name, key, **kwargs) # Register hidden URL for the plugin content publish(r'^/plugin_content_%s' % (key_to_url(key)), PluginInstanceProxy, key=key, modules=modules, method='POST', **kwargs)
def __init__(self, helps=None): Widget.__init__(self) if not helps: self.helps = [] else: self.helps = helps[:]
def __init__(self, text="", asHTML=False, targetHistoryToken="", Element=None, **kwargs): self.targetHistoryToken = "" if not Element: Element = DOM.createDiv() self.anchorElem = DOM.createAnchor() self.setElement(Element) DOM.appendChild(self.getElement(), self.anchorElem) if not kwargs.has_key('StyleName'): kwargs['StyleName'] = "gwt-Hyperlink" if text: if asHTML: kwargs['HTML'] = text else: kwargs['Text'] = text if targetHistoryToken: kwargs['TargetHistoryToken'] = targetHistoryToken Widget.__init__(self, **kwargs) ClickHandler.__init__(self)
def __init__(self, titulo=""): Widget.__init__(self,titulo) self._html="<b class='titulo'>{}</b>" self.estilos={} self._imagen="img.png" self._btns=[] self._randomBg=False
def __init__ (self, helps=None): Widget.__init__ (self) if not helps: self.helps = [] else: self.helps = helps[:]
def __init__ (self, key, modules, **kwargs): def key_to_url (key): return ''.join ([('_',c)[c in string.letters + string.digits] for c in key]) Widget.__init__ (self) # Properties self._key = key self._mods = modules active_name = cfg.get_val (self._key) # URL self._url = '/plugin_content_%s' %(key_to_url(key)) srv = get_server() if srv.use_sec_submit: self._url += '?key=%s' %(srv.sec_submit) # Widgets self.selector_widget = ComboCfg (key, modules) self.plugin = instance_plugin (active_name, key, **kwargs) # Register hidden URL for the plugin content publish (r'^/plugin_content_%s' %(key_to_url(key)), PluginInstanceProxy, key=key, modules=modules, method='POST', **kwargs)
def __init__(self, parent, **kwargs): Widget.__init__(self, parent) # data self.color = None self.margins = (0, 0, 0, 0) # flags self.processKWArguments(kwargs) parent.registerWidget(self)
def drawWidget(self, draw=True): if self._text: self._text.isDrawing = draw self._textSelect.isDrawing = draw if self._image: self._image.isDrawing = draw self._imageSelect.isDrawing = draw Widget.drawWidget(self, draw)
def __init__(self, parent, **kwargs): Widget.__init__(self, parent) # data self.text = None self.icons = [] # flags self.processKWArguments(kwargs) parent.registerWidget(self)
def onBrowserEvent(self, event): Widget.onBrowserEvent(self, event) type = DOM.eventGetType(event) if type == "load": for listener in self.loadListeners: listener.onLoad(self) elif type == "error": for listener in self.loadListeners: listener.onError(self)
def __init__ (self, props={}): Widget.__init__ (self) self.id = "progressbar_%d" %(self.uniq_id) self.props = props.copy() if 'class' in props: self.props['class'] += ' progressbar' else: self.props['class'] = 'progressbar'
def render(self, super_surface, force = 0): if force or (self.need_render and self.active): Widget.render(self) if self.is_open: for item in self.item_lines: item.render(super_surface, force) else: self.title_line.render(super_surface, force)
def __init__(self, **kwargs): if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-FileUpload" if kwargs.has_key('Element'): element = kwargs.pop('Element') else: element = DOM.createElement("input") DOM.setAttribute(element, "type", "file") self.setElement(element) Widget.__init__(self, **kwargs)
def __init__(self, parent, **kwargs): Widget.__init__(self, parent) # data self.min = 0 self.max = 100 self.value = 0 # flags self.processKWArguments(kwargs) parent.registerWidget(self)
def setPos(self, pos, withOrigin=True): Widget.setPos(self, pos, withOrigin) if self.hasImage: self._image.setPos(self.getPos(False), False) self._imageSelect.setPos(self.getPos(False), False) if self.hasLabel: self._text.setPos(self.getPos(False) + self.size/2) self._textSelect.setPos(self.getPos(False) + self.size/2)
def __init__ (self, _props={}): Widget.__init__ (self) assert 'id' in _props, "Property 'id' must be provided" self.props = _props.copy() self.id = self.props.pop('id') self.url = "/refreshable/%s" %(self.id) self.build_func = None
def __init__ (self, props, options): Widget.__init__ (self) self.props = props.copy() self._options = options if not 'id' in self.props: self.props['id'] = 'Combobox_%s' %(self.uniq_id) self.id = self.props['id']
def __init__(self, parent=None, rect=sf.Rectangle, backgroundColor=sf.Color.BLACK,\ title=str(), backgroundImage=Image()): Widget.__init__(self,parent, rect) self.canFocus = False self._backgroundImage=None self.backgroundColor = backgroundColor self.backgroundImage = backgroundImage self._clipRect = None self._title = title self._currentViewSizeClip = None
def __init__ (self, title, widget, comment, props=None): Widget.__init__ (self) self.title = title self.widget = widget self.comment = comment self.props = ({}, props)[bool(props)] if 'id' in self.props: self.id = self.props.pop('id')
def __init__ (self, props=None): Widget.__init__ (self) if props: self.props = props else: self.props = {} if 'id' in self.props: self.id = self.props.pop('id')
def __init__(self, props=None): Widget.__init__(self) if props: self.props = props else: self.props = {} if "id" in self.props: self.id = self.props.pop("id")
def __init__(self, pos, width, menu_texts, font, menu_width = -1): Widget.__init__(self, pos, (width, font.get_height())) self.menus = [] pos_x = pos[0] for title, items in menu_texts: self.menus.append(Menu(pos, title, items, font, menu_width)) pos_x += self.menus[-1].dim[0] + 1
def test(): a = App() w = Widget() w.text = 'moshe' w.font_size.final=50 a.add_widget(w) a.run()
def __init__ (self, **kwargs): Widget.__init__ (self) self.filename = None self.content = None self.vars = {} if kwargs.has_key('filename'): self.filename = kwargs['filename'] elif kwargs.has_key('content'): self.content = kwargs['content']
def __init__(self, widget=None, **kwargs): # this is all a bit awkward! initialising # stuff that really should be done in Widget.__init__ # allows us to call self.initWidget here and thus # have **kwargs applied afterwards. self.widget = None self.attached = None if widget: self.initWidget(widget) Widget.__init__(self, **kwargs)
def __init__(self, parent=0, path=None, rect=sf.Rectangle()): self._texture = sf.Texture.create(1,1) self._sprite = sf.Sprite(self._texture) self.path = path #The player self.player = Gst.ElementFactory.make("playbin", "player") #Config the video output binVideo = Gst.Bin() videoScale = Gst.ElementFactory.make("videoscale", "videoScale") videoScale.set_property("method", 0) self.videoFilter = Gst.ElementFactory.make("capsfilter", "videoFiltered") videoConvert = Gst.ElementFactory.make("videoconvert", "videoConvert") self.videoSink=Gst.ElementFactory.make("appsink", "videoSink") self.videoSink.set_property("max_buffers", 8) self.videoSink.set_property("drop", True) self.videoSink.set_property("sync", True) self.videoSink.set_property("async", False) self.videoSink.set_property("emit-signals", True) self.videoSink.connect("new-preroll", self.initTexture) videoCaps = Gst.Caps("video/x-raw, format=(string)RGBx") self.videoFilter.set_property("caps", videoCaps) self.videoCaps = Gst.Caps(videoCaps.to_string()) #Add and link the elements to the bin video binVideo.add(videoScale) binVideo.add(self.videoFilter) binVideo.add(videoConvert) binVideo.add(self.videoSink) videoScale.link(self.videoFilter) self.videoFilter.link(videoConvert) videoConvert.link(self.videoSink) pad = videoScale.get_static_pad("sink") ghostPad = Gst.GhostPad.new("sink", pad) binVideo.add_pad(ghostPad) self.player.set_property("video-sink", binVideo) if path: self.player.set_property("uri", Gst.filename_to_uri(path)) self.player.set_state(Gst.State.PLAYING) Widget.__init__(self, parent, rect) self.pos = rect.position self.size = rect.size self._speed = 1 self.requestTime = 10**9*60 self._canSetSpeed = False self.bus = self.player.get_bus() self.streamStart = False