diff --git a/main.py b/main.py index 1f2486c..4227ab9 100644 --- a/main.py +++ b/main.py @@ -57,6 +57,8 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.selected_ops = None # 选择的运算符 # 清空运算符显示 self.lb_ops_selected.setText("") # 运算符显示 + self.p1_selected.setStyleSheet("border-image: none;") # 清空已选牌面 + def select_ops(self, ops): self.lb_ops_selected.setText(ops) @@ -131,9 +133,18 @@ class MainWindow(QMainWindow, Ui_MainWindow): else: QMessageBox.warning(self, '警告', '请先选择一个运算符') + # 根据节点ID,找到对应的节点 + def find_node(self, id): + for node in self.TreeNode: + if node.NodeID == id: + return node def exchange_value_node(self): # 修改节点值 if len(self.selected_id) == 1: + node = self.find_node(self.selected_id[0]) + if node.NodeType == 'Operator': + QMessageBox.warning(self, '警告', '请选择数值节点') + return if self.selected_value: if self.TreeNode: for node in self.TreeNode: @@ -152,6 +163,10 @@ class MainWindow(QMainWindow, Ui_MainWindow): def exchange_ops_node(self): # 修改节点运算符 if len(self.selected_id) == 1: + node = self.find_node(self.selected_id[0]) + if node.NodeType == 'Value': + QMessageBox.warning(self, '警告', '请选择运算符节点') + return if self.selected_ops: if self.TreeNode: for node in self.TreeNode: @@ -254,11 +269,11 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.p4.clicked.connect(lambda: current_selection(Tree_4_nums[index], path)) def show_card(self): + self.secen_clear() # 清空画布 self.pushButton_ast.setEnabled(True) self.pushButton_allan.setEnabled(True) self.pushButton_dtree.setEnabled(True) self.pushButton_autosv.setEnabled(True) - self.p1_selected.setStyleSheet("border-image: none;") # 原始数组 self.lineEdit.clear() self.label_result.setText(" =? ") diff --git a/main_ui.py b/main_ui.py index b9c3142..c8b787c 100644 --- a/main_ui.py +++ b/main_ui.py @@ -221,7 +221,7 @@ class Ui_MainWindow(object): MainWindow.setCentralWidget(self.centralwidget) self.menubar = QMenuBar(MainWindow) self.menubar.setObjectName(u"menubar") - self.menubar.setGeometry(QRect(0, 0, 1190, 32)) + self.menubar.setGeometry(QRect(0, 0, 1190, 33)) MainWindow.setMenuBar(self.menubar) self.statusbar = QStatusBar(MainWindow) self.statusbar.setObjectName(u"statusbar") @@ -243,11 +243,32 @@ class Ui_MainWindow(object): self.pushButton.setText(QCoreApplication.translate("MainWindow", u"\u8ba1\u7b97", None)) self.pushButton_q.setText(QCoreApplication.translate("MainWindow", u"\u51fa\u9898", None)) self.pushButton_ex.setText(QCoreApplication.translate("MainWindow", u"\u6362\u724c", None)) +#if QT_CONFIG(tooltip) + self.pushButton_autosv.setToolTip(QCoreApplication.translate("MainWindow", u"

\u81ea\u52a8\u6839\u636e\u724c\u9762\u8ba1\u7b97\u4e00\u4e2a24\u70b9\u7684\u8868\u8fbe\u5f0f\uff0c\u5e76\u4e14\u753b\u51fa\u8bed\u6cd5\u6811\u3002

", None)) +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(whatsthis) + self.pushButton_autosv.setWhatsThis(QCoreApplication.translate("MainWindow", u"


", None)) +#endif // QT_CONFIG(whatsthis) self.pushButton_autosv.setText(QCoreApplication.translate("MainWindow", u"\u81ea\u52a8\u6c42\u89e3", None)) +#if QT_CONFIG(tooltip) + self.pushButton_dtree.setToolTip(QCoreApplication.translate("MainWindow", u"

\u6839\u636e\u8868\u8fbe\u5f0f\u753b\u51fa\u5bf9\u5e94\u7684\u8bed\u6cd5\u6811\u3002

