最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

使用Python實(shí)現(xiàn)大學(xué)座位預(yù)約功能

 更新時(shí)間:2022年03月22日 14:14:55   作者:螞蟻ailing  
這篇文章主要介紹了如何用Python實(shí)現(xiàn)大學(xué)座位預(yù)約,今天這個(gè)教程教你如何搶到座位,有座位了還怕聽不到課嗎?感興趣的朋友一起看看吧

在大學(xué),有很多喜歡的課是需要搶的。但是,這個(gè)課的人數(shù)和座位都是有限的,今天這個(gè)教程教你如何搶到座位,有座位了還怕聽不到課嗎?趕緊學(xué)起來吧,真的很有用噢!

0. 效果

座位選擇框

1. 關(guān)于所需庫

Python 環(huán)境中需要安裝下列 python 包:

1.PySide2

2.datetime

3.json

4.argparse

2. 關(guān)于座位選擇框

選擇框內(nèi)桌子數(shù)量,大小,樣式以及每個(gè)椅子位置都是可變的,例如我們可以將桌子顏色和是否圓角改變:

這主要依靠seatInf.json內(nèi)的信息,展示如下:

#   {
    "tableNum": 6,
    "tablePos": [
        [0.02,0.15],
        [0.35,0.15],
        [0.68,0.15],
        [0.02,0.65],
        [0.35,0.65],
        [0.68,0.65]
    ],
    "tableSize": [
        [0.25,0.2],
        [0.25,0.2],
        [0.25,0.2],
        [0.25,0.2],
        [0.25,0.2],
        [0.25,0.2]
    ],
    "tableType": [
        0,1,2,0,0,0
    ],
    "tableSS": [
        "QLabel{background: rgb(245,245,245);color:rgb(92,92,92);border-radius:50px;border: 3px solid rgb(142,142,142)}",
        "QLabel{background: rgb(245,245,245);color:rgb(92,92,92);border: 3px solid rgb(142,142,142)}",
        "QLabel{background: rgb(221,217,195);color:rgb(92,92,92);border: 3px solid rgb(142,142,142)}"
    ],
    "tableId": [
        "A","B","C","D","E","F"
    ],
    "chairNum": [
        6,6,6,6,6,6
    ],
    "chairPos": [
        [
            [0.04,-0.08],
            [0.105,-0.08],
            [0.17,-0.08],
            [0.04,0.21],
            [0.105,0.21],
            [0.17,0.21]
        ],
        [
            [0.04,-0.08],
            [0.105,-0.08],
            [0.17,-0.08],
            [0.04,0.21],
            [0.105,0.21],
            [0.17,0.21]
        ],[
            [0.04,-0.08],
            [0.105,-0.08],
            [0.17,-0.08],
            [0.04,0.21],
            [0.105,0.21],
            [0.17,0.21]
        ],[
            [0.04,-0.08],
            [0.105,-0.08],
            [0.17,-0.08],
            [0.04,0.21],
            [0.105,0.21],
            [0.17,0.21]
        ],[
            [0.04,-0.08],
            [0.105,-0.08],
            [0.17,-0.08],
            [0.04,0.21],
            [0.105,0.21],
            [0.17,0.21]
        ],[
            [0.04,-0.08],
            [0.105,-0.08],
            [0.17,-0.08],
            [0.04,0.21],
            [0.105,0.21],
            [0.17,0.21]
        ]
    ],
    "chairSize": [
        0.032,0.07
    ],
    "chairSS_W": "background: rgb(242,242,242);border-radius:15px;border: 3px solid rgb(74,69,42)",
    "chairSS_K": "background: rgb(64,64,64);border-radius:15px;border: 3px solid rgb(74,69,42)",
    "chairSS_R": "background: rgb(149,55,43);border-radius:15px;border: 3px solid rgb(74,69,42)",
    "mapSize": [
        2,2
    ]
}

3. 關(guān)于申請(qǐng)表和座位被占情況

由于只是為了模擬過程,現(xiàn)申請(qǐng)表以及座位被占情況分別存儲(chǔ)在orderList.json和occupied.json中:

3.1 orderList.json:

#   "[[\"A1\", \"A2\", \"A3\", \"A4\", \"A5\", \"A6\", \"B1\", \"B2\", \"B3\", \"B4\", \"B5\", \"B6\", \"C1\", \"C2\", \"C3\", \"C4\", \"C5\", \"C6\", \"D1\", \"D2\", \"D3\", \"D4\", \"D5\", \"D6\", \"E1\", \"E2\", \"E3\", \"E4\", \"E5\", \"E6\", \"F1\", \"F2\", \"F3\", \"F4\", \"F5\", \"F6\"], [\"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"1816000XXXX\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\"], [\"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"temp\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\"]]"

3.2 occupied.json:

#   "{\"A1\": false, \"A2\": false, \"A3\": false, \"A4\": false, \"A5\": false, \"A6\": false, \"B1\": false, \"B2\": false, \"B3\": false, \"B4\": false, \"B5\": false, \"B6\": false, \"C1\": false, \"C2\": false, \"C3\": false, \"C4\": true, \"C5\": false, \"C6\": false, \"D1\": false, \"D2\": false, \"D3\": false, \"D4\": false, \"D5\": false, \"D6\": false, \"E1\": false, \"E2\": false, \"E3\": false, \"E4\": false, \"E5\": false, \"E6\": false, \"F1\": false, \"F2\": false, \"F3\": false, \"F4\": false, \"F5\": false, \"F6\": false}"

 

