Beispiel #1
0
 def create_widget(self):
     self.name_input = Input(self, '客户名称', self.name)
     self.name_input.entry['width'] = 60
     self.company_type_input = Input(self, '公司类型', self.company_type)
     self.company_type_input.entry['width'] = 60
     self.company_address_input = Input(self, '注册地址', self.company_address)
     self.company_address_input.entry['width'] = 60
     self.confirm_button = Button(self, text='确定')
     def confirm_button_func():
         save_people_information(self.get_information())
         self.master.refresh_mutilistbox()
         self.destroy()
     self.confirm_button['command'] = confirm_button_func
     self.cancel_button = Button(self, text='取消')
     self.cancel_button['command'] = self.destroy
Beispiel #2
0
    def create_widget(self):
        Input(self, '用户名', self.user).pack(pady=5)
        Password_input(self, '密码', self.password).pack(pady=5)
        self.confirm_button = Button(self, text='确定')
        def login_func(user, password):
            good, user_type = login_model(user, password)
            if good:
                const.user_type = user_type
                const.user_name = self.user.get()
                client_type = ['', '信贷员', '主管', '副行长', '行长']
                self.panel_manager.people.status_frame.set_status_text(('%s(%s)' % (const.user_name, client_type[int(const.user_type)]), '客户信息'))
                self.panel_manager.message.status_frame.set_status_text(('%s(%s)' % (const.user_name, client_type[int(const.user_type)]), '消息中心'))
                self.panel_manager.applys.status_frame.set_status_text(('%s(%s)' % (const.user_name, client_type[int(const.user_type)]), '放款申请'))
                self.panel_manager.switch_panel(self, 'message')
            else:
                self.password.set('')
                MessageBox('错误的用户名/密码', '错误的用户名/密码')

        self.confirm_button['command'] = lambda:login_func(self.user.get(), self.password.get())
        self.confirm_button.pack(pady=5)
Beispiel #3
0
    def create_widget(self):
        self.name_input = Input(self, '客户名称', self.name)
        self.name_input.entry['width'] = 60
        self.company_type_input = Input(self, '公司类型', self.company_type)
        self.company_type_input.entry['width'] = 60
        self.company_address_input = Input(self, '注册地址', self.company_address)
        self.company_address_input.entry['width'] = 60
        self.confirm_button = Button(self, text='确定')

        def confirm_button_func():
            save_people_information(self.get_information())
            self.master.refresh_mutilistbox()
            self.destroy()

        self.confirm_button['command'] = confirm_button_func
        self.cancel_button = Button(self, text='取消')
        self.cancel_button['command'] = self.destroy
