Ejemplo n.º 1
0
    def addNewMessage(self):
        name = self.ui.txt_name.text()
        text = self.ui.txt_message.text()
        now = datetime.now().strftime('%H')

        if name != "" and text != "":
            for message in self.messages:
                if name == message[1]:
                    if int(now) - int(message[3][11:12]) <= 0:
                        self.msgBox("Your message should be for 1 hour ago or more")
                        break
            else:
                response = Database.insert(name, text)
                if response:
                    self.length += 1
                    label = QLabel()
                    label.setText(name + ": " + text)
                    self.ui.gl_messages.addWidget(label, self.length, 1, alignment=Qt.Alignment())
                    
                    btn = QPushButton()
                    btn.setText('×')
                    btn.setStyleSheet('max-width: 18px; min-height: 18px; background-color: red; color: white; border: 0px; border-radius: 5px;')
                    self.ui.gl_messages.addWidget(btn, self.length, 0, alignment=Qt.Alignment())
                    btn.clicked.connect(partial(self.deleteMessage, self.messages[-1][0], btn, label))
                
                    self.ui.txt_name.setText("")
                    self.ui.txt_message.setText("")

                    self.msgBox("Your message sent successfully!")
                else:
                    self.msgBox("Database error!")                
        else:
            self.msgBox("Error: feilds are empty!")
Ejemplo n.º 2
0
Archivo: 14.py Proyecto: fncong/pyqt6
    def penChanged(self):
        width = self.penWidthSpinBox.value()
        style = Qt.PenStyle(self.penStyleComboBox.itemData(
            self.penStyleComboBox.currentIndex(), IdRole))
        cap = Qt.PenCapStyle(self.penCapComboBox.itemData(
            self.penCapComboBox.currentIndex(), IdRole))
        join = Qt.PenJoinStyle(self.penJoinComboBox.itemData(
            self.penJoinComboBox.currentIndex(), IdRole))

        self.renderArea.setPen(QPen(Qt.blue, width, style, cap, join))
Ejemplo n.º 3
0
    def saveStopWatch(self):
        self.length_stw += 1

        label_num = QLabel()
        label_total = QLabel()
        label_num.setText(str(self.length_stw))
        label_total.setText(self.ui.lbl_stopwatch.text())
        label_num.setStyleSheet('max-width: 50px; padding-left: 20px;')
        self.ui.gl_saved_times.addWidget(label_num, self.length_stw, 0, alignment=Qt.Alignment())
        self.ui.gl_saved_times.addWidget(label_total, self.length_stw, 1, alignment=Qt.Alignment())
Ejemplo n.º 4
0
    def readMessages(self):
        messages = Database.select()
        for i, message in enumerate(messages):
            label = QLabel()
            label.setText(message[1] + ": " + message[2])
            self.ui.gl_messages.addWidget(label,i, 1, alignment=Qt.Alignment())
            
            btn = QPushButton()
            btn.setText('×')
            btn.setStyleSheet('max-width: 18px; min-height: 18px; background-color: red; color: white; border: 0px; border-radius: 5px;')

            self.ui.gl_messages.addWidget(btn, i, 0, alignment=Qt.Alignment())
            btn.clicked.connect(partial(self.deleteMessage, message[0], btn, label))
        return messages
Ejemplo n.º 5
0
 def __init__(self, parent=None):
     super(DonutBreakdownChart,
           self).__init__(QtCharts.QChart.ChartTypeCartesian, parent,
                          Qt.WindowFlags())
     self.main_series = QtCharts.QPieSeries()
     self.main_series.setPieSize(0.7)
     self.addSeries(self.main_series)
Ejemplo n.º 6
0
    def __init__(self, parent=None, flags=Qt.WindowFlags()):
        super(MainWindow, self).__init__(parent, flags)

        self.dayWidth = 70
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.initModel()
        self.initActions()
        self.initItemDelegate()
        self.initGrid()

        leftView = self.ui.ganttView.leftView()
        leftView.setColumnHidden(1, True)
        leftView.setColumnHidden(2, True)
        leftView.setColumnHidden(3, True)
        leftView.setColumnHidden(4, True)
        leftView.setColumnHidden(5, True)
        leftView.header().setStretchLastSection(True)

        self.ui.ganttView.leftView().customContextMenuRequested.connect(
            self.showContextMenu)
        self.ui.ganttView.selectionModel().selectionChanged.connect(
            self.enableActions)
        self.ui.ganttView.graphicsView().clicked.connect(self.slotClicked)
        self.ui.ganttView.graphicsView().qrealClicked.connect(
            self.slotDoubleClicked)
