master
ZiYi 4 years ago
parent a15b6c45ee
commit 15c19df1e8

@ -1 +0,0 @@
# test

@ -1,45 +0,0 @@
from tkinter import *
def run1():
a = float(inp1.get())
b = float(inp2.get())
s = '%0.2f+%0.2f=%0.2f\n' % (a, b, a + b)
txt.insert(END, s) # 追加显示运算结果
inp1.delete(0, END) # 清空输入
inp2.delete(0, END) # 清空输入
def run2(x, y):
a = float(x)
b = float(y)
s = '%0.2f+%0.2f=%0.2f\n' % (a, b, a + b)
txt.insert(END, s) # 追加显示运算结果
inp1.delete(0, END) # 清空输入
inp2.delete(0, END) # 清空输入
root = Tk()
root.geometry('460x240')
root.title('简单加法器')
lb1 = Label(root, text='请输入两个数,按下面两个按钮之一进行加法计算')
lb1.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.1)
inp1 = Entry(root)
inp1.place(relx=0.1, rely=0.2, relwidth=0.3, relheight=0.1)
inp2 = Entry(root)
inp2.place(relx=0.6, rely=0.2, relwidth=0.3, relheight=0.1)
# 方法-直接调用 run1()
btn1 = Button(root, text='方法一', command=run1)
btn1.place(relx=0.1, rely=0.4, relwidth=0.3, relheight=0.1)
'''
# 方法二利用 lambda 传参数调用run2()
btn2 = Button(root, text='方法二', command=lambda: run2(inp1.get(), inp2.get()))
btn2.place(relx=0.6, rely=0.4, relwidth=0.3, relheight=0.1)
'''
# 在窗体垂直自上而下位置60%处起布局相对窗体高度40%高的文本框
txt = Text(root)
txt.place(rely=0.6, relheight=0.4)
root.mainloop()

@ -5,10 +5,12 @@
html,body{
margin: 0px;
padding: 0;
width: 100%;
height: 90%;
overflow: hidden;
background: #c2ccd0;
overflow-y: hidden;
background: #c2ccd0e5;
}
body{
width: 100vw;
height: 100vh;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
@ -29,17 +31,21 @@ h1{
box-shadow: 4px 4px 5px #888888;
}
ul{
width: 60%;
display: block;
height: 50%;
min-width: 500px;
max-width: 50%;
position: relative;
left: 20%;
left: 25%;
text-align: right;
border: 1px solid #bbcdc5;
box-shadow: 4px 4px 5px #888888;
overflow: auto;
}
li{
height: 10px;
margin: 5px;
padding: 10px;
width: 80%;
list-style: none;
}
.notice{
@ -55,14 +61,14 @@ li{
display: block;
margin: 10px;
padding: 10px;
height: 25%;
height: 15%;
text-align: center;
font-size: large;
font-weight: bold;
background: #e0eee8;
}
.display{
height: 90%;
height: 85%;
margin: 10px;
padding: 10px;
position: relative;
@ -72,6 +78,8 @@ li{
font-weight: bold;
text-align: center;
background: #e0eee8;
overflow-y: auto;
overflow-x: hidden;
}
.result{
outline: none;

@ -1,25 +0,0 @@
//计时器
var intDiff = parseInt(15);//倒计时总秒数量
function timer(intDiff) {
window.setInterval(function () {
var minute = 0,
second = 0;//时间默认值
if (intDiff > 0) {
minute = Math.floor(intDiff / 60);
second = Math.floor(intDiff) - (minute * 60);
}
if (minute <= 9) minute = '0' + minute;
if (second <= 9) second = '0' + second;
$('#minute').html('<s></s>' + minute + '分');
$('#second').html('<s></s>' + second + '秒');
intDiff++;
if (intDiff >= 20) {
clearInterval(timer); //定时器清除;
history.back(-1);
}
}, 1000);
}
$(function () {
timer(intDiff);
});

@ -31,9 +31,7 @@
</div>
<div class="display">
<span id="info" style="display: none;"></span>
<ul id="ul" style="display: none">
</ul>
</div>
<ul id="ul" style="display: none"></ul>
</div>
</body>

Loading…
Cancel
Save