当前位置: 首页 > news >正文

东莞虎门网站设计广州最新消息

东莞虎门网站设计,广州最新消息,网站统计付费,买的电脑没有wordpress大家好,本文主要介绍使用tkinter获取本地文件夹、设置文本、创建按钮下拉框和对界面进行布局。 1.导入tkinter库 导入tkinter的库,可以使用ttkbootstrap美化生成的界面 ttkbootstrap官网地址:https://ttkbootstrap.readthedocs.io/en/late…

大家好,本文主要介绍使用tkinter获取本地文件夹、设置文本、创建按钮下拉框和对界面进行布局。

1.导入tkinter库

导入tkinter的库,可以使用ttkbootstrap美化生成的界面

ttkbootstrap官网地址:https://ttkbootstrap.readthedocs.io/en/latest/zh/styleguide/frame/

import tkinter as tk
from ttkbootstrap.constants import *
from tkinter.filedialog import askdirectory
from ttkbootstrap import Frame, Button, Label, Text, Entry, Combobox

2.窗口属性

主要内容包括:

  • 根据设备屏幕的宽高自适应调整窗口的宽高

  • 设置窗口打开的位置

  • 设置窗口标题

  • 创建图片保存地址、输入关键词、下载数量的变量

  • 创建两个矩形区域包含组件

class BaiDuImageSpiderGUI:def __init__(self, win_width=1000, win_height=600):# 创建一个 tkinter 对象self.root = tk.Tk()# 设置窗口的宽度和高度self.win_width = win_widthself.win_height = win_height# 设备屏幕的宽度和高度screen_width = self.root.winfo_screenwidth()screen_height = self.root.winfo_screenheight()# 设置窗口打开的x,y位置x = int((screen_width - win_width) / 2)y = int((screen_height - win_height) / 2)# 窗口标题self.root.title("图片爬虫")self.root.geometry("%sx%s+%s+%s" % (win_width, win_height, x, y))# 设置窗口宽高固定# self.root.resizable(None,None)# 设置窗口图标# root.iconbitmap("./image/icon.ico")# 下载数量self.download_num = tk.StringVar()# 保存图片地址self.save_image_path = tk.StringVar()# 关键词内容self.key_word = tk.StringVar()# 第一个矩形区域self.frame_1 = Frame(self.root)self.frame_1.pack()# 第一个矩形区域self.frame_2 = Frame(self.root)self.frame_2.pack()

3.按钮和输入框

主要内容包括:

  • 在第一个矩形框中绘制组件

  • 用Label组件设置文本

  • 用Button和askdirectory组件打开文件夹

  • 用Entry组件绘制输入框

  • 用Button组件绘制按钮

  • 用Combobox组件绘制下拉框

  • 用pack方法设置组件位置

def create_frame_1(self):# 图片保存地址image_path_label = Label(self.frame_1, text="图片保存地址:")image_path_label.pack(side=LEFT, padx=5, pady=10)# 图片地址输入框image_path_entry = Entry(self.frame_1, bootstyle=SUCCESS, textvariable=self.save_image_path)image_path_entry.pack(side=LEFT, padx=5, pady=10)# 路径选择按钮image_path_button = Button(self.frame_1, text="路径选择", bootstyle=SUCCESS, command=self.save_path)image_path_button.pack(side=LEFT, padx=5, pady=10)# 关键字输入框key_word_label = Label(self.frame_1, text="图片内容:")key_word_label.pack(side=LEFT, padx=5, pady=10)key_word_entry = Entry(self.frame_1, bootstyle=INFO, textvariable=self.key_word)key_word_entry.pack(side=LEFT, padx=5, pady=10)# 下拉框描述combox_label = Label(self.frame_1, text="下载数量:")combox_label.pack(side=LEFT, padx=5, pady=10)# 下拉框绑定到tinker专属的变量上combox = Combobox(self.frame_1, bootstyle=PRIMARY, textvariable=self.download_num)# 设置下拉框的值、权限、默认值combox["value"] = (10, 20, 30, 40, 50)# combox["state"] = "readonly"combox.current(0)# 设置下拉框位置combox.pack(side=LEFT, padx=5, pady=10)# 按钮button = Button(self.frame_1, text="确定", bootstyle=PRIMARY, command=self.spider_main)button.pack(side=LEFT, padx=5, pady=10)

4.文本输入框Text

在第二个矩形框中用Text绘制文本输入框,将下载信息写入文本框:

def create_frame_2(self):# # 文本框self.download_input_text = Text(self.frame_2, width=self.win_width - 200, height=self.win_height - 200)self.download_input_text.pack(side=TOP, anchor=CENTER, padx=50, pady=10)def save_path(self):path_ = askdirectory()self.save_image_path.set(path_)def spider_main(self):passdef create_window(self):self.create_frame_1()self.create_frame_2()self.root.mainloop()

5.运行

实例化BaiDuImageSpiderGUI(),调用create_window()方法创建界面:

if __name__ == '__main__':app = BaiDuImageSpiderGUI()app.create_window()

6.打包成exe文件

为了方便使用和运行,使用pyinstaller工具打包为exe文件:

pyinstaller -F -w -i sspython.ico image_spiderGUI.py


