小程序?
2024-07-25 11:18:00
发布于:广东
没做关于页面,作者正在集中集训营偷偷打代码
main.py
from PyQt6.QtGui import *
from PyQt6.QtWidgets import *
from qfluentwidgets import *
from ACGOPage import ACGOPage
from ToolKitPage import ToolPage
from AboutPage import AboutPage
class mainWindow(FluentWindow):
def __init__(self, parent=None):
super().__init__(parent=parent)
self.resize(400, 500)
self.setWindowTitle("ACGO工具箱")
setTheme(Theme.DARK)
self.setWindowIcon(QIcon("acgo_ico.png"))
self.ACGOPage = ACGOPage(self)
self.addSubInterface(self.ACGOPage, QIcon("training_ico.png"), "ACGO刷题")
self.ToolKitPage = ToolPage(self)
self.addSubInterface(self.ToolKitPage,QIcon("toolkit_ico.png"),"ACGO杂项工具")
self.AboutPage = AboutPage(self)
self.addSubInterface(self.AboutPage,FluentIcon.INFO,"关于",NavigationItemPosition.BOTTOM)
self.navigationInterface.setAcrylicEnabled(True)
app = QApplication([])
frame = mainWindow()
frame.show()
app.exec()
ACGOPage.py
from PyQt6.QtGui import *
from PyQt6.QtWidgets import *
from qfluentwidgets import *
import webbrowser
from statics import browse
class ACGOPage(QFrame):
def __init__(self, parent=None):
super().__init__(parent=parent)
self.setObjectName("ACGOPAGE")
title = TitleLabel(self)
title.setText("ACGO刷题器")
title.setGeometry(40, 0, 200, 50)
whatgo = BodyLabel(self)
whatgo.setText("也是WAGO,REGO,TLEGO......")
whatgo.setGeometry(40, 50, 200, 50)
num = LineEdit(self)
num.setGeometry(40, 130, 200, 50)
num.setPlaceholderText("输入题号")
num.setToolTip('ACGO:Axxx CODEFORCE:CFxxx Enter \'random\'to randomize')
num.setToolTipDuration(6000)
num.installEventFilter(ToolTipFilter(num, showDelay=300, position=ToolTipPosition.TOP))
confirm = PushButton(self)
confirm.setGeometry(40, 350, 200, 50)
confirm.setText("开始刷题!!!")
confirm.clicked.connect(lambda x: browse(num.text(), self))
ToolKitPage.py
from PyQt6.QtGui import *
from PyQt6.QtWidgets import *
from qfluentwidgets import *
import webbrowser
import statics
class ToolPage(QFrame):
def __init__(self, parent=None):
super().__init__(parent=parent)
self.setObjectName("ToolKitPage")
title = TitleLabel("ACGO杂项工具箱", self)
title.setGeometry(40, 0, 300, 60)
discuss = PushButton(self)
discuss.setText("讨论")
discuss.setIcon(QIcon("discuss_ico.png"))
discuss.setGeometry(40, 100, 250, 60)
setFont(discuss, 20, QFont.Weight.Normal)
discuss.clicked.connect(lambda x:webbrowser.open("http://acgo.cn/discuss"))
team_name = LineEdit(self)
team_name.setPlaceholderText("键入团队ID")
team_name.setGeometry(40,180,250,40)
setFont(team_name,20)
search_team = PushButton(self)
search_team.setGeometry(40,260,250,40)
search_team.setText("进入团队")
search_team.clicked.connect(lambda x:webbrowser.open(f"http://acgo.cn/team/{team_name.text()}"))
write_file = PushButton(self)
write_file.setGeometry(40,220,120,40)
write_file.setText("将ID写入文件")
write_file.clicked.connect(lambda x:statics.writefile("team",team_name))
read_file = PushButton(self)
read_file.setGeometry(160,220,130,40)
read_file.setText("从文件中读取ID")
read_file.clicked.connect(lambda x:statics.readfile("team",team_name))
team_tip = StrongBodyLabel(self)
team_tip.setGeometry(40,300,200,30)
team_tip.setText("请勿访问未加入的团队")
AboutPage.py
不如不放
from PyQt6.QtGui import *
from PyQt6.QtWidgets import *
from qfluentwidgets import *
class AboutPage(QFrame):
def __init__(self, parent=None):
super().__init__(parent=parent)
self.setObjectName("AboutPage")
title = TitleLabel(self)
title.setGeometry(40,0,300,50)
title.setText("关于ACGO工具箱")
statics.py
import webbrowser
import random
def browse(num):
url = "http://acgo.cn/problemset?s="
if num == 'random':
addon = 'A' + str(random.randint(1, 25323))
url += addon
elif num[:2] == 'CF':
url += (num + '&tab=1')
else:
url += num
webbrowser.open(url)
def readfile(fname,s_text):
with open(f"{fname}.txt",'r') as f:
text = f.read()
s_text.setText(text)
def writefile(fname,r_text):
with open(f"{fname}.txt",'w') as f:
text = r_text.text()
f.write(text)
需要一只qfluentwidgets库
这里空空如也
有帮助,赞一个