Ejemplo n.º 1
0
def load_data():
    """从mongo导入数据"""
    data = []
    for user in mongo_collection.find({"appearance": {"$exists": True},
                                       "satisfy": {"$exists": True}}):
        data.append([user.get('appearance', 0),
                     user.get('age', u'0'),
                     user.get('height', u'0'),
                     SALARY.get(user.get('salary', u'0'), u'--'),
                     EDUCATION.get(user.get('education', u'0'), u'--'),
                     SATISFY[user['satisfy']]])
    labels = [u'颜值', u'年龄', u'身高', u'工资', u'学历']
    return data, labels
Ejemplo n.º 2
0
def init():
    """初始化页面"""
    global user, offset, photo, url, buy_house, buy_car, age, height, salary, \
        education, company, industry, school, position, satisfy, appearance
    get_user(offset)
    image_url = u'{}&quality=85&thumbnail=410y410'.format(user['avatar'])
    place_image(image_url)

    photo = Label(master, image=tk_image)
    photo.place(anchor=u'nw', x=10, y=40)
    url = Label(master, text=user['url'], font=Font(size=20, weight='bold'))
    url.place(anchor=u'nw', x=10, y=5)
    buy_house = Label(master, text=BUY_HOUSE.get(user['house']) or user['house'])
    buy_house.place(anchor=u'nw', x=490, y=50)
    buy_car = Label(master, text=BUY_CAR.get(user['car']) or user['car'])
    buy_car.place(anchor=u'nw', x=490, y=75)
    age = Label(master, text=user['age'])
    age.place(anchor=u'nw', x=490, y=100)
    height = Label(master, text=user['height'])
    height.place(anchor=u'nw', x=490, y=125)
    salary = Label(master, text=SALARY.get(user['salary']) or user['salary'])
    salary.place(anchor=u'nw', x=490, y=150)
    education = Label(master, text=EDUCATION.get(user['education']) or user['education'])
    education.place(anchor=u'nw', x=490, y=175)
    company = Label(master, text=user['company'] if user['company'] else u'--')
    company.place(anchor=u'nw', x=490, y=200)
    industry = Label(master, text=INDUSTRY.get(user['industry']) or user['industry'])
    industry.place(anchor=u'nw', x=490, y=225)
    school = Label(master, text=user['school'] if user['school'] else u'--')
    school.place(anchor=u'nw', x=490, y=250)
    position = Label(master, text=POSITION.get(user['position']) or user['position'])
    position.place(anchor=u'nw', x=490, y=275)

    satisfy = IntVar()
    satisfy.set(int(user.get(u'satisfy', -1)))
    satisfied = Radiobutton(master, text=u"满意", variable=satisfy,
                            value=1, command=set_satisfy)
    not_satisfied = Radiobutton(master, text=u"不满意", variable=satisfy,
                                value=0, command=set_satisfy)
    satisfied.place(anchor=u'nw', x=450, y=10)
    not_satisfied.place(anchor=u'nw', x=510, y=10)

    appearance = IntVar()
    appearance.set(int(user.get(u'appearance', -1)))
    for i in range(1, 11):
        score_i = Radiobutton(master, text=str(i), variable=appearance,
                              value=i, command=set_appearance)
        score_i.place(anchor=u'nw', x=i * 40 - 30, y=460)
Ejemplo n.º 3
0
def load_data():
    """从mongo导入数据"""
    data = []
    for user in mongo_collection.find({
            "appearance": {
                "$exists": True
            },
            "satisfy": {
                "$exists": True
            }
    }):
        data.append([
            user.get('appearance', 0),
            user.get('age', u'0'),
            user.get('height', u'0'),
            SALARY.get(user.get('salary', u'0'), u'--'),
            EDUCATION.get(user.get('education', u'0'), u'--'),
            SATISFY[user['satisfy']]
        ])
    labels = [u'颜值', u'年龄', u'身高', u'工资', u'学历']
    return data, labels