", None)) +#endif // QT_CONFIG(tooltip) self.pushButton_dtree.setText(QCoreApplication.translate("MainWindow", u"\u753b\u6811", None)) +#if QT_CONFIG(tooltip) + self.pushButton_allan.setToolTip(QCoreApplication.translate("MainWindow", u"

\u53ef\u4ee5\u591a\u6b21\u70b9\u51fb\u5207\u6362\u6240\u6709\u7b26\u5408\u8981\u6c42\u7684\u8868\u8fbe\u5f0f\uff0c\u5e76\u540c\u6b65\u753b\u51fa\u8bed\u6cd5\u6811\u3002

", None)) +#endif // QT_CONFIG(tooltip) self.pushButton_allan.setText(QCoreApplication.translate("MainWindow", u"\u6240\u6709\u7b54\u6848", None)) +#if QT_CONFIG(tooltip) + self.pushButton_exp.setToolTip(QCoreApplication.translate("MainWindow", u"

\u4ece\u8bed\u6cd5\u6811\u751f\u6210\u8868\u8fbe\u5f0f\u3002

", None)) +#endif // QT_CONFIG(tooltip) self.pushButton_exp.setText(QCoreApplication.translate("MainWindow", u"\u751f\u6210\u8868\u8fbe\u5f0f", None)) +#if QT_CONFIG(tooltip) + self.pushButton_ast.setToolTip(QCoreApplication.translate("MainWindow", u"

\u4ece\u8868\u8fbe\u5f0f\u751f\u6210\u8bed\u6cd5\u6811\u3002

", None)) +#endif // QT_CONFIG(tooltip) self.pushButton_ast.setText(QCoreApplication.translate("MainWindow", u"\u751f\u6210\u8bed\u6cd5\u6811", None)) +#if QT_CONFIG(tooltip) + self.pushButton_9.setToolTip(QCoreApplication.translate("MainWindow", u"

\u68c0\u67e5\u8868\u8fbe\u5f0f\u548c\u8bed\u6cd5\u6811\u662f\u5426\u7b49\u6548\u3002

", None)) +#endif // QT_CONFIG(tooltip) self.pushButton_9.setText(QCoreApplication.translate("MainWindow", u"\u4e00\u81f4\u6027\u68c0\u67e5", None)) self.label.setText(QCoreApplication.translate("MainWindow", u"\u5df2\u9009\u724c\u9762", None)) self.p1_selected.setText("") @@ -255,10 +276,25 @@ class Ui_MainWindow(object): self.pushButton_sub.setText(QCoreApplication.translate("MainWindow", u"-", None)) self.pushButton_div.setText(QCoreApplication.translate("MainWindow", u"/", None)) self.pushButton_mul.setText(QCoreApplication.translate("MainWindow", u"*", None)) +#if QT_CONFIG(tooltip) + self.add_ops_node.setToolTip(QCoreApplication.translate("MainWindow", u"

\u5728\u5de6\u4fa7\u8bed\u6cd5\u6811\u533a\u57df\u9009\u62e9\u4e24\u4e2a\u53f6\u5b50\u8282\u70b9\u540e\uff0c\u9009\u62e9\u597d\u8981\u6dfb\u52a0\u7684\u8fd0\u7b97\u7b26\u540e\uff0c\u53ef\u4ee5\u6dfb\u52a0\u8fd0\u7b97\u7b26\u5e76\u7ec4\u6210\u65b0\u7684\u8bed\u6cd5\u6811\u3002

", None)) +#endif // QT_CONFIG(tooltip) self.add_ops_node.setText(QCoreApplication.translate("MainWindow", u"\u6dfb\u52a0\u8fd0\u7b97\u8282\u70b9", None)) +#if QT_CONFIG(tooltip) + self.add_val_node.setToolTip(QCoreApplication.translate("MainWindow", u"

\u6839\u636e\u5df2\u9009\u724c\u9762\u7684\u503c\uff0c\u5411\u5de6\u4fa7\u533a\u57df\u6dfb\u52a0\u4e00\u4e2a\u6570\u503c\u8282\u70b9\u3002

", None)) +#endif // QT_CONFIG(tooltip) self.add_val_node.setText(QCoreApplication.translate("MainWindow", u"\u6dfb\u52a0\u6570\u503c\u8282\u70b9", None)) +#if QT_CONFIG(tooltip) + self.ex_node_value.setToolTip(QCoreApplication.translate("MainWindow", u"

