Ejemplo n.º 1
0
    def detach(self):
        render = self.widget.GetCurrentRenderer()
        if render is None:
            return

        if render.HasViewProp(self.repr):
            render.RemoveViewProp(self.repr)
        self.unsubscribe(*self.subscriptions.keys())
        self.widget.SetCurrentRenderer(None)
        self.widget.SetInteractor(None)
        self.widget.Off()
        get_manager(self.interactor).remove_widget(self)
        self.interactor = None
Ejemplo n.º 2
0
 def SetCurrentRenderer(self, renderer):
     """
     The main cause of all this hubbub; need to use the actor_renderer.
     """
     man = get_manager(self._inter)
     self._ren = man.actor_renderer
     self._ren.AddActor(self._actor)
Ejemplo n.º 3
0
 def SetCurrentRenderer(self, renderer):
     """
     The main cause of all this hubbub; need to use the actor_renderer.
     """
     man = get_manager(self._inter)
     self._ren = man.actor_renderer
     self._ren.AddActor(self._actor)
Ejemplo n.º 4
0
 def __init__(self, interactor, widget):
     self.interactor = interactor
     self.widget = widget
     self.widget.SetInteractor(interactor)
     self.repr = widget.GetRepresentation()
     self.subscriptions = {}
     self.manager = get_manager(interactor)
     self.manager.add_widget(self)
     super(Widget, self).__init__()
Ejemplo n.º 5
0
 def __init__(self, interactor, widget):
     self.interactor = interactor
     self.widget = widget
     self.widget.SetInteractor(interactor)
     self.repr = widget.GetRepresentation()
     # By default, VTK will map the 'i' key to activating a widget.
     # This was doing weird things and making buttons disappear.
     self.widget.SetKeyPressActivation(False)
     self.subscriptions = {}
     self.manager = get_manager(interactor)
     self.manager.add_widget(self)
     super(Widget, self).__init__()
Ejemplo n.º 6
0
 def __init__(self, interactor, widget):
     self.interactor = interactor
     self.widget = widget
     self.widget.SetInteractor(interactor)
     self.repr = widget.GetRepresentation()
     # By default, VTK will map the 'i' key to activating a widget.
     # This was doing weird things and making buttons disappear.
     self.widget.SetKeyPressActivation(False)
     self.subscriptions = {}
     self.manager = get_manager(interactor)
     self.manager.add_widget(self)
     super(Widget, self).__init__()
Ejemplo n.º 7
0
        page = pq(page)
        all_link = page.find('a')
        res = {}
        for link in all_link:
            link = pq(link)
            href = link.attr('href')
            if href.startswith('/comic/%s/list_' % type_id):
                if href in res:
                    continue
                res[href] = True
                yield '/%s%s' % (self.app_label, href), link.attr('title')
    
    def get_img(self, type_id, part_id, ct=0):
        server = random.choice(self.pic_host_list)
        img = int(ct) + 1
        url = '%s/Files/Images/%s/%s/imanhua_%03d.jpg' % (server, type_id, part_id, img)
        headers = {
            'Referer' : 'http://www.imanhua.com/comic/%s/list_%s.html' % (type_id, part_id)
        }
        page = get_page(url, headers=headers)
        return page
                
    def get_server(self):
        return self.pic_host_list
    

get_manager('manhua').add(IManHua.host, IManHua)

if __name__ == '__main__':
    app = IManHua()
    app.get_img('2331', '53503', 10)
Ejemplo n.º 8
0
#! /usr/bin/env python
#coding=utf-8
from django.http import HttpResponseRedirect,HttpResponse
from ext.common import render_template
import urlparse
from manager import get_manager

manager = get_manager('manhua')
def trans_to_app(url):
    if not url:
        return None
    urls = urlparse.urlsplit(url)
    if not urls[0].startswith('http'):
        return None
    cls = manager.get(urls[1])
    if not cls:
        return None
    return HttpResponseRedirect('%s%s' % (cls.app_label, urls[2]))
    

def index(request):
    url = request.POST.get('url', '')
    if request.method == 'POST':
        res = trans_to_app(url)
        if res:
            return res
    return render_template(request, 'base.html', {'url' : url})

Ejemplo n.º 9
0
# Create your views here.
from django.http import HttpResponseRedirect, HttpResponse
from ext.common import render_template, render_to_response
from manager import get_manager

app = get_manager('manhua').get_ins('www.imanhua.com')


def comic(request, type_id):
    part_list = app.comic(type_id)
    return render_template(request, 'comic.html', {
        'part_list': part_list,
        'app_label': app.app_label
    })


def comic_part(request, type_id, part_id):
    app_label = app.app_label
    server_list = app.get_server()
    img_list = app.get_img_list(type_id, part_id)
    return render_template(request, 'comic_part.html', locals())


def comic_show(request, type_id, part_id, img_id):
    page = app.get_img(type_id, part_id, img_id)
    return HttpResponse(page, mimetype='image/jpeg')
Ejemplo n.º 10
0
        res = {}
        for link in all_link:
            link = pq(link)
            href = link.attr('href')
            if href.startswith('/comic/%s/list_' % type_id):
                if href in res:
                    continue
                res[href] = True
                yield '/%s%s' % (self.app_label, href), link.attr('title')

    def get_img(self, type_id, part_id, ct=0):
        server = random.choice(self.pic_host_list)
        img = int(ct) + 1
        url = '%s/Files/Images/%s/%s/imanhua_%03d.jpg' % (server, type_id,
                                                          part_id, img)
        headers = {
            'Referer':
            'http://www.imanhua.com/comic/%s/list_%s.html' % (type_id, part_id)
        }
        page = get_page(url, headers=headers)
        return page

    def get_server(self):
        return self.pic_host_list


get_manager('manhua').add(IManHua.host, IManHua)

if __name__ == '__main__':
    app = IManHua()
    app.get_img('2331', '53503', 10)
Ejemplo n.º 11
0
# Create your views here.
from django.http import HttpResponseRedirect,HttpResponse
from ext.common import render_template, render_to_response
from manager import get_manager

app = get_manager('manhua').get_ins('www.imanhua.com')
def comic(request, type_id):
    part_list = app.comic(type_id)
    return render_template(request, 'comic.html', {'part_list' : part_list, 'app_label' : app.app_label})

def comic_part(request, type_id, part_id):
    app_label = app.app_label
    server_list = app.get_server()
    img_list = app.get_img_list(type_id, part_id)
    return render_template(request, 'comic_part.html', locals())


def comic_show(request, type_id, part_id, img_id):
    page = app.get_img(type_id, part_id, img_id)
    return HttpResponse(page, mimetype='image/jpeg')