class View(QMainWindow):
    def __init__(self):
        super().__init__()

        self.setWindowTitle('Editor de Tags')
        self.setFixedSize(700, 480)

        self._central_widget = QWidget(self)
        self.setCentralWidget(self._central_widget)

        self.left_widget = QWidget(self._central_widget)
        self.left_widget.setGeometry(0, 80, 300, 380)
        self.right_widget = QWidget(self._central_widget)
        self.right_widget.setGeometry(305, 50, 400, 480)

        self.left_widget_top = QWidget(self.left_widget)
        self.left_widget_top.setGeometry(21, 10, 300, 50)
        self.left_widget_bot = QWidget(self.left_widget)
        self.left_widget_bot.setGeometry(0, 40, 300, 300)

        self._create_file_path_display()
        self._create_metadata_display()
        self._create_buttons()
        self._create_tool_bar()
        self._create_status_bar()

    #crear el visor de archivos y los metadatos
    def _create_file_path_display(self):
        self.file_path_display = QLineEdit(parent=self._central_widget)
        self.file_path_display.setGeometry(0, 0, 700, 60)
        self.file_path_display.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.file_path_display.setReadOnly(True)

    def _create_metadata_display(self):
        self.hlayout_track_bpm = QHBoxLayout()
        self.form_layout_track = QFormLayout()
        self.form_layout_bpm = QFormLayout()

        self.display_title = QLineEdit()
        self.display_title.setFixedSize(200, 20)
        self.display_artist = QLineEdit()
        self.display_artist.setFixedSize(200, 20)
        self.display_album = QLineEdit()
        self.display_album.setFixedSize(200, 20)
        self.display_album_artist = QLineEdit()
        self.display_album_artist.setFixedSize(200, 20)
        self.display_genre = QLineEdit()
        self.display_genre.setFixedSize(200, 20)
        self.display_track = QLineEdit()
        self.display_track.setFixedSize(60, 20)
        self.display_release_date = QLineEdit()
        self.display_release_date.setFixedSize(200, 20)
        self.display_bpm = QLineEdit()
        self.display_bpm.setFixedSize(60, 20)
        self.display_publisher = QLineEdit()
        self.display_publisher.setFixedSize(200, 20)

        self.hlayout_track_bpm.addLayout(self.form_layout_track)
        self.form_layout_track.addRow('Pista:', self.display_track)
        self.hlayout_track_bpm.addLayout(self.form_layout_bpm)
        self.form_layout_bpm.addRow('BPM:', self.display_bpm)
        self.left_widget_top.setLayout(self.hlayout_track_bpm)

        self.form_layout = QFormLayout()
        self.form_layout.addRow('Titulo:', self.display_title)
        self.form_layout.addRow('Artista:', self.display_artist)
        self.form_layout.addRow('Album:', self.display_album)
        self.form_layout.addRow('Album artist:', self.display_album_artist)
        self.form_layout.addRow('Genero:', self.display_genre)
        self.form_layout.addRow('Fecha:', self.display_release_date)
        self.form_layout.addRow('Publicacion:', self.display_publisher)
        self.left_widget_bot.setLayout(self.form_layout)

    #crear barra de tareas y botones

    def _create_buttons(self):
        self.close_button = QPushButton('Cerrar', parent=self.right_widget)
        self.close_button.setGeometry(220, 350, 70, 30)
        self.save_button = QPushButton('Guardar', parent=self.right_widget)
        self.save_button.setGeometry(300, 350, 70, 30)

    def _create_tool_bar(self):
        self.tools = QToolBar()
        self.addToolBar(self.tools)

    def _create_status_bar(self):
        status = QStatusBar()
        status.showMessage("Activo")
        self.setStatusBar(status)

    #crear el texto del display

    def set_display_text(self, file_path, title, artist, album, album_artist,
                         genre, track, release_date, bpm, publisher):
        self.file_path_display.setText(file_path)
        self.display_title.setText(title)
        self.display_artist.setText(artist)
        self.display_album.setText(album)
        self.display_album_artist.setText(album_artist)
        self.display_genre.setText(str(genre))
        self.display_track.setText(str(track))
        self.display_release_date.setText(str(release_date))
        self.display_bpm.setText(str(bpm))
        self.display_publisher.setText(publisher)

    def display_text(self):
        return self.display_title.text(), self.display_artist.text(
        ), self.display_album.text(), self.display_album_artist.text(
        ), self.display_genre.text(), self.display_track.text(
        ), self.display_release_date.text(), self.display_bpm.text(
        ), self.display_publisher.text()
Пример #2
0
class PyCalcUi(QMainWindow):
    """PyCalc's View (GUI)."""

    def __init__(self):
        """View initializer."""
        super().__init__()
        # Set some main window's properties
        self.setWindowTitle("PyCalc")
        self.setFixedSize(235, 235)
        # Set the central widget and the general layout
        self.generalLayout = QVBoxLayout()
        self._centralWidget = QWidget(self)
        self.setCentralWidget(self._centralWidget)
        self._centralWidget.setLayout(self.generalLayout)
        # Create the display and the buttons
        self._createDisplay()
        self._createButtons()

    def _createDisplay(self):
        """Create the display."""
        # Create the display widget
        self.display = QLineEdit()
        # Set some display's properties
        self.display.setFixedHeight(35)
        self.display.setAlignment(Qt.AlignmentFlag.AlignRight)
        self.display.setReadOnly(True)
        # Add the display to the general layout
        self.generalLayout.addWidget(self.display)

    def _createButtons(self):
        """Create the buttons."""
        self.buttons = {}
        buttonsLayout = QGridLayout()
        # Button text | position on the QGridLayout
        buttons = {
            "7": (0, 0),
            "8": (0, 1),
            "9": (0, 2),
            "/": (0, 3),
            "C": (0, 4),
            "4": (1, 0),
            "5": (1, 1),
            "6": (1, 2),
            "*": (1, 3),
            "(": (1, 4),
            "1": (2, 0),
            "2": (2, 1),
            "3": (2, 2),
            "-": (2, 3),
            ")": (2, 4),
            "0": (3, 0),
            "00": (3, 1),
            ".": (3, 2),
            "+": (3, 3),
            "=": (3, 4),
        }
        # Create the buttons and add them to the grid layout
        for btnText, pos in buttons.items():
            self.buttons[btnText] = QPushButton(btnText)
            self.buttons[btnText].setFixedSize(40, 40)
            buttonsLayout.addWidget(self.buttons[btnText], pos[0], pos[1])
        # Add buttonsLayout to the general layout
        self.generalLayout.addLayout(buttonsLayout)

    def setDisplayText(self, text):
        """Set display's text."""
        self.display.setText(text)
        self.display.setFocus()

    def displayText(self):
        """Get display's text."""
        return self.display.text()

    def clearDisplay(self):
        """Clear the display."""
        self.setDisplayText("")