Ejemplo n.º 4
0
def update():
    """更新页面"""
    global user, offset, photo, url, buy_house, buy_car, age, height, salary, \
        education, company, industry, school, position, satisfy, appearance
    image_url = u'{}&quality=85&thumbnail=410y410'.format(user['avatar'])
    place_image(image_url)

    print offset

    photo['image'] = tk_image
    url['text'] = user['url']
    buy_house['text'] = BUY_HOUSE.get(user['house']) or user['house']
    buy_car['text'] = BUY_CAR.get(user['car']) or user['car']
    age['text'] = user['age']
    height['text'] = user['height']
    salary['text'] = SALARY.get(user['salary']) or user['salary']
    education['text'] = EDUCATION.get(user['education']) or user['education']
    company['text'] = user['company'] if user['company'] else u'--'
    industry['text'] = INDUSTRY.get(user['industry']) or user['industry']
    school['text'] = user['school'] if user['school'] else u'--'
    position = POSITION.get(user['position']) or user['position']

    satisfy.set(int(user.get(u'satisfy', -1)))
    appearance.set(int(user.get(u'appearance', -1)))
Ejemplo n.º 5
0
def update():
    """更新页面"""
    global user, offset, photo, url, buy_house, buy_car, age, height, salary, \
        education, company, industry, school, position, satisfy, appearance
    image_url = u'{}&quality=85&thumbnail=410y410'.format(user['avatar'])
    place_image(image_url)

    print offset

    photo['image'] = tk_image
    url['text'] = user['url']
    buy_house['text'] = BUY_HOUSE.get(user['house']) or user['house']
    buy_car['text'] = BUY_CAR.get(user['car']) or user['car']
    age['text'] = user['age']
    height['text'] = user['height']
    salary['text'] = SALARY.get(user['salary']) or user['salary']
    education['text'] = EDUCATION.get(user['education']) or user['education']
    company['text'] = user['company'] if user['company'] else u'--'
    industry['text'] = INDUSTRY.get(user['industry']) or user['industry']
    school['text'] = user['school'] if user['school'] else u'--'
    position = POSITION.get(user['position']) or user['position']

    satisfy.set(int(user.get(u'satisfy', -1)))
    appearance.set(int(user.get(u'appearance', -1)))
Ejemplo n.º 6
0
def init():
    """初始化页面"""
    global user, offset, photo, url, buy_house, buy_car, age, height, salary, \
        education, company, industry, school, position, satisfy, appearance
    get_user(offset)
    image_url = u'{}&quality=85&thumbnail=410y410'.format(user['avatar'])
    place_image(image_url)

    photo = Label(master, image=tk_image)
    photo.place(anchor=u'nw', x=10, y=40)
    url = Label(master, text=user['url'], font=Font(size=20, weight='bold'))
    url.place(anchor=u'nw', x=10, y=5)
    buy_house = Label(master,
                      text=BUY_HOUSE.get(user['house']) or user['house'])
    buy_house.place(anchor=u'nw', x=490, y=50)
    buy_car = Label(master, text=BUY_CAR.get(user['car']) or user['car'])
    buy_car.place(anchor=u'nw', x=490, y=75)
    age = Label(master, text=user['age'])
    age.place(anchor=u'nw', x=490, y=100)
    height = Label(master, text=user['height'])
    height.place(anchor=u'nw', x=490, y=125)
    salary = Label(master, text=SALARY.get(user['salary']) or user['salary'])
    salary.place(anchor=u'nw', x=490, y=150)
    education = Label(master,
                      text=EDUCATION.get(user['education'])
                      or user['education'])
    education.place(anchor=u'nw', x=490, y=175)
    company = Label(master, text=user['company'] if user['company'] else u'--')
    company.place(anchor=u'nw', x=490, y=200)
    industry = Label(master,
                     text=INDUSTRY.get(user['industry']) or user['industry'])
    industry.place(anchor=u'nw', x=490, y=225)
    school = Label(master, text=user['school'] if user['school'] else u'--')
    school.place(anchor=u'nw', x=490, y=250)
    position = Label(master,
                     text=POSITION.get(user['position']) or user['position'])
    position.place(anchor=u'nw', x=490, y=275)

    satisfy = IntVar()
    satisfy.set(int(user.get(u'satisfy', -1)))
    satisfied = Radiobutton(master,
                            text=u"满意",
                            variable=satisfy,
                            value=1,
                            command=set_satisfy)
    not_satisfied = Radiobutton(master,
                                text=u"不满意",
                                variable=satisfy,
                                value=0,
                                command=set_satisfy)
    satisfied.place(anchor=u'nw', x=450, y=10)
    not_satisfied.place(anchor=u'nw', x=510, y=10)

    appearance = IntVar()
    appearance.set(int(user.get(u'appearance', -1)))
    for i in range(1, 11):
        score_i = Radiobutton(master,
                              text=str(i),
                              variable=appearance,
                              value=i,
                              command=set_appearance)
        score_i.place(anchor=u'nw', x=i * 40 - 30, y=460)