text: # Filename: qt_view.py
  
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  # SOFTWARE.
  
  """PyCalc is a simple calculator built using Python and the MVC pattern."""
  
  # Import QApplication and the required widgets from PyQt5.QtWidgets
  from PyQt5.QtWidgets import QMainWindow
  from PyQt5.QtWidgets import QWidget
  from PyQt5.QtWidgets import QVBoxLayout
  from PyQt5.QtWidgets import QGridLayout
  from PyQt5.QtWidgets import QLineEdit
  from PyQt5.QtWidgets import QPushButton
  from PyQt5.QtCore import Qt
  
  
  # Create a subclass of QMainWindow to setup the calculator's GUI
  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()
          self.show()
  
      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.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("")
  