tkinter实现项目小工具

简介: tkinter实现项目小工具

一、tkinter实现项目小工具

# coding=utf-8
"""
    @Project :pachong-master 
    @File    :test.py
    @Author  :gaojs
    @Date    :2022/8/6 19:54
    @Blogs   : https://www.gaojs.com.cn
"""
import tkinter
from tkinter import Tk
import tkinter as tk
import sys
import logging
import tkinter.messagebox
import paramiko
from time import sleep
import re
import requests
from faker import Factory
sys.setrecursionlimit(5000)
def create_test_password(sn):
    """
    生成test用户密码
    """
    url = 'http://10.3.0.50/cgi-bin/passwd_res'
    f = Factory.create()
    ua = f.user_agent()
    headers = {
        'User-Agent': ua
    }
    data = {
        'serial': sn
    }
    rsp = requests.post(url=url, headers=headers, data=data)
    passwd = re.findall('password: (.*?)</pre>', rsp.text)[0]
    print(passwd)
    return passwd
t = tk.Tk()
t.title("test账户密码获取平台")
t.geometry('300x150')
t.resizable(0, 0)
var = tk.StringVar()
# 设置账号
li = tk.Label(t, font='Asia')
li.pack()
tk.Label(text='SN码: ', bg='red').place(x=50, y=30)
uname = tk.Entry(t)
uname.place(x=100, y=30)
# 设置密码
# tk.Label(text='密码: ').place(x=50, y=70)
# pwd = tk.Entry(t)
# pwd.place(x=100, y=70)
def login():
    """
    输入sn号,得到test密码
    :return:
    """
    username = uname.get()
    # password = pwd.get()
    pwd_result = create_test_password(username)
    if username == '':
        tk.messagebox.showwarning(title='test账户密码', message='sn码不能为空,请重试!')
    else:
        tk.messagebox.showinfo(title='test账户密码', message=pwd_result)
        print(pwd_result)
tk.Button(text='登录', command=login).place(x=150, y=110)
t.mainloop()

二、效果

1.输入sn码

image.png

2.点击登录---->弹出test账户密码

image.png

3.sn码为空

image.png

相关文章
|
2月前
|
开发框架 开发者 Python
探索Python GUI编程:从Tkinter到PyQt的全方位使用
在当今技术发展日新月异的时代,Python作为一种简洁高效的编程语言,拥有广泛的应用领域。其中,GUI(图形用户界面)编程是Python开发者经常涉足的领域之一。本文将介绍两个常用的Python GUI库——Tkinter和PyQt,并深入探讨其使用方法、特点以及适用场景,帮助读者全面了解Python GUI编程的魅力。
|
2月前
|
存储 Python
Python实战项目(十三)使用 Tkinter GUI 库构建闹钟应用程序
Python实战项目(十三)使用 Tkinter GUI 库构建闹钟应用程序
50 0
|
9月前
|
前端开发 Python
Tkinter的基础使用介绍
Tkinter的基础使用介绍。更多文章请关注个人公众号:python学习杂记
61 0
|
12月前
|
Python
tkinter GUI编程(学习笔记-2 tkinter的常用组件)
tkinter GUI编程(学习笔记-2 tkinter的常用组件)
|
前端开发 测试技术 人机交互
软件测试|超好用超简单的Python GUI库——tkinter(十四)
软件测试|超好用超简单的Python GUI库——tkinter(十四)
113 1
|
前端开发 测试技术 Python
软件测试|超好用超简单的Python GUI库——tkinter(十五)
软件测试|超好用超简单的Python GUI库——tkinter(十五)
99 0
|
数据可视化 测试技术 Python
软件测试|超好用超简单的Python GUI库——tkinter(十六)
软件测试|超好用超简单的Python GUI库——tkinter(十六)
105 0
|
测试技术 Python 内存技术
软件测试|超好用超简单的Python GUI库——tkinter(十二)
软件测试|超好用超简单的Python GUI库——tkinter(十二)
89 0
|
编解码 测试技术 Python
软件测试|超好用超简单的Python GUI库——tkinter(十三)
软件测试|超好用超简单的Python GUI库——tkinter(十三)
90 0
|
测试技术 Python
软件测试|超好用超简单的GUI库——tkinter(三)
软件测试|超好用超简单的GUI库——tkinter(三)
89 0
软件测试|超好用超简单的GUI库——tkinter(三)