Example #1
0
    def initUI(self):
        grid = QGridLayout()
        grid.setHorizontalSpacing(2)
        grid.setVerticalSpacing(2)
        # Reference
        # https://stackoverflow.com/questions/16673074/how-can-i-fully-disable-resizing-a-window-including-the-resize-icon-when-the-mou
        grid.setSizeConstraint(QLayout.SetFixedSize)
        self.setLayout(grid)

        # This is register
        self.ent = Register()

        # This is display value of register
        self.lcd = QLCDNumber(self)
        self.lcd.setDigitCount(self.max_chars + 2)
        self.lcd.setSmallDecimalPoint(True)
        self.lcd.display(self.ent.get_text())
        self.lcd.setStyleSheet("QLCDNumber {color:darkgreen;}")
        self.lcd.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        grid.addWidget(self.lcd, 0, 0, 1, 4)
        grid.setRowMinimumHeight(0, 40)

        for key in self.keys_info:
            but = QPushButton(key['label'])
            method_name = key['method']
            method = getattr(self, method_name)
            but.clicked.connect(method)
            but.setStyleSheet(
                "QPushButton {font-size:12pt; padding:5px 30px; color:#666;}")
            but.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
            grid.addWidget(but, key['y'], key['x'], key['h'], key['w'])
Example #2
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setFont(QFont("Berlin Sans FB", 10))
        self.setWindowTitle("File ENC")
        self.setFixedSize(500, 220)

        self.btn_src = QPushButton("browse")
        self.btn_dst = QPushButton("browse")
        self.btn_enc = QPushButton("Encrypt")
        self.btn_dec = QPushButton("Decrypt")
        self.btn_src.setFixedSize(60, WIDGET_HEIGHT)
        self.btn_dst.setFixedSize(60, WIDGET_HEIGHT)
        self.btn_src.clicked.connect(self.open_file_dialog)
        self.btn_dst.clicked.connect(self.open_dir_dialog)
        self.btn_enc.clicked.connect(self.encrypt_file)
        self.btn_dec.clicked.connect(self.decrypt_file)

        self.LE_file_path = QLineEdit()
        self.LE_file_path.setPlaceholderText("Source File Path...")
        self.LE_file_path.setFixedHeight(WIDGET_HEIGHT)
        self.LE_file_path.setReadOnly(True)

        self.LE_dir_path = QLineEdit()
        self.LE_dir_path.setPlaceholderText("Destination Path...")
        self.LE_dir_path.setFixedHeight(WIDGET_HEIGHT)
        self.LE_dir_path.setReadOnly(True)

        self.LE_key = QLineEdit()
        self.LE_key.setPlaceholderText("Enter the Cipher Key...")
        self.LE_key.setFixedHeight(WIDGET_HEIGHT)

        layout = QGridLayout()
        layout.setRowMinimumHeight(0, 30)
        layout.addWidget(self.btn_src, 0, 1)
        layout.addWidget(self.btn_dst, 1, 1)
        layout.addWidget(self.btn_enc, 3, 0, 1, 2, alignment=Qt.AlignHCenter)
        layout.addWidget(self.btn_dec, 4, 0, 1, 2, alignment=Qt.AlignHCenter)
        layout.addWidget(self.LE_file_path, 0, 0)
        layout.addWidget(self.LE_dir_path, 1, 0)
        layout.addWidget(self.LE_key, 2, 0, 1, 2)
        layout.setHorizontalSpacing(10)
        layout.setHorizontalSpacing(0)
        print(layout.rowStretch(0))
        self.setLayout(layout)
        self.show()
