首页 编程教程正文

python编辑图形界面单一功能MAC随机地址生成

piaodoo 编程教程 2020-02-22 22:08:20 905 0 python教程

本文来源吾爱破解论坛

无版权,随便改,单一功能,很好改,可以自己扩展需要随机密码,随机用户名,随机EMAIL名,随机随机~
[Python] 纯文本查看 复制代码

# -*- coding: utf-8 -*-
#@copyright python36
from PyQt5 import QtWidgets,QtCore,QtGui
from sys import argv,exit
from os import system
from datetime import datetime,timedelta
from random import sample

class Ui_MainWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.retranslateUi(self)
        self.codeall=0
        self.codeok=0
        self.todaystr=''
        self.macstr=''

    def setupUi(self, MainWindow):
        MainWindow.resize(365,265)
        MainWindow.setFixedSize(365,265)
        self.centralwidget = QtWidgets.QWidget(MainWindow)

        self.from_dy_btn = QtWidgets.QPushButton(self.centralwidget)
        self.from_dy_btn.setGeometry(QtCore.QRect(10, 50, 75, 30))
        self.from_dy_text = QtWidgets.QTextEdit(self.centralwidget)
        self.from_dy_text.setGeometry(QtCore.QRect(95, 10, 250, 100))

        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(10, 200, 150, 30))

        self.label_codeall = QtWidgets.QLabel(self.centralwidget)
        self.label_codeall.setGeometry(QtCore.QRect(10, 120, 35, 30))

        self.label_codeall_child = QtWidgets.QLabel(self.centralwidget)
        self.label_codeall_child.setGeometry(QtCore.QRect(47, 120, 130, 30))

        self.label_codeok = QtWidgets.QLabel(self.centralwidget)
        self.label_codeok.setGeometry(QtCore.QRect(175, 120, 35, 30))

        self.label_codeok_child = QtWidgets.QLabel(self.centralwidget)
        self.label_codeok_child.setGeometry(QtCore.QRect(212, 120, 130, 30))

        # 左边距, 上边距 ,宽,高
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        MainWindow.setStatusBar(self.statusbar)
        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow","随机数"))

        self.todaystr=(datetime.now()).strftime("%Y-%m-%d %H:%M:%S")
        self.label.setText(_translate("MainWindow",self.todaystr))

        self.label_codeall.setText(_translate("MainWindow","请求数"))
        self.label_codeall_child.setText(_translate("MainWindow","0"))
        self.label_codeok.setText(_translate("MainWindow","处理数"))
        self.label_codeok_child.setText(_translate("MainWindow","0"))

        self.from_dy_btn.setText(_translate("MainWindow","GO"))
        self.from_dy_btn.clicked.connect(self.get_id)
        self.from_dy_text.setPlainText(_translate("MainWindow","随机MAC地址"))

        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.time_go)
        self.timer.start(1000)

    def time_go(self):
        self.todaystr=(datetime.now()).strftime("%Y-%m-%d %H:%M:%S")
        self.label.setText(self.todaystr)

    def get_id(self):
        self.codeall+=1
        self.label_codeall_child.setText(str(self.codeall))
        try:
            Maclist = []
            for i in range(1,7):
                RANDSTR = "".join(sample("0123456789ABCDEF",2))
                Maclist.append(RANDSTR)
            self.macstr="".join(Maclist)
        except Exception:
            self.from_dy_text.setPlainText('get_id: '+str(Exception))
        else:
            self.from_dy_text.setPlainText(self.macstr)
            self.codeok+=1
            self.label_codeok_child.setText(str(self.codeok))

if __name__ =='__main__':
	app = QtWidgets.QApplication(argv)
	MainWindow = QtWidgets.QMainWindow()
	ui = Ui_MainWindow()
	ui.setupUi(MainWindow)
	MainWindow.show()
	exit(app.exec_())

微信截图_20191013145356.png (20.03 KB, 下载次数: 0)

下载附件  保存到相册

2019-10-13 14:56 上传

微信截图_20191013145716.png (18.77 KB, 下载次数: 0)

下载附件  保存到相册

2019-10-13 14:57 上传

版权声明:

本站所有资源均为站长或网友整理自互联网或站长购买自互联网,站长无法分辨资源版权出自何处,所以不承担任何版权以及其他问题带来的法律责任,如有侵权或者其他问题请联系站长删除!站长QQ754403226 谢谢。

有关影视版权:本站只供百度云网盘资源,版权均属于影片公司所有,请在下载后24小时删除,切勿用于商业用途。本站所有资源信息均从互联网搜索而来,本站不对显示的内容承担责任,如您认为本站页面信息侵犯了您的权益,请附上版权证明邮件告知【754403226@qq.com】,在收到邮件后72小时内删除。本文链接:https://www.piaodoo.com/7653.html

搜索