小游戏-种田
目录
小游戏-种田
安装pillow,datetime
安装pillow
安装datetime
main.py
引入库
窗口
数据文档自动读写
数据文档读写
显示图片
部分数据重置
更新数据
浇水施肥
种植小麦或水稻
赚金币
打印数据
金币商城
完整main.py代码
dy.py
引入库
打印函数
完整dy.py代码
jifen.py
引入库
积分商城函数
完整 jifen.py代码
tp.py
小麦图
水稻图
空白
完整tp.py代码
扩展-种田十五位数据码验证
yz.py
文件目录架构
完整代码下载
百度网盘
安装pillow,datetime
安装pillow
pip install pillow
安装datetime
pip install datetime
main.py
引入库
from jifen import *
from tkinter import *
import tkinter as tk
from tp import *
from dy import *
import os
import pickle
import random
import tkinter.messagebox
from PIL import Image,ImageTk
import datetime
import time as t
窗口
# -*- coding: utf-8 -*-
def main():
# 窗口
global nr
window = tk.Tk()
window.title('种田')
window.geometry('600x640')
window.iconbitmap('.\m.ico')
tk.Label(window, text='田地:').place(x=10, y=10)
jbz = StringVar()
tk.Label(window, textvariable=jbz,text='金币:0').place(x=500, y=10)
bt_login = tk.Button(window, text='种麦子', command=mz)
bt_login.place(x=430, y=355)
bt_logquit = tk.Button(window, text='种水稻', command=sd)
bt_logquit.place(x=510, y=355)
bt_logquit = tk.Button(window, text='签到(浇水等)', command=qd)
bt_logquit.place(x=430, y=175)
bt_logquit = tk.Button(window, text='赚金币', command=jb)
bt_logquit.place(x=430, y=265)
bt_logquit = tk.Button(window, text='金币商城', command=jfsc1)
bt_logquit.place(x=510, y=265)
bt_logquit = tk.Button(window, text='打印后台数据', command=dyht)
bt_logquit.place(x=430, y=445)
window.mainloop()
main()
数据文档自动读写
if os.path.exists('./sjk/sjk.px'):
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
print(nr)
else:
nr = {'td': 0,
'lx': 0,
'lb': 0,
'ts': 0,
'jb': 100,
'zjb': 0.1,
'fb': 0}
with open('./sjk/sjk.px', 'wb') as usr_file:
pickle.dump(nr, usr_file)
数据文档读写
def op():
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
print(nr)
def bc():
with open('./sjk/sjk.px', 'wb') as usr_file:
pickle.dump(nr, usr_file)
print(nr)
显示图片
def aa(dz):
op()
global img0
photo = Image.open(dz)
photo = photo.resize((390, 595))
img0 = ImageTk.PhotoImage(photo)
tk.Label(window, image=img0).place(x=10, y=30)
bc()
部分数据重置
def cl():
op()
nr['td'] = 0
nr['lx'] = 0
nr['lb'] = 0
nr['ts'] = 0
nr['fb'] = 0
gx()
bc()
更新数据
def gx():
op()
if nr['td'] != 0:
today = datetime.datetime.today()
yesterday = today - datetime.timedelta(days=1)
yesterday = str(yesterday)
yesterday = yesterday[0:10]
today = str(today)
today = today[0:10]
if (not ((nr['lb'] == 0) or (nr['lb'] == yesterday or nr['lb'] == today))):
tkinter.messagebox.showerror('失败', '你的农作物已死亡!')
cl()
if nr['td'] != 0:
if nr['lx'] == 1:
if nr['ts'] != 0 and nr['ts'] <= 8:
xmt('.\zp\xm\xm' + str(nr['ts']) + '.png', '.\sjk\cs.png')
elif nr['ts'] > 8:
xmt('.\zp\xm\xm8.png', '.\sjk\cs.png')
else:
xmt('.\zp\xm\xm1.png', '.\sjk\cs.png')
else:
if nr['ts'] != 0 and nr['ts'] <= 8:
sdt('.\zp\sd\sd' + str(nr['ts']) + '.png', '.\sjk\cs.png')
elif nr['ts'] > 8:
sdt('.\zp\sd\sd8.png', '.\sjk\sd.png')
else:
sdt('.\zp\sd\sd8.png', '.\sjk\sd.png')
else:
kj('.\sjk\cs.png')
aa('.\sjk\cs.png')
jbz.set('金币:' + str(nr['jb']))
if nr['ts'] == 9:
if (nr['lx'] == 1):
tkinter.messagebox.showinfo('提示', '小麦已成熟,准备收割!')
t.sleep(1)
tkinter.messagebox.showinfo('提示', '小麦收割完毕!')
if (nr['fb'] == 1):
nr['jb'] += 200
else:
nr['jb'] += 100
cl()
else:
tkinter.messagebox.showinfo('提示', '水稻已成熟,准备收割!')
t.sleep(1)
tkinter.messagebox.showinfo('提示', '水稻收割完毕!')
if (nr['fb'] == 1):
nr['jb'] += 160
else:
nr['jb'] += 80
cl()
bc()
浇水施肥
def qd():
op()
if nr['td'] != 0:
# 获取今天(现在时间)
today = datetime.datetime.today()
today = str(today)
today = today[0:10]
if nr['lb'] != today:
nr['lb'] = today
nr['ts'] += 1
tkinter.messagebox.showinfo('提示', '打卡成功!')
else:
tkinter.messagebox.showinfo('提示', '今日你已打卡,明天再来吧!')
gx()
bc()
种植小麦或水稻
def mz():
op()
if nr['td'] == 0:
nr['td'] = 1
nr['lx'] = 1
nr['jb'] -= 10
tkinter.messagebox.showinfo('提示', '种植小麦成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
def sd():
op()
if nr['td'] == 0:
nr['td'] = 1
nr['lx'] = 2
nr['jb'] -= 8
tkinter.messagebox.showinfo('提示', '种植水稻成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
赚金币
pip install pillow
安装datetime
pip install datetime
main.py
引入库
from jifen import *
from tkinter import *
import tkinter as tk
from tp import *
from dy import *
import os
import pickle
import random
import tkinter.messagebox
from PIL import Image,ImageTk
import datetime
import time as t
窗口
# -*- coding: utf-8 -*-
def main():
# 窗口
global nr
window = tk.Tk()
window.title('种田')
window.geometry('600x640')
window.iconbitmap('.\m.ico')
tk.Label(window, text='田地:').place(x=10, y=10)
jbz = StringVar()
tk.Label(window, textvariable=jbz,text='金币:0').place(x=500, y=10)
bt_login = tk.Button(window, text='种麦子', command=mz)
bt_login.place(x=430, y=355)
bt_logquit = tk.Button(window, text='种水稻', command=sd)
bt_logquit.place(x=510, y=355)
bt_logquit = tk.Button(window, text='签到(浇水等)', command=qd)
bt_logquit.place(x=430, y=175)
bt_logquit = tk.Button(window, text='赚金币', command=jb)
bt_logquit.place(x=430, y=265)
bt_logquit = tk.Button(window, text='金币商城', command=jfsc1)
bt_logquit.place(x=510, y=265)
bt_logquit = tk.Button(window, text='打印后台数据', command=dyht)
bt_logquit.place(x=430, y=445)
window.mainloop()
main()
数据文档自动读写
if os.path.exists('./sjk/sjk.px'):
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
print(nr)
else:
nr = {'td': 0,
'lx': 0,
'lb': 0,
'ts': 0,
'jb': 100,
'zjb': 0.1,
'fb': 0}
with open('./sjk/sjk.px', 'wb') as usr_file:
pickle.dump(nr, usr_file)
数据文档读写
def op():
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
print(nr)
def bc():
with open('./sjk/sjk.px', 'wb') as usr_file:
pickle.dump(nr, usr_file)
print(nr)
显示图片
def aa(dz):
op()
global img0
photo = Image.open(dz)
photo = photo.resize((390, 595))
img0 = ImageTk.PhotoImage(photo)
tk.Label(window, image=img0).place(x=10, y=30)
bc()
部分数据重置
def cl():
op()
nr['td'] = 0
nr['lx'] = 0
nr['lb'] = 0
nr['ts'] = 0
nr['fb'] = 0
gx()
bc()
更新数据
def gx():
op()
if nr['td'] != 0:
today = datetime.datetime.today()
yesterday = today - datetime.timedelta(days=1)
yesterday = str(yesterday)
yesterday = yesterday[0:10]
today = str(today)
today = today[0:10]
if (not ((nr['lb'] == 0) or (nr['lb'] == yesterday or nr['lb'] == today))):
tkinter.messagebox.showerror('失败', '你的农作物已死亡!')
cl()
if nr['td'] != 0:
if nr['lx'] == 1:
if nr['ts'] != 0 and nr['ts'] <= 8:
xmt('.\zp\xm\xm' + str(nr['ts']) + '.png', '.\sjk\cs.png')
elif nr['ts'] > 8:
xmt('.\zp\xm\xm8.png', '.\sjk\cs.png')
else:
xmt('.\zp\xm\xm1.png', '.\sjk\cs.png')
else:
if nr['ts'] != 0 and nr['ts'] <= 8:
sdt('.\zp\sd\sd' + str(nr['ts']) + '.png', '.\sjk\cs.png')
elif nr['ts'] > 8:
sdt('.\zp\sd\sd8.png', '.\sjk\sd.png')
else:
sdt('.\zp\sd\sd8.png', '.\sjk\sd.png')
else:
kj('.\sjk\cs.png')
aa('.\sjk\cs.png')
jbz.set('金币:' + str(nr['jb']))
if nr['ts'] == 9:
if (nr['lx'] == 1):
tkinter.messagebox.showinfo('提示', '小麦已成熟,准备收割!')
t.sleep(1)
tkinter.messagebox.showinfo('提示', '小麦收割完毕!')
if (nr['fb'] == 1):
nr['jb'] += 200
else:
nr['jb'] += 100
cl()
else:
tkinter.messagebox.showinfo('提示', '水稻已成熟,准备收割!')
t.sleep(1)
tkinter.messagebox.showinfo('提示', '水稻收割完毕!')
if (nr['fb'] == 1):
nr['jb'] += 160
else:
nr['jb'] += 80
cl()
bc()
浇水施肥
def qd():
op()
if nr['td'] != 0:
# 获取今天(现在时间)
today = datetime.datetime.today()
today = str(today)
today = today[0:10]
if nr['lb'] != today:
nr['lb'] = today
nr['ts'] += 1
tkinter.messagebox.showinfo('提示', '打卡成功!')
else:
tkinter.messagebox.showinfo('提示', '今日你已打卡,明天再来吧!')
gx()
bc()
种植小麦或水稻
def mz():
op()
if nr['td'] == 0:
nr['td'] = 1
nr['lx'] = 1
nr['jb'] -= 10
tkinter.messagebox.showinfo('提示', '种植小麦成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
def sd():
op()
if nr['td'] == 0:
nr['td'] = 1
nr['lx'] = 2
nr['jb'] -= 8
tkinter.messagebox.showinfo('提示', '种植水稻成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
赚金币
pip install datetime
引入库
from jifen import *
from tkinter import *
import tkinter as tk
from tp import *
from dy import *
import os
import pickle
import random
import tkinter.messagebox
from PIL import Image,ImageTk
import datetime
import time as t
窗口
# -*- coding: utf-8 -*-
def main():
# 窗口
global nr
window = tk.Tk()
window.title('种田')
window.geometry('600x640')
window.iconbitmap('.\m.ico')
tk.Label(window, text='田地:').place(x=10, y=10)
jbz = StringVar()
tk.Label(window, textvariable=jbz,text='金币:0').place(x=500, y=10)
bt_login = tk.Button(window, text='种麦子', command=mz)
bt_login.place(x=430, y=355)
bt_logquit = tk.Button(window, text='种水稻', command=sd)
bt_logquit.place(x=510, y=355)
bt_logquit = tk.Button(window, text='签到(浇水等)', command=qd)
bt_logquit.place(x=430, y=175)
bt_logquit = tk.Button(window, text='赚金币', command=jb)
bt_logquit.place(x=430, y=265)
bt_logquit = tk.Button(window, text='金币商城', command=jfsc1)
bt_logquit.place(x=510, y=265)
bt_logquit = tk.Button(window, text='打印后台数据', command=dyht)
bt_logquit.place(x=430, y=445)
window.mainloop()
main()
数据文档自动读写
if os.path.exists('./sjk/sjk.px'):
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
print(nr)
else:
nr = {'td': 0,
'lx': 0,
'lb': 0,
'ts': 0,
'jb': 100,
'zjb': 0.1,
'fb': 0}
with open('./sjk/sjk.px', 'wb') as usr_file:
pickle.dump(nr, usr_file)
数据文档读写
def op():
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
print(nr)
def bc():
with open('./sjk/sjk.px', 'wb') as usr_file:
pickle.dump(nr, usr_file)
print(nr)
显示图片
def aa(dz):
op()
global img0
photo = Image.open(dz)
photo = photo.resize((390, 595))
img0 = ImageTk.PhotoImage(photo)
tk.Label(window, image=img0).place(x=10, y=30)
bc()
部分数据重置
def cl():
op()
nr['td'] = 0
nr['lx'] = 0
nr['lb'] = 0
nr['ts'] = 0
nr['fb'] = 0
gx()
bc()
更新数据
def gx():
op()
if nr['td'] != 0:
today = datetime.datetime.today()
yesterday = today - datetime.timedelta(days=1)
yesterday = str(yesterday)
yesterday = yesterday[0:10]
today = str(today)
today = today[0:10]
if (not ((nr['lb'] == 0) or (nr['lb'] == yesterday or nr['lb'] == today))):
tkinter.messagebox.showerror('失败', '你的农作物已死亡!')
cl()
if nr['td'] != 0:
if nr['lx'] == 1:
if nr['ts'] != 0 and nr['ts'] <= 8:
xmt('.\zp\xm\xm' + str(nr['ts']) + '.png', '.\sjk\cs.png')
elif nr['ts'] > 8:
xmt('.\zp\xm\xm8.png', '.\sjk\cs.png')
else:
xmt('.\zp\xm\xm1.png', '.\sjk\cs.png')
else:
if nr['ts'] != 0 and nr['ts'] <= 8:
sdt('.\zp\sd\sd' + str(nr['ts']) + '.png', '.\sjk\cs.png')
elif nr['ts'] > 8:
sdt('.\zp\sd\sd8.png', '.\sjk\sd.png')
else:
sdt('.\zp\sd\sd8.png', '.\sjk\sd.png')
else:
kj('.\sjk\cs.png')
aa('.\sjk\cs.png')
jbz.set('金币:' + str(nr['jb']))
if nr['ts'] == 9:
if (nr['lx'] == 1):
tkinter.messagebox.showinfo('提示', '小麦已成熟,准备收割!')
t.sleep(1)
tkinter.messagebox.showinfo('提示', '小麦收割完毕!')
if (nr['fb'] == 1):
nr['jb'] += 200
else:
nr['jb'] += 100
cl()
else:
tkinter.messagebox.showinfo('提示', '水稻已成熟,准备收割!')
t.sleep(1)
tkinter.messagebox.showinfo('提示', '水稻收割完毕!')
if (nr['fb'] == 1):
nr['jb'] += 160
else:
nr['jb'] += 80
cl()
bc()
浇水施肥
def qd():
op()
if nr['td'] != 0:
# 获取今天(现在时间)
today = datetime.datetime.today()
today = str(today)
today = today[0:10]
if nr['lb'] != today:
nr['lb'] = today
nr['ts'] += 1
tkinter.messagebox.showinfo('提示', '打卡成功!')
else:
tkinter.messagebox.showinfo('提示', '今日你已打卡,明天再来吧!')
gx()
bc()
种植小麦或水稻
def mz():
op()
if nr['td'] == 0:
nr['td'] = 1
nr['lx'] = 1
nr['jb'] -= 10
tkinter.messagebox.showinfo('提示', '种植小麦成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
def sd():
op()
if nr['td'] == 0:
nr['td'] = 1
nr['lx'] = 2
nr['jb'] -= 8
tkinter.messagebox.showinfo('提示', '种植水稻成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
赚金币
# -*- coding: utf-8 -*-
def main():
# 窗口
global nr
window = tk.Tk()
window.title('种田')
window.geometry('600x640')
window.iconbitmap('.\m.ico')
tk.Label(window, text='田地:').place(x=10, y=10)
jbz = StringVar()
tk.Label(window, textvariable=jbz,text='金币:0').place(x=500, y=10)
bt_login = tk.Button(window, text='种麦子', command=mz)
bt_login.place(x=430, y=355)
bt_logquit = tk.Button(window, text='种水稻', command=sd)
bt_logquit.place(x=510, y=355)
bt_logquit = tk.Button(window, text='签到(浇水等)', command=qd)
bt_logquit.place(x=430, y=175)
bt_logquit = tk.Button(window, text='赚金币', command=jb)
bt_logquit.place(x=430, y=265)
bt_logquit = tk.Button(window, text='金币商城', command=jfsc1)
bt_logquit.place(x=510, y=265)
bt_logquit = tk.Button(window, text='打印后台数据', command=dyht)
bt_logquit.place(x=430, y=445)
window.mainloop()
main()
数据文档自动读写
if os.path.exists('./sjk/sjk.px'):
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
print(nr)
else:
nr = {'td': 0,
'lx': 0,
'lb': 0,
'ts': 0,
'jb': 100,
'zjb': 0.1,
'fb': 0}
with open('./sjk/sjk.px', 'wb') as usr_file:
pickle.dump(nr, usr_file)
数据文档读写
def op():
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
print(nr)
def bc():
with open('./sjk/sjk.px', 'wb') as usr_file:
pickle.dump(nr, usr_file)
print(nr)
显示图片
def aa(dz):
op()
global img0
photo = Image.open(dz)
photo = photo.resize((390, 595))
img0 = ImageTk.PhotoImage(photo)
tk.Label(window, image=img0).place(x=10, y=30)
bc()
部分数据重置
def cl():
op()
nr['td'] = 0
nr['lx'] = 0
nr['lb'] = 0
nr['ts'] = 0
nr['fb'] = 0
gx()
bc()
更新数据
def gx():
op()
if nr['td'] != 0:
today = datetime.datetime.today()
yesterday = today - datetime.timedelta(days=1)
yesterday = str(yesterday)
yesterday = yesterday[0:10]
today = str(today)
today = today[0:10]
if (not ((nr['lb'] == 0) or (nr['lb'] == yesterday or nr['lb'] == today))):
tkinter.messagebox.showerror('失败', '你的农作物已死亡!')
cl()
if nr['td'] != 0:
if nr['lx'] == 1:
if nr['ts'] != 0 and nr['ts'] <= 8:
xmt('.\zp\xm\xm' + str(nr['ts']) + '.png', '.\sjk\cs.png')
elif nr['ts'] > 8:
xmt('.\zp\xm\xm8.png', '.\sjk\cs.png')
else:
xmt('.\zp\xm\xm1.png', '.\sjk\cs.png')
else:
if nr['ts'] != 0 and nr['ts'] <= 8:
sdt('.\zp\sd\sd' + str(nr['ts']) + '.png', '.\sjk\cs.png')
elif nr['ts'] > 8:
sdt('.\zp\sd\sd8.png', '.\sjk\sd.png')
else:
sdt('.\zp\sd\sd8.png', '.\sjk\sd.png')
else:
kj('.\sjk\cs.png')
aa('.\sjk\cs.png')
jbz.set('金币:' + str(nr['jb']))
if nr['ts'] == 9:
if (nr['lx'] == 1):
tkinter.messagebox.showinfo('提示', '小麦已成熟,准备收割!')
t.sleep(1)
tkinter.messagebox.showinfo('提示', '小麦收割完毕!')
if (nr['fb'] == 1):
nr['jb'] += 200
else:
nr['jb'] += 100
cl()
else:
tkinter.messagebox.showinfo('提示', '水稻已成熟,准备收割!')
t.sleep(1)
tkinter.messagebox.showinfo('提示', '水稻收割完毕!')
if (nr['fb'] == 1):
nr['jb'] += 160
else:
nr['jb'] += 80
cl()
bc()
浇水施肥
def qd():
op()
if nr['td'] != 0:
# 获取今天(现在时间)
today = datetime.datetime.today()
today = str(today)
today = today[0:10]
if nr['lb'] != today:
nr['lb'] = today
nr['ts'] += 1
tkinter.messagebox.showinfo('提示', '打卡成功!')
else:
tkinter.messagebox.showinfo('提示', '今日你已打卡,明天再来吧!')
gx()
bc()
种植小麦或水稻
def mz():
op()
if nr['td'] == 0:
nr['td'] = 1
nr['lx'] = 1
nr['jb'] -= 10
tkinter.messagebox.showinfo('提示', '种植小麦成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
def sd():
op()
if nr['td'] == 0:
nr['td'] = 1
nr['lx'] = 2
nr['jb'] -= 8
tkinter.messagebox.showinfo('提示', '种植水稻成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
赚金币
def op():
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
print(nr)
def bc():
with open('./sjk/sjk.px', 'wb') as usr_file:
pickle.dump(nr, usr_file)
print(nr)
显示图片
def aa(dz):
op()
global img0
photo = Image.open(dz)
photo = photo.resize((390, 595))
img0 = ImageTk.PhotoImage(photo)
tk.Label(window, image=img0).place(x=10, y=30)
bc()
部分数据重置
def cl():
op()
nr['td'] = 0
nr['lx'] = 0
nr['lb'] = 0
nr['ts'] = 0
nr['fb'] = 0
gx()
bc()
更新数据
def gx():
op()
if nr['td'] != 0:
today = datetime.datetime.today()
yesterday = today - datetime.timedelta(days=1)
yesterday = str(yesterday)
yesterday = yesterday[0:10]
today = str(today)
today = today[0:10]
if (not ((nr['lb'] == 0) or (nr['lb'] == yesterday or nr['lb'] == today))):
tkinter.messagebox.showerror('失败', '你的农作物已死亡!')
cl()
if nr['td'] != 0:
if nr['lx'] == 1:
if nr['ts'] != 0 and nr['ts'] <= 8:
xmt('.\zp\xm\xm' + str(nr['ts']) + '.png', '.\sjk\cs.png')
elif nr['ts'] > 8:
xmt('.\zp\xm\xm8.png', '.\sjk\cs.png')
else:
xmt('.\zp\xm\xm1.png', '.\sjk\cs.png')
else:
if nr['ts'] != 0 and nr['ts'] <= 8:
sdt('.\zp\sd\sd' + str(nr['ts']) + '.png', '.\sjk\cs.png')
elif nr['ts'] > 8:
sdt('.\zp\sd\sd8.png', '.\sjk\sd.png')
else:
sdt('.\zp\sd\sd8.png', '.\sjk\sd.png')
else:
kj('.\sjk\cs.png')
aa('.\sjk\cs.png')
jbz.set('金币:' + str(nr['jb']))
if nr['ts'] == 9:
if (nr['lx'] == 1):
tkinter.messagebox.showinfo('提示', '小麦已成熟,准备收割!')
t.sleep(1)
tkinter.messagebox.showinfo('提示', '小麦收割完毕!')
if (nr['fb'] == 1):
nr['jb'] += 200
else:
nr['jb'] += 100
cl()
else:
tkinter.messagebox.showinfo('提示', '水稻已成熟,准备收割!')
t.sleep(1)
tkinter.messagebox.showinfo('提示', '水稻收割完毕!')
if (nr['fb'] == 1):
nr['jb'] += 160
else:
nr['jb'] += 80
cl()
bc()
浇水施肥
def qd():
op()
if nr['td'] != 0:
# 获取今天(现在时间)
today = datetime.datetime.today()
today = str(today)
today = today[0:10]
if nr['lb'] != today:
nr['lb'] = today
nr['ts'] += 1
tkinter.messagebox.showinfo('提示', '打卡成功!')
else:
tkinter.messagebox.showinfo('提示', '今日你已打卡,明天再来吧!')
gx()
bc()
种植小麦或水稻
def mz():
op()
if nr['td'] == 0:
nr['td'] = 1
nr['lx'] = 1
nr['jb'] -= 10
tkinter.messagebox.showinfo('提示', '种植小麦成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
def sd():
op()
if nr['td'] == 0:
nr['td'] = 1
nr['lx'] = 2
nr['jb'] -= 8
tkinter.messagebox.showinfo('提示', '种植水稻成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
赚金币
def cl():
op()
nr['td'] = 0
nr['lx'] = 0
nr['lb'] = 0
nr['ts'] = 0
nr['fb'] = 0
gx()
bc()
更新数据
def gx():
op()
if nr['td'] != 0:
today = datetime.datetime.today()
yesterday = today - datetime.timedelta(days=1)
yesterday = str(yesterday)
yesterday = yesterday[0:10]
today = str(today)
today = today[0:10]
if (not ((nr['lb'] == 0) or (nr['lb'] == yesterday or nr['lb'] == today))):
tkinter.messagebox.showerror('失败', '你的农作物已死亡!')
cl()
if nr['td'] != 0:
if nr['lx'] == 1:
if nr['ts'] != 0 and nr['ts'] <= 8:
xmt('.\zp\xm\xm' + str(nr['ts']) + '.png', '.\sjk\cs.png')
elif nr['ts'] > 8:
xmt('.\zp\xm\xm8.png', '.\sjk\cs.png')
else:
xmt('.\zp\xm\xm1.png', '.\sjk\cs.png')
else:
if nr['ts'] != 0 and nr['ts'] <= 8:
sdt('.\zp\sd\sd' + str(nr['ts']) + '.png', '.\sjk\cs.png')
elif nr['ts'] > 8:
sdt('.\zp\sd\sd8.png', '.\sjk\sd.png')
else:
sdt('.\zp\sd\sd8.png', '.\sjk\sd.png')
else:
kj('.\sjk\cs.png')
aa('.\sjk\cs.png')
jbz.set('金币:' + str(nr['jb']))
if nr['ts'] == 9:
if (nr['lx'] == 1):
tkinter.messagebox.showinfo('提示', '小麦已成熟,准备收割!')
t.sleep(1)
tkinter.messagebox.showinfo('提示', '小麦收割完毕!')
if (nr['fb'] == 1):
nr['jb'] += 200
else:
nr['jb'] += 100
cl()
else:
tkinter.messagebox.showinfo('提示', '水稻已成熟,准备收割!')
t.sleep(1)
tkinter.messagebox.showinfo('提示', '水稻收割完毕!')
if (nr['fb'] == 1):
nr['jb'] += 160
else:
nr['jb'] += 80
cl()
bc()
浇水施肥
def qd():
op()
if nr['td'] != 0:
# 获取今天(现在时间)
today = datetime.datetime.today()
today = str(today)
today = today[0:10]
if nr['lb'] != today:
nr['lb'] = today
nr['ts'] += 1
tkinter.messagebox.showinfo('提示', '打卡成功!')
else:
tkinter.messagebox.showinfo('提示', '今日你已打卡,明天再来吧!')
gx()
bc()
种植小麦或水稻
def mz():
op()
if nr['td'] == 0:
nr['td'] = 1
nr['lx'] = 1
nr['jb'] -= 10
tkinter.messagebox.showinfo('提示', '种植小麦成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
def sd():
op()
if nr['td'] == 0:
nr['td'] = 1
nr['lx'] = 2
nr['jb'] -= 8
tkinter.messagebox.showinfo('提示', '种植水稻成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
赚金币
def qd():
op()
if nr['td'] != 0:
# 获取今天(现在时间)
today = datetime.datetime.today()
today = str(today)
today = today[0:10]
if nr['lb'] != today:
nr['lb'] = today
nr['ts'] += 1
tkinter.messagebox.showinfo('提示', '打卡成功!')
else:
tkinter.messagebox.showinfo('提示', '今日你已打卡,明天再来吧!')
gx()
bc()
种植小麦或水稻
def mz():
op()
if nr['td'] == 0:
nr['td'] = 1
nr['lx'] = 1
nr['jb'] -= 10
tkinter.messagebox.showinfo('提示', '种植小麦成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
def sd():
op()
if nr['td'] == 0:
nr['td'] = 1
nr['lx'] = 2
nr['jb'] -= 8
tkinter.messagebox.showinfo('提示', '种植水稻成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
赚金币
def jb():
op()
nr['jb']+=nr['zjb']
nr['jb']=int(nr['jb']*10)/10
gx()
bc()
打印数据
def jb():
op()
nr['jb']+=nr['zjb']
nr['jb']=int(nr['jb']*10)/10
gx()
bc()
金币商城
def jfsc1():
op()
jfsc()
with open('./sjk/sjkjfsc.px', 'rb') as usr_file:
m = pickle.load(usr_file)
if m == 1:
if nr['jb'] >= 80:
nr['zjb'] *= 10
nr['jb'] -= 50
tkinter.messagebox.showinfo('提示', '兑换“赚金币速度x10”成功!花费50金币!')
else:
tkinter.messagebox.showinfo('提示', '金币不足!')
if m == 2:
if nr['jb'] >= 80:
nr['fb'] = 1
nr['jb'] -= 50
tkinter.messagebox.showinfo('提示', '兑换“收获翻倍一次”成功!花费50金币!')
else:
tkinter.messagebox.showinfo('提示', '金币不足!')
if m == 3:
if nr['jb'] >= 100:
nr['ts'] = 9
nr['jb'] -= 50
tkinter.messagebox.showinfo('提示', '兑换“快速种成”成功!花费50金币!')
else:
tkinter.messagebox.showinfo('提示', '金币不足!')
if m == 4:
if nr['jb'] >= 10:
zf = ''
sum = 0
for i in range(11):
dz = random.randint(0, 9)
zf += str(dz)
sum += dz
j = chr(sum % 10 + ord('A'))
j1 = sum % 10
zf = zf + str(j)
nr['jb'] -= 5
ax = [zf[0:3], zf[3:6], zf[6:9], zf[9:11] + str(j1)]
zf1 = ''
for i in ax:
sum1 = 0
for z in i:
sum1 += int(z)
if sum1 < 10:
zf1 += str(sum1)
else:
zf1 += chr(sum1 - 10 + ord('A'))
wj = []
with open('./a.txt', "r") as fr: # 以r形式打开文件
for line in fr:
wj.append(line.replace('n', ''))
file = open('.\a.txt', 'w')
file.write('n'.join(wj) + '兑换码:' + zf + 'n校验码:' + zf1 + 'nn')
tkinter.messagebox.showinfo('提示', '兑换“epnswe劵”成功!花费5金币!兑换码:' + zf + ' 校验码:' + zf1)
else:
tkinter.messagebox.showinfo('提示', '金币不足!')
gx()
bc()
完整main.py代码
# -*- coding: utf-8 -*-
from jifen import *
from tkinter import *
import tkinter as tk
from tp import *
from dy import *
import os
import pickle
import random
import tkinter.messagebox
from PIL import Image,ImageTk
import datetime
import time as t
def main():
global nr
window = tk.Tk()
window.title('种田')
window.geometry('600x640')
window.iconbitmap('.\m.ico')
tk.Label(window, text='田地:').place(x=10, y=10)
jbz = StringVar()
tk.Label(window, textvariable=jbz,text='金币:0').place(x=500, y=10)
if os.path.exists('./sjk/sjk.px'):
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
print(nr)
else:
nr = {'td': 0,
'lx': 0,
'lb':0,
'ts':0,
'jb': 100,
'zjb':0.1,
'fb':0}
with open('./sjk/sjk.px', 'wb') as usr_file:
pickle.dump(nr, usr_file)
def op():
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
print(nr)
def bc():
with open('./sjk/sjk.px', 'wb') as usr_file:
pickle.dump(nr, usr_file)
print(nr)
def aa(dz):
op()
global img0
photo = Image.open(dz)
photo = photo.resize((390, 595))
img0 = ImageTk.PhotoImage(photo)
tk.Label(window,image=img0).place(x=10, y=30)
bc()
def cl():
op()
nr['td']=0
nr['lx'] = 0
nr['lb'] = 0
nr['ts'] = 0
nr['fb'] = 0
gx()
bc()
def gx():
op()
if nr['td'] != 0:
today = datetime.datetime.today()
yesterday = today - datetime.timedelta(days=1)
yesterday = str(yesterday)
yesterday = yesterday[0:10]
today = str(today)
today = today[0:10]
if (not ((nr['lb']==0) or( nr['lb']==yesterday or nr['lb']==today))):
tkinter.messagebox.showerror('失败', '你的农作物已死亡!')
cl()
if nr['td']!=0:
if nr['lx']==1:
if nr['ts']!=0 and nr['ts']<=8:
xmt('.\zp\xm\xm' + str(nr['ts']) + '.png', '.\sjk\cs.png')
elif nr['ts']>8:
xmt('.\zp\xm\xm8.png', '.\sjk\cs.png')
else:
xmt('.\zp\xm\xm1.png', '.\sjk\cs.png')
else:
if nr['ts']!=0 and nr['ts']<=8:
sdt('.\zp\sd\sd' + str(nr['ts']) + '.png', '.\sjk\cs.png')
elif nr['ts'] > 8:
sdt('.\zp\sd\sd8.png', '.\sjk\sd.png')
else:
sdt('.\zp\sd\sd8.png', '.\sjk\sd.png')
else:
kj('.\sjk\cs.png')
aa('.\sjk\cs.png')
jbz.set('金币:'+str(nr['jb']))
if nr['ts']==9:
if(nr['lx']==1):
tkinter.messagebox.showinfo('提示', '小麦已成熟,准备收割!')
t.sleep(1)
tkinter.messagebox.showinfo('提示', '小麦收割完毕!')
if(nr['fb']==1):
nr['jb']+=200
else:
nr['jb'] += 100
cl()
else:
tkinter.messagebox.showinfo('提示', '水稻已成熟,准备收割!')
t.sleep(1)
tkinter.messagebox.showinfo('提示', '水稻收割完毕!')
if (nr['fb'] == 1):
nr['jb'] += 160
else:
nr['jb'] += 80
cl()
bc()
gx()
def qd():
op()
if nr['td']!=0:
today = datetime.datetime.today()
today = str(today)
today = today[0:10]
if nr['lb']!=today:
nr['lb'] = today
nr['ts']+=1
tkinter.messagebox.showinfo('提示', '打卡成功!')
else:
tkinter.messagebox.showinfo('提示', '今日你已打卡,明天再来吧!')
gx()
bc()
def mz():
op()
if nr['td']==0:
nr['td'] = 1
nr['lx'] = 1
nr['jb']-=10
tkinter.messagebox.showinfo('提示', '种植小麦成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
def sd():
op()
if nr['td']==0:
nr['td'] = 1
nr['lx'] = 2
nr['jb'] -= 8
tkinter.messagebox.showinfo('提示', '种植水稻成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
def jb():
op()
nr['jb']+=nr['zjb']
nr['jb']=int(nr['jb']*10)/10
gx()
bc()
def dyht():
op()
dysj()
gx()
bc()
def jfsc1():
op()
jfsc()
with open('./sjk/sjkjfsc.px', 'rb') as usr_file:
m = pickle.load(usr_file)
if m==1:
if nr['jb'] >= 80:
nr['zjb'] *= 10
nr['jb'] -= 50
tkinter.messagebox.showinfo('提示', '兑换“赚金币速度x10”成功!花费50金币!')
else:
tkinter.messagebox.showinfo('提示', '金币不足!')
if m==2:
if nr['jb']>=80:
nr['fb'] = 1
nr['jb']-=50
tkinter.messagebox.showinfo('提示', '兑换“收获翻倍一次”成功!花费50金币!')
else:
tkinter.messagebox.showinfo('提示', '金币不足!')
if m==3:
if nr['jb']>=100:
nr['ts'] = 9
nr['jb']-=50
tkinter.messagebox.showinfo('提示', '兑换“快速种成”成功!花费50金币!')
else:
tkinter.messagebox.showinfo('提示', '金币不足!')
if m == 4:
if nr['jb']>=10:
zf=''
sum=0
for i in range(11):
dz=random.randint(0,9)
zf+=str(dz)
sum+=dz
j=chr(sum%10+ord('A'))
j1=sum%10
zf=zf+str(j)
nr['jb']-=5
ax=[zf[0:3],zf[3:6],zf[6:9],zf[9:11]+str(j1)]
zf1=''
for i in ax:
sum1=0
for z in i:
sum1+=int(z)
if sum1<10:
zf1+=str(sum1)
else:
zf1 +=chr(sum1-10+ord('A'))
wj = []
with open('./a.txt', "r") as fr: # 以r形式打开文件
for line in fr:
wj.append(line.replace('n', ''))
file = open('.\a.txt', 'w')
file.write('n'.join(wj)+'兑换码:'+zf+'n校验码:'+zf1+'nn')
tkinter.messagebox.showinfo('提示', '兑换“epnswe劵”成功!花费5金币!兑换码:'+zf+' 校验码:'+zf1)
else:
tkinter.messagebox.showinfo('提示', '金币不足!')
gx()
bc()
bt_login = tk.Button(window, text='种麦子', command=mz)
bt_login.place(x=430, y=355)
bt_logquit = tk.Button(window, text='种水稻', command=sd)
bt_logquit.place(x=510, y=355)
bt_logquit = tk.Button(window, text='签到(浇水等)', command=qd)
bt_logquit.place(x=430, y=175)
bt_logquit = tk.Button(window, text='赚金币', command=jb)
bt_logquit.place(x=430, y=265)
bt_logquit = tk.Button(window, text='金币商城', command=jfsc1)
bt_logquit.place(x=510, y=265)
bt_logquit = tk.Button(window, text='打印后台数据', command=dyht)
bt_logquit.place(x=430, y=445)
window.mainloop()
main()
dy.py
引入库
import pickle
import win32api
import win32print
import random
import time
import os
打印函数
def dysj():
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
s=time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
sum = 0
for i in s:
sum += int(i)
j = chr(sum % 10 + ord('A'))
s = s + str(j)
m=''
for i in range(12):
m1=''
for j in range(60):
m1+=str(random.randint(0, 1))
m+=m1+'n'
h=['破译:',
' open:',
' with open('./sjk/sjk.px', 'rb') as usr_file:',
' nr = pickle.load(usr_file)',
' save:',
' with open('./sjk/sjk.px', 'wb') as usr_file:',
' pickle.dump(nr, usr_file)',
'Binary code:',
m,
'15位数据码:',
s]
a=['sjk.px:']
for x,y in nr.items():
a.append(' ''+x+'':'+str(y))
a+=h
a='n'.join(a)
print(a)
file = open('./sjk/hc.txt', 'w')
file.write(a)
current_path = os.path.abspath(__file__)
father_path = os.path.abspath(os.path.dirname(current_path) + os.path.sep +'.')+ './sjk/hc.txt'
win32api.ShellExecute(0, "print", father_path, '/d:"%s"' % win32print.GetDefaultPrinter(), ".", 0)
return a
完整dy.py代码
import pickle
import win32api
import win32print
import random
import time
import os
def dysj():
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
s=time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
sum = 0
for i in s:
sum += int(i)
j = chr(sum % 10 + ord('A'))
s = s + str(j)
m=''
for i in range(12):
m1=''
for j in range(60):
m1+=str(random.randint(0, 1))
m+=m1+'n'
h=['破译:',
' open:',
' with open('./sjk/sjk.px', 'rb') as usr_file:',
' nr = pickle.load(usr_file)',
' save:',
' with open('./sjk/sjk.px', 'wb') as usr_file:',
' pickle.dump(nr, usr_file)',
'Binary code:',
m,
'15位数据码:',
s]
a=['sjk.px:']
for x,y in nr.items():
a.append(' ''+x+'':'+str(y))
a+=h
a='n'.join(a)
print(a)
file = open('./sjk/hc.txt', 'w')
file.write(a)
current_path = os.path.abspath(__file__)
father_path = os.path.abspath(os.path.dirname(current_path) + os.path.sep +'.')+ './sjk/hc.txt'
win32api.ShellExecute(0, "print", father_path, '/d:"%s"' % win32print.GetDefaultPrinter(), ".", 0)
return a
jifen.py
引入库
import tkinter as tk
import pickle
积分商城函数
def jfsc():
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(0, usr_file)
window1 = tk.Toplevel()
window1.title('种田-金币商城')
window1.geometry('300x200')
window1.iconbitmap('.\m.ico')
global z,jb
z=0
jb=0
def a():
z=1
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def b():
z=2
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def c():
z=3
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def d():
z=4
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
bt_login = tk.Button(window1, text='赚金币速度x10n50金币', command=a)
bt_login.place(x=10, y=10)
bt_logquit = tk.Button(window1, text='收获翻倍一次n50金币', command=b)
bt_logquit.place(x=110, y=10)
bt_logquit = tk.Button(window1, text='快速种成n50金币', command=c)
bt_logquit.place(x=10, y=65)
bt_logquit = tk.Button(window1, text='epnswe劵n5金币', command=d)
bt_logquit.place(x=80, y=65)
window1.mainloop()
完整 jifen.py代码
# -*- coding: utf-8 -*-
import tkinter as tk
import pickle
def jfsc():
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(0, usr_file)
window1 = tk.Toplevel()
window1.title('种田-金币商城')
window1.geometry('300x200')
window1.iconbitmap('.\m.ico')
global z,jb
z=0
jb=0
def a():
z=1
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def b():
z=2
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def c():
z=3
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def d():
z=4
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
bt_login = tk.Button(window1, text='赚金币速度x10n50金币', command=a)
bt_login.place(x=10, y=10)
bt_logquit = tk.Button(window1, text='收获翻倍一次n50金币', command=b)
bt_logquit.place(x=110, y=10)
bt_logquit = tk.Button(window1, text='快速种成n50金币', command=c)
bt_logquit.place(x=10, y=65)
bt_logquit = tk.Button(window1, text='epnswe劵n5金币', command=d)
bt_logquit.place(x=80, y=65)
window1.mainloop()
tp.py
小麦图
def xmt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
x=[30,180,330,480,630]
y=[30,320,610,900]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img.save(bc, "PNG")
水稻图
def sdt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (680, 660), (255, 255, 255))
x=[30,160,290,420,530]
y=[30,160,290,420]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img=img.resize((780, 1190), Image.ANTIALIAS)
img.save(bc, "PNG")
空白
def kj(bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
img.save(bc, "PNG")
完整tp.py代码
def xmt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
x=[30,180,330,480,630]
y=[30,320,610,900]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img.save(bc, "PNG")
def sdt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (680, 660), (255, 255, 255))
x=[30,160,290,420,530]
y=[30,160,290,420]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img=img.resize((780, 1190), Image.ANTIALIAS)
img.save(bc, "PNG")
def kj(bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
img.save(bc, "PNG")
扩展-种田十五位数据码验证
yz.py
import tkinter
from tkinter import ttk
from tkinter import *
import os
import pickle
win = tkinter.Tk()
win.title('种田15位数据码')
win.geometry('400x190')
win.iconbitmap('.\m.ico')
tkinter.Label(win,text='输入:').place(x=100, y=45)
zt = StringVar()
zt1=tkinter.Label(win, textvariable=zt,text='')
zt1.place(x=5, y=165)
db=tkinter.Entry(win, width=20)
db.place(x=100,y=65,height=23)
comvalue = tkinter.StringVar()
comboxlist = ttk.Combobox(win, textvariable=comvalue,width=3)
comboxlist["values"] = ('A','B','C','D','E','F','G','H','I','J')
comboxlist.current(0)
comboxlist.place(x=250, y=65)
def lr():
s=db.get()
z=comboxlist.get()
try:
if(len(s)==14):
db.delete(0, "end")
sum = 0
for i in s:
sum += int(i)
j = chr(sum % 10 + ord('A'))
if z==j:
wj=[]
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
wj.append(s+z)
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
zt.set('录入成功!')
else:
zt.set('录入失败!')
else:
zt.set('录入失败!')
except:
zt.set('录入失败!')
def sjk():
window1 = tkinter.Tk()
window1.title('数据库')
window1.geometry('450x320')
window1.iconbitmap('.\m.ico')
bz = tkinter.Text(window1)
bz.place(x=10, y=10, width=430, height=275)
s = tkinter.Entry(window1, width=30)
s.place(x=50, y=290, height=23)
def sx():
wj = []
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
for i in range(len(wj)):
wj[i] = str(i + 1) + ' ' + wj[i]
bz.delete(1.0, "end")
bz.insert('end', 'n'.join(wj))
sx()
def qk():
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump([], usr_file)
sx()
def sc():
sz=s.get()
sz=int(sz)
if sz<0:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
else:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz-1]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
s.delete(0,'end')
sx()
bt_login = tkinter.Button(window1, text='刷新', command=sx)
bt_login.place(x=310, y=285)
bt_login = tkinter.Button(window1, text='清空', command=qk)
bt_login.place(x=270, y=285)
bt_login = tkinter.Button(window1, text='删除', command=sc)
bt_login.place(x=10, y=285)
window1.mainloop()
bt_login = tkinter.Button(win, text='录入', command=lr)
bt_login.place(x=180, y=120)
bt_login = tkinter.Button(win, text='数据库', command=sjk)
bt_login.place(x=345, y=155)
win.mainloop()
文件目录架构
def jfsc1():
op()
jfsc()
with open('./sjk/sjkjfsc.px', 'rb') as usr_file:
m = pickle.load(usr_file)
if m == 1:
if nr['jb'] >= 80:
nr['zjb'] *= 10
nr['jb'] -= 50
tkinter.messagebox.showinfo('提示', '兑换“赚金币速度x10”成功!花费50金币!')
else:
tkinter.messagebox.showinfo('提示', '金币不足!')
if m == 2:
if nr['jb'] >= 80:
nr['fb'] = 1
nr['jb'] -= 50
tkinter.messagebox.showinfo('提示', '兑换“收获翻倍一次”成功!花费50金币!')
else:
tkinter.messagebox.showinfo('提示', '金币不足!')
if m == 3:
if nr['jb'] >= 100:
nr['ts'] = 9
nr['jb'] -= 50
tkinter.messagebox.showinfo('提示', '兑换“快速种成”成功!花费50金币!')
else:
tkinter.messagebox.showinfo('提示', '金币不足!')
if m == 4:
if nr['jb'] >= 10:
zf = ''
sum = 0
for i in range(11):
dz = random.randint(0, 9)
zf += str(dz)
sum += dz
j = chr(sum % 10 + ord('A'))
j1 = sum % 10
zf = zf + str(j)
nr['jb'] -= 5
ax = [zf[0:3], zf[3:6], zf[6:9], zf[9:11] + str(j1)]
zf1 = ''
for i in ax:
sum1 = 0
for z in i:
sum1 += int(z)
if sum1 < 10:
zf1 += str(sum1)
else:
zf1 += chr(sum1 - 10 + ord('A'))
wj = []
with open('./a.txt', "r") as fr: # 以r形式打开文件
for line in fr:
wj.append(line.replace('n', ''))
file = open('.\a.txt', 'w')
file.write('n'.join(wj) + '兑换码:' + zf + 'n校验码:' + zf1 + 'nn')
tkinter.messagebox.showinfo('提示', '兑换“epnswe劵”成功!花费5金币!兑换码:' + zf + ' 校验码:' + zf1)
else:
tkinter.messagebox.showinfo('提示', '金币不足!')
gx()
bc()
完整main.py代码
# -*- coding: utf-8 -*-
from jifen import *
from tkinter import *
import tkinter as tk
from tp import *
from dy import *
import os
import pickle
import random
import tkinter.messagebox
from PIL import Image,ImageTk
import datetime
import time as t
def main():
global nr
window = tk.Tk()
window.title('种田')
window.geometry('600x640')
window.iconbitmap('.\m.ico')
tk.Label(window, text='田地:').place(x=10, y=10)
jbz = StringVar()
tk.Label(window, textvariable=jbz,text='金币:0').place(x=500, y=10)
if os.path.exists('./sjk/sjk.px'):
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
print(nr)
else:
nr = {'td': 0,
'lx': 0,
'lb':0,
'ts':0,
'jb': 100,
'zjb':0.1,
'fb':0}
with open('./sjk/sjk.px', 'wb') as usr_file:
pickle.dump(nr, usr_file)
def op():
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
print(nr)
def bc():
with open('./sjk/sjk.px', 'wb') as usr_file:
pickle.dump(nr, usr_file)
print(nr)
def aa(dz):
op()
global img0
photo = Image.open(dz)
photo = photo.resize((390, 595))
img0 = ImageTk.PhotoImage(photo)
tk.Label(window,image=img0).place(x=10, y=30)
bc()
def cl():
op()
nr['td']=0
nr['lx'] = 0
nr['lb'] = 0
nr['ts'] = 0
nr['fb'] = 0
gx()
bc()
def gx():
op()
if nr['td'] != 0:
today = datetime.datetime.today()
yesterday = today - datetime.timedelta(days=1)
yesterday = str(yesterday)
yesterday = yesterday[0:10]
today = str(today)
today = today[0:10]
if (not ((nr['lb']==0) or( nr['lb']==yesterday or nr['lb']==today))):
tkinter.messagebox.showerror('失败', '你的农作物已死亡!')
cl()
if nr['td']!=0:
if nr['lx']==1:
if nr['ts']!=0 and nr['ts']<=8:
xmt('.\zp\xm\xm' + str(nr['ts']) + '.png', '.\sjk\cs.png')
elif nr['ts']>8:
xmt('.\zp\xm\xm8.png', '.\sjk\cs.png')
else:
xmt('.\zp\xm\xm1.png', '.\sjk\cs.png')
else:
if nr['ts']!=0 and nr['ts']<=8:
sdt('.\zp\sd\sd' + str(nr['ts']) + '.png', '.\sjk\cs.png')
elif nr['ts'] > 8:
sdt('.\zp\sd\sd8.png', '.\sjk\sd.png')
else:
sdt('.\zp\sd\sd8.png', '.\sjk\sd.png')
else:
kj('.\sjk\cs.png')
aa('.\sjk\cs.png')
jbz.set('金币:'+str(nr['jb']))
if nr['ts']==9:
if(nr['lx']==1):
tkinter.messagebox.showinfo('提示', '小麦已成熟,准备收割!')
t.sleep(1)
tkinter.messagebox.showinfo('提示', '小麦收割完毕!')
if(nr['fb']==1):
nr['jb']+=200
else:
nr['jb'] += 100
cl()
else:
tkinter.messagebox.showinfo('提示', '水稻已成熟,准备收割!')
t.sleep(1)
tkinter.messagebox.showinfo('提示', '水稻收割完毕!')
if (nr['fb'] == 1):
nr['jb'] += 160
else:
nr['jb'] += 80
cl()
bc()
gx()
def qd():
op()
if nr['td']!=0:
today = datetime.datetime.today()
today = str(today)
today = today[0:10]
if nr['lb']!=today:
nr['lb'] = today
nr['ts']+=1
tkinter.messagebox.showinfo('提示', '打卡成功!')
else:
tkinter.messagebox.showinfo('提示', '今日你已打卡,明天再来吧!')
gx()
bc()
def mz():
op()
if nr['td']==0:
nr['td'] = 1
nr['lx'] = 1
nr['jb']-=10
tkinter.messagebox.showinfo('提示', '种植小麦成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
def sd():
op()
if nr['td']==0:
nr['td'] = 1
nr['lx'] = 2
nr['jb'] -= 8
tkinter.messagebox.showinfo('提示', '种植水稻成功!')
else:
tkinter.messagebox.showinfo('提示', '你的农田已种上农作物了!')
gx()
bc()
def jb():
op()
nr['jb']+=nr['zjb']
nr['jb']=int(nr['jb']*10)/10
gx()
bc()
def dyht():
op()
dysj()
gx()
bc()
def jfsc1():
op()
jfsc()
with open('./sjk/sjkjfsc.px', 'rb') as usr_file:
m = pickle.load(usr_file)
if m==1:
if nr['jb'] >= 80:
nr['zjb'] *= 10
nr['jb'] -= 50
tkinter.messagebox.showinfo('提示', '兑换“赚金币速度x10”成功!花费50金币!')
else:
tkinter.messagebox.showinfo('提示', '金币不足!')
if m==2:
if nr['jb']>=80:
nr['fb'] = 1
nr['jb']-=50
tkinter.messagebox.showinfo('提示', '兑换“收获翻倍一次”成功!花费50金币!')
else:
tkinter.messagebox.showinfo('提示', '金币不足!')
if m==3:
if nr['jb']>=100:
nr['ts'] = 9
nr['jb']-=50
tkinter.messagebox.showinfo('提示', '兑换“快速种成”成功!花费50金币!')
else:
tkinter.messagebox.showinfo('提示', '金币不足!')
if m == 4:
if nr['jb']>=10:
zf=''
sum=0
for i in range(11):
dz=random.randint(0,9)
zf+=str(dz)
sum+=dz
j=chr(sum%10+ord('A'))
j1=sum%10
zf=zf+str(j)
nr['jb']-=5
ax=[zf[0:3],zf[3:6],zf[6:9],zf[9:11]+str(j1)]
zf1=''
for i in ax:
sum1=0
for z in i:
sum1+=int(z)
if sum1<10:
zf1+=str(sum1)
else:
zf1 +=chr(sum1-10+ord('A'))
wj = []
with open('./a.txt', "r") as fr: # 以r形式打开文件
for line in fr:
wj.append(line.replace('n', ''))
file = open('.\a.txt', 'w')
file.write('n'.join(wj)+'兑换码:'+zf+'n校验码:'+zf1+'nn')
tkinter.messagebox.showinfo('提示', '兑换“epnswe劵”成功!花费5金币!兑换码:'+zf+' 校验码:'+zf1)
else:
tkinter.messagebox.showinfo('提示', '金币不足!')
gx()
bc()
bt_login = tk.Button(window, text='种麦子', command=mz)
bt_login.place(x=430, y=355)
bt_logquit = tk.Button(window, text='种水稻', command=sd)
bt_logquit.place(x=510, y=355)
bt_logquit = tk.Button(window, text='签到(浇水等)', command=qd)
bt_logquit.place(x=430, y=175)
bt_logquit = tk.Button(window, text='赚金币', command=jb)
bt_logquit.place(x=430, y=265)
bt_logquit = tk.Button(window, text='金币商城', command=jfsc1)
bt_logquit.place(x=510, y=265)
bt_logquit = tk.Button(window, text='打印后台数据', command=dyht)
bt_logquit.place(x=430, y=445)
window.mainloop()
main()
dy.py
引入库
import pickle
import win32api
import win32print
import random
import time
import os
打印函数
def dysj():
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
s=time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
sum = 0
for i in s:
sum += int(i)
j = chr(sum % 10 + ord('A'))
s = s + str(j)
m=''
for i in range(12):
m1=''
for j in range(60):
m1+=str(random.randint(0, 1))
m+=m1+'n'
h=['破译:',
' open:',
' with open('./sjk/sjk.px', 'rb') as usr_file:',
' nr = pickle.load(usr_file)',
' save:',
' with open('./sjk/sjk.px', 'wb') as usr_file:',
' pickle.dump(nr, usr_file)',
'Binary code:',
m,
'15位数据码:',
s]
a=['sjk.px:']
for x,y in nr.items():
a.append(' ''+x+'':'+str(y))
a+=h
a='n'.join(a)
print(a)
file = open('./sjk/hc.txt', 'w')
file.write(a)
current_path = os.path.abspath(__file__)
father_path = os.path.abspath(os.path.dirname(current_path) + os.path.sep +'.')+ './sjk/hc.txt'
win32api.ShellExecute(0, "print", father_path, '/d:"%s"' % win32print.GetDefaultPrinter(), ".", 0)
return a
完整dy.py代码
import pickle
import win32api
import win32print
import random
import time
import os
def dysj():
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
s=time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
sum = 0
for i in s:
sum += int(i)
j = chr(sum % 10 + ord('A'))
s = s + str(j)
m=''
for i in range(12):
m1=''
for j in range(60):
m1+=str(random.randint(0, 1))
m+=m1+'n'
h=['破译:',
' open:',
' with open('./sjk/sjk.px', 'rb') as usr_file:',
' nr = pickle.load(usr_file)',
' save:',
' with open('./sjk/sjk.px', 'wb') as usr_file:',
' pickle.dump(nr, usr_file)',
'Binary code:',
m,
'15位数据码:',
s]
a=['sjk.px:']
for x,y in nr.items():
a.append(' ''+x+'':'+str(y))
a+=h
a='n'.join(a)
print(a)
file = open('./sjk/hc.txt', 'w')
file.write(a)
current_path = os.path.abspath(__file__)
father_path = os.path.abspath(os.path.dirname(current_path) + os.path.sep +'.')+ './sjk/hc.txt'
win32api.ShellExecute(0, "print", father_path, '/d:"%s"' % win32print.GetDefaultPrinter(), ".", 0)
return a
jifen.py
引入库
import tkinter as tk
import pickle
积分商城函数
def jfsc():
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(0, usr_file)
window1 = tk.Toplevel()
window1.title('种田-金币商城')
window1.geometry('300x200')
window1.iconbitmap('.\m.ico')
global z,jb
z=0
jb=0
def a():
z=1
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def b():
z=2
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def c():
z=3
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def d():
z=4
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
bt_login = tk.Button(window1, text='赚金币速度x10n50金币', command=a)
bt_login.place(x=10, y=10)
bt_logquit = tk.Button(window1, text='收获翻倍一次n50金币', command=b)
bt_logquit.place(x=110, y=10)
bt_logquit = tk.Button(window1, text='快速种成n50金币', command=c)
bt_logquit.place(x=10, y=65)
bt_logquit = tk.Button(window1, text='epnswe劵n5金币', command=d)
bt_logquit.place(x=80, y=65)
window1.mainloop()
完整 jifen.py代码
# -*- coding: utf-8 -*-
import tkinter as tk
import pickle
def jfsc():
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(0, usr_file)
window1 = tk.Toplevel()
window1.title('种田-金币商城')
window1.geometry('300x200')
window1.iconbitmap('.\m.ico')
global z,jb
z=0
jb=0
def a():
z=1
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def b():
z=2
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def c():
z=3
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def d():
z=4
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
bt_login = tk.Button(window1, text='赚金币速度x10n50金币', command=a)
bt_login.place(x=10, y=10)
bt_logquit = tk.Button(window1, text='收获翻倍一次n50金币', command=b)
bt_logquit.place(x=110, y=10)
bt_logquit = tk.Button(window1, text='快速种成n50金币', command=c)
bt_logquit.place(x=10, y=65)
bt_logquit = tk.Button(window1, text='epnswe劵n5金币', command=d)
bt_logquit.place(x=80, y=65)
window1.mainloop()
tp.py
小麦图
def xmt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
x=[30,180,330,480,630]
y=[30,320,610,900]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img.save(bc, "PNG")
水稻图
def sdt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (680, 660), (255, 255, 255))
x=[30,160,290,420,530]
y=[30,160,290,420]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img=img.resize((780, 1190), Image.ANTIALIAS)
img.save(bc, "PNG")
空白
def kj(bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
img.save(bc, "PNG")
完整tp.py代码
def xmt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
x=[30,180,330,480,630]
y=[30,320,610,900]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img.save(bc, "PNG")
def sdt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (680, 660), (255, 255, 255))
x=[30,160,290,420,530]
y=[30,160,290,420]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img=img.resize((780, 1190), Image.ANTIALIAS)
img.save(bc, "PNG")
def kj(bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
img.save(bc, "PNG")
扩展-种田十五位数据码验证
yz.py
import tkinter
from tkinter import ttk
from tkinter import *
import os
import pickle
win = tkinter.Tk()
win.title('种田15位数据码')
win.geometry('400x190')
win.iconbitmap('.\m.ico')
tkinter.Label(win,text='输入:').place(x=100, y=45)
zt = StringVar()
zt1=tkinter.Label(win, textvariable=zt,text='')
zt1.place(x=5, y=165)
db=tkinter.Entry(win, width=20)
db.place(x=100,y=65,height=23)
comvalue = tkinter.StringVar()
comboxlist = ttk.Combobox(win, textvariable=comvalue,width=3)
comboxlist["values"] = ('A','B','C','D','E','F','G','H','I','J')
comboxlist.current(0)
comboxlist.place(x=250, y=65)
def lr():
s=db.get()
z=comboxlist.get()
try:
if(len(s)==14):
db.delete(0, "end")
sum = 0
for i in s:
sum += int(i)
j = chr(sum % 10 + ord('A'))
if z==j:
wj=[]
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
wj.append(s+z)
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
zt.set('录入成功!')
else:
zt.set('录入失败!')
else:
zt.set('录入失败!')
except:
zt.set('录入失败!')
def sjk():
window1 = tkinter.Tk()
window1.title('数据库')
window1.geometry('450x320')
window1.iconbitmap('.\m.ico')
bz = tkinter.Text(window1)
bz.place(x=10, y=10, width=430, height=275)
s = tkinter.Entry(window1, width=30)
s.place(x=50, y=290, height=23)
def sx():
wj = []
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
for i in range(len(wj)):
wj[i] = str(i + 1) + ' ' + wj[i]
bz.delete(1.0, "end")
bz.insert('end', 'n'.join(wj))
sx()
def qk():
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump([], usr_file)
sx()
def sc():
sz=s.get()
sz=int(sz)
if sz<0:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
else:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz-1]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
s.delete(0,'end')
sx()
bt_login = tkinter.Button(window1, text='刷新', command=sx)
bt_login.place(x=310, y=285)
bt_login = tkinter.Button(window1, text='清空', command=qk)
bt_login.place(x=270, y=285)
bt_login = tkinter.Button(window1, text='删除', command=sc)
bt_login.place(x=10, y=285)
window1.mainloop()
bt_login = tkinter.Button(win, text='录入', command=lr)
bt_login.place(x=180, y=120)
bt_login = tkinter.Button(win, text='数据库', command=sjk)
bt_login.place(x=345, y=155)
win.mainloop()
文件目录架构
import pickle import win32api import win32print import random import time import os
打印函数
def dysj():
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
s=time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
sum = 0
for i in s:
sum += int(i)
j = chr(sum % 10 + ord('A'))
s = s + str(j)
m=''
for i in range(12):
m1=''
for j in range(60):
m1+=str(random.randint(0, 1))
m+=m1+'n'
h=['破译:',
' open:',
' with open('./sjk/sjk.px', 'rb') as usr_file:',
' nr = pickle.load(usr_file)',
' save:',
' with open('./sjk/sjk.px', 'wb') as usr_file:',
' pickle.dump(nr, usr_file)',
'Binary code:',
m,
'15位数据码:',
s]
a=['sjk.px:']
for x,y in nr.items():
a.append(' ''+x+'':'+str(y))
a+=h
a='n'.join(a)
print(a)
file = open('./sjk/hc.txt', 'w')
file.write(a)
current_path = os.path.abspath(__file__)
father_path = os.path.abspath(os.path.dirname(current_path) + os.path.sep +'.')+ './sjk/hc.txt'
win32api.ShellExecute(0, "print", father_path, '/d:"%s"' % win32print.GetDefaultPrinter(), ".", 0)
return a
完整dy.py代码
import pickle
import win32api
import win32print
import random
import time
import os
def dysj():
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
s=time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
sum = 0
for i in s:
sum += int(i)
j = chr(sum % 10 + ord('A'))
s = s + str(j)
m=''
for i in range(12):
m1=''
for j in range(60):
m1+=str(random.randint(0, 1))
m+=m1+'n'
h=['破译:',
' open:',
' with open('./sjk/sjk.px', 'rb') as usr_file:',
' nr = pickle.load(usr_file)',
' save:',
' with open('./sjk/sjk.px', 'wb') as usr_file:',
' pickle.dump(nr, usr_file)',
'Binary code:',
m,
'15位数据码:',
s]
a=['sjk.px:']
for x,y in nr.items():
a.append(' ''+x+'':'+str(y))
a+=h
a='n'.join(a)
print(a)
file = open('./sjk/hc.txt', 'w')
file.write(a)
current_path = os.path.abspath(__file__)
father_path = os.path.abspath(os.path.dirname(current_path) + os.path.sep +'.')+ './sjk/hc.txt'
win32api.ShellExecute(0, "print", father_path, '/d:"%s"' % win32print.GetDefaultPrinter(), ".", 0)
return a
jifen.py
引入库
import tkinter as tk
import pickle
积分商城函数
def jfsc():
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(0, usr_file)
window1 = tk.Toplevel()
window1.title('种田-金币商城')
window1.geometry('300x200')
window1.iconbitmap('.\m.ico')
global z,jb
z=0
jb=0
def a():
z=1
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def b():
z=2
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def c():
z=3
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def d():
z=4
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
bt_login = tk.Button(window1, text='赚金币速度x10n50金币', command=a)
bt_login.place(x=10, y=10)
bt_logquit = tk.Button(window1, text='收获翻倍一次n50金币', command=b)
bt_logquit.place(x=110, y=10)
bt_logquit = tk.Button(window1, text='快速种成n50金币', command=c)
bt_logquit.place(x=10, y=65)
bt_logquit = tk.Button(window1, text='epnswe劵n5金币', command=d)
bt_logquit.place(x=80, y=65)
window1.mainloop()
完整 jifen.py代码
# -*- coding: utf-8 -*-
import tkinter as tk
import pickle
def jfsc():
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(0, usr_file)
window1 = tk.Toplevel()
window1.title('种田-金币商城')
window1.geometry('300x200')
window1.iconbitmap('.\m.ico')
global z,jb
z=0
jb=0
def a():
z=1
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def b():
z=2
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def c():
z=3
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def d():
z=4
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
bt_login = tk.Button(window1, text='赚金币速度x10n50金币', command=a)
bt_login.place(x=10, y=10)
bt_logquit = tk.Button(window1, text='收获翻倍一次n50金币', command=b)
bt_logquit.place(x=110, y=10)
bt_logquit = tk.Button(window1, text='快速种成n50金币', command=c)
bt_logquit.place(x=10, y=65)
bt_logquit = tk.Button(window1, text='epnswe劵n5金币', command=d)
bt_logquit.place(x=80, y=65)
window1.mainloop()
tp.py
小麦图
def xmt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
x=[30,180,330,480,630]
y=[30,320,610,900]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img.save(bc, "PNG")
水稻图
def sdt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (680, 660), (255, 255, 255))
x=[30,160,290,420,530]
y=[30,160,290,420]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img=img.resize((780, 1190), Image.ANTIALIAS)
img.save(bc, "PNG")
空白
def kj(bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
img.save(bc, "PNG")
完整tp.py代码
def xmt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
x=[30,180,330,480,630]
y=[30,320,610,900]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img.save(bc, "PNG")
def sdt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (680, 660), (255, 255, 255))
x=[30,160,290,420,530]
y=[30,160,290,420]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img=img.resize((780, 1190), Image.ANTIALIAS)
img.save(bc, "PNG")
def kj(bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
img.save(bc, "PNG")
扩展-种田十五位数据码验证
yz.py
import tkinter
from tkinter import ttk
from tkinter import *
import os
import pickle
win = tkinter.Tk()
win.title('种田15位数据码')
win.geometry('400x190')
win.iconbitmap('.\m.ico')
tkinter.Label(win,text='输入:').place(x=100, y=45)
zt = StringVar()
zt1=tkinter.Label(win, textvariable=zt,text='')
zt1.place(x=5, y=165)
db=tkinter.Entry(win, width=20)
db.place(x=100,y=65,height=23)
comvalue = tkinter.StringVar()
comboxlist = ttk.Combobox(win, textvariable=comvalue,width=3)
comboxlist["values"] = ('A','B','C','D','E','F','G','H','I','J')
comboxlist.current(0)
comboxlist.place(x=250, y=65)
def lr():
s=db.get()
z=comboxlist.get()
try:
if(len(s)==14):
db.delete(0, "end")
sum = 0
for i in s:
sum += int(i)
j = chr(sum % 10 + ord('A'))
if z==j:
wj=[]
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
wj.append(s+z)
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
zt.set('录入成功!')
else:
zt.set('录入失败!')
else:
zt.set('录入失败!')
except:
zt.set('录入失败!')
def sjk():
window1 = tkinter.Tk()
window1.title('数据库')
window1.geometry('450x320')
window1.iconbitmap('.\m.ico')
bz = tkinter.Text(window1)
bz.place(x=10, y=10, width=430, height=275)
s = tkinter.Entry(window1, width=30)
s.place(x=50, y=290, height=23)
def sx():
wj = []
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
for i in range(len(wj)):
wj[i] = str(i + 1) + ' ' + wj[i]
bz.delete(1.0, "end")
bz.insert('end', 'n'.join(wj))
sx()
def qk():
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump([], usr_file)
sx()
def sc():
sz=s.get()
sz=int(sz)
if sz<0:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
else:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz-1]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
s.delete(0,'end')
sx()
bt_login = tkinter.Button(window1, text='刷新', command=sx)
bt_login.place(x=310, y=285)
bt_login = tkinter.Button(window1, text='清空', command=qk)
bt_login.place(x=270, y=285)
bt_login = tkinter.Button(window1, text='删除', command=sc)
bt_login.place(x=10, y=285)
window1.mainloop()
bt_login = tkinter.Button(win, text='录入', command=lr)
bt_login.place(x=180, y=120)
bt_login = tkinter.Button(win, text='数据库', command=sjk)
bt_login.place(x=345, y=155)
win.mainloop()
文件目录架构
import pickle
import win32api
import win32print
import random
import time
import os
def dysj():
with open('./sjk/sjk.px', 'rb') as usr_file:
nr = pickle.load(usr_file)
s=time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
sum = 0
for i in s:
sum += int(i)
j = chr(sum % 10 + ord('A'))
s = s + str(j)
m=''
for i in range(12):
m1=''
for j in range(60):
m1+=str(random.randint(0, 1))
m+=m1+'n'
h=['破译:',
' open:',
' with open('./sjk/sjk.px', 'rb') as usr_file:',
' nr = pickle.load(usr_file)',
' save:',
' with open('./sjk/sjk.px', 'wb') as usr_file:',
' pickle.dump(nr, usr_file)',
'Binary code:',
m,
'15位数据码:',
s]
a=['sjk.px:']
for x,y in nr.items():
a.append(' ''+x+'':'+str(y))
a+=h
a='n'.join(a)
print(a)
file = open('./sjk/hc.txt', 'w')
file.write(a)
current_path = os.path.abspath(__file__)
father_path = os.path.abspath(os.path.dirname(current_path) + os.path.sep +'.')+ './sjk/hc.txt'
win32api.ShellExecute(0, "print", father_path, '/d:"%s"' % win32print.GetDefaultPrinter(), ".", 0)
return a
jifen.py
引入库
import tkinter as tk
import pickle
积分商城函数
def jfsc():
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(0, usr_file)
window1 = tk.Toplevel()
window1.title('种田-金币商城')
window1.geometry('300x200')
window1.iconbitmap('.\m.ico')
global z,jb
z=0
jb=0
def a():
z=1
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def b():
z=2
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def c():
z=3
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def d():
z=4
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
bt_login = tk.Button(window1, text='赚金币速度x10n50金币', command=a)
bt_login.place(x=10, y=10)
bt_logquit = tk.Button(window1, text='收获翻倍一次n50金币', command=b)
bt_logquit.place(x=110, y=10)
bt_logquit = tk.Button(window1, text='快速种成n50金币', command=c)
bt_logquit.place(x=10, y=65)
bt_logquit = tk.Button(window1, text='epnswe劵n5金币', command=d)
bt_logquit.place(x=80, y=65)
window1.mainloop()
完整 jifen.py代码
# -*- coding: utf-8 -*-
import tkinter as tk
import pickle
def jfsc():
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(0, usr_file)
window1 = tk.Toplevel()
window1.title('种田-金币商城')
window1.geometry('300x200')
window1.iconbitmap('.\m.ico')
global z,jb
z=0
jb=0
def a():
z=1
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def b():
z=2
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def c():
z=3
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def d():
z=4
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
bt_login = tk.Button(window1, text='赚金币速度x10n50金币', command=a)
bt_login.place(x=10, y=10)
bt_logquit = tk.Button(window1, text='收获翻倍一次n50金币', command=b)
bt_logquit.place(x=110, y=10)
bt_logquit = tk.Button(window1, text='快速种成n50金币', command=c)
bt_logquit.place(x=10, y=65)
bt_logquit = tk.Button(window1, text='epnswe劵n5金币', command=d)
bt_logquit.place(x=80, y=65)
window1.mainloop()
tp.py
小麦图
def xmt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
x=[30,180,330,480,630]
y=[30,320,610,900]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img.save(bc, "PNG")
水稻图
def sdt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (680, 660), (255, 255, 255))
x=[30,160,290,420,530]
y=[30,160,290,420]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img=img.resize((780, 1190), Image.ANTIALIAS)
img.save(bc, "PNG")
空白
def kj(bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
img.save(bc, "PNG")
完整tp.py代码
def xmt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
x=[30,180,330,480,630]
y=[30,320,610,900]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img.save(bc, "PNG")
def sdt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (680, 660), (255, 255, 255))
x=[30,160,290,420,530]
y=[30,160,290,420]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img=img.resize((780, 1190), Image.ANTIALIAS)
img.save(bc, "PNG")
def kj(bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
img.save(bc, "PNG")
扩展-种田十五位数据码验证
yz.py
import tkinter
from tkinter import ttk
from tkinter import *
import os
import pickle
win = tkinter.Tk()
win.title('种田15位数据码')
win.geometry('400x190')
win.iconbitmap('.\m.ico')
tkinter.Label(win,text='输入:').place(x=100, y=45)
zt = StringVar()
zt1=tkinter.Label(win, textvariable=zt,text='')
zt1.place(x=5, y=165)
db=tkinter.Entry(win, width=20)
db.place(x=100,y=65,height=23)
comvalue = tkinter.StringVar()
comboxlist = ttk.Combobox(win, textvariable=comvalue,width=3)
comboxlist["values"] = ('A','B','C','D','E','F','G','H','I','J')
comboxlist.current(0)
comboxlist.place(x=250, y=65)
def lr():
s=db.get()
z=comboxlist.get()
try:
if(len(s)==14):
db.delete(0, "end")
sum = 0
for i in s:
sum += int(i)
j = chr(sum % 10 + ord('A'))
if z==j:
wj=[]
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
wj.append(s+z)
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
zt.set('录入成功!')
else:
zt.set('录入失败!')
else:
zt.set('录入失败!')
except:
zt.set('录入失败!')
def sjk():
window1 = tkinter.Tk()
window1.title('数据库')
window1.geometry('450x320')
window1.iconbitmap('.\m.ico')
bz = tkinter.Text(window1)
bz.place(x=10, y=10, width=430, height=275)
s = tkinter.Entry(window1, width=30)
s.place(x=50, y=290, height=23)
def sx():
wj = []
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
for i in range(len(wj)):
wj[i] = str(i + 1) + ' ' + wj[i]
bz.delete(1.0, "end")
bz.insert('end', 'n'.join(wj))
sx()
def qk():
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump([], usr_file)
sx()
def sc():
sz=s.get()
sz=int(sz)
if sz<0:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
else:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz-1]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
s.delete(0,'end')
sx()
bt_login = tkinter.Button(window1, text='刷新', command=sx)
bt_login.place(x=310, y=285)
bt_login = tkinter.Button(window1, text='清空', command=qk)
bt_login.place(x=270, y=285)
bt_login = tkinter.Button(window1, text='删除', command=sc)
bt_login.place(x=10, y=285)
window1.mainloop()
bt_login = tkinter.Button(win, text='录入', command=lr)
bt_login.place(x=180, y=120)
bt_login = tkinter.Button(win, text='数据库', command=sjk)
bt_login.place(x=345, y=155)
win.mainloop()
文件目录架构
def jfsc():
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(0, usr_file)
window1 = tk.Toplevel()
window1.title('种田-金币商城')
window1.geometry('300x200')
window1.iconbitmap('.\m.ico')
global z,jb
z=0
jb=0
def a():
z=1
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def b():
z=2
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def c():
z=3
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def d():
z=4
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
bt_login = tk.Button(window1, text='赚金币速度x10n50金币', command=a)
bt_login.place(x=10, y=10)
bt_logquit = tk.Button(window1, text='收获翻倍一次n50金币', command=b)
bt_logquit.place(x=110, y=10)
bt_logquit = tk.Button(window1, text='快速种成n50金币', command=c)
bt_logquit.place(x=10, y=65)
bt_logquit = tk.Button(window1, text='epnswe劵n5金币', command=d)
bt_logquit.place(x=80, y=65)
window1.mainloop()
完整 jifen.py代码
# -*- coding: utf-8 -*-
import tkinter as tk
import pickle
def jfsc():
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(0, usr_file)
window1 = tk.Toplevel()
window1.title('种田-金币商城')
window1.geometry('300x200')
window1.iconbitmap('.\m.ico')
global z,jb
z=0
jb=0
def a():
z=1
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def b():
z=2
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def c():
z=3
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
def d():
z=4
with open('./sjk/sjkjfsc.px', 'wb') as usr_file:
pickle.dump(z, usr_file)
window1.quit()
bt_login = tk.Button(window1, text='赚金币速度x10n50金币', command=a)
bt_login.place(x=10, y=10)
bt_logquit = tk.Button(window1, text='收获翻倍一次n50金币', command=b)
bt_logquit.place(x=110, y=10)
bt_logquit = tk.Button(window1, text='快速种成n50金币', command=c)
bt_logquit.place(x=10, y=65)
bt_logquit = tk.Button(window1, text='epnswe劵n5金币', command=d)
bt_logquit.place(x=80, y=65)
window1.mainloop()
tp.py
小麦图
def xmt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
x=[30,180,330,480,630]
y=[30,320,610,900]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img.save(bc, "PNG")
水稻图
def sdt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (680, 660), (255, 255, 255))
x=[30,160,290,420,530]
y=[30,160,290,420]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img=img.resize((780, 1190), Image.ANTIALIAS)
img.save(bc, "PNG")
空白
def kj(bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
img.save(bc, "PNG")
完整tp.py代码
def xmt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
x=[30,180,330,480,630]
y=[30,320,610,900]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img.save(bc, "PNG")
def sdt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (680, 660), (255, 255, 255))
x=[30,160,290,420,530]
y=[30,160,290,420]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img=img.resize((780, 1190), Image.ANTIALIAS)
img.save(bc, "PNG")
def kj(bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
img.save(bc, "PNG")
扩展-种田十五位数据码验证
yz.py
import tkinter
from tkinter import ttk
from tkinter import *
import os
import pickle
win = tkinter.Tk()
win.title('种田15位数据码')
win.geometry('400x190')
win.iconbitmap('.\m.ico')
tkinter.Label(win,text='输入:').place(x=100, y=45)
zt = StringVar()
zt1=tkinter.Label(win, textvariable=zt,text='')
zt1.place(x=5, y=165)
db=tkinter.Entry(win, width=20)
db.place(x=100,y=65,height=23)
comvalue = tkinter.StringVar()
comboxlist = ttk.Combobox(win, textvariable=comvalue,width=3)
comboxlist["values"] = ('A','B','C','D','E','F','G','H','I','J')
comboxlist.current(0)
comboxlist.place(x=250, y=65)
def lr():
s=db.get()
z=comboxlist.get()
try:
if(len(s)==14):
db.delete(0, "end")
sum = 0
for i in s:
sum += int(i)
j = chr(sum % 10 + ord('A'))
if z==j:
wj=[]
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
wj.append(s+z)
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
zt.set('录入成功!')
else:
zt.set('录入失败!')
else:
zt.set('录入失败!')
except:
zt.set('录入失败!')
def sjk():
window1 = tkinter.Tk()
window1.title('数据库')
window1.geometry('450x320')
window1.iconbitmap('.\m.ico')
bz = tkinter.Text(window1)
bz.place(x=10, y=10, width=430, height=275)
s = tkinter.Entry(window1, width=30)
s.place(x=50, y=290, height=23)
def sx():
wj = []
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
for i in range(len(wj)):
wj[i] = str(i + 1) + ' ' + wj[i]
bz.delete(1.0, "end")
bz.insert('end', 'n'.join(wj))
sx()
def qk():
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump([], usr_file)
sx()
def sc():
sz=s.get()
sz=int(sz)
if sz<0:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
else:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz-1]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
s.delete(0,'end')
sx()
bt_login = tkinter.Button(window1, text='刷新', command=sx)
bt_login.place(x=310, y=285)
bt_login = tkinter.Button(window1, text='清空', command=qk)
bt_login.place(x=270, y=285)
bt_login = tkinter.Button(window1, text='删除', command=sc)
bt_login.place(x=10, y=285)
window1.mainloop()
bt_login = tkinter.Button(win, text='录入', command=lr)
bt_login.place(x=180, y=120)
bt_login = tkinter.Button(win, text='数据库', command=sjk)
bt_login.place(x=345, y=155)
win.mainloop()
文件目录架构
小麦图
def xmt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
x=[30,180,330,480,630]
y=[30,320,610,900]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img.save(bc, "PNG")
水稻图
def sdt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (680, 660), (255, 255, 255))
x=[30,160,290,420,530]
y=[30,160,290,420]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img=img.resize((780, 1190), Image.ANTIALIAS)
img.save(bc, "PNG")
空白
def kj(bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
img.save(bc, "PNG")
完整tp.py代码
def xmt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
x=[30,180,330,480,630]
y=[30,320,610,900]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img.save(bc, "PNG")
def sdt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (680, 660), (255, 255, 255))
x=[30,160,290,420,530]
y=[30,160,290,420]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img=img.resize((780, 1190), Image.ANTIALIAS)
img.save(bc, "PNG")
def kj(bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
img.save(bc, "PNG")
扩展-种田十五位数据码验证
yz.py
import tkinter
from tkinter import ttk
from tkinter import *
import os
import pickle
win = tkinter.Tk()
win.title('种田15位数据码')
win.geometry('400x190')
win.iconbitmap('.\m.ico')
tkinter.Label(win,text='输入:').place(x=100, y=45)
zt = StringVar()
zt1=tkinter.Label(win, textvariable=zt,text='')
zt1.place(x=5, y=165)
db=tkinter.Entry(win, width=20)
db.place(x=100,y=65,height=23)
comvalue = tkinter.StringVar()
comboxlist = ttk.Combobox(win, textvariable=comvalue,width=3)
comboxlist["values"] = ('A','B','C','D','E','F','G','H','I','J')
comboxlist.current(0)
comboxlist.place(x=250, y=65)
def lr():
s=db.get()
z=comboxlist.get()
try:
if(len(s)==14):
db.delete(0, "end")
sum = 0
for i in s:
sum += int(i)
j = chr(sum % 10 + ord('A'))
if z==j:
wj=[]
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
wj.append(s+z)
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
zt.set('录入成功!')
else:
zt.set('录入失败!')
else:
zt.set('录入失败!')
except:
zt.set('录入失败!')
def sjk():
window1 = tkinter.Tk()
window1.title('数据库')
window1.geometry('450x320')
window1.iconbitmap('.\m.ico')
bz = tkinter.Text(window1)
bz.place(x=10, y=10, width=430, height=275)
s = tkinter.Entry(window1, width=30)
s.place(x=50, y=290, height=23)
def sx():
wj = []
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
for i in range(len(wj)):
wj[i] = str(i + 1) + ' ' + wj[i]
bz.delete(1.0, "end")
bz.insert('end', 'n'.join(wj))
sx()
def qk():
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump([], usr_file)
sx()
def sc():
sz=s.get()
sz=int(sz)
if sz<0:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
else:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz-1]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
s.delete(0,'end')
sx()
bt_login = tkinter.Button(window1, text='刷新', command=sx)
bt_login.place(x=310, y=285)
bt_login = tkinter.Button(window1, text='清空', command=qk)
bt_login.place(x=270, y=285)
bt_login = tkinter.Button(window1, text='删除', command=sc)
bt_login.place(x=10, y=285)
window1.mainloop()
bt_login = tkinter.Button(win, text='录入', command=lr)
bt_login.place(x=180, y=120)
bt_login = tkinter.Button(win, text='数据库', command=sjk)
bt_login.place(x=345, y=155)
win.mainloop()
文件目录架构
def sdt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (680, 660), (255, 255, 255))
x=[30,160,290,420,530]
y=[30,160,290,420]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img=img.resize((780, 1190), Image.ANTIALIAS)
img.save(bc, "PNG")
空白
def kj(bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
img.save(bc, "PNG")
完整tp.py代码
def xmt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
x=[30,180,330,480,630]
y=[30,320,610,900]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img.save(bc, "PNG")
def sdt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (680, 660), (255, 255, 255))
x=[30,160,290,420,530]
y=[30,160,290,420]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img=img.resize((780, 1190), Image.ANTIALIAS)
img.save(bc, "PNG")
def kj(bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
img.save(bc, "PNG")
扩展-种田十五位数据码验证
yz.py
import tkinter
from tkinter import ttk
from tkinter import *
import os
import pickle
win = tkinter.Tk()
win.title('种田15位数据码')
win.geometry('400x190')
win.iconbitmap('.\m.ico')
tkinter.Label(win,text='输入:').place(x=100, y=45)
zt = StringVar()
zt1=tkinter.Label(win, textvariable=zt,text='')
zt1.place(x=5, y=165)
db=tkinter.Entry(win, width=20)
db.place(x=100,y=65,height=23)
comvalue = tkinter.StringVar()
comboxlist = ttk.Combobox(win, textvariable=comvalue,width=3)
comboxlist["values"] = ('A','B','C','D','E','F','G','H','I','J')
comboxlist.current(0)
comboxlist.place(x=250, y=65)
def lr():
s=db.get()
z=comboxlist.get()
try:
if(len(s)==14):
db.delete(0, "end")
sum = 0
for i in s:
sum += int(i)
j = chr(sum % 10 + ord('A'))
if z==j:
wj=[]
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
wj.append(s+z)
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
zt.set('录入成功!')
else:
zt.set('录入失败!')
else:
zt.set('录入失败!')
except:
zt.set('录入失败!')
def sjk():
window1 = tkinter.Tk()
window1.title('数据库')
window1.geometry('450x320')
window1.iconbitmap('.\m.ico')
bz = tkinter.Text(window1)
bz.place(x=10, y=10, width=430, height=275)
s = tkinter.Entry(window1, width=30)
s.place(x=50, y=290, height=23)
def sx():
wj = []
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
for i in range(len(wj)):
wj[i] = str(i + 1) + ' ' + wj[i]
bz.delete(1.0, "end")
bz.insert('end', 'n'.join(wj))
sx()
def qk():
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump([], usr_file)
sx()
def sc():
sz=s.get()
sz=int(sz)
if sz<0:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
else:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz-1]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
s.delete(0,'end')
sx()
bt_login = tkinter.Button(window1, text='刷新', command=sx)
bt_login.place(x=310, y=285)
bt_login = tkinter.Button(window1, text='清空', command=qk)
bt_login.place(x=270, y=285)
bt_login = tkinter.Button(window1, text='删除', command=sc)
bt_login.place(x=10, y=285)
window1.mainloop()
bt_login = tkinter.Button(win, text='录入', command=lr)
bt_login.place(x=180, y=120)
bt_login = tkinter.Button(win, text='数据库', command=sjk)
bt_login.place(x=345, y=155)
win.mainloop()
文件目录架构
def xmt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
x=[30,180,330,480,630]
y=[30,320,610,900]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img.save(bc, "PNG")
def sdt(zp,bc):
from PIL import Image
img = Image.new("RGBA", (680, 660), (255, 255, 255))
x=[30,160,290,420,530]
y=[30,160,290,420]
img1 = Image.open(zp)
for i in x:
for j in y:
img.paste(img1, (i, j))
img=img.resize((780, 1190), Image.ANTIALIAS)
img.save(bc, "PNG")
def kj(bc):
from PIL import Image
img = Image.new("RGBA", (780, 1190), (255, 255, 255))
img.save(bc, "PNG")
扩展-种田十五位数据码验证
yz.py
import tkinter
from tkinter import ttk
from tkinter import *
import os
import pickle
win = tkinter.Tk()
win.title('种田15位数据码')
win.geometry('400x190')
win.iconbitmap('.\m.ico')
tkinter.Label(win,text='输入:').place(x=100, y=45)
zt = StringVar()
zt1=tkinter.Label(win, textvariable=zt,text='')
zt1.place(x=5, y=165)
db=tkinter.Entry(win, width=20)
db.place(x=100,y=65,height=23)
comvalue = tkinter.StringVar()
comboxlist = ttk.Combobox(win, textvariable=comvalue,width=3)
comboxlist["values"] = ('A','B','C','D','E','F','G','H','I','J')
comboxlist.current(0)
comboxlist.place(x=250, y=65)
def lr():
s=db.get()
z=comboxlist.get()
try:
if(len(s)==14):
db.delete(0, "end")
sum = 0
for i in s:
sum += int(i)
j = chr(sum % 10 + ord('A'))
if z==j:
wj=[]
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
wj.append(s+z)
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
zt.set('录入成功!')
else:
zt.set('录入失败!')
else:
zt.set('录入失败!')
except:
zt.set('录入失败!')
def sjk():
window1 = tkinter.Tk()
window1.title('数据库')
window1.geometry('450x320')
window1.iconbitmap('.\m.ico')
bz = tkinter.Text(window1)
bz.place(x=10, y=10, width=430, height=275)
s = tkinter.Entry(window1, width=30)
s.place(x=50, y=290, height=23)
def sx():
wj = []
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
for i in range(len(wj)):
wj[i] = str(i + 1) + ' ' + wj[i]
bz.delete(1.0, "end")
bz.insert('end', 'n'.join(wj))
sx()
def qk():
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump([], usr_file)
sx()
def sc():
sz=s.get()
sz=int(sz)
if sz<0:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
else:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz-1]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
s.delete(0,'end')
sx()
bt_login = tkinter.Button(window1, text='刷新', command=sx)
bt_login.place(x=310, y=285)
bt_login = tkinter.Button(window1, text='清空', command=qk)
bt_login.place(x=270, y=285)
bt_login = tkinter.Button(window1, text='删除', command=sc)
bt_login.place(x=10, y=285)
window1.mainloop()
bt_login = tkinter.Button(win, text='录入', command=lr)
bt_login.place(x=180, y=120)
bt_login = tkinter.Button(win, text='数据库', command=sjk)
bt_login.place(x=345, y=155)
win.mainloop()
文件目录架构
import tkinter
from tkinter import ttk
from tkinter import *
import os
import pickle
win = tkinter.Tk()
win.title('种田15位数据码')
win.geometry('400x190')
win.iconbitmap('.\m.ico')
tkinter.Label(win,text='输入:').place(x=100, y=45)
zt = StringVar()
zt1=tkinter.Label(win, textvariable=zt,text='')
zt1.place(x=5, y=165)
db=tkinter.Entry(win, width=20)
db.place(x=100,y=65,height=23)
comvalue = tkinter.StringVar()
comboxlist = ttk.Combobox(win, textvariable=comvalue,width=3)
comboxlist["values"] = ('A','B','C','D','E','F','G','H','I','J')
comboxlist.current(0)
comboxlist.place(x=250, y=65)
def lr():
s=db.get()
z=comboxlist.get()
try:
if(len(s)==14):
db.delete(0, "end")
sum = 0
for i in s:
sum += int(i)
j = chr(sum % 10 + ord('A'))
if z==j:
wj=[]
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
wj.append(s+z)
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
zt.set('录入成功!')
else:
zt.set('录入失败!')
else:
zt.set('录入失败!')
except:
zt.set('录入失败!')
def sjk():
window1 = tkinter.Tk()
window1.title('数据库')
window1.geometry('450x320')
window1.iconbitmap('.\m.ico')
bz = tkinter.Text(window1)
bz.place(x=10, y=10, width=430, height=275)
s = tkinter.Entry(window1, width=30)
s.place(x=50, y=290, height=23)
def sx():
wj = []
if os.path.exists('./sjk/b.px'):
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
for i in range(len(wj)):
wj[i] = str(i + 1) + ' ' + wj[i]
bz.delete(1.0, "end")
bz.insert('end', 'n'.join(wj))
sx()
def qk():
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump([], usr_file)
sx()
def sc():
sz=s.get()
sz=int(sz)
if sz<0:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
else:
with open('./sjk/b.px', 'rb') as usr_file:
wj = pickle.load(usr_file)
del wj[sz-1]
with open('./sjk/b.px', 'wb') as usr_file:
pickle.dump(wj, usr_file)
s.delete(0,'end')
sx()
bt_login = tkinter.Button(window1, text='刷新', command=sx)
bt_login.place(x=310, y=285)
bt_login = tkinter.Button(window1, text='清空', command=qk)
bt_login.place(x=270, y=285)
bt_login = tkinter.Button(window1, text='删除', command=sc)
bt_login.place(x=10, y=285)
window1.mainloop()
bt_login = tkinter.Button(win, text='录入', command=lr)
bt_login.place(x=180, y=120)
bt_login = tkinter.Button(win, text='数据库', command=sjk)
bt_login.place(x=345, y=155)
win.mainloop()
文件目录架构
完整代码下载
百度网盘
https://pan.baidu.com/s/1U7Tw8gv4EAh1ouBTJqM3Ng?pwd=esgn