Ejemplo n.º 7
0
    def brushChanged(self):
        style = Qt.BrushStyle(
            self.brushStyleComboBox.itemData(
                self.brushStyleComboBox.currentIndex(), IdRole))

        if style == Qt.LinearGradientPattern:
            linearGradient = QLinearGradient(0, 0, 100, 100)
            linearGradient.setColorAt(0.0, Qt.white)
            linearGradient.setColorAt(0.2, Qt.green)
            linearGradient.setColorAt(1.0, Qt.black)
            self.renderArea.setBrush(QBrush(linearGradient))
        elif style == Qt.RadialGradientPattern:
            radialGradient = QRadialGradient(50, 50, 50, 70, 70)
            radialGradient.setColorAt(0.0, Qt.white)
            radialGradient.setColorAt(0.2, Qt.green)
            radialGradient.setColorAt(1.0, Qt.black)
            self.renderArea.setBrush(QBrush(radialGradient))
        elif style == Qt.ConicalGradientPattern:
            conicalGradient = QConicalGradient(50, 50, 150)
            conicalGradient.setColorAt(0.0, Qt.white)
            conicalGradient.setColorAt(0.2, Qt.green)
            conicalGradient.setColorAt(1.0, Qt.black)
            self.renderArea.setBrush(QBrush(conicalGradient))
        elif style == Qt.TexturePattern:
            self.renderArea.setBrush(QBrush(QPixmap(':/images/brick.png')))
        else:
            self.renderArea.setBrush(QBrush(Qt.green, style))
Ejemplo n.º 8
0
    def buttonsOrientationChanged(self, index):
        self.mainLayout.setSizeConstraint(QLayout.SetNoConstraint)
        self.setMinimumSize(0, 0)

        orientation = Qt.Orientation(
            int(self.buttonsOrientationComboBox.itemData(index)))

        if orientation == self.buttonBox.orientation():
            return

        self.mainLayout.removeWidget(self.buttonBox)

        spacing = self.mainLayout.spacing()

        oldSizeHint = self.buttonBox.sizeHint() + QSize(spacing, spacing)
        self.buttonBox.setOrientation(orientation)
        newSizeHint = self.buttonBox.sizeHint() + QSize(spacing, spacing)

        if orientation == Qt.Horizontal:
            self.mainLayout.addWidget(self.buttonBox, 2, 0)
            self.resize(self.size() +
                        QSize(-oldSizeHint.width(), newSizeHint.height()))
        else:
            self.mainLayout.addWidget(self.buttonBox, 0, 3, 2, 1)
            self.resize(self.size() +
                        QSize(newSizeHint.width(), -oldSizeHint.height()))

        self.mainLayout.setSizeConstraint(QLayout.SetDefaultConstraint)
Ejemplo n.º 9
0
 def slot_trigger_line_width(self):
     width = QInputDialog.getDouble(
         self, "Width selection",
         "Please pass decimal value from range 0.01 to 20.00 <br /> with maximally "
         "2 decimal places", self.graphicsView.actual_pen.width(), 0.01,
         20.00, 2, Qt.WindowFlags(), 1.0)
     if width[1]:
         self.graphicsView.actual_pen.setWidthF(width[0])
Ejemplo n.º 10
0
    def __init__(self, model, parent=None, f=Qt.WindowFlags()):
        super(EntryDialog, self).__init__(parent, f)

        self.indexList = []
        self.ui = Ui_EntryDialog()
        self.ui.setupUi(self)
        self.model = model
        self.init()
