window.resizeTo()和window.open()的作用

函数:window.resizeTo(width, height)
作用:改变窗口大小到设定的宽和高
参数:width - 宽度像素,必须设定的参数
          height - 高度像素,可选参数
这个高度和宽度指的是整个窗口外框的宽度和高度,包括窗口的标题栏、地址栏、状态栏、边框等等,而不是页面内容的高度和宽度。


函数:window.open(url, name, specs, replace)
作用:打开指定的页面
参数:url - 页面地址,可选参数,默认为about:blank
          name - 可选参数,默认为_blank(打开在新窗口)。也可以设置为_self(打开在自身),_parent(打开在父页面),_top(打开在顶级页面),或者指定一个窗口名称打开。
          specs - 可选参数,可以设置打开的窗口的样式。
                       width - 宽度,像素
                       height - 高度,像素

这个函数中specs参数里面的width和height指的却是网页内容区域的宽度和高度,比网页窗口外框的宽度和高度要小。因此你用 window.open函数打开一个400x300的窗口,然后再用window.resizeTo函数将这个窗口变成400x300尺寸就会发现窗口变小了一点。

如何能使window.open()方法打开一个400x300的窗口,然后再用window.resizeTo函数调整窗口大小的时候窗口不变小。
----------------------------------------------------------------------------------------------------------------------------------------------------------------

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,你可以使用 OpenCV 库对选择的图片进行降噪,然后将处理后的图片传给预测函数进行识别。下面是修改后的代码: ``` import tkinter as tk from tkinter import filedialog from PIL import ImageTk, Image import cv2 import numpy as np # 创建窗口 window = tk.Tk() window.title("宝石预测") window.geometry("400x400") # 加载模型参数 para_state_dict = paddle.load("MyCNN") model = MyCNN() model.set_state_dict(para_state_dict) model.eval() # 加载标签字典 label_dict = train_parameters['label_dict'] # 创建预测函数 def predict(): # 获取待预测图片路径 img_path = filedialog.askopenfilename() # 降噪处理 img = cv2.imread(img_path) img = cv2.fastNlMeansDenoisingColored(img, None, 10, 10, 7, 21) # 预处理图片 img = cv2.resize(img, (224, 224)) img = img.transpose((2, 0, 1)) img = img / 255 img = np.array([img]) # 进行预测 img = paddle.to_tensor(img) out = model(img) label = np.argmax(out.numpy()) result = label_dict[str(label)] # 显示预测结果 result_label.config(text="预测结果:{}".format(result)) # 显示待预测图片 img = ImageTk.PhotoImage(Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)).resize((200, 200))) img_label.config(image=img) img_label.image = img # 创建选择图片按钮 select_button = tk.Button(window, text="选择图片", command=predict) select_button.pack(pady=20) # 创建待预测图片区域 img_label = tk.Label(window) img_label.pack() # 创建预测结果区域 result_label = tk.Label(window, font=("Helvetica", 16)) result_label.pack(pady=20) # 进入消息循环 window.mainloop() ```

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值