Example #3
0
    def init_ui(self):
        # Menu grid layout and its settings
        grid = QGridLayout(self)
        grid.setColumnMinimumWidth(4, 260)
        grid.setColumnStretch(4, 0)
        for i in [1, 2, 3, 5]:
            grid.setColumnMinimumWidth(i, 75)
            grid.setColumnStretch(i, 0)
        for i in [0, 6]:
            grid.setColumnStretch(i, 1)
        grid.setRowMinimumHeight(1, 360)
        grid.setRowMinimumHeight(2, 25)
        for i in [0, 3]:
            grid.setRowStretch(i, 1)

        # Widgets
        self.tabw = QTabWidget(self)
        grid.addWidget(self.tabw, 1, 1, 1, 5)
        self.tabs = {}
        self.tabs['pile'] = QWidget(self)
        self.pilegrid = QGridLayout(self.tabs['pile'])
        self.pilegrid.setRowStretch(6, 1)
        self.tabw.addTab(self.tabs['pile'], 'Sandpile')
        self.tabs['visl'] = QWidget(self)
        self.vslgrid = QGridLayout(self.tabs['visl'])
        self.tabw.addTab(self.tabs['visl'], 'Visual')

        self.pilegrid.addWidget(QLabel('Seed:', self.tabs['pile']), 0, 0, 1, 1)
        self.pilegrid.addWidget(QLabel('Type:', self.tabs['pile']), 2, 0, 1, 1)

        self.seedfield = QLineEdit(self.tabs['pile'])
        self.pilegrid.addWidget(self.seedfield, 1, 0, 1, 4)

        self.buttons = {}
        self.buttons['cont'] = QPushButton('Continue', self)

        def func1():
            self.root.toggle_menu()
            self.root.toggle_pause()

        self.buttons['cont'].clicked.connect(func1)
        grid.addWidget(self.buttons['cont'], 2, 1, 1, 1)
        self.buttons['rest'] = QPushButton('Restart', self)

        def func2():
            self.root.restart_pile()
            func1()

        self.buttons['rest'].clicked.connect(func2)
        grid.addWidget(self.buttons['rest'], 2, 2, 1, 1)
        self.buttons['roll'] = QPushButton('Reset', self)

        def func3():
            txt = self.seedfield.text()
            try:
                seed = eval(txt)
            except:
                seed = [[8]]
            self.root.reroll_pile(piletype=self.piletype, seed=seed)
            func1()

        self.buttons['roll'].clicked.connect(func3)
        grid.addWidget(self.buttons['roll'], 2, 3, 1, 1)
        self.buttons['clsm'] = QPushButton('Close Menu', self)
        self.buttons['clsm'].clicked.connect(self.root.toggle_menu)
        grid.addWidget(self.buttons['clsm'], 2, 5, 1, 1)

        self.typeradios = {}
        for i, key in enumerate(['o4i', 'o4f', 'o8i', 'o8f']):
            b = QRadioButton(key, self.tabs['pile'])
            self.typeradios[key] = b
            self.pilegrid.addWidget(b, 3, i, 1, 1)
        for i, key in enumerate(['t4i', 't4f', 't8f']):
            b = QRadioButton(key, self.tabs['pile'])
            self.typeradios[key] = b
            self.pilegrid.addWidget(b, 4, i, 1, 1)
        for i, key in enumerate(['t6hi', 't6hf', 't6vi', 't6vf']):
            b = QRadioButton(key, self.tabs['pile'])
            self.typeradios[key] = b
            self.pilegrid.addWidget(b, 5, i, 1, 1)
        for k in self.typeradios:
            b = self.typeradios[k]
            b.clicked.connect(self.set_piletype)

        self.vslgrid.addWidget(QLabel('Timed delay:', self.tabs['visl']), 0, 0,
                               1, 1)
        self.vslgrid.addWidget(QLabel('Frames per step:', self.tabs['visl']),
                               1, 0, 1, 1)
        self.vslgrid.setRowStretch(2, 1)
        self.vslgrid.setColumnStretch(2, 1)

        self.tdspinbox = QSpinBox(self.tabs['visl'])
        self.tdspinbox.setMinimum(10)
        self.tdspinbox.valueChanged.connect(self.set_td)
        self.vslgrid.addWidget(self.tdspinbox, 0, 1, 1, 1)

        self.fpsspinbox = QSpinBox(self.tabs['visl'])
        self.fpsspinbox.setMinimum(1)
        self.fpsspinbox.setMaximum(300)
        self.fpsspinbox.valueChanged.connect(self.set_fps)
        self.vslgrid.addWidget(self.fpsspinbox, 1, 1, 1, 1)