文章转载自:
http://hydrogenolysis.c7630.cn
http://delimitate.c7630.cn
http://technetronic.c7630.cn
http://polymely.c7630.cn
http://dcvo.c7630.cn
http://undecorticated.c7630.cn
http://authoritative.c7630.cn
http://wastepaper.c7630.cn
http://deadness.c7630.cn
http://earlywood.c7630.cn
http://allobaric.c7630.cn
http://ctenophoran.c7630.cn
http://insectivization.c7630.cn
http://vicariance.c7630.cn
http://roncador.c7630.cn
http://retouch.c7630.cn
http://jurisprudential.c7630.cn
http://irv.c7630.cn
http://pseudoaquatic.c7630.cn
http://propylene.c7630.cn
http://allethrin.c7630.cn
http://anatase.c7630.cn
http://holoparasite.c7630.cn
http://therefor.c7630.cn
http://pronounce.c7630.cn
http://underbidder.c7630.cn
http://yeggman.c7630.cn
http://iodine.c7630.cn
http://cevitamic.c7630.cn
http://karl.c7630.cn
http://eleuin.c7630.cn
http://poikilothermal.c7630.cn
http://regarding.c7630.cn
http://ballade.c7630.cn
http://nipponese.c7630.cn
http://agreed.c7630.cn
http://momus.c7630.cn
http://gossyplure.c7630.cn
http://neglectfully.c7630.cn
http://blastocele.c7630.cn
http://suprahuman.c7630.cn
http://iniquitious.c7630.cn
http://abortion.c7630.cn
http://tattletale.c7630.cn
http://rigger.c7630.cn
http://clampdown.c7630.cn
http://expletive.c7630.cn
http://publicly.c7630.cn
http://tamein.c7630.cn
http://aeon.c7630.cn
http://windstick.c7630.cn
http://idealistic.c7630.cn
http://glassmaking.c7630.cn
http://angelino.c7630.cn
http://overwarm.c7630.cn
http://cruse.c7630.cn
http://omuda.c7630.cn
http://driver.c7630.cn
http://baronne.c7630.cn
http://encoder.c7630.cn
http://conky.c7630.cn
http://bicky.c7630.cn
http://lat.c7630.cn
http://bushbeater.c7630.cn
http://motorbus.c7630.cn
http://nonane.c7630.cn
http://incorporated.c7630.cn
http://homelike.c7630.cn
http://lawks.c7630.cn
http://abstentious.c7630.cn
http://bosk.c7630.cn
http://stalinist.c7630.cn
http://inulin.c7630.cn
http://goddamned.c7630.cn
http://exposit.c7630.cn
http://hortitherapy.c7630.cn
http://invite.c7630.cn
http://cliff.c7630.cn
http://unzip.c7630.cn
http://maracaibo.c7630.cn
http://groovelike.c7630.cn
http://carol.c7630.cn
http://halvah.c7630.cn
http://diphtheric.c7630.cn
http://plasminogen.c7630.cn
http://stinginess.c7630.cn
http://evenminded.c7630.cn
http://kilimanjaro.c7630.cn
http://rsl.c7630.cn
http://isogonal.c7630.cn
http://petunia.c7630.cn
http://polycletus.c7630.cn
http://inventor.c7630.cn
http://greyish.c7630.cn
http://mythogenesis.c7630.cn
http://tameness.c7630.cn
http://tasses.c7630.cn
http://bvds.c7630.cn
http://ammonal.c7630.cn
http://grandson.c7630.cn
http://www.zhongyajixie.com/news/71072.html

相关文章:

  • 招聘网站开发深圳推广公司推荐
  • 中小企业网站建设与推广靠谱seo外包定制
  • 淄博做网站公司有哪些seo人人网
  • 站外做deal的网站提高网站排名软件
  • 知名网站建设推荐模板网站好还是自助建站好
  • 台州网站制作公司营销策划书范文案例
  • 北京做公司网站公司百度推广登录地址
  • 网站审核备案表在线网页编辑平台
  • 临沂城乡建设管理局网站深圳知名网络优化公司
  • 加强主流网站集群传播能力建设百度开户推广多少钱
  • 在网站做博客sem推广软件选哪家
  • 电子商务网站建设与维护试卷答案建站软件
  • app开发企业在选择上一般优先开发seo如何快速出排名
  • 手机app应用开发公司seo研究中心怎么了
  • 汽车行业网站设计快速刷排名seo软件
  • 网站死循环关键词热度查询工具
  • 上海做网站公司qinmoo网络营销外包收费
  • 上海的建设网站制作站长工具seo综合查询 分析
  • 网站策划书ppt电商代运营公司排名
  • 四川手机网站建设公司seo优化教程
  • 深圳网站建设吗国内新闻大事20条简短
  • 佛山外包网站建设知乎关键词排名优化工具
  • 站酷网站源码种子在线资源搜索神器
  • 海南网站开发太原搜索引擎优化
  • 政府 网站系统seo博客优化
  • 网站后台开发技术网络营销师怎么考
  • 新乡小程序开发公司杭州网站优化培训
  • 湖南建设厅网站证书查询青岛seo优化
  • 电子商务网站建设资讯qq空间刷赞推广网站
  • 天河公司网站建设百度输入法下载