Beispiel #4
0
class PeopleInformationToplevel(Toplevel):
    def __init__(self, master , title='添加客户信息'):
        Toplevel.__init__(self)
        self.name = StringVar()
        self.people_type = StringVar()
        self.nation = StringVar()
        self.org_code = StringVar()
        self.check_data = StringVar()
        self.cride_code = StringVar()
        self.signed_data = StringVar()
        self.company_type = StringVar()
        self.company_address = StringVar()
        self.money_type = StringVar()
        self.money_count = StringVar()
        self.company_range = StringVar()
        self.tex_code = StringVar()
        self.tex_type = StringVar()
        self.tex_data = StringVar()
        self.master = master
        self.title(title)
        self.create_widget()
        self.pack_all()

    def get_information(self):
        information_list = []
        information_list.append(self.name.get())
        information_list.append(self.people_type.get())
        information_list.append(self.nation.get())
        information_list.append(self.org_code.get())
        information_list.append(self.check_data.get())
        information_list.append(self.cride_code.get())
        information_list.append(self.signed_data.get())
        information_list.append(self.company_type.get())
        information_list.append(self.company_address.get())
        information_list.append(self.money_type.get())
        information_list.append(self.money_count.get())
        information_list.append(self.company_range.get())
        information_list.append(self.tex_code.get())
        information_list.append(self.tex_type.get())
        information_list.append(self.tex_data.get())
        return map(lambda x:x.strip(), information_list)

    def create_widget(self):
        self.name_input = Input(self, '客户名称', self.name)
        self.name_input.entry['width'] = 60
        self.company_type_input = Input(self, '公司类型', self.company_type)
        self.company_type_input.entry['width'] = 60
        self.company_address_input = Input(self, '注册地址', self.company_address)
        self.company_address_input.entry['width'] = 60
        self.confirm_button = Button(self, text='确定')
        def confirm_button_func():
            save_people_information(self.get_information())
            self.master.refresh_mutilistbox()
            self.destroy()
        self.confirm_button['command'] = confirm_button_func
        self.cancel_button = Button(self, text='取消')
        self.cancel_button['command'] = self.destroy

    def pack_all(self):
        Label(self, text='添加客户信息').grid(row=0, pady=20, columnspan=3 )
        self.name_input.grid(row=1, pady=5, column=0, columnspan=2)
        Label(self, width=10).grid(row=1, column=2)
        Input(self, '机构类型', self.people_type).grid(row=2, pady=5, column=0)
        Input(self, '国别', self.nation).grid(row=2, pady=5, column=1)
        Label(self, text='机构代码信息', anchor='w', width=35).grid(row=3, column=0, pady=10)
        Input(self, '组织机构代码', self.org_code).grid(row=4, pady=5, column=0)
        Input(self, '年检到期日', self.check_data).grid(row=4, pady=5, column=1)
        Label(self, text='注册信息', anchor='w', width=35).grid(row=5, column=0, pady=10)
        Input(self, '营业执照编号', self.cride_code).grid(row=6, pady=5, column=0)
        Input(self, '注册登记日', self.signed_data).grid(row=6, pady=5, column=1)
        self.company_type_input.grid(row=7, pady=5, column=0, columnspan=2)
        self.company_address_input.grid(row=8, pady=5, column=0, columnspan=2)
        Input(self, '注册本金币种', self.money_type).grid(row=9, pady=5, column=0)
        Input(self, '注册资本', self.money_count).grid(row=9, pady=5, column=1)
        Input(self, '经营范围', self.company_range, is_big=True).grid(row=10, pady=5, column=0, columnspan=2)
        Label(self, text='税务信息', anchor='w', width=35).grid(row=11, column=0, pady=10)
        Input(self, '税务登记证件类型', self.tex_type).grid(row=12, pady=5, column=0)
        Input(self, '税务登记证号', self.tex_code).grid(row=12, pady=5, column=1)
        Input(self, '年检到期日', self.tex_data).grid(row=13, pady=5, column=0)
        self.confirm_button.grid(row=14, column=0, pady=10)
        self.cancel_button.grid(row=14, column=1)