Example #4
0
	def __init__(self, parent=None):
		super(WidgetGallery, self).__init__(parent)

		# System State
		self.adc_scale = 1
		self.adc_decimation = 1
		self.offset = 0
		self.samples = None

		self.serial_state = None
		self.serial_state_timeout = time.time()

		self.originalPalette = QApplication.palette()

		QApplication.setStyle(QStyleFactory.create("Fusion"))

		serial_label = QLabel()
		serial_label.setText("Serial Port:")

		self.Serial_Handel = serial.Serial()
		self.Serial_Handel.timeout = 0
		self.Serial_Handel.baudrate = 115200
		self.serial_lock = QtCore.QMutex()

		self.serial_thread = SerialThread(self.Serial_Handel, self.serial_lock, self.command_callback)
		self.serial_thread.start()

		self.Serial_Port_Box = SelfPopulatingComboBox()
		self.Serial_Port_Box.view().setMinimumWidth(30)
		self.update_ports()
		self.Serial_Port_Box.setCurrentIndex(0)
		self.port_list = dict()
		self.Serial_Port_Box.popupAboutToBeShown.connect(self.update_ports)
		self.Serial_Port_Box.currentIndexChanged.connect(self.selected_port)

		# create plot
		self.main_plot = pyqtgraph.PlotWidget()

		self.curve = self.main_plot.plot()
		self.curve.setPen((200, 200, 100))
		self.main_plot.getAxis('left').setGrid(255)
		self.main_plot.getAxis('bottom').setGrid(255)
		self.curve.getViewBox().setMouseMode(pyqtgraph.ViewBox.RectMode)

		self.ControlGroupBox = QGroupBox("Controls")
		self.create_control_group_box()

		topLayout = QHBoxLayout()
		topLayout.addStretch(1)
		topLayout.addWidget(serial_label)
		topLayout.addWidget(self.Serial_Port_Box, 2)

		self.label_font = QtGui.QFont("Times", 600, QtGui.QFont.Bold)
		self.bottom_layout = QHBoxLayout()
		self.bottom_layout.addStretch(1)
		measurement_label = QLabel()
		measurement_label.setText("Measurements:")
		measurement_label.setFont(self.label_font)

		self.measurements_list = list()
		self.measurements_functions = [
			measurements.meas_pk_pk,
			measurements.meas_rms,
			measurements.meas_average,
			None
		]

		for i in range(4):
			print("{}: N/A".format(i + 1))
			meas_n = QLabel()
			meas_n.setText("{}: N/A".format(i + 1))
			meas_n.setAlignment(QtCore.Qt.AlignLeft)
			self.measurements_list.append(meas_n)
			self.bottom_layout.addWidget(meas_n, alignment=QtCore.Qt.AlignLeft)

		mainLayout = QGridLayout()
		mainLayout.addLayout(topLayout, 0, 0, 1, 2)
		mainLayout.addWidget(self.main_plot, 1, 0, 2, 1)
		mainLayout.addWidget(self.ControlGroupBox, 1, 1, 2, 1)
		mainLayout.addLayout(self.bottom_layout, 3, 0, 1, 2, alignment=QtCore.Qt.AlignLeft)
		mainLayout.setRowMinimumHeight(3, 20)
		mainLayout.setRowStretch(1, 1)
		mainLayout.setRowStretch(2, 1)
		mainLayout.setColumnStretch(0, 10)
		mainLayout.setColumnStretch(1, 1)

		self.cent_widget = QWidget(self)
		self.setCentralWidget(self.cent_widget)
		self.cent_widget.setLayout(mainLayout)

		self.setWindowTitle("Probe-Scope Acquisition")
