qiyuan -ding talk

# 来写一个窗口
import PIL
import tkinter as ek
from  tkinter.filedialog import askopenfilename
from PIL import Image, ImageTk
import  base64

class da_fen():
    mywindow = ek.Tk()
    mywindow.geometry("888x666")
    mywindow.title("你钉起来真好听")
    # 修改背景色
    canvas = ek.Canvas(mywindow, width=888,height=666,bg="#9400D3")
    canvas.pack()

    def start(self):
        # 按钮: 打开文件
        ek.Button(self.mywindow,text="打开文件",command=self.show_picture).place(x=50,y=150)
        # 按钮: 颜值识别
        ek.Button(self.mywindow,text="颜值识别",command=self.show_picture).place(x=50,y=250)
        # 按钮: 退出软件
        ek.Button(self.mywindow,text="退出软件",command=self.show_picture).place(x=50,y=350)
        # 原图  标签:Label
        ek.Label(self.mywindow,text="原图").place(x=420,y=50)
        ek.Label(self.mywindow,text="性别").place(x=680,y=150)
        ek.Label(self.mywindow,text="颜值").place(x=680,y=250)
        ek.Label(self.mywindow,text="年龄").place(x=680,y=350)

        # 显示图框
        self.label_img = ek.Label(self.mywindow)
        # 显示图框背景
        self.cv_img = ek.Canvas(self.mywindow, bg='white',width=270,height=270)
        # 显示图框边框
        self.cv_img.create_rectangle(8,8,260,260,width=1,outline="red")
        # 设置位置
        self.cv_img.place(x=265,y=150)
        self.label_img.place(x=265,y=150)

        self.text1 = ek.Text(self.mywindow, font=15,width=10,height=2)
        self.text1.place(x=680,y=175)

        self.text2 = ek.Text(self.mywindow, font=15,width=10,height=2)
        self.text2.place(x=680,y=275)

        self.text3 = ek.Text(self.mywindow, font=15, width=10, height=2)
        self.text3.place(x=680, y=375)

        self.mywindow.mainloop()

    def show_picture(self):
        # 1.选择文件
        self.path = askopenfilename(title="选择文件")
        # 2.处理文件
        img = Image.open(fr'{self.path}')
        img = img.resize((270,270),PIL.Image.ANTIALIAS)
        # 生成一张图像
        img_png = ImageTk.PhotoImage(img)
        # 3,。设置图像
        self.label_img.config(image=img_png)
        self.label_img.image=img_png
        self.cv_img.create_image(5,5,anchor="nw",image=img_png) # 船锚

# 通过类新建一个对象

xi_tong = da_fen()
xi_tong.start()




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值