Beispiel #5
0
class PeopleInformationToplevel(Toplevel):
    def __init__(self, master, title='添加客户信息'):
        Toplevel.__init__(self)
        self.name = StringVar()
        self.people_type = StringVar()
        self.nation = StringVar()
        self.org_code = StringVar()
        self.check_data = StringVar()
        self.cride_code = StringVar()
        self.signed_data = StringVar()
        self.company_type = StringVar()
        self.company_address = StringVar()
        self.money_type = StringVar()
        self.money_count = StringVar()
        self.company_range = StringVar()
        self.tex_code = StringVar()
        self.tex_type = StringVar()
        self.tex_data = StringVar()
        self.master = master
        self.title(title)
        self.create_widget()
        self.pack_all()

    def get_information(self):
        information_list = []
        information_list.append(self.name.get())
        information_list.append(self.people_type.get())
        information_list.append(self.nation.get())
        information_list.append(self.org_code.get())
        information_list.append(self.check_data.get())
        information_list.append(self.cride_code.get())
        information_list.append(self.signed_data.get())
        information_list.append(self.company_type.get())
        information_list.append(self.company_address.get())
        information_list.append(self.money_type.get())
        information_list.append(self.money_count.get())
        information_list.append(self.company_range.get())
        information_list.append(self.tex_code.get())
        information_list.append(self.tex_type.get())
        information_list.append(self.tex_data.get())
        return map(lambda x: x.strip(), information_list)

    def create_widget(self):
        self.name_input = Input(self, '客户名称', self.name)
        self.name_input.entry['width'] = 60
        self.company_type_input = Input(self, '公司类型', self.company_type)
        self.company_type_input.entry['width'] = 60
        self.company_address_input = Input(self, '注册地址', self.company_address)
        self.company_address_input.entry['width'] = 60
        self.confirm_button = Button(self, text='确定')

        def confirm_button_func():
            save_people_information(self.get_information())
            self.master.refresh_mutilistbox()
            self.destroy()

        self.confirm_button['command'] = confirm_button_func
        self.cancel_button = Button(self, text='取消')
        self.cancel_button['command'] = self.destroy

    def pack_all(self):
        Label(self, text='添加客户信息').grid(row=0, pady=20, columnspan=3)
        self.name_input.grid(row=1, pady=5, column=0, columnspan=2)
        Label(self, width=10).grid(row=1, column=2)
        Input(self, '机构类型', self.people_type).grid(row=2, pady=5, column=0)
        Input(self, '国别', self.nation).grid(row=2, pady=5, column=1)
        Label(self, text='机构代码信息', anchor='w', width=35).grid(row=3,
                                                              column=0,
                                                              pady=10)
        Input(self, '组织机构代码', self.org_code).grid(row=4, pady=5, column=0)
        Input(self, '年检到期日', self.check_data).grid(row=4, pady=5, column=1)
        Label(self, text='注册信息', anchor='w', width=35).grid(row=5,
                                                            column=0,
                                                            pady=10)
        Input(self, '营业执照编号', self.cride_code).grid(row=6, pady=5, column=0)
        Input(self, '注册登记日', self.signed_data).grid(row=6, pady=5, column=1)
        self.company_type_input.grid(row=7, pady=5, column=0, columnspan=2)
        self.company_address_input.grid(row=8, pady=5, column=0, columnspan=2)
        Input(self, '注册本金币种', self.money_type).grid(row=9, pady=5, column=0)
        Input(self, '注册资本', self.money_count).grid(row=9, pady=5, column=1)
        Input(self, '经营范围', self.company_range, is_big=True).grid(row=10,
                                                                  pady=5,
                                                                  column=0,
                                                                  columnspan=2)
        Label(self, text='税务信息', anchor='w', width=35).grid(row=11,
                                                            column=0,
                                                            pady=10)
        Input(self, '税务登记证件类型', self.tex_type).grid(row=12, pady=5, column=0)
        Input(self, '税务登记证号', self.tex_code).grid(row=12, pady=5, column=1)
        Input(self, '年检到期日', self.tex_data).grid(row=13, pady=5, column=0)
        self.confirm_button.grid(row=14, column=0, pady=10)
        self.cancel_button.grid(row=14, column=1)