Example #5
0
    def __init__(self):
        super(Window, self).__init__()

        self.renderArea = RenderArea()

        self.shapeComboBox = QComboBox()
        self.shapeComboBox.addItem("Polygon", RenderArea.Polygon)
        self.shapeComboBox.addItem("Rectangle", RenderArea.Rect)
        self.shapeComboBox.addItem("Rounded Rectangle", RenderArea.RoundedRect)
        self.shapeComboBox.addItem("Ellipse", RenderArea.Ellipse)
        self.shapeComboBox.addItem("Pie", RenderArea.Pie)
        self.shapeComboBox.addItem("Chord", RenderArea.Chord)
        self.shapeComboBox.addItem("Path", RenderArea.Path)
        self.shapeComboBox.addItem("Line", RenderArea.Line)
        self.shapeComboBox.addItem("Polyline", RenderArea.Polyline)
        self.shapeComboBox.addItem("Arc", RenderArea.Arc)
        self.shapeComboBox.addItem("Points", RenderArea.Points)
        self.shapeComboBox.addItem("Text", RenderArea.Text)
        self.shapeComboBox.addItem("Pixmap", RenderArea.Pixmap)

        shapeLabel = QLabel("&Shape:")
        shapeLabel.setBuddy(self.shapeComboBox)

        self.penWidthSpinBox = QSpinBox()
        self.penWidthSpinBox.setRange(0, 20)
        self.penWidthSpinBox.setSpecialValueText("0 (cosmetic pen)")

        penWidthLabel = QLabel("Pen &Width:")
        penWidthLabel.setBuddy(self.penWidthSpinBox)

        self.penStyleComboBox = QComboBox()
        self.penStyleComboBox.addItem("Solid", Qt.SolidLine)
        self.penStyleComboBox.addItem("Dash", Qt.DashLine)
        self.penStyleComboBox.addItem("Dot", Qt.DotLine)
        self.penStyleComboBox.addItem("Dash Dot", Qt.DashDotLine)
        self.penStyleComboBox.addItem("Dash Dot Dot", Qt.DashDotDotLine)
        self.penStyleComboBox.addItem("None", Qt.NoPen)

        penStyleLabel = QLabel("&Pen Style:")
        penStyleLabel.setBuddy(self.penStyleComboBox)

        self.penCapComboBox = QComboBox()
        self.penCapComboBox.addItem("Flat", Qt.FlatCap)
        self.penCapComboBox.addItem("Square", Qt.SquareCap)
        self.penCapComboBox.addItem("Round", Qt.RoundCap)

        penCapLabel = QLabel("Pen &Cap:")
        penCapLabel.setBuddy(self.penCapComboBox)

        self.penJoinComboBox = QComboBox()
        self.penJoinComboBox.addItem("Miter", Qt.MiterJoin)
        self.penJoinComboBox.addItem("Bevel", Qt.BevelJoin)
        self.penJoinComboBox.addItem("Round", Qt.RoundJoin)

        penJoinLabel = QLabel("Pen &Join:")
        penJoinLabel.setBuddy(self.penJoinComboBox)

        self.brushStyleComboBox = QComboBox()
        self.brushStyleComboBox.addItem("Linear Gradient",
                Qt.LinearGradientPattern)
        self.brushStyleComboBox.addItem("Radial Gradient",
                Qt.RadialGradientPattern)
        self.brushStyleComboBox.addItem("Conical Gradient",
                Qt.ConicalGradientPattern)
        self.brushStyleComboBox.addItem("Texture", Qt.TexturePattern)
        self.brushStyleComboBox.addItem("Solid", Qt.SolidPattern)
        self.brushStyleComboBox.addItem("Horizontal", Qt.HorPattern)
        self.brushStyleComboBox.addItem("Vertical", Qt.VerPattern)
        self.brushStyleComboBox.addItem("Cross", Qt.CrossPattern)
        self.brushStyleComboBox.addItem("Backward Diagonal", Qt.BDiagPattern)
        self.brushStyleComboBox.addItem("Forward Diagonal", Qt.FDiagPattern)
        self.brushStyleComboBox.addItem("Diagonal Cross", Qt.DiagCrossPattern)
        self.brushStyleComboBox.addItem("Dense 1", Qt.Dense1Pattern)
        self.brushStyleComboBox.addItem("Dense 2", Qt.Dense2Pattern)
        self.brushStyleComboBox.addItem("Dense 3", Qt.Dense3Pattern)
        self.brushStyleComboBox.addItem("Dense 4", Qt.Dense4Pattern)
        self.brushStyleComboBox.addItem("Dense 5", Qt.Dense5Pattern)
        self.brushStyleComboBox.addItem("Dense 6", Qt.Dense6Pattern)
        self.brushStyleComboBox.addItem("Dense 7", Qt.Dense7Pattern)
        self.brushStyleComboBox.addItem("None", Qt.NoBrush)

        brushStyleLabel = QLabel("&Brush Style:")
        brushStyleLabel.setBuddy(self.brushStyleComboBox)

        otherOptionsLabel = QLabel("Other Options:")
        self.antialiasingCheckBox = QCheckBox("&Antialiasing")
        self.transformationsCheckBox = QCheckBox("&Transformations")

        self.shapeComboBox.activated.connect(self.shapeChanged)
        self.penWidthSpinBox.valueChanged.connect(self.penChanged)
        self.penStyleComboBox.activated.connect(self.penChanged)
        self.penCapComboBox.activated.connect(self.penChanged)
        self.penJoinComboBox.activated.connect(self.penChanged)
        self.brushStyleComboBox.activated.connect(self.brushChanged)
        self.antialiasingCheckBox.toggled.connect(self.renderArea.setAntialiased)
        self.transformationsCheckBox.toggled.connect(self.renderArea.setTransformed)

        mainLayout = QGridLayout()
        mainLayout.setColumnStretch(0, 1)
        mainLayout.setColumnStretch(3, 1)
        mainLayout.addWidget(self.renderArea, 0, 0, 1, 4)
        mainLayout.setRowMinimumHeight(1, 6)
        mainLayout.addWidget(shapeLabel, 2, 1, Qt.AlignRight)
        mainLayout.addWidget(self.shapeComboBox, 2, 2)
        mainLayout.addWidget(penWidthLabel, 3, 1, Qt.AlignRight)
        mainLayout.addWidget(self.penWidthSpinBox, 3, 2)
        mainLayout.addWidget(penStyleLabel, 4, 1, Qt.AlignRight)
        mainLayout.addWidget(self.penStyleComboBox, 4, 2)
        mainLayout.addWidget(penCapLabel, 5, 1, Qt.AlignRight)
        mainLayout.addWidget(self.penCapComboBox, 5, 2)
        mainLayout.addWidget(penJoinLabel, 6, 1, Qt.AlignRight)
        mainLayout.addWidget(self.penJoinComboBox, 6, 2)
        mainLayout.addWidget(brushStyleLabel, 7, 1, Qt.AlignRight)
        mainLayout.addWidget(self.brushStyleComboBox, 7, 2)
        mainLayout.setRowMinimumHeight(8, 6)
        mainLayout.addWidget(otherOptionsLabel, 9, 1, Qt.AlignRight)
        mainLayout.addWidget(self.antialiasingCheckBox, 9, 2)
        mainLayout.addWidget(self.transformationsCheckBox, 10, 2)
        self.setLayout(mainLayout)

        self.shapeChanged()
        self.penChanged()
        self.brushChanged()
        self.antialiasingCheckBox.setChecked(True)

        self.setWindowTitle("Basic Drawing")
    def __init__(self):
        super(Window, self).__init__()

        self.renderArea = RenderArea()

        self.shapeComboBox = QComboBox()
        self.shapeComboBox.addItem("Polygon", RenderArea.Polygon)
        self.shapeComboBox.addItem("Rectangle", RenderArea.Rect)
        self.shapeComboBox.addItem("Rounded Rectangle", RenderArea.RoundedRect)
        self.shapeComboBox.addItem("Ellipse", RenderArea.Ellipse)
        self.shapeComboBox.addItem("Pie", RenderArea.Pie)
        self.shapeComboBox.addItem("Chord", RenderArea.Chord)
        self.shapeComboBox.addItem("Path", RenderArea.Path)
        self.shapeComboBox.addItem("Line", RenderArea.Line)
        self.shapeComboBox.addItem("Polyline", RenderArea.Polyline)
        self.shapeComboBox.addItem("Arc", RenderArea.Arc)
        self.shapeComboBox.addItem("Points", RenderArea.Points)
        self.shapeComboBox.addItem("Text", RenderArea.Text)
        self.shapeComboBox.addItem("Pixmap", RenderArea.Pixmap)

        shapeLabel = QLabel("&Shape:")
        shapeLabel.setBuddy(self.shapeComboBox)

        self.penWidthSpinBox = QSpinBox()
        self.penWidthSpinBox.setRange(0, 20)
        self.penWidthSpinBox.setSpecialValueText("0 (cosmetic pen)")

        penWidthLabel = QLabel("Pen &Width:")
        penWidthLabel.setBuddy(self.penWidthSpinBox)

        self.penStyleComboBox = QComboBox()
        self.penStyleComboBox.addItem("Solid", Qt.SolidLine)
        self.penStyleComboBox.addItem("Dash", Qt.DashLine)
        self.penStyleComboBox.addItem("Dot", Qt.DotLine)
        self.penStyleComboBox.addItem("Dash Dot", Qt.DashDotLine)
        self.penStyleComboBox.addItem("Dash Dot Dot", Qt.DashDotDotLine)
        self.penStyleComboBox.addItem("None", Qt.NoPen)

        penStyleLabel = QLabel("&Pen Style:")
        penStyleLabel.setBuddy(self.penStyleComboBox)

        self.penCapComboBox = QComboBox()
        self.penCapComboBox.addItem("Flat", Qt.FlatCap)
        self.penCapComboBox.addItem("Square", Qt.SquareCap)
        self.penCapComboBox.addItem("Round", Qt.RoundCap)

        penCapLabel = QLabel("Pen &Cap:")
        penCapLabel.setBuddy(self.penCapComboBox)

        self.penJoinComboBox = QComboBox()
        self.penJoinComboBox.addItem("Miter", Qt.MiterJoin)
        self.penJoinComboBox.addItem("Bevel", Qt.BevelJoin)
        self.penJoinComboBox.addItem("Round", Qt.RoundJoin)

        penJoinLabel = QLabel("Pen &Join:")
        penJoinLabel.setBuddy(self.penJoinComboBox)

        self.brushStyleComboBox = QComboBox()
        self.brushStyleComboBox.addItem("Linear Gradient",
                                        Qt.LinearGradientPattern)
        self.brushStyleComboBox.addItem("Radial Gradient",
                                        Qt.RadialGradientPattern)
        self.brushStyleComboBox.addItem("Conical Gradient",
                                        Qt.ConicalGradientPattern)
        self.brushStyleComboBox.addItem("Texture", Qt.TexturePattern)
        self.brushStyleComboBox.addItem("Solid", Qt.SolidPattern)
        self.brushStyleComboBox.addItem("Horizontal", Qt.HorPattern)
        self.brushStyleComboBox.addItem("Vertical", Qt.VerPattern)
        self.brushStyleComboBox.addItem("Cross", Qt.CrossPattern)
        self.brushStyleComboBox.addItem("Backward Diagonal", Qt.BDiagPattern)
        self.brushStyleComboBox.addItem("Forward Diagonal", Qt.FDiagPattern)
        self.brushStyleComboBox.addItem("Diagonal Cross", Qt.DiagCrossPattern)
        self.brushStyleComboBox.addItem("Dense 1", Qt.Dense1Pattern)
        self.brushStyleComboBox.addItem("Dense 2", Qt.Dense2Pattern)
        self.brushStyleComboBox.addItem("Dense 3", Qt.Dense3Pattern)
        self.brushStyleComboBox.addItem("Dense 4", Qt.Dense4Pattern)
        self.brushStyleComboBox.addItem("Dense 5", Qt.Dense5Pattern)
        self.brushStyleComboBox.addItem("Dense 6", Qt.Dense6Pattern)
        self.brushStyleComboBox.addItem("Dense 7", Qt.Dense7Pattern)
        self.brushStyleComboBox.addItem("None", Qt.NoBrush)

        brushStyleLabel = QLabel("&Brush Style:")
        brushStyleLabel.setBuddy(self.brushStyleComboBox)

        otherOptionsLabel = QLabel("Other Options:")
        self.antialiasingCheckBox = QCheckBox("&Antialiasing")
        self.transformationsCheckBox = QCheckBox("&Transformations")

        self.shapeComboBox.activated.connect(self.shapeChanged)
        self.penWidthSpinBox.valueChanged.connect(self.penChanged)
        self.penStyleComboBox.activated.connect(self.penChanged)
        self.penCapComboBox.activated.connect(self.penChanged)
        self.penJoinComboBox.activated.connect(self.penChanged)
        self.brushStyleComboBox.activated.connect(self.brushChanged)
        self.antialiasingCheckBox.toggled.connect(
            self.renderArea.setAntialiased)
        self.transformationsCheckBox.toggled.connect(
            self.renderArea.setTransformed)

        mainLayout = QGridLayout()
        mainLayout.setColumnStretch(0, 1)
        mainLayout.setColumnStretch(3, 1)
        mainLayout.addWidget(self.renderArea, 0, 0, 1, 4)
        mainLayout.setRowMinimumHeight(1, 6)
        mainLayout.addWidget(shapeLabel, 2, 1, Qt.AlignRight)
        mainLayout.addWidget(self.shapeComboBox, 2, 2)
        mainLayout.addWidget(penWidthLabel, 3, 1, Qt.AlignRight)
        mainLayout.addWidget(self.penWidthSpinBox, 3, 2)
        mainLayout.addWidget(penStyleLabel, 4, 1, Qt.AlignRight)
        mainLayout.addWidget(self.penStyleComboBox, 4, 2)
        mainLayout.addWidget(penCapLabel, 5, 1, Qt.AlignRight)
        mainLayout.addWidget(self.penCapComboBox, 5, 2)
        mainLayout.addWidget(penJoinLabel, 6, 1, Qt.AlignRight)
        mainLayout.addWidget(self.penJoinComboBox, 6, 2)
        mainLayout.addWidget(brushStyleLabel, 7, 1, Qt.AlignRight)
        mainLayout.addWidget(self.brushStyleComboBox, 7, 2)
        mainLayout.setRowMinimumHeight(8, 6)
        mainLayout.addWidget(otherOptionsLabel, 9, 1, Qt.AlignRight)
        mainLayout.addWidget(self.antialiasingCheckBox, 9, 2)
        mainLayout.addWidget(self.transformationsCheckBox, 10, 2)
        self.setLayout(mainLayout)

        self.shapeChanged()
        self.penChanged()
        self.brushChanged()
        self.antialiasingCheckBox.setChecked(True)

        self.setWindowTitle("Basic Drawing")