Ejemplo n.º 11
0
 def flags(self, index):
     """ Set the item flags at the given index. Seems like we're
         implementing this function just to see how it's done, as we
         manually adjust each tableView to have NoEditTriggers.
     """
     if not index.isValid():
         return Qt.ItemIsEnabled
     return Qt.ItemFlags(
         QAbstractTableModel.flags(self, index) | Qt.ItemIsEditable)
 def input_to_polygon_item(self, input_stream: QDataStream,
                           item: QGraphicsPolygonItem):
     self.input_to_shape_item(input_stream, item)
     # Type
     fill_rule = Qt.FillRule()
     polygon = QPolygonF()
     # Read
     input_stream >> fill_rule
     input_stream >> polygon
     # Set
     item.setFillRule(fill_rule)
     item.setPolygon(polygon)
Ejemplo n.º 13
0
 def expandingDirections(self):
     return Qt.Orientations(Qt.Orientation(0))
Ejemplo n.º 14
0
    def __init__(self, parent=None, **kw):
        # the current button
        self._ActiveButton = Qt.NoButton

        # private attributes
        self.__saveX = 0
        self.__saveY = 0
        self.__saveModifiers = Qt.NoModifier
        self.__saveButtons = Qt.NoButton
        self.__wheelDelta = 0

        # do special handling of some keywords:
        # stereo, rw

        try:
            stereo = bool(kw['stereo'])
        except KeyError:
            stereo = False

        try:
            rw = kw['rw']
        except KeyError:
            rw = None

        # create base qt-level widget
        if QVTKRWIBase == "QWidget":
            if "wflags" in kw:
                wflags = kw['wflags']
            else:
                wflags = Qt.WindowFlags()
            QWidget.__init__(self, parent, wflags | Qt.MSWindowsOwnDC)
        elif QVTKRWIBase == "QOpenGLWidget":
            QOpenGLWidget.__init__(self, parent)

        if rw:  # user-supplied render window
            self._RenderWindow = rw
        else:
            self._RenderWindow = vtkRenderWindow()

        WId = self.winId()

        # Python2
        if type(WId).__name__ == 'PyCObject':
            from ctypes import pythonapi, c_void_p, py_object

            pythonapi.PyCObject_AsVoidPtr.restype = c_void_p
            pythonapi.PyCObject_AsVoidPtr.argtypes = [py_object]

            WId = pythonapi.PyCObject_AsVoidPtr(WId)

        # Python3
        elif type(WId).__name__ == 'PyCapsule':
            from ctypes import pythonapi, c_void_p, py_object, c_char_p

            pythonapi.PyCapsule_GetName.restype = c_char_p
            pythonapi.PyCapsule_GetName.argtypes = [py_object]

            name = pythonapi.PyCapsule_GetName(WId)

            pythonapi.PyCapsule_GetPointer.restype = c_void_p
            pythonapi.PyCapsule_GetPointer.argtypes = [py_object, c_char_p]

            WId = pythonapi.PyCapsule_GetPointer(WId, name)

        self._RenderWindow.SetWindowInfo(str(int(WId)))

        if stereo:  # stereo mode
            self._RenderWindow.StereoCapableWindowOn()
            self._RenderWindow.SetStereoTypeToCrystalEyes()

        try:
            self._Iren = kw['iren']
        except KeyError:
            self._Iren = vtkGenericRenderWindowInteractor()
            self._Iren.SetRenderWindow(self._RenderWindow)

        # do all the necessary qt setup
        self.setAttribute(Qt.WA_OpaquePaintEvent)
        self.setAttribute(Qt.WA_PaintOnScreen)
        self.setMouseTracking(True)  # get all mouse events
        self.setFocusPolicy(Qt.WheelFocus)
        self.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))

        self._Timer = QTimer(self)
        self._Timer.timeout.connect(self.TimerEvent)

        self._Iren.AddObserver('CreateTimerEvent', self.CreateTimer)
        self._Iren.AddObserver('DestroyTimerEvent', self.DestroyTimer)
        self._Iren.GetRenderWindow().AddObserver('CursorChangedEvent',
                                                 self.CursorChangedEvent)

        # If we've a parent, it does not close the child when closed.
        # Connect the parent's destroyed signal to this widget's close
        # slot for proper cleanup of VTK objects.
        if self.parent():
            self.parent().destroyed.connect(self.close, Qt.DirectConnection)
Ejemplo n.º 15
0
 def expandingDirections(self) -> PySide6.QtCore.Qt.Orientations:
     return Qt.Orientations(Qt.Orientation(0))