Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up some variables not actually used in MainWindow #193

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions zxlive/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,13 @@ def export_proof_dialog(parent: QWidget) -> Optional[str]:

def get_lemma_name_and_description(parent: MainWindow) -> tuple[Optional[str], Optional[str]]:
dialog = QDialog()
parent.rewrite_form = QFormLayout(dialog)
rewrite_form = QFormLayout(dialog)
name = QLineEdit()
parent.rewrite_form.addRow("Name", name)
rewrite_form.addRow("Name", name)
description = QTextEdit()
parent.rewrite_form.addRow("Description", description)
rewrite_form.addRow("Description", description)
button_box = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)
parent.rewrite_form.addRow(button_box)
rewrite_form.addRow(button_box)
button_box.accepted.connect(dialog.accept)
button_box.rejected.connect(dialog.reject)
if dialog.exec() == QDialog.DialogCode.Accepted:
Expand All @@ -263,36 +263,37 @@ def get_lemma_name_and_description(parent: MainWindow) -> tuple[Optional[str], O

def create_new_rewrite(parent: MainWindow) -> None:
dialog = QDialog()
parent.rewrite_form = QFormLayout(dialog)
rewrite_form = QFormLayout(dialog)
name = QLineEdit()
parent.rewrite_form.addRow("Name", name)
rewrite_form.addRow("Name", name)
description = QTextEdit()
parent.rewrite_form.addRow("Description", description)
rewrite_form.addRow("Description", description)
left_button = QPushButton("Left-hand side of the rule")
right_button = QPushButton("Right-hand side of the rule")
parent.left_graph = None
parent.right_graph = None
left_graph = None
right_graph = None

def get_file(self: MainWindow, button: QPushButton, side: str) -> None:
nonlocal left_graph, right_graph
out = import_diagram_dialog(self)
if out is not None and isinstance(out, ImportGraphOutput):
button.setText(out.file_path)
if side == "left":
self.left_graph = out.g
left_graph = out.g
else:
self.right_graph = out.g
right_graph = out.g

left_button.clicked.connect(lambda: get_file(parent, left_button, "left"))
right_button.clicked.connect(lambda: get_file(parent, right_button, "right"))
parent.rewrite_form.addRow(left_button)
parent.rewrite_form.addRow(right_button)
rewrite_form.addRow(left_button)
rewrite_form.addRow(right_button)
button_box = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)
parent.rewrite_form.addRow(button_box)
rewrite_form.addRow(button_box)
def add_rewrite() -> None:
if parent.left_graph is None or parent.right_graph is None or \
name.text() == "" or description.toPlainText() == "":
nonlocal left_graph, right_graph
if left_graph is None or right_graph is None or name.text() == "" or description.toPlainText() == "":
return
rule = CustomRule(parent.left_graph, parent.right_graph, name.text(), description.toPlainText())
rule = CustomRule(left_graph, right_graph, name.text(), description.toPlainText())
check_rule(rule, show_error=True)
if safe_rule_dialog(rule, parent):
dialog.accept()
Expand Down
14 changes: 2 additions & 12 deletions zxlive/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,18 @@
from __future__ import annotations

import copy
from typing import Callable, Optional, TypedDict
from typing import Callable, Optional

from PySide6.QtCore import (QByteArray, QEvent, QFile, QFileInfo, QIODevice,
QSettings, QTextStream, Qt)
from PySide6.QtGui import QAction, QCloseEvent, QIcon, QKeySequence
from PySide6.QtWidgets import (QDialog, QFormLayout, QMainWindow, QMessageBox,
QTableWidget, QTableWidgetItem, QTabWidget,
QVBoxLayout, QWidget)
from pyzx import extract_circuit, simplify
from pyzx.graph.base import BaseGraph

import pyperclip

from .base_panel import BasePanel
from .commands import AddRewriteStep
from .common import GraphT, get_data, to_tikz, from_tikz
from .construct import *
from .custom_rule import CustomRule, check_rule
Expand All @@ -42,7 +39,6 @@
export_proof_dialog)
from zxlive.settings_dialog import open_settings_dialog

from .editor_base_panel import EditorBasePanel
from .edit_panel import GraphEditPanel
from .proof_panel import ProofPanel
from .rule_panel import RulePanel
Expand All @@ -52,12 +48,6 @@
class MainWindow(QMainWindow):
"""The main window of the ZXLive application."""

edit_panel: GraphEditPanel
proof_panel: ProofPanel
rewrite_form: QFormLayout
left_graph: Optional[GraphT]
right_graph: Optional[GraphT]

def __init__(self) -> None:
super().__init__()
self.settings = QSettings("zxlive", "zxlive")
Expand Down Expand Up @@ -552,4 +542,4 @@ def proof_as_lemma(self) -> None:

def update_colors(self) -> None:
if self.active_panel is not None:
self.active_panel.update_colors()
self.active_panel.update_colors()
Loading