4. 關(guān)于命令行參數(shù)

我們使用命令行代碼模擬刷卡過程,同時(shí)我們也設(shè)置了預(yù)約和申請(qǐng)暫離的命令行代碼:

4.1 slotCard_in

#   Python slotCard_in.py -i="XXXXXXXXXXX"
Python slotCard_in.py --student-id="XXXXXXXXXXX"

4.2 slotCard_out

#  Python slotCard_out.py -i="XXXXXXXXXXX"
Python slotCard_out.py --student-id="XXXXXXXXXXX"

4.3 cmd_order

#   '''
TEST CODE:
--------------------------------
see Map:
Python cmd_order.py
--------------------------------
order seat: 
Python cmd_order.py -i="XXXXXXXXXXX" -n="xxx" -s="A1"

-h   --help         show the help message and exit
-i   --student-id   student id
-n   --student-name student name
-s   --seatPos      seat id  
'''

4.4 cmd_leave

#   '''
TEST CODE:
----------------------------------------------
leave for temp
Python cmd_leave.py -i="XXXXXXXXXXX" -t="temp"
----------------------------------------------
leave
Python cmd_leave.py -i="XXXXXXXXXXX" -t="free"  
[or]
Python cmd_leave.py -i="XXXXXXXXXXX" 

-h   --help         show the help message and exit
-i   --student-id   student id
-t   --leave-type   temp/free 
'''

5. 關(guān)于命令行輸出

5.1 cmd_order 預(yù)約

#   > Python cmd_order.py
[seat]============================
可預(yù)約座位:

 ▇ A2 A3 A4 A5 A6
 B1 B2 B3 B4 B5 B6
 C1 C2 C3 C4 C5 C6
 D1 D2 D3 D4 D5 D6
 E1 E2 E3 E4 E5 E6
 F1 F2 F3 F4 F5 F6
> Python cmd_order.py -i="18160000000" -n="xxx" -s="A1"
[book error]========================
座位已被占,請(qǐng)選擇其他位置申請(qǐng)
> Python cmd_order.py -i="18160000000" -n="xxx" -s="A100"
座位編號(hào)格式不正確
> Python cmd_order.py -i="18160000000" -n="xxx" -s="A2"
[book]===========================================
2021-05-31 18:04:35
姓名:xxx
學(xué)號(hào):18160000000
座次:A2
預(yù)約成功!
-------------------------------------------------
注意事項(xiàng):
1、預(yù)約成功后請(qǐng)?jiān)?0分鐘內(nèi)到達(dá),否則預(yù)約信息將失效。
2、進(jìn)入自習(xí)室前請(qǐng)刷校園卡核驗(yàn)信息。
3、如要暫離請(qǐng)cmd運(yùn)行如下代碼:
   Python cmd_leave.py -i='XXXXXXXXXXX' -t='temp'
4、離開、取消預(yù)約請(qǐng)cmd運(yùn)行如下代碼:
   Python cmd_leave.py -i='XXXXXXXXXXX' -t='free'
> Python cmd_order.py -i="18160000000" -n="xxx" -s="A3"
請(qǐng)勿重復(fù)預(yù)約

5.2 slotCard_in 刷卡進(jìn)入

#   > Python slotCard_in.py -i="1816000XXXX"
[in error]==========================
非本校校園卡或已超時(shí)
> Python slotCard_in.py -i="18160000000"
[in]================================
預(yù)約時(shí)間:2021-05-31 18:04:35
校園卡號(hào):18160000000
座次:A2

5.3 cmd_leave 申請(qǐng)離開或暫離

#   > Python cmd_leave.py -i="1816000XXXX" -t="temp"
[out error]=========================
可能輸入了錯(cuò)誤的校園卡號(hào)

> Python cmd_leave.py -i="18160000000" -t="temp"
[out]===============================
已進(jìn)行暫離申請(qǐng)
> Python cmd_leave.py -i="18160000000" -t="free"
已釋放位置

5.4 slotCard_out 刷卡離開或暫離

#   > Python slotCard_out.py -i="18160000000"
[out]===============================
暫離時(shí)間:2021-05-31 18:23:09
校園卡號(hào):18160000000
座次:A1

> Python slotCard_out.py -i="1816000XXXX"
[out error]=========================
請(qǐng)更換卡片再次嘗試

6. 關(guān)于界面代碼

6.1 orderSystem.py

#   from PySide2.QtWidgets import QApplication, QWidget,QScrollArea
from PySide2.QtWidgets import QLabel,QPushButton,QLineEdit
from PySide2.QtGui import QIcon,QFont
from PySide2.QtCore import Qt
import sys
sys.path.append("...")
import json
import datetime
from orderDataDisplay import orderDisplay
from InfOperate import occupySeat,order,timeoutDetection,alreadyOreder

###加Q群:906715085
class Window_main(QWidget):
    def __init__(self,Width=700,Height=840):
        super().__init__() 
        self.setWindowTitle("book seat online")
        timeoutDetection()
        self.Width=Width
        self.Height=Height
        self.selectedId=""
        self.selectedBtn=[]
        self.icoPath="./gallery/icon.ico"
        # 字體標(biāo)簽
        title_qf=QFont()
        title_qf.setPointSize(11)
        title_qf.setBold(True)
        title_qf.setFamily("Cambria")
        main_qf=QFont()
        main_qf.setPointSize(27)
        main_qf.setBold(True)
        main_qf.setFamily("Cambria")
        Inf_qf=QFont()
        Inf_qf.setPointSize(10)
        Inf_qf.setBold(True)
        Inf_qf.setFamily("Cambria")
        table_qf=QFont()
        table_qf.setPointSize(16)
        table_qf.setBold(True)
        table_qf.setFamily("Cambria")
        # ---
        self.QF_part_title=title_qf         # 框標(biāo)題字體標(biāo)簽
        self.QF_main_title=main_qf          # 主標(biāo)題字體標(biāo)簽
        self.QF_state_explain=Inf_qf        # 狀態(tài)標(biāo)簽解釋文本字體標(biāo)簽
        self.QF_Inf_title=title_qf          # 信息標(biāo)題字體標(biāo)簽
        self.QF_Inf_text=Inf_qf             # 信息文本字體標(biāo)簽
        self.QF_table_name=table_qf         # 桌子編號(hào)信息標(biāo)簽
        # 樣式表
        self.SS_part_frame="QLabel{background: rgb(245,245,245);color:rgb(92,92,92);border-radius:8px;border: 2.5px solid rgb(122,122,122)}"
        self.SS_part_title="QLabel{background: rgb(245,245,245);color:rgb(92,92,92)}"
        self.SS_main_title="QLabel{background: rgb(245,245,245);color:rgb(92,92,92);border-radius:50px;border: 3px solid rgb(142,142,142)}"
        self.SS_state_frame="QLabel{background: rgb(245,245,245);border-radius:5px;border: 3px solid rgb(172,172,172)}"
        self.SS_W="QLabel{background: rgb(242,242,242);border-radius:9px;border: 3px solid rgb(74,69,42)}"
        self.SS_K="QLabel{background: rgb(64,64,64);border-radius:9px;border: 3px solid rgb(74,69,42)}"
        self.SS_R="QLabel{background: rgb(149,55,43);border-radius:9px;border: 3px solid rgb(74,69,42)}"
        self.SS_state_explain="QLabel{background: rgb(214,219,233);color:rgb(92,92,92)}"
        self.SS_Inf_title="QLabel{background: rgb(230,230,230);color:rgb(82,82,82);border-radius:8px}"
        self.SS_text_Line="QLineEdit{border-radius:3px;background: rgb(205,205,205);color:rgb(82,82,82)}"
        self.SS_book_btn="color:rgb(255,255,255);background: rgb(79,148,204)"
        # path=sys.argv[0]
        # path=path[0:path.rfind("/")]
        f=open("./config/seatInf.json","r")
        seatInf=json.load(f)
        f=open("./config/occupied.json","r")
        seatOccupied=json.load(f)
        self.seatInf=seatInf
        self.seatOccupied=json.loads(seatOccupied)
        self.setSize()
        self.setIcon()
        self.partition()
        self.setStateExp()
        self.setInfBox()
        self.setMap()
        self.setBookBtn()    
    # ================================================================================================
    # 回調(diào)函數(shù)部分:
    def selectedPos(self):# 座位選擇回調(diào)
        btn=self.sender()
        tempSelectedId=btn.property("chairId")
        if not self.seatOccupied[tempSelectedId]:
            if len(self.selectedId)==0:
                self.selectedId=tempSelectedId
                self.selectedBtn=btn
                btn.setStyleSheet(self.seatInf["chairSS_R"])
                self.selectedBox.setText(" 當(dāng)前選擇:  "+tempSelectedId)
            else:
                self.selectedBtn.setStyleSheet(self.seatInf["chairSS_W"])
    def bookSeat(self):
        if not len(self.selectedId)==0:
            if alreadyOreder(self.InfBox_Id.text()):
                print("================================")
                print("請(qǐng)勿重復(fù)預(yù)約")
                print(" ")
                nowDate=datetime.datetime.now()
                nowDateStr=nowDate.strftime('%Y-%m-%d %H:%M:%S')
                print(nowDateStr)
                print("姓名:"+self.InfBox_Name.text())
                print("學(xué)號(hào):"+self.InfBox_Id.text())
                print("座次:"+self.selectedId)
                # myapp.exit()
                # app = QApplication.instance()
                # if app is None: 
                #     app = QApplication(sys.argv)
                self.window_disp= orderDisplay(self.InfBox_Name.text(),
                            self.InfBox_Id.text(),
                            nowDateStr,
                            self.selectedId,700,840)
                self.window_disp.show()
                self.close()
                occupySeat(self.selectedId)
                order(self.InfBox_Id.text(),nowDateStr,self.selectedId)
            
    # 框架構(gòu)造函數(shù)部分:
    def setSize(self):# 調(diào)整框架大小
        self.setGeometry(80,80,self.Width,self.Height)
        self.setMaximumSize(self.Width,self.Height)
        self.setMinimumSize(self.Width,self.Height)
    def setIcon(self):# 設(shè)置圖標(biāo)
        appIcon=QIcon(self.icoPath)
        self.setWindowIcon(appIcon)
    def setStateExp(self):# 繪制狀態(tài)解釋框
        Width=self.Width
        Height=self.Height
        self.part0=QLabel(self)
        self.part0.setGeometry(0.66*Width,0.045*Height,
                               0.28*Width,0.14*Height)
        self.part0.setStyleSheet(self.SS_state_frame)
        # ---Color Bar--------------------------------------------------------------------
        self.CB1=QLabel(self)
        self.CB1.setGeometry(0.68*Width,0.06*Height,0.05*Width,0.03*Height)
        self.CB1.setStyleSheet(self.SS_W) 
        self.CB2=QLabel(self)
        self.CB2.setGeometry(0.68*Width,(0.06+0.04)*Height,0.05*Width,0.03*Height)
        self.CB2.setStyleSheet(self.SS_K) 
        self.CB3=QLabel(self)
        self.CB3.setGeometry(0.68*Width,(0.06+0.08)*Height,0.05*Width,0.03*Height)
        self.CB3.setStyleSheet(self.SS_R) 
        # ---Color Bar 解釋文本-------------------------------------------------------------
        self.plaintext1=QLabel(self)
        self.plaintext1.setGeometry(0.76*Width,(0.059)*Height,0.15*Width,0.032*Height)
        self.plaintext1.setStyleSheet(self.SS_state_explain)
        self.plaintext1.setText(" 可選擇")
        self.plaintext1.setFont(self.QF_state_explain)
        self.plaintext2=QLabel(self)
        self.plaintext2.setGeometry(0.76*Width,(0.059+0.04)*Height,0.15*Width,0.032*Height)
        self.plaintext2.setStyleSheet(self.SS_state_explain)
        self.plaintext2.setText(" 已被選")
        self.plaintext2.setFont(self.QF_state_explain)
        self.plaintext3=QLabel(self)
        self.plaintext3.setGeometry(0.76*Width,(0.059+0.08)*Height,0.15*Width,0.032*Height)
        self.plaintext3.setStyleSheet(self.SS_state_explain)
        self.plaintext3.setText(" 當(dāng)前選擇")
        self.plaintext3.setFont(self.QF_state_explain)
    def setInfBox(self):
        # ---信息標(biāo)題------------------------------------------
        self.InfTitle_Name=QLabel(self)
        self.InfTitle_Name.setGeometry(0.09*Width,0.28*Height,
                                       0.16*Width,0.05*Height)
        self.InfTitle_Name.setStyleSheet(self.SS_Inf_title)
        self.InfTitle_Name.setText("   姓名:")
        self.InfTitle_Name.setFont(self.QF_Inf_title)
        self.InfTitle_Id=QLabel(self)
        self.InfTitle_Id.setGeometry(0.09*Width,0.36*Height,
                                     0.16*Width,0.05*Height)
        self.InfTitle_Id.setStyleSheet(self.SS_Inf_title)
        self.InfTitle_Id.setText("   學(xué)號(hào):")
        self.InfTitle_Id.setFont(self.QF_Inf_title)
        # ---信息文本框------------------------------------------
        self.InfBox_Name=QLineEdit(self) 
        self.InfBox_Name.setText("示例:李華") 
        self.InfBox_Name.move(0.3*Width,0.281*Height)  
        self.InfBox_Name.resize(0.6*Width,0.048*Height)
        self.InfBox_Name.setFont(self.QF_Inf_text)
        self.InfBox_Name.setStyleSheet(self.SS_text_Line)
        #self.InfBox_Name.textChanged.connect(self.colorCheckFunc)
        self.InfBox_Id=QLineEdit(self) 
        self.InfBox_Id.setText("示例:XXXXXXXXXXX") 
        self.InfBox_Id.move(0.3*Width,0.361*Height)  
        self.InfBox_Id.resize(0.6*Width,0.048*Height)
        self.InfBox_Id.setFont(self.QF_Inf_text)
        self.InfBox_Id.setStyleSheet(self.SS_text_Line)
        #self.InfBox_ID.textChanged.connect(self.colorCheckFunc)
    def partition(self):# 繪制框線分布
        # ---標(biāo)題框---------------------------------------------------
        self.part0.setGeometry(0.05*Width,0.045*Height,
                               0.52*Width,0.14*Height)
        self.part0.setStyleSheet(self.SS_main_title)
        self.part0.setAlignment(Qt.AlignCenter)
        self.part0.setText(" 自習(xí)室預(yù)約")
        self.part0.setFont(self.QF_main_title)
        # self.part0title=QLabel(self)
        # self.part0title.setGeometry(0.098*Width,0.06*Height,
        #                             0.43*Width,0.11*Height)
        # self.part0title.setStyleSheet(self.SS_part_title)
        # self.part0title.setText(" 自習(xí)室預(yù)約")
        # self.part0title.setFont(self.QF_main_title)
        
        # ---信息填寫框-----------------------------------------------
        self.part1=QLabel(self)
        self.part1.setGeometry(0.04*Width,0.23*Height,
                               0.92*Width,0.24*Height)
        self.part1.setStyleSheet(self.SS_part_frame)
        self.part1title=QLabel(self)
        self.part1title.setGeometry(0.08*Width,0.21*Height,
                                    0.15*Width,0.04*Height)
        self.part1title.setStyleSheet(self.SS_part_title)
        self.part1title.setText(" 信息填寫")
        self.part1title.setFont(self.QF_part_title)
    
        # ---座位選擇框------------------------------------------------
        self.part2=QLabel(self)
        self.part2.setGeometry(0.04*Width,0.53*Height,
                               0.92*Width,0.355*Height)
        self.part2.setStyleSheet(self.SS_part_frame)
        self.part1title.setGeometry(0.08*Width,0.51*Height,
        self.part1title.setText(" 座位選擇")
        # ================================================================================================
        # 可滑動(dòng)區(qū)域部分:
    def setMap(self):
        self.map=QScrollArea(self)
        self.map.setGeometry(0.05*Width,0.545*Height,
                             0.9*Width,0.325*Height)
        self.drawMap()
        self.map.setWidget(self.mapContent)
    def drawMap(self):# 繪制座位地圖
        self.mapContent=QWidget(self)   
        boxWidth=0.9*self.Width
        boxHeight=0.325*self.Height
        seatInf=self.seatInf
        seatOccupied=self.seatOccupied
        mapWidth=boxWidth*seatInf["mapSize"][0]
        mapHeight=boxHeight*seatInf["mapSize"][1]
        tableSize=seatInf["tableSize"]
        tablePos=seatInf["tablePos"]
        chairSize=seatInf["chairSize"]
        chairPos=seatInf["chairPos"]
        self.mapContent.setGeometry(0,0,mapWidth,mapHeight) 
        self.mapContent.setMaximumSize(mapWidth,mapHeight)
        self.mapContent.setMinimumSize(mapWidth,mapHeight)
        for i in range(0,seatInf["tableNum"]):
            table=QLabel(self.mapContent)
            table.setGeometry(tablePos[i][0]*mapWidth,tablePos[i][1]*mapHeight,
                              tableSize[i][0]*mapWidth,tableSize[i][1]*mapHeight)
            table.setText(seatInf["tableId"][i])
            table.setFont(self.QF_table_name)
            table.setAlignment(Qt.AlignCenter)
            table.setStyleSheet(seatInf["tableSS"][seatInf["tableType"][i]])
            for j in range(0,seatInf["chairNum"][i]):
                chairBnt=QPushButton(self.mapContent)
                chairBnt.setGeometry((tablePos[i][0]+chairPos[i][j][0])*mapWidth,
                                     (tablePos[i][1]+chairPos[i][j][1])*mapHeight,
                                     chairSize[0]*mapWidth,
                                     chairSize[1]*mapHeight)
                chairId=seatInf["tableId"][i]+str(j+1)
                if seatOccupied[chairId]:
                    chairBnt.setStyleSheet(seatInf["chairSS_K"])
                else:
                    chairBnt.setStyleSheet(seatInf["chairSS_W"])
                chairBnt.setProperty("chairId",chairId)
                chairBnt.clicked.connect(self.selectedPos)
    def setBookBtn(self):
        self.selectedBox=QLabel(self)
        self.selectedBox.setGeometry(0.54*Width,(0.92)*Height,0.22*Width,0.05*Height)
        self.selectedBox.setStyleSheet(self.SS_state_explain)
        self.selectedBox.setText(" 當(dāng)前選擇:")
        self.selectedBox.setFont(self.QF_Inf_title)
        self.bookBtn=QPushButton(self)
        self.bookBtn.setGeometry(0.79*Width,(0.92)*Height,0.16*Width,0.05*Height)
        self.bookBtn.setStyleSheet(self.SS_book_btn)
        self.bookBtn.setText("預(yù)約")
        self.bookBtn.setFont(self.QF_Inf_title)
        self.bookBtn.clicked.connect(self.bookSeat)
# ===========================================================================================
# 函數(shù)調(diào)用:
myapp = QApplication(sys.argv)
window_main = Window_main(700,840)
window_main.show()
sys.exit(myapp.exec_())

6.2 orderDataDisplay.py

#   from PySide2.QtWidgets import QApplication, QWidget
from PySide2.QtWidgets import QLabel,QPushButton
from PySide2.QtGui import QIcon,QFont,QPixmap
from PySide2.QtCore import Qt
import sys
sys.path.append("...")
import datetime
from InfOperate import freeSeat,setString

class Window_disp(QWidget):
    def __init__(self,studentName,studentId,bookTime,seatId,Width=700,Height=840):
        super().__init__() 
        self.setWindowTitle("order successfully")
        
        self.studentName=studentName
        self.studentId=studentId
        self.bookTime=bookTime
        self.seatId=seatId
        self.Width=Width
        self.Height=Height
        # path=sys.argv[0]
        # path=path[0:path.rfind("/")]
        self.orderSuccTitlePath="./gallery/order_succ_title.png"
        self.icoPath="./gallery/icon.ico"
        # 字體標(biāo)簽
        title_qf=QFont()
        title_qf.setPointSize(11)
        title_qf.setBold(True)
        title_qf.setFamily("Cambria")
        Inf_qf=QFont()
        Inf_qf.setPointSize(10)
        Inf_qf.setBold(True)
        Inf_qf.setFamily("Cambria")
        matters_qf=QFont()
        matters_qf.setPointSize(10.5)
        matters_qf.setBold(True)
        matters_qf.setFamily("Cambria")
        # ---
        self.QF_part_title=title_qf         # 框標(biāo)題字體標(biāo)簽
        self.QF_Inf_title=title_qf          # 信息標(biāo)題字體標(biāo)簽
        self.QF_Inf_text=Inf_qf             # 信息文本字體標(biāo)簽
        self.QF_matters=matters_qf          # 注意事項(xiàng)字體標(biāo)簽
        # 樣式表
        self.SS_part_frame="QLabel{background: rgb(245,245,245);color:rgb(92,92,92);border-radius:8px;border: 2.5px solid rgb(122,122,122)}"
        self.SS_part_title="QLabel{background: rgb(245,245,245);color:rgb(92,92,92)}"
        self.SS_Inf_title="QLabel{background: rgb(230,230,230);color:rgb(82,82,82);border-radius:8px}"
        self.SS_text_Line="QLabel{border-radius:3px;background: rgb(205,205,205);color:rgb(82,82,82)}"
        self.SS_book_btn="color:rgb(255,255,255);background: rgb(79,148,204)"
        self.setSize()
        self.setIcon()
        self.setTitle()
        self.partition()
        self.InfDisplay()
        self.mattersDisplay()
        self.setBtn()
    # ================================================================================================
    # 回調(diào)函數(shù)部分:
    def tempLeave(self):
        if self.tleaveBtn.text()=="暫離":
            setString(self.seatId,"temp")
            nowDate=datetime.datetime.now()
            nowDateStr=nowDate.strftime('%Y-%m-%d %H:%M:%S')
            self.InfBox_Time.setText(nowDateStr) 
            self.tleaveBtn.setText("暫離中")
    def leave(self):
        freeSeat(self.seatId)
        self.close()
    # 框架構(gòu)造函數(shù)部分:
    def setSize(self):# 調(diào)整框架大小
        self.setGeometry(80,80,self.Width,self.Height)
        self.setMaximumSize(self.Width,self.Height)
        self.setMinimumSize(self.Width,self.Height)
    def setIcon(self):# 設(shè)置圖標(biāo)
        appIcon=QIcon(self.icoPath)
        self.setWindowIcon(appIcon)
    def setTitle(self):
        Width=self.Width
        Height=self.Height
        self.Imgbox=QLabel(self)
        self.Imgbox.setGeometry(0.24*Width,0.02*Height,
                                0.52*Width,0.18*Height)
        self.Imgpic=QPixmap(self.orderSuccTitlePath)
        self.Imgpic=self.Imgpic.scaled(0.52*Width,0.18*Height)
        self.Imgbox.setPixmap(self.Imgpic)
    def partition(self):# 繪制框線分布
        # ---信息展示框-----------------------------------------------
        self.part1=QLabel(self)
        self.part1.setGeometry(0.04*Width,0.23*Height,
                               0.92*Width,0.40*Height)
        self.part1.setStyleSheet(self.SS_part_frame)
        self.part1title=QLabel(self)
        self.part1title.setGeometry(0.08*Width,0.21*Height,
                                    0.15*Width,0.04*Height)
        self.part1title.setStyleSheet(self.SS_part_title)
        self.part1title.setText(" 個(gè)人信息 ")
        self.part1title.setFont(self.QF_part_title)
        # ---注意事項(xiàng)框-----------------------------------------------
        self.part2=QLabel(self)
        self.part2.setGeometry(0.04*Width,0.67*Height,
                               0.92*Width,0.22*Height)
        self.part2.setStyleSheet(self.SS_part_frame)
        self.part2title=QLabel(self)
        self.part2title.setGeometry(0.08*Width,0.65*Height,
        self.part2title.setStyleSheet(self.SS_part_title)
        self.part2title.setText(" 注意事項(xiàng)")
        self.part2title.setFont(self.QF_part_title)
    def InfDisplay(self):
        # ---信息標(biāo)題------------------------------------------
        self.InfTitle_Name=QLabel(self)
        self.InfTitle_Name.setGeometry(0.09*Width,0.28*Height,
                                       0.16*Width,0.05*Height)
        self.InfTitle_Name.setStyleSheet(self.SS_Inf_title)
        self.InfTitle_Name.setText("   姓名:")
        self.InfTitle_Name.setFont(self.QF_Inf_title)
        self.InfTitle_Id=QLabel(self)
        self.InfTitle_Id.setGeometry(0.09*Width,0.36*Height,
                                     0.16*Width,0.05*Height)
        self.InfTitle_Id.setStyleSheet(self.SS_Inf_title)
        self.InfTitle_Id.setText("   學(xué)號(hào):")
        self.InfTitle_Id.setFont(self.QF_Inf_title)
        self.InfTitle_Time=QLabel(self)
        self.InfTitle_Time.setGeometry(0.09*Width,0.44*Height,
        self.InfTitle_Time.setStyleSheet(self.SS_Inf_title)
        self.InfTitle_Time.setText("   時(shí)間:")
        self.InfTitle_Time.setFont(self.QF_Inf_title)
        self.InfTitle_Seat=QLabel(self)
        self.InfTitle_Seat.setGeometry(0.09*Width,0.52*Height,
        self.InfTitle_Seat.setStyleSheet(self.SS_Inf_title)
        self.InfTitle_Seat.setText("   座次:")
        self.InfTitle_Seat.setFont(self.QF_Inf_title)
        # ---信息文本框------------------------------------------
        self.InfBox_Name=QLabel(self) 
        self.InfBox_Name.setText(self.studentName) 
        self.InfBox_Name.move(0.3*Width,0.281*Height)  
        self.InfBox_Name.resize(0.6*Width,0.048*Height)
        self.InfBox_Name.setFont(self.QF_Inf_text)
        self.InfBox_Name.setStyleSheet(self.SS_text_Line)
        self.InfBox_Name.setAlignment(Qt.AlignCenter)
        self.InfBox_Id=QLabel(self) 
        self.InfBox_Id.setText(self.studentId) 
        self.InfBox_Id.move(0.3*Width,0.361*Height)  
        self.InfBox_Id.resize(0.6*Width,0.048*Height)
        self.InfBox_Id.setFont(self.QF_Inf_text)
        self.InfBox_Id.setStyleSheet(self.SS_text_Line)
        self.InfBox_Id.setAlignment(Qt.AlignCenter)
        self.InfBox_Time=QLabel(self) 
        self.InfBox_Time.setText(self.bookTime) 
        self.InfBox_Time.move(0.3*Width,0.441*Height)  
        self.InfBox_Time.resize(0.6*Width,0.048*Height)
        self.InfBox_Time.setFont(self.QF_Inf_text)
        self.InfBox_Time.setStyleSheet(self.SS_text_Line)
        self.InfBox_Time.setAlignment(Qt.AlignCenter)
        self.InfBox_Seat=QLabel(self) 
        self.InfBox_Seat.setText(self.seatId) 
        self.InfBox_Seat.move(0.3*Width,0.521*Height)  
        self.InfBox_Seat.resize(0.6*Width,0.048*Height)
        self.InfBox_Seat.setFont(self.QF_Inf_text)
        self.InfBox_Seat.setStyleSheet(self.SS_text_Line)
        self.InfBox_Seat.setAlignment(Qt.AlignCenter)
    def mattersDisplay(self):
        self.m1=QLabel(self) 
        self.m1.setText("1、預(yù)約成功后請(qǐng)?jiān)?0分鐘內(nèi)到達(dá),否則預(yù)約信息將失效。") 
        self.m1.setGeometry(0.06*Width,0.71*Height,
                            0.87*Width,0.03*Height)
        self.m1.setStyleSheet("QLabel{color:rgb(82,82,82)}")
        self.m1.setFont(self.QF_matters)
        self.m2=QLabel(self) 
        self.m2.setText("2、進(jìn)入自習(xí)室前請(qǐng)刷校園卡核驗(yàn)信息。") 
        self.m2.setGeometry(0.06*Width,0.75*Height,
        self.m2.setStyleSheet("QLabel{color:rgb(82,82,82)}")
        self.m2.setFont(self.QF_matters)
        self.m3=QLabel(self) 
        self.m3.setText("3、如要離開請(qǐng)點(diǎn)擊下方“暫離”按鈕,否則將釋放座位信息。") 
        self.m3.setGeometry(0.06*Width,0.79*Height,
        self.m3.setStyleSheet("QLabel{color:rgb(82,82,82)}")
        self.m3.setFont(self.QF_matters)
        self.m4=QLabel(self) 
        self.m4.setText("4、離開、取消預(yù)約請(qǐng)點(diǎn)擊下方“離開\取消”按鈕。") 
        self.m4.setGeometry(0.06*Width,0.83*Height,
        self.m4.setStyleSheet("QLabel{color:rgb(82,82,82)}")
        self.m4.setFont(self.QF_matters)
    def setBtn(self):
        self.tleaveBtn=QPushButton(self)
        self.tleaveBtn.setGeometry(0.18*Width,(0.92)*Height,0.2*Width,0.05*Height)
        self.tleaveBtn.setStyleSheet(self.SS_book_btn)
        self.tleaveBtn.setText("暫離")
        self.tleaveBtn.setFont(self.QF_Inf_title)
        self.tleaveBtn.clicked.connect(self.tempLeave)
        self.leaveBtn=QPushButton(self)
        self.leaveBtn.setGeometry((1-0.2-0.18)*Width,(0.92)*Height,0.2*Width,0.05*Height)
        self.leaveBtn.setStyleSheet(self.SS_book_btn)
        self.leaveBtn.setText("離開\取消")
        self.leaveBtn.setFont(self.QF_Inf_title)
        self.leaveBtn.clicked.connect(self.leave)
# ===========================================================================================
# 函數(shù)調(diào)用:
# myapp = QApplication(sys.argv)
# window_disp = Window_disp("李華","1816000XXXX","2021-05-30 17:04:24","A1",700,840)
# window_disp.show()
# myapp.exec_()
def orderDisplay(studentName,studentId,bookTime,seatId,Width=700,Height=840):
    window_disp = Window_disp(studentName,studentId,bookTime,seatId,Width,Height)
    return window_disp

學(xué)會(huì)這個(gè)技能 ,再也不用擔(dān)心搶不到座位了,密密麻麻碼了那么多代碼。

到此這篇關(guān)于如何用Python實(shí)現(xiàn)大學(xué)座位預(yù)約的文章就介紹到這了,更多相關(guān)Python實(shí)現(xiàn)大學(xué)座位預(yù)約內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Python GUI自動(dòng)化實(shí)現(xiàn)繞過驗(yàn)證碼登錄

    Python GUI自動(dòng)化實(shí)現(xiàn)繞過驗(yàn)證碼登錄

    這篇文章主要介紹了python GUI自動(dòng)化實(shí)現(xiàn)繞過驗(yàn)證碼登錄,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-01-01
  • 初步解析Python下的多進(jìn)程編程

    初步解析Python下的多進(jìn)程編程

    這篇文章主要介紹了初步解析Python下的多進(jìn)程編程,使用多進(jìn)程編程一直是Python編程當(dāng)中的重點(diǎn)和難點(diǎn),需要的朋友可以參考下
    2015-04-04
  • pytorch 如何使用amp進(jìn)行混合精度訓(xùn)練

    pytorch 如何使用amp進(jìn)行混合精度訓(xùn)練

    這篇文章主要介紹了pytorch 使用amp進(jìn)行混合精度訓(xùn)練的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-05-05
  • flask post獲取前端請(qǐng)求參數(shù)的三種方式總結(jié)

    flask post獲取前端請(qǐng)求參數(shù)的三種方式總結(jié)

    這篇文章主要介紹了flask post獲取前端請(qǐng)求參數(shù)的三種方式總結(jié),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-12-12
  • Python中__repr__和__str__區(qū)別詳解

    Python中__repr__和__str__區(qū)別詳解

    這篇文章主要介紹了Python中__repr__和__str__區(qū)別詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11
  • 總結(jié)Python函數(shù)參數(shù)的六種類型

    總結(jié)Python函數(shù)參數(shù)的六種類型

    這篇文章主要總結(jié)了Python函數(shù)參數(shù)的六種類型,傳遞參數(shù)實(shí)現(xiàn)不同場(chǎng)景的靈活使用,下面總結(jié)的六種函數(shù)參數(shù)類型,需要的小伙伴可以參考一下
    2022-03-03
  • Python 帶你快速上手 Apache APISIX 插件開發(fā)

    Python 帶你快速上手 Apache APISIX 插件開發(fā)

    Apache APISIX Python Runner 來了,社區(qū)中的小伙伴們?cè)陂_發(fā) Apache APISIX 插件時(shí)又多了一種新選擇,本文將用實(shí)列向大家介紹,需要的朋友可以參考下面文章內(nèi)容
    2021-09-09
  • 一文帶你掌握python中*星號(hào)的用法

    一文帶你掌握python中*星號(hào)的用法

    Python中的?*號(hào)是一個(gè)特殊的符號(hào),在其他編程語言中,它最廣為人知的用途就是作為乘法運(yùn)算的符號(hào),而在Python中,它的用途遠(yuǎn)不止如此,下面我們就來學(xué)習(xí)一下它的具體用法吧
    2023-10-10
  • Pandas聚合運(yùn)算和分組運(yùn)算的實(shí)現(xiàn)示例

    Pandas聚合運(yùn)算和分組運(yùn)算的實(shí)現(xiàn)示例

    這篇文章主要介紹了Pandas聚合運(yùn)算和分組運(yùn)算的實(shí)現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-10-10
  • git使用.gitignore設(shè)置不生效或不起作用問題的解決方法

    git使用.gitignore設(shè)置不生效或不起作用問題的解決方法

    下面小編就為大家?guī)硪黄猤it使用.gitignore設(shè)置不生效或不起作用問題的解決方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-06-06

最新評(píng)論

顺义区| 丽江市| 龙井市| 屯留县| 扬中市| 虞城县| 崇义县| 林周县| 通化市| 潢川县| 新田县| 思南县| 鄂伦春自治旗| 屯昌县| 依兰县| 剑阁县| 皮山县| 定襄县| 清水河县| 东平县| 确山县| 芜湖市| 泽普县| 股票| 玉屏| 镇巴县| 耒阳市| 西盟| 施秉县| 门头沟区| 专栏| 毕节市| 尤溪县| 张家口市| 沙雅县| 峨眉山市| 社旗县| 曲沃县| 彝良县| 获嘉县| 扎赉特旗|