Beispiel #6
0
 def pack_all(self):
     Label(self, text='添加客户信息').grid(row=0, pady=20, columnspan=3)
     self.name_input.grid(row=1, pady=5, column=0, columnspan=2)
     Label(self, width=10).grid(row=1, column=2)
     Input(self, '机构类型', self.people_type).grid(row=2, pady=5, column=0)
     Input(self, '国别', self.nation).grid(row=2, pady=5, column=1)
     Label(self, text='机构代码信息', anchor='w', width=35).grid(row=3,
                                                           column=0,
                                                           pady=10)
     Input(self, '组织机构代码', self.org_code).grid(row=4, pady=5, column=0)
     Input(self, '年检到期日', self.check_data).grid(row=4, pady=5, column=1)
     Label(self, text='注册信息', anchor='w', width=35).grid(row=5,
                                                         column=0,
                                                         pady=10)
     Input(self, '营业执照编号', self.cride_code).grid(row=6, pady=5, column=0)
     Input(self, '注册登记日', self.signed_data).grid(row=6, pady=5, column=1)
     self.company_type_input.grid(row=7, pady=5, column=0, columnspan=2)
     self.company_address_input.grid(row=8, pady=5, column=0, columnspan=2)
     Input(self, '注册本金币种', self.money_type).grid(row=9, pady=5, column=0)
     Input(self, '注册资本', self.money_count).grid(row=9, pady=5, column=1)
     Input(self, '经营范围', self.company_range, is_big=True).grid(row=10,
                                                               pady=5,
                                                               column=0,
                                                               columnspan=2)
     Label(self, text='税务信息', anchor='w', width=35).grid(row=11,
                                                         column=0,
                                                         pady=10)
     Input(self, '税务登记证件类型', self.tex_type).grid(row=12, pady=5, column=0)
     Input(self, '税务登记证号', self.tex_code).grid(row=12, pady=5, column=1)
     Input(self, '年检到期日', self.tex_data).grid(row=13, pady=5, column=0)
     self.confirm_button.grid(row=14, column=0, pady=10)
     self.cancel_button.grid(row=14, column=1)
Beispiel #7
0
from util import Input

# https://adventofcode.com/2018/day/1


def parse(lines):
    return [int(n) for n in lines]


def find_repeat(deltas):
    seen = set()
    freq = 0

    while True:
        for change in deltas:
            if freq in seen:
                return freq

            seen.add(freq)
            freq += change


changes = parse(Input(1))

# Part 1
print(sum(changes))

# Part 2
print(find_repeat(changes))
Beispiel #8
0
 def fill_application_information(self):
     Input(self, '业务编号', self.number).grid(pady=5, row=0, column=0)
     Input(self, '产品名称', self.product_name).grid(pady=5, row=0, column=1)
     Input(self, '客户编号', self.people_number).grid(pady=5, row=1, column=0)
     Input(self, '客户名称', self.people_name).grid(pady=5, row=1, column=1)
     Input(self, '贷款金额', self.money_count).grid(pady=5, row=2, column=0)
     Input(self, '币种', self.money_type).grid(pady=5, row=2, column=1)
     Input(self, '用途说明', self.intent, is_big=True).grid(pady=5, row=3, columnspan=2)
     Input(self, '还款来源', self.rent_from, is_big=True).grid(pady=5, row=4, columnspan=2)
     Input(self, '贷款投向行业', self.aim_to_subject).grid(pady=5, row=5)
     Input(self, '发放日期', self.start_date).grid(pady=5, row=6, column=0)
     Input(self, '到期日期', self.end_date).grid(pady=5, row=6, column=1)
     Input(self, '期限', self.limit).grid(pady=5, row=7, column=0)
     Input(self, '利率', self.rate).grid(pady=5, row=7, column=1)
     self.confirm_button = Button(self, text='确认')
     def confirm_func():
         apply_information = self.get_information()
         self.master.apply_information_frame.forget()
         self.master.apply_confirm_frame = ApplyConfirm(self.master, apply_information)
         self.master.apply_confirm_frame.pack()
     self.confirm_button['command'] = confirm_func
     self.confirm_button.grid(row=8, column=0)
     self.cancel_button= Button(self, text='取消')
     def cancel_func():
         self.master.apply_information_frame.destroy()
         self.master.people_list_frame.pack()
     self.cancel_button['command'] = cancel_func
     self.cancel_button.grid(row=8, column=1)
Beispiel #9
0
from util import Input
from collections import Counter

# https://adventofcode.com/2018/day/2

# Part 1
words = [s.strip() for s in Input(2)]
doubles = 0
triples = 0

