Tkinter编写窗口程序 崩坏3周常任务计算窗口

要和 崩坏3水晶计算 关于日期的计算篇 上 中编写的方法time一同使用

import tkinter as tk       #编写可视化程序要使用的库
from 日期 import time      #配合我上篇写的time方法一同使用
import os


root = tk.Tk()  #格式化

root.title('日期计算器')   #窗口名称
root.geometry('695x265')   #窗口大小
root.resizable(width = False,height = False)   #False表示窗口大小不可变True反之


tk.Label(root,text = '差异日期').place(x = 10,y = 15)  
e1 = tk.Entry(root,width = 20,show = None)     #创建输入框
e1.place(x = 3,y = 50)      #输入框的位置  请不要将这一步与上一步合并,否则会导致无法获得输入框写入的数值


def s(): 
	time_different = int(e1.get())   #获取输入框填入的字符并转换成数字格式
	All = time(time_different)      #调用之前写的日期函数 获得返回值
	total = All[0]   
	Abyss_open = All[1]
	Abyss_end = All[2]
	Battle_open = All[3]
	Battle_end = All[4]

	#清除写字板上的内容
	w1.delete('1.0','end')
	w2.delete('1.0','end')
	w3.delete('1.0','end')
	w4.delete('1.0','end')
	w5.delete('1.0','end')
	

	w1.insert('end',total)
	save_title = total
	w2.insert('end','深渊开放日期\n------------------------\n')
	save_title = save_title +'\n\n\n深渊开放日期\n------------------------\n'
	#英语不过关,就不要纠结我的变量名了,看得懂就可以
	for A_O in Abyss_open:   
		save_title = save_title + A_O +'\n'
		w2.insert('end',str(A_O)+'\n')
	w3.insert('end','深渊结算日期\n------------------------\n')
	save_title = save_title +'\n\n\n深渊结算日期\n------------------------\n'
	for A_E in Abyss_end:
		save_title = save_title + A_E +'\n'
		w3.insert('end',str(A_E)+'\n')
	w4.insert('end','战场开放日期\n------------------------\n')
	save_title = save_title +'\n\n\n战场开放日期\n------------------------\n'
	for B_O in Battle_open:
		save_title = save_title + B_O +'\n'
		w4.insert('end',str(B_O)+'\n')
	w5.insert('end','战场结算日期\n------------------------\n')
	save_title = save_title +'\n\n\n战场结算日期\n------------------------\n'
	for B_E in Battle_end:
		save_title = save_title + B_E +'\n'
		w5.insert('end',str(B_E)+'\n')
	tk.Label(root,text = 'tips:输出界面可以向下翻动').place(x = 2,y = 240)
	return save_title

def delete():     #清除方法
	w1.delete('1.0','end')
	w2.delete('1.0','end')
	w3.delete('1.0','end')
	w4.delete('1.0','end')
	w5.delete('1.0','end')
	e1.delete('0','end')	 



def S(save_title):    #点击计算时使用的方法
	name = 'Record_book'
	filename = 'C:\\Users\\Public\\Desktop\\'+name+'.txt'
	with open(filename,'a') as save:
		save.write(save_title)
	return filename


def save():      #点击保存时使用的方法
	save_title = s()
	filename = S(save_title)
	os.remove(filename)
	S(save_title)
	

b_start = tk.Button(root,text = '计算',command =s,width = 20,height = 2 ).place(x = 2,y = 80)
b_save = tk.Button(root,text = '保存',command = save,width = 20,height = 2).place(x = 2,y = 130)
b_exit = tk.Button(root,text = '退出',command = root.quit,width = 20,height = 2).place(x = 2,y = 180)
b_X = tk.Button(root,text = '清除',command = delete,width = 5,height = 0).place(x = 90,y = 10)

#关于写字板属性的定义
w1 = tk.Text(root,width = 24,height = 19)
w2 = tk.Text(root,width = 24,height = 9)
w3 = tk.Text(root,width = 24,height = 9)
w4 = tk.Text(root,width = 24,height = 9)
w5 = tk.Text(root,width = 24,height = 9)

#写字板位置
w1.place(x = 154,y = 5)
w2.place(x = 334,y = 5)
w3.place(x = 334,y =135)
w4.place(x = 514,y = 5)
w5.place(x = 514,y = 135)


#开始循环
root.mainloop()

在这里插入图片描述

时间 2020/2/24

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值