\u4fee\u6539\u6570\u503c\u8282\u70b9\u7684\u503c\uff0c\u5c06\u8bed\u6cd5\u6811\u4e2d\u9009\u4e2d\u7684\u6570\u503c\u8282\u70b9\u7684\u503c\u4fee\u6539\u4e3a\u5df2\u9009\u724c\u9762\u7684\u503c\u3002

", None)) +#endif // QT_CONFIG(tooltip) self.ex_node_value.setText(QCoreApplication.translate("MainWindow", u"\u6539\u53d8\u8fd0\u7b97\u8f93\u5165", None)) +#if QT_CONFIG(tooltip) + self.ex_node_ops.setToolTip(QCoreApplication.translate("MainWindow", u"

\u6839\u636e\u5df2\u9009\u8fd0\u7b97\u7b26\uff0c\u4fee\u6539\u5df2\u9009\u8bed\u6cd5\u6811\u4e2d\u8fd0\u7b97\u7b26\u8282\u70b9\u7684\u503c\u3002

", None)) +#endif // QT_CONFIG(tooltip) self.ex_node_ops.setText(QCoreApplication.translate("MainWindow", u"\u6539\u53d8\u8282\u70b9\u8fd0\u7b97", None)) +#if QT_CONFIG(tooltip) + self.ex_node_self.setToolTip(QCoreApplication.translate("MainWindow", u"

\u4ea4\u6362\u8bed\u6cd5\u6811\u4e2d\u4e24\u4e2a\u5df2\u9009\u7684\u6570\u503c\u8282\u70b9\u3002

", None)) +#endif // QT_CONFIG(tooltip) self.ex_node_self.setText(QCoreApplication.translate("MainWindow", u"\u6570\u503c\u8282\u70b9\u4ea4\u6362", None)) self.label_2.setText(QCoreApplication.translate("MainWindow", u"\u5df2\u9009\u8fd0\u7b97\u7b26", None)) self.lb_ops_selected.setText("") diff --git a/main_ui.ui b/main_ui.ui index a29d468..9bd0070 100644 --- a/main_ui.ui +++ b/main_ui.ui @@ -245,6 +245,12 @@ true + + <html><head/><body><p>自动根据牌面计算一个24点的表达式,并且画出语法树。</p></body></html> + + + <html><head/><body><p><br/></p></body></html> + 自动求解 @@ -264,6 +270,9 @@ true + + <html><head/><body><p>根据表达式画出对应的语法树。</p></body></html> + 画树 @@ -283,6 +292,9 @@ true + + <html><head/><body><p>可以多次点击切换所有符合要求的表达式,并同步画出语法树。</p></body></html> + 所有答案 @@ -302,6 +314,9 @@ true + + <html><head/><body><p>从语法树生成表达式。</p></body></html> + 生成表达式 @@ -321,6 +336,9 @@ true + + <html><head/><body><p>从表达式生成语法树。</p></body></html> + 生成语法树 @@ -340,6 +358,9 @@ true + + <html><head/><body><p>检查表达式和语法树是否等效。</p></body></html> + 一致性检查 @@ -518,6 +539,9 @@ false + + <html><head/><body><p>在左侧语法树区域选择两个叶子节点后,选择好要添加的运算符后,可以添加运算符并组成新的语法树。</p></body></html> + 添加运算节点 @@ -537,6 +561,9 @@ false + + <html><head/><body><p>根据已选牌面的值,向左侧区域添加一个数值节点。</p></body></html> + 添加数值节点 @@ -556,6 +583,9 @@ false + + <html><head/><body><p>修改数值节点的值,将语法树中选中的数值节点的值修改为已选牌面的值。</p></body></html> + 改变运算输入 @@ -575,6 +605,9 @@ false + + <html><head/><body><p>根据已选运算符,修改已选语法树中运算符节点的值。</p></body></html> + 改变节点运算 @@ -594,6 +627,9 @@ false + + <html><head/><body><p>交换语法树中两个已选的数值节点。</p></body></html> + 数值节点交换 @@ -665,7 +701,7 @@ 0 0 1190 - 32 + 33