Tkinter做的小工具有问题
程序需要输入数量,生成等数量的数据,但是总是实现不了,求帮帮看看# -*- coding: utf-8 -*-
"""
Created on Tue Jun9 08:43:46 2020
@author: Roy
"""
import random
from tkinter import *
from tkinter.scrolledtext import ScrolledText
# 建立窗口
window = Tk ()
window.title('个人化数据生成器')
window.geometry('650x450')
# 建立输入栏和按钮
res = IntVar()
entry = Entry(window,width =10,textvariable = res)
entry.grid(row=0,column=1,sticky=W)
text = ScrolledText(window,undo=True)
text.grid(row=4,column=1)
# 定义函数
def get_random():
return random.randint(0,9)
def get_random2():
return random.choice()
#换算后会有0x 0x的现象
def get_random3():
# if len(hex(random.randint(0,255))) >= 4:
a = hex(random.randint(0,255))
if len(a) >= 4:
return a[-2:].upper()
else:
return '0'+a[-1:].upper()
def get_value():
return
def insert_no():
for i in range(get_value()):
a1 = get_random()
a2 = get_random()
a3 = get_random()
a4 = get_random()
b1 = get_random()
b2 = get_random()
b3 = get_random()
b4 = get_random()
c1 = get_random2()
c2 = get_random2()
c3 = get_random2()
c4 = get_random2()
c5 = get_random2()
c6 = get_random2()
c7 = get_random2()
c8 = get_random2()
d1 = get_random3()
d2 = get_random3()
d3 = get_random3()
d4 = get_random3()
d5 = get_random3()
d6 = get_random3()
d7 = get_random3()
d8 = get_random3()
d9 = get_random3()
d10 = get_random3()
d11 = get_random3()
d12 = get_random3()
d13 = get_random3()
d14 = get_random3()
d15 = get_random3()
d16 = get_random3()
e1 = get_random()
e2 = get_random()
e3 = get_random()
e4 = get_random()
e5 = get_random()
e6 = get_random()
e7 = get_random()
e8 = get_random()
f1 = get_random()
f2 = get_random()
f3 = get_random()
f4 = get_random()
f5 = get_random()
f6 = get_random()
f7 = get_random()
f8 = get_random()
# 拼装输出字符,\用来换行交接,\n用来换行
PIN1 = str(a1) + str(a2) + str(a3) + str(a4)
PIN2 = str(b1) + str(b2) + str(b3) + str(b4)
ADM = str(c1) + str(c2) + str(c3) + str(c4) + str(c5) + str(c6) + str(c7) + str(c8)
KI = d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8 + d9 + d10 + d11 + d12 + d13 + d14 + d15 + d16
PUK1 = str(e1) + str(e2) + str(e3) + str(e4) + str(e5) + str(e6) + str(e7) + str(e8)
PUK2 = str(f1) + str(f2) + str(f3) + str(f4) + str(f5) + str(f6) + str(f7) + str(f8)
output ='<--! %sPIN1=@asc({})+'.format(PIN1) + 'f'*8 + ' '*49 +\
'<--! %sPIN2=@asc({})+'.format(PIN2) + 'f'*8 + ' '*49 +\
'<--! %sPUK1=@asc({})'.format(PUK1) + ' '*54 +\
'<--! %sPUK2=@asc({})'.format(PUK2) + ' '*54 +\
'<--! %seki={}'.format(KI) + '\n'*2
# 给输出文本框导入输出数据
# text.insert('insert',output2)
text.insert('insert',output)
button = Button(window,text = '请输入数量',width = 10,command = insert_no())
button.grid(row=1,column=1,sticky=W)
window.mainloop()
为啥不用列表存放呢...这么多行 刚接触一个多星期,还不太懂{:5_108:}····代码可以忽略,如果能帮忙优化和实现那是感激不尽了
页:
[1]