for word in words:
    c = Counter(word)
    if 2 in c.values():
        doubles += 1
    if 3 in c.values():
        triples += 1

print(doubles * triples)


# Part 2
def match(first, second):
    location = -1
    for i, c in enumerate(first):
        if first[i] != second[i]:
            if location != -1:
                return None
            location = i

    return second[:location] + second[location + 1:]
Beispiel #10
0

def predictable_minute(guards):
    guards_favorite_minutes = [(guard.id, guard.minutes.most_common(1)[0])
                               for guard in guards.values() if guard.minutes]
    guard, (minute, count) = max(guards_favorite_minutes, key=lambda x: x[1][1])
    return (guard, minute)

test = ["[1518-11-01 23:58] Guard #99 begins shift",
        "[1518-11-01 00:05] falls asleep",
        "[1518-11-01 00:55] wakes up",
        "[1518-11-02 00:40] falls asleep",
        "[1518-11-01 00:30] falls asleep",
        "[1518-11-02 01:01] wakes up",
        "[1518-11-01 00:00] Guard #10 begins shift",
        "[1518-11-01 00:25] wakes up"]

test_logs = parse(test)
assert test_logs[0].message == 'Guard #10 begins shift'
assert test_logs[-1].message == 'wakes up'

logs = parse(Input(4))
guards = tally_guards(logs)

# Part 1
sleepiest = sleepiest_guard(guards)
print(sleepiest * most_common_minute(guards[sleepiest]))

# Part 2
guard, minute = predictable_minute(guards)
print(guard * minute)
Beispiel #11
0

test_claim_1 = Claim("first", 1, 3, 4, 4)
test_claim_2 = Claim("second", 3, 1, 4, 4)
test_claim_3 = Claim("third", 5, 5, 2, 2)
assert test_claim_1.pixels == [
    '1,3', '1,4', '1,5', '1,6', '2,3', '2,4', '2,5', '2,6', '3,3', '3,4',
    '3,5', '3,6', '4,3', '4,4', '4,5', '4,6'
]
assert test_claim_2.pixels == [
    '3,1', '3,2', '3,3', '3,4', '4,1', '4,2', '4,3', '4,4', '5,1', '5,2',
    '5,3', '5,4', '6,1', '6,2', '6,3', '6,4'
]
assert get_overlaps([test_claim_1, test_claim_2, test_claim_3]) == 4

claims = parse(Input(3))

# Part 1
print(get_overlaps(claims))


# Part 2
def find_overlapless(claims):
    claimed = Counter()

    # Build claim map
    for claim in claims:
        for pixel in claim.pixels:
            claimed[pixel] += 1

    for claim in claims:
Beispiel #12
0
    for x, y in points:
        total += distance((x, y), (j, i))
        if total >= boundary:
            return False
    return True


def mark_safe(grid, points):
    for i, row in enumerate(grid):
        for j, col in enumerate(row):
            if is_safe(i, j, points):
                grid[i][j] = grid[i][j]._replace(safe=True)


text = Input(6).readlines()
points, grid = parse(text)

for point in points:
    flood_fill(grid, point, point)

areas = Counter([item.neighbor for row in grid for item in row])
border_points = get_border_points(grid)
for x, y in border_points:
    del areas[grid[y][x].neighbor]

# Part 1
print(max(areas.values()))

# Part 2
mark_safe(grid, points)
Beispiel #13
0
from util import Input
import string

# https://adventofcode.com/2018/day/5#part2

text = Input(5).read().strip()


def reduce(text):
    polymer = []
    for c in text:
        if polymer and c != polymer[-1] and c.lower() == polymer[-1].lower():
            polymer.pop()
        else:
            polymer.append(c)
    return len(polymer)


# Part 1
print(reduce(text))


# Part 2
def experiment(c):
    candidate = text.replace(c, '')
    candidate = candidate.replace(c.upper(), '')
    return reduce(candidate)


print(min(experiment(c) for c in string.ascii_lowercase))