
Lv.1
风拂花影渐无形,片叶不惊惟忆君
签名: 2019年入猫,2020年末淡退,2021年寒假前正式退猫。当时认识了许多朋友,但似乎全都退了(不知道是不是受了当时很多大佬退猫的影响),但仍然活跃于岛3(现在叫神岛)。2022年3月初回归,第一个加的工作室叫XPOC文社,认识了凚离,C*等朋友。 现状:制作一个新游戏 friend:凚离,C*,伊柒,云雾,梦狐以及很多人……
在 【你想要的全都有!】Python标准教程等优质图书+趣味课程+人气周边优惠上架!限时3折起! 中回复
一套268,假设1000个人买,268,000,26万,人家随便做做生意就能赚上万元,甚至几十万。
编程猫nb
2020-06-23T19:16:58 点赞:0
在 成语积累不到位?编程带你全景解密成语学习,一招喵语基! 中回复
import random
import sys
from PySide2.QtWidgets import *
from PySide2.QtCore import*
from ui_mainwindow import Ui_mainwindow
class Word(QMainWindow, Ui_word):
def __init__(self):
super().__init__()
self.setupUi(self)
#单词文件路径
self.file = None
#单词集合
self.words = {}
#供验证的答案
self.word = ""
#单词总数
self.words_count = 0
self.pbtn_file.clicked.connect(self.select_file)
#提交问题的按钮交互
self.pbtn_submit.clicked.connect(self.verity)
self.show()
#选择单词文件
def select_file(self):
file_path = QFileDialog.getOpenFileName(
caption="选择单词文件", filter="(*.txt)")
if file_path[0]:
self.file = file_path[0]
self.lb_file_path.setText(self.file)
self.get_words()
else:
QMessageBox.warning(self, "注意", "请重新选择单词文件")
#加载单词
def get_words(self):
self.words = {}
with open(self.file, "r", encoding="utf-8") as f:
words = f.read()
try:
words = words.strip().split("\n")
for word in words:
meaning, word = word.split(":")
self.words[meaning.strip()] = word.strip()
#回答正确数量
self.correct_count = 0
#单词总数
self.words_count = len(self.words)
self.get_question()
except:
QMessageBox.warning(self, "注意", "内容为空或者格式有误,请重新选择单词文件")
def get_question(self):
if len(self.words) == 0:
QMessageBox.information(self, "", "背单词结束,单词总数{}个,回答正确{}个".format(
self.words_count, self.correct_count))
self.lb_file_path.setText("")
self.lb_question.setText("")
self.word = ""
self.words = {}
else:
#随机抽取待背的单词作为问题
self.meaning = random.choice(list(self.words.keys()))
#记录对应的答案
self.word = self.words.pop(self.meaning)
#标签上显示问题
self.lb_question.setText(self.meaning)
def verity(self):
if self.word:
#获取文本输入框的内容
answer = self.le_answer.text()
if answer == "":
QMessageBox.warning(self, "注意", "请输入你的回答")
elif answer == self.word:
QMessageBox.warning(self, "", "回答正确")
#每次正确值加1
self.correct_count += 1
self.get_question()
else:
QMessageBox.warning(self, "", "回答错误")
self.get_question()
#清空输入框
self.le_answer.clear()
else:
QMessageBox.warning(self, "注意", "请先准备好单词")
#按键事件绑定
def keyPressEvent(self, event):
#按下回车键验证回答
if event.key() == Qt.Key_Return:
self.verity()
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Word()
sys.exit(app.exec_())
我的代码和这个效果很像
2020-06-23T19:32:14 点赞:2
在 珠联璧合bug 中回复
Are you kidding?
You are proud of your English?
Kid,I do not know why you say English.
I do not know if you are a foreigner ,or you are a Chinese,just like me.
So,do not say English usually in CodeMao community,no one will admire at you.
Ps:I do not use English translation software!
2020-06-24T19:44:44 点赞:0
在 银河系又做了个龙舟图(因为上个图的权限没了),不过这次不是来招龙舟的,而是来招人的! 中回复
不好意思,放错图了。。。。。。。。。。
不好意思,又放错了。。。。。。。
这才是最新动态
2020-06-27T14:46:27 点赞:0