开发背景:
封校,闲出屁
主程序:

# auth:愚者
# blog:www.reaper0s.com
import tkinter as tk
import webbrowser
import requests


def open_url(event):
    webbrowser.open("http://www.reaper0s.com", new=0)


def getbalance(roomid):
    buildingid = int(int(roomid) / 1000 + 1)
    s = requests.session()
    s.headers = {
        'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Mobile Safari/537.36'
    }
    commonapi = 'http://218.91.39.59:8988/web/Common/Tsm.html'
    data = {
        'jsondata': '{"query_elec_roominfo": {"aid": "0030000000002501", "account": "110", "room": {"roomid":' + str(
            roomid) + ', "room": ""},"floor": {"floorid": "", "floor": ""},"area": {"area": "南京邮电大学通达学院", "areaname": "南京邮电大学通达学院"},"building": {"buildingid": "' + str(
            buildingid) + '", "building": ""}}}',
        'json': 'true',
        'funname': 'synjones.onecard.query.elec.roominfo'
    }
    commoninfo = s.post(commonapi, data).json()
    balancemsg = rf'{roomid}: {commoninfo["query_elec_roominfo"]["errmsg"]}'
    return balancemsg


def select(event):
    msg = getbalance(entry.get())
    label1.config(text=msg)

window = tk.Tk()
window.title('南京邮电大学通达学院查电费助手')
window.geometry('360x280')
window.resizable(False, False)

label1 = tk.Label(window, width=35, height=3, bg='yellow', text='请输入宿舍号后,点击查询按钮', font='50')
label2 = tk.Label(window, text='宿舍号:')
entry = tk.Entry(window, font='50', highlightcolor='blue', highlightthickness=1)
button = tk.Button(window, text='查询', width=20, height=3, bg='#2f3542', fg='#ffffff', font='楷体,30')
link = tk.Label(window, text='auth:愚者\nblog:www.reaper0s.com', font=('Arial', 10))

entry.bind("<Return>", select)
button.bind("<Button-1>", select)
link.bind("<Button-1>", open_url)


label1.place(relx=0.5, rely=0.2, anchor='n')
label2.place(relx=0.37, rely=0.41, anchor='n')
entry.place(relx=0.5, rely=0.4, anchor='n', width=50, height=30)
button.place(relx=0.5, rely=0.52, anchor='n')
link.place(relx=1, rely=1, anchor='se')
window.mainloop()

运行结果:

image.png
image.png
image.png
image.png

下载地址:

最后修改:2022 年 10 月 03 日
如果觉得我的文章对你有用,请随意赞赏