Exemplo n.º 1
0
def PageTwo():
    window = tk.Tk()
    club_name = simpledialog.askstring(":::club name:::",
                                       "입장하고자 하는 클럽명을 입력해주세요")
    # 클럽명에 따라 manager email 가져오는 함수
    controller = BoardController()
    board_list = controller.get_all_board(club_name)
    if not bool(board_list):
        tkinter.messagebox.showerror("error", "죄송합니다. 해당 클럽은 존재하지 않습니다.")
    else:
        print("deguging gui")
        TopFrame = tk.Frame(window, width=500, height=500)
        TopFrame.pack(side="top")
        BottomFrame = tk.Frame(window, width=500, height=300)
        BottomFrame.pack(side="bottom")

        treeview = ttk.Treeview(
            TopFrame,
            columns=["one", "two"])  #, displaycolumns =["three","two","one"])
        treeview.pack(side="left")

        treeview.column("one", width=350, anchor="center")
        treeview.heading("one", text="작성자", anchor="center")

        treeview.column("two", width=100, anchor="center")
        treeview.heading("two", text="제목", anchor="center")

        controller = BoardController()
        board_list = controller.get_all_board(club_name)
        print(board_list)
        for i, board in enumerate(board_list):
            treeview.insert('',
                            'end',
                            values=(board['title'], board['member_email']))

        label1 = tk.Label(BottomFrame, text="확인하고 싶은 게시판 글의 제목")
        label1.pack(side="left")
        title = tk.StringVar(window)
        entry1 = tk.Entry(BottomFrame, textvariable=title)
        entry1.pack(side="left")
        button = tk.Button(BottomFrame,
                           text="검색",
                           command=lambda: show_text(title.get(), club_name))
        button.pack()
        homebutton = tk.Button(BottomFrame,
                               text="home",
                               command=lambda: to_home(window))
        homebutton.pack(side="right")
        window.mainloop()
Exemplo n.º 2
0
def PageFour():
    try:
        window = tk.Tk()
        club_name = simpledialog.askstring(":::club name:::",
                                           "입장하고자 하는 클럽명을 입력해주세요")
        TopFrame = tk.Frame(window, width=500, height=500)
        TopFrame.pack(side="top")
        BottomFrame = tk.Frame(window, width=500, height=300)
        BottomFrame.pack(side="bottom")
        controller = BoardController()
        board_list = controller.get_all_board(
            club_name)  #`id`, `content`,`title`,`member_email`   반환
        print(board_list)
        title_list = tk.Listbox(TopFrame, selectmode='extended', height=0)
        for i, board in enumerate(board_list):
            board_list.insert(i, board[i]["title"])
        title_list.pack()
        label1 = tk.Label(BottomFrame, text="삭제하고 싶은 게시글의 제목을 적어주세요")
        label1.pack(side="left")
        title = tk.StringVar()
        entry1 = tk.Entry(BottomFrame, textvariable=title)
        entry1.pack(side="left")
        button1 = tk.Button(BottomFrame,
                            text="검색",
                            command=lambda: delete_by_email(title, board_list))
        button1.pack(side="left")
        homebutton = tk.Button(window, text="home", command=to_home(window))
        homebutton.pack()
        window.mainloop()
    except:
        tkinter.messagebox.showerror(
            "error", "error : 죄송합니다. error가 발생했습니다. 빠른 정비 후 찾아뵙도록 하겠습니다.")
Exemplo n.º 3
0
def show_text(title, club_name):
    controller = BoardController()
    board_list = controller.get_all_board(club_name)
    # borad_view(따로 생성한 view창)
    # title만 필요하다.
    # 이거 나중에 title로 검색해서 내용 출력할 예정이다.
    titles = []
    for board in board_list:
        if board["title"] == title:
            titles.append(board["content"])
    if not len(titles):
        tkinter.messagebox.showinfo("::결과창::", "검색한 제목의 글이 없어요")
    else:
        tkinter.messagebox.showinfo("::결과창::", titles)