Example #7
0
class ConsolePanel(QDialog):
    def __init__(self, parent=None):
        super().__init__(parent=parent, f=Qt.Window)
        self.setWindowTitle(self.tr("Console"))
        self.init_ui()
        self.normal_msg = QMessageBox(self)
        self.normal_msg.setWindowTitle(self.tr("Warning"))
        self.normal_msg.setText(
            self.
            tr("Close this window will terminate the work of other windows, are you sure to close it?"
               ))
        self.normal_msg.setStandardButtons(QMessageBox.Close
                                           | QMessageBox.Cancel)
        self.normal_msg.setDefaultButton(QMessageBox.Cancel)

    def init_ui(self):
        self.dataset_generator = RandomDatasetGenerator(parent=self)
        self.dataset_viewer = GrainSizeDatasetViewer(parent=self)
        self.pca_resolver = PCAResolverPanel(parent=self)
        self.hc_resolver = HCResolverPanel(parent=self)
        self.emma_resolver = EMMAResolverPanel(parent=self)
        self.ssu_resolver = SSUResolverPanel(parent=self)
        self.ssu_tester = SSUAlgorithmTesterPanel(parent=self)
        # self.setting_window = AppSettingPanel(parent=self)
        self.abount_window = AboutPanel(parent=self)

        self.main_layout = QGridLayout(self)
        self.main_layout.setRowMinimumHeight(0, 120)
        self.main_layout.setRowMinimumHeight(1, 120)
        self.main_layout.setColumnMinimumWidth(0, 160)
        self.main_layout.setColumnMinimumWidth(1, 160)
        self.main_layout.setColumnMinimumWidth(2, 160)
        self.main_layout.setColumnMinimumWidth(3, 160)

        self.dataset_generator_button = QToolButton()
        self.dataset_generator_button.setSizePolicy(
            QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
        self.dataset_generator_button.setIcon(qta.icon("fa.random"))
        self.dataset_generator_button.setIconSize(QSize(64, 64))
        self.dataset_generator_button.setText(self.tr("Dataset Generator"))
        self.dataset_generator_button.setToolButtonStyle(
            Qt.ToolButtonTextUnderIcon)
        self.dataset_generator_button.clicked.connect(
            lambda: self.dataset_generator.show())
        self.dataset_viewer_button = QToolButton()
        self.dataset_viewer_button.setSizePolicy(QSizePolicy.MinimumExpanding,
                                                 QSizePolicy.MinimumExpanding)
        self.dataset_viewer_button.setIcon(qta.icon("fa.table"))
        self.dataset_viewer_button.setIconSize(QSize(64, 64))
        self.dataset_viewer_button.setText(self.tr("Dataset Viewer"))
        self.dataset_viewer_button.setToolButtonStyle(
            Qt.ToolButtonTextUnderIcon)
        self.dataset_viewer_button.clicked.connect(
            lambda: self.dataset_viewer.show())
        self.pca_resolver_button = QToolButton()
        self.pca_resolver_button.setSizePolicy(QSizePolicy.MinimumExpanding,
                                               QSizePolicy.MinimumExpanding)
        self.pca_resolver_button.setIcon(qta.icon("fa.exchange"))
        self.pca_resolver_button.setIconSize(QSize(64, 64))
        self.pca_resolver_button.setText(self.tr("PCA Resolver"))
        self.pca_resolver_button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self.pca_resolver_button.clicked.connect(
            lambda: self.pca_resolver.show())
        self.hc_resolver_button = QToolButton()
        self.hc_resolver_button.setSizePolicy(QSizePolicy.MinimumExpanding,
                                              QSizePolicy.MinimumExpanding)
        self.hc_resolver_button.setIcon(qta.icon("fa.sitemap"))
        self.hc_resolver_button.setIconSize(QSize(64, 64))
        self.hc_resolver_button.setText(self.tr("HC Resolver"))
        self.hc_resolver_button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self.hc_resolver_button.clicked.connect(
            lambda: self.hc_resolver.show())
        self.emma_resolver_button = QToolButton()
        self.emma_resolver_button.setSizePolicy(QSizePolicy.MinimumExpanding,
                                                QSizePolicy.MinimumExpanding)
        self.emma_resolver_button.setIcon(qta.icon("fa.cubes"))
        self.emma_resolver_button.setIconSize(QSize(64, 64))
        self.emma_resolver_button.setText(self.tr("EMMA Resolver"))
        self.emma_resolver_button.setToolButtonStyle(
            Qt.ToolButtonTextUnderIcon)
        self.emma_resolver_button.clicked.connect(
            lambda: self.emma_resolver.show())
        self.ssu_resolver_button = QToolButton()
        self.ssu_resolver_button.setSizePolicy(QSizePolicy.MinimumExpanding,
                                               QSizePolicy.MinimumExpanding)
        self.ssu_resolver_button.setIcon(qta.icon("fa.puzzle-piece"))
        self.ssu_resolver_button.setIconSize(QSize(64, 64))
        self.ssu_resolver_button.setText(self.tr("SSU Resolver"))
        self.ssu_resolver_button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self.ssu_resolver_button.clicked.connect(
            lambda: self.ssu_resolver.show())
        self.ssu_tester_button = QToolButton()
        self.ssu_tester_button.setSizePolicy(QSizePolicy.MinimumExpanding,
                                             QSizePolicy.MinimumExpanding)
        self.ssu_tester_button.setIcon(qta.icon("fa.flask"))
        self.ssu_tester_button.setIconSize(QSize(64, 64))
        self.ssu_tester_button.setText(self.tr("SSU Tester"))
        self.ssu_tester_button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self.ssu_tester_button.clicked.connect(lambda: self.ssu_tester.show())
        # self.setting_button = QToolButton()
        # self.setting_button.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
        # self.setting_button.setIcon(qta.icon("fa.gears"))
        # self.setting_button.setIconSize(QSize(64, 64))
        # self.setting_button.setText(self.tr("Setting"))
        # self.setting_button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        # self.setting_button.clicked.connect(lambda: self.setting_window.show())
        self.about_button = QToolButton()
        self.about_button.setSizePolicy(QSizePolicy.MinimumExpanding,
                                        QSizePolicy.MinimumExpanding)
        self.about_button.setIcon(qta.icon("fa.info-circle"))
        self.about_button.setIconSize(QSize(64, 64))
        self.about_button.setText(self.tr("About"))
        self.about_button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self.about_button.clicked.connect(lambda: self.abount_window.show())

        self.main_layout.addWidget(self.dataset_generator_button, 0, 0)
        self.main_layout.addWidget(self.dataset_viewer_button, 0, 1)
        self.main_layout.addWidget(self.pca_resolver_button, 0, 2)
        self.main_layout.addWidget(self.hc_resolver_button, 0, 3)
        self.main_layout.addWidget(self.emma_resolver_button, 1, 0)
        self.main_layout.addWidget(self.ssu_resolver_button, 1, 1)
        self.main_layout.addWidget(self.ssu_tester_button, 1, 2)
        self.main_layout.addWidget(self.about_button, 1, 3)

    def closeEvent(self, event: QCloseEvent):
        res = self.normal_msg.exec_()
        if res == QMessageBox.Close:
            event.accept()
        else:
            event.ignore()
    def __init__(self, plain_text_edit: QPlainTextEdit, parent=None):
        """
        Sets up the dialog.

        :param plain_text_edit: Text Editor to operate on.
        :param parent: QWidget parent
        """
        super().__init__(parent=parent, f=Qt.Tool)
        self.plain_text_edit = plain_text_edit
        self.cursors_needed = True
        self.find_flags = QTextDocument.FindFlags()
        self.found_cursors: List[QTextCursor] = []
        self.current_cursor = QTextCursor()

        # UI
        layout = QVBoxLayout()
        find_and_replace_layout = QGridLayout()
        layout.addLayout(
            find_and_replace_layout
        )  # if QGL is sub-layout, add to parent layout before doing stuff.

        self.find_line_edit = QLineEdit()
        find_label = QLabel("&Find")
        find_label.setBuddy(self.find_line_edit)

        options_layout = QHBoxLayout()
        self.match_case_check_box = QCheckBox("Match Case")
        self.whole_word_check_box = QCheckBox("Whole Word")
        options_layout.addWidget(self.match_case_check_box)
        options_layout.addWidget(self.whole_word_check_box)
        options_layout.addStretch()

        self.found_info_label = QLabel()

        self.replace_line_edit = QLineEdit()
        replace_label = QLabel("&Replace")
        replace_label.setBuddy(self.replace_line_edit)

        find_and_replace_layout.addWidget(find_label, 0, 0)
        find_and_replace_layout.addWidget(self.find_line_edit, 0, 1)
        find_and_replace_layout.addLayout(options_layout, 1, 1)
        find_and_replace_layout.setRowMinimumHeight(2, 20)
        find_and_replace_layout.addWidget(self.found_info_label, 2, 1)
        find_and_replace_layout.addWidget(replace_label, 3, 0)
        find_and_replace_layout.addWidget(self.replace_line_edit, 3, 1)

        self.btn_box = QDialogButtonBox(QDialogButtonBox.Close)
        self.find_next_btn = QPushButton("Next")
        self.find_next_btn.setEnabled(False)
        self.find_prev_btn = QPushButton("Previous")
        self.find_prev_btn.setEnabled(False)
        self.replace_btn = QPushButton("Replace")
        self.replace_btn.setEnabled(False)
        self.replace_all_btn = QPushButton("Replace All")
        self.replace_all_btn.setEnabled(False)
        self.btn_box.addButton(self.replace_btn, QDialogButtonBox.ActionRole)
        self.btn_box.addButton(self.replace_all_btn,
                               QDialogButtonBox.ActionRole)
        self.btn_box.addButton(self.find_prev_btn, QDialogButtonBox.ActionRole)
        self.btn_box.addButton(self.find_next_btn, QDialogButtonBox.ActionRole)

        layout.addWidget(self.btn_box)
        self.setLayout(layout)
        # End UI

        self.btn_box.rejected.connect(self.reject)
        self.find_line_edit.textEdited.connect(self.handle_text_edited)
        self.find_next_btn.clicked.connect(self.next)
        self.find_prev_btn.clicked.connect(self.prev)
        self.replace_btn.clicked.connect(self.replace)
        self.replace_all_btn.clicked.connect(self.replace_all)
        self.plain_text_edit.document().contentsChanged.connect(
            self.set_cursors_needed_true)
        self.whole_word_check_box.stateChanged.connect(
            self.toggle_whole_word_flag)
        self.match_case_check_box.stateChanged.connect(
            self.toggle_match_case_flag)