pamhyr: Minor change.

mesh
Pierre-Antoine Rouby 2023-04-05 14:24:12 +02:00
parent 90b8205f8e
commit 5b33093ed1
3 changed files with 23 additions and 4 deletions

View File

@ -67,9 +67,8 @@ class Graph(object):
def add_edge(self, n1:Node, n2:Node): def add_edge(self, n1:Node, n2:Node):
# This edge already exists ? # This edge already exists ?
if list(filter(lambda e: (e.node1 == n1 and if any(filter(lambda e: (e.node1 == n1 and e.node2 == n2),
e.node2 == n2), self._edges)):
self._edges)):
return None return None
edge = Edge(self._edges_ids, "", n1, n2) edge = Edge(self._edges_ids, "", n1, n2)

View File

@ -10,7 +10,7 @@ from PyQt5.QtWidgets import (
QPushButton, QLineEdit, QCheckBox, QPushButton, QLineEdit, QCheckBox,
QTimeEdit, QSpinBox, QTextEdit, QTimeEdit, QSpinBox, QTextEdit,
QRadioButton, QComboBox, QFileDialog, QRadioButton, QComboBox, QFileDialog,
QMessageBox, QMessageBox, QTableView,
) )
from PyQt5.QtCore import ( from PyQt5.QtCore import (
QTime, QTime,
@ -91,6 +91,22 @@ class ASubWindow(QDialog, WindowToolKit):
# Commun use features # Commun use features
def _qtype_from_component_name(self, name):
qtype = None
if "action" in name:
qtype = QAction
elif "lineEdit" in name:
qtype = QLineEdit
elif "pushButton" in name:
qtype = QPushButton
elif "radioButton" in name:
qtype = QRadioButton
elif "tableView" in name:
qtype = QTableView
return qtype
def find(self, qtype, name): def find(self, qtype, name):
"""Find an ui component """Find an ui component
@ -101,6 +117,9 @@ class ASubWindow(QDialog, WindowToolKit):
Returns: Returns:
return the component return the component
""" """
if qtype is None:
qtype = self._qtype_from_component_name(name)
return self.ui.findChild(qtype, name) return self.ui.findChild(qtype, name)
def set_line_edit_text(self, name:str, text:str): def set_line_edit_text(self, name:str, text:str):

View File

@ -59,6 +59,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow):
# Model # Model
self.model = None self.model = None
# UI # UI
self.ui = loadUi( self.ui = loadUi(
os.path.join(os.path.dirname(__file__), "ui", "MainWindow.ui"), os.path.join(os.path.dirname(__file__), "ui", "MainWindow.ui"),