alex -顏值打分系統(未完待續)

import tkinter as tk
from tkinter.filedialog import askopenfilename


class ScoreSystem():
    # 新建一個窗口對象
    root = tk.Tk()

    # 設置窗口大小
    root.geometry("800x500")
    # 設置標題
    root.title("顏值打分系統")

    # 設置背景顏色
    canvas = tk.Canvas(
        root,
        width=800,
        height = 500,
        bg = "#E6E8FA"
    )
    canvas.pack()



    def start_interface(self):
        # 設置標籤 Label
        lb = tk.Label(
            self.root,
            text = "顏值打分系統",
            bg = "#6495ED",
            fg="lightpink",
            font=(None,32),
            width = 20,
            height = 2,
        )
        lb.place(x=200, y=10)


        # 打開文件按鈕
        tk.Button(
            self.root,
            text = "打開文件",
            command = self.show_original_pic
        ).place(x=50, y=150)

        # 顏值評分按鈕
        tk.Button(
            self.root,
            text = "顏值評分",
            command = self.open_files2
        ).place(x=50, y=230)

        # 退出軟件按鈕
        tk.Button(
            self.root,
            text = "退出軟件",
            command = self.quit
        ).place(x=50, y=390)

        # 設置標題
        tk.Label(
            self.root,
            text = "原圖",
            font=(None,10),
        ).place(x=380, y=120)

        # 修改圖片大小
        self.label_img_original = tk.Label(self.root)
        # 設置顯示標籤的圖框背景
        self.cv_original = tk.Canvas(self.root, bg="white",width=270,height=270)
        # 顯示圖框邊框
        self.cv_original.create_rectangle(8,8,260,260,width=1,outline="red")
        # 設置位置
        self.cv_original.place(x=255,y=150)
        # 顯示圖片位置
        self.label_img_original.place(x=265,y=150)

        # 顯示評分標籤
        tk.Label(self.root, text="性別",font=10).place(x=680,y=150)
        self.text1=tk.Text(self.root,width=10,height=2).place(x=680,y=175)
        tk.Label(self.root, text="年齡",font=10).place(x=680,y=250)
        self.text1=tk.Text(self.root,width=10,height=2).place(x=680,y=285)
        tk.Label(self.root, text="評分",font=10).place(x=680,y=350)
        self.text1=tk.Text(self.root,width=10,height=2).place(x=680,y=385)

        self.root.mainloop()

    def show_original_pic(self):
        self.path = askopenfilename(title="選擇文件")
        print(self.path)

    def open_files2(self):
        pass

    def quit(self):
        pass


# 通過一個類新建一個對象
scoreSystem = ScoreSystem()
scoreSystem.start_interface()

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章