예제 #1
0
    def __init__(self, title=None):
        super(TitleWidget, self).__init__()

        if sys.platform.startswith("darwin"):
            color1 = QColor(230, 230, 230, 255)
            color2 = QColor(177, 177, 177, 255)

            gradient = QLinearGradient()
            gradient.setStart(0, 0)
            gradient.setFinalStop(0, TitleWidget.TitleHeight)
            gradient.setColorAt(0, color1)
            gradient.setColorAt(1, color2)

            brush = QBrush(gradient)
            palette = QPalette()
            palette.setBrush(QPalette.Background, brush)
            self.setPalette(palette)
            self.setAutoFillBackground(True)

        self.setMaximumHeight(TitleWidget.TitleHeight)
        self.setMinimumHeight(TitleWidget.TitleHeight)

        self.titleLabel = QLabel("", parent=self)
        font = self.titleLabel.font()
        font.setPixelSize(11)
        self.titleLabel.setFont(font)
        self.titleLabel.setAlignment(Qt.AlignCenter)
        self.titleLabel.setText(title)

        layout = QVBoxLayout()
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.titleLabel)
        self.setLayout(layout)
예제 #2
0
 def initUI(self):
     self.addKeyHandler(16777216, self.escHandler)
     p = QPalette()
     p.setColor(QPalette.Background, QtGui.QColor(255, 255, 255))
     self.setPalette(p)
     self.setGeometry(0, 0, self._width, self._height)
     self.setWindowTitle('Projector Calibration')
     self.show()
예제 #3
0
 def __init__(self, parent):
     self.parent = parent
     QWidget.__init__(self)
     self.setAutoFillBackground(True)
     bgCol = QPalette()
     bgCol.setColor(QPalette.Background, Qt.yellow)
     self.setPalette(bgCol)
     self.initUI()
예제 #4
0
 def initUI(self):
     posX, posY, sizeW, sizeH = s.GEOMETRY_MAINWIDOW
     self.setGeometry(posX, posY, sizeW, sizeH)
     self.setWindowTitle("Hospital Management System")
     palette = QPalette()
     palette.setBrush(QPalette.Background, QBrush(QPixmap(s.PATH_IMG_BG_LOGIN)))
     self.setPalette(palette)
     self.initButton()
     self.forDev()
예제 #5
0
 def __init__(self, parent):
     self.parent = parent
     QWidget.__init__(self)
     print "Application started"
     self.setAutoFillBackground(True)
     bgCol = QPalette()
     bgCol.setColor(QPalette.Background, Qt.black)
     self.setPalette(bgCol)
     self.initUI()
예제 #6
0
 def initButton(self):
     loader = QUiLoader()
     form = loader.load('RSC/loginUI/Widget_LoginUI.ui', self)
     self.user_id = form.findChild(QLineEdit, "lineEdit_username")
     self.password = form.findChild(QLineEdit, "lineEdit_password")
     self.login_button = form.findChild(QPushButton, "button_login")
     self.login_button.clicked.connect(self.logIn)
     palette = QPalette()
     palette.setBrush(QPalette.Background, QBrush(QPixmap(s.PATH_IMG_BG_LOGIN)))
     self.setPalette(palette)
예제 #7
0
 def paintEvent(self, e):
     p = QPalette()
     print self.width(), self.height()
     gradient = QtGui.QRadialGradient(self.width() / 2,
                                      self.height() / 2,
                                      min(self.width(), self.height()))
     gradient.setColorAt(0.7, QtGui.QColor(0, 0, 0))
     gradient.setColorAt(0.0, QtGui.QColor(0, 255, 0))
     p.setBrush(QPalette.Window, QtGui.QBrush(gradient))
     self.setPalette(p)
예제 #8
0
    def _init_ui(self, txt):
        self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint)

        pal = QPalette()
        color = QColor()
        color.setNamedColor(self._window_bgcolor)
        color.setAlpha(255 * self._opacity)
        pal.setColor(QPalette.Background, color)

        self.setAutoFillBackground(True)
        self.setPalette(pal)

        wm, hm = 5, 5
        spacing = 8
        layout = QVBoxLayout()
        layout.setSpacing(spacing)
        layout.setContentsMargins(wm, hm, wm, hm)

        nlines, ts = self._generate_text(txt)

        qlabel = QLabel('\n'.join(ts))

        ss = 'QLabel {{color: {}; font-family:{}, sans-serif; font-size: {}px}}'.format(self._color,
                                                                                        self._font,
                                                                                        self._fontsize)
        qlabel.setStyleSheet(ss)
        layout.addWidget(qlabel)

        hlabel = QLabel('double click to dismiss')
        hlabel.setStyleSheet('QLabel {font-size: 10px}')

        hlayout = QHBoxLayout()

        hlayout.addStretch()
        hlayout.addWidget(hlabel)
        hlayout.addStretch()

        layout.addLayout(hlayout)

        self.setLayout(layout)

        font = QFont(self._font, self._fontsize)
        fm = QFontMetrics(font)

        pw = max([fm.width(ti) for ti in ts])
        ph = (fm.height() + 2) * nlines

        w = pw + wm * 2
        h = ph + (hm + spacing + 1) * 2

        self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.setFixedWidth(w)
        self.setFixedHeight(h)

        self.setMask(mask(self.rect(), 10))
예제 #9
0
    def __init__(self):
        '''
        Constructor
        '''
        super(LoginDialog, self).__init__()
        formLayout = QFormLayout()
        
        self.input1 = QLineEdit()
        self.input2 = QLineEdit()
        self.input2.setEchoMode(QLineEdit.EchoMode.Password)

        self.input3 = QLineEdit()
        self.input3.setEchoMode(QLineEdit.EchoMode.Password)    
        
        self.cb = QComboBox()
        self.cb.addItems(["Sef stanice", "Radnik u centrali", "Radnik na naplatnom mestu", "Admin"])
        
        palete = QPalette()
        palete.setColor(self.backgroundRole(), Qt.black)
        self.setPalette(palete)
        self.setWindowTitle("Login")
        self.resize(370, 100)
        
        label2 = QLabel("<font color='White'>Username</font>")
        label3 = QLabel("<font color='White'>Password</font>")
        label4 = QLabel("<font color='White'>Registration key</font>")
        label5 = QLabel("<font color='White'>Role</font>")
        
        formLayout.addRow(label2, self.input1)
        formLayout.addRow(label3, self.input2)
    
        
        btnOK = QPushButton("Login")
        btnOK.clicked.connect(self.loginAction)
        btnCancel = QPushButton("Cancel")
        btnCancel.clicked.connect(self.reject)
        btnRegister = QPushButton("Register")
        btnRegister.clicked.connect(self.registerAction)
        
        
        group = QDialogButtonBox()
        group.addButton(btnOK, QDialogButtonBox.AcceptRole)
        group.addButton(btnCancel, QDialogButtonBox.RejectRole)
        
        
        formLayout.addRow(group)
        formLayout.addRow(label4, self.input3)
        formLayout.addRow(label5, self.cb)
        formLayout.addWidget(btnRegister)
        
        self.result = None
        self.setLayout(formLayout)
예제 #10
0
    def init(self, parent):
        """

        """
        if self.control is None:
            self.control = self.control_klass()

            if self.factory.bg_color:
                p = QPalette()
                p.setColor(QPalette.Base, self.factory.bg_color)
                self.control.setPalette(p)
            self.control.setReadOnly(True)

        # self.object.on_trait_change(self._on_clear, self.factory.clear)

        self.sync_value(self.factory.refresh, 'refresh', mode='from')
예제 #11
0
def log(msg, level, msgbox=False, parent="auto", stack=None):
    """docstring for error"""

    if stack is None:
        stack = inspect.stack()[1][0]

    #print inspect.stack()
    #print stack
    #print inspect.getmodule(stack)


    if inspect.getmodule(stack) is None:
        mod = inspect.stack()[1][1]
    else:
        mod = inspect.getmodule(stack).__name__
    lineno = stack.f_lineno

    if mod == "__main__":
        mod = "__main__:" + os.path.basename(__main__.__file__)

    logging.log(level, msg, extra={"mod": mod, "line": lineno})

    if msgbox:
        if parent == "auto":
            qapp = QApplication.instance()
            if qapp is None:
                qapp = QApplication([])
                qapp.setStyle(QStyleFactory.create("plastique") )
                palette = QPalette(QColor(62, 62, 62), QColor(62, 62, 62))
                palette.setColor(palette.Highlight, QColor(255*0.6, 198*0.6, 0))
                qapp.setPalette(palette)
            parent = qapp.activeWindow()

        if level == logging.DEBUG:
            QMessageBox.info(parent, logging.getLevelName(level).capitalize(), msg)
        elif level == logging.INFO:
            QMessageBox.information(parent, logging.getLevelName(level).capitalize(), msg)
        elif level == logging.WARNING:
            QMessageBox.warning(parent, logging.getLevelName(level).capitalize(), msg)
        elif level == logging.ERROR:
            QMessageBox.critical(parent, logging.getLevelName(level).capitalize(), msg)
        elif level == logging.CRITICAL:
            QMessageBox.critical(parent, logging.getLevelName(level).capitalize(), msg)
    def initUI(self):
        """
		Initializes UI. Creates a horizontal layout
		to which buttons can be added.
		"""
        if self._osx:
            # Mimic the style of buttons underneath a list view
            gradient = QLinearGradient()
            gradient.setStart(0, 0)
            gradient.setFinalStop(0, self.Height)

            colorTop = QColor(250, 250, 250, 255)
            colorMid = QColor(244, 244, 244, 255)
            colorInBetween = QColor(238, 238, 238, 255)
            colorMidLow = QColor(234, 234, 234, 255)
            colorLow = QColor(239, 239, 239, 255)
            gradient.setColorAt(0, colorTop)
            gradient.setColorAt(0.45, colorMid)
            gradient.setColorAt(0.5, colorInBetween)
            gradient.setColorAt(0.55, colorMidLow)
            gradient.setColorAt(1, colorLow)

            brush = QBrush(gradient)
            palette = QPalette()
            palette.setBrush(QPalette.Background, brush)

            self.setAutoFillBackground(True)
            self.setPalette(palette)

        # Use a horizontal layout in which to keep
        # buttons. Initialize with an empty QWidget to
        # make the buttons align to the left
        if self.orientation == Qt.Horizontal:
            self.layout = QHBoxLayout()
        else:
            self.layout = QVBoxLayout()
        self.layout.setSpacing(0)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.addWidget(QWidget())
        self.setLayout(self.layout)
    def __init__(self, parent=None, filePath=''):
        """Default class constructor."""
        super(MDISubWindow_TextEdit, self).__init__(parent)

        print(filePath)
        self.filePath = filePath
        self.fileName = os.path.basename(os.path.abspath(filePath))
        self.fileExt = os.path.splitext(self.fileName)[1]

        if not filePath:
            self.setWindowTitle('Untitled[*]')
            parent.setWindowIcon(QIcon(gIconDir + os.sep + 'new.png'))
        else:
            f = open(filePath, 'r')
            txt = f.read()
            f.close()
            self.setText(txt)

            self.setWindowTitle('%s[*]' % self.fileName)

            # TODO: This is changing all the subwindows icons. We want individual icons based on filetype...?
            if self.fileExt in ('.py', '.pyw'):
                parent.setWindowIcon(QIcon(gIconDir + os.sep + 'pyscript.png'))
            else:
                parent.setWindowIcon(QIcon(gIconDir + os.sep + 'new.png'))

        monoFont = QFont('Courier New')
        monoFont.setFixedPitch(True)
        self.setFont(monoFont)
        self.setWordWrapMode(QTextOption.NoWrap)
        ## self.setTextBackgroundColor(QColor('#000000'))
        ## self.setTextColor(QColor('#FFFFFF'))
        self.setCursorWidth(2)
        self.CreateActions()

        self.zoomLevel = 0

        gMainWin.action_Edit_Cut.setEnabled(False)
        gMainWin.action_Edit_Copy.setEnabled(False)
        self.copyAvailable.connect(gMainWin.action_Edit_Cut.setEnabled)
        self.copyAvailable.connect(gMainWin.action_Edit_Copy.setEnabled)
        # Handle the Context Menu Entries Also.
        self.action_Edit_Undo.setEnabled(False)
        self.action_Edit_Redo.setEnabled(False)
        self.action_Edit_Cut.setEnabled(False)
        self.action_Edit_Copy.setEnabled(False)
        self.undoAvailable.connect(self.action_Edit_Undo.setEnabled)
        self.redoAvailable.connect(self.action_Edit_Redo.setEnabled)
        self.copyAvailable.connect(self.action_Edit_Cut.setEnabled)
        self.copyAvailable.connect(self.action_Edit_Copy.setEnabled)

        self.document().contentsChanged.connect(self.TheDocumentWasModified)

        # self.show()
        # self.showMaximized()
        # self.setFocusPolicy(Qt.WheelFocus)
        ##### self.setFocus() # This makes the MDIArea go into SubWindowView...?

        self.gCornerWidget = QToolButton(self)
        # self.gCornerWidgetToolTip = QToolTip()
        QToolTip.setFont(QFont('SansSerif', 10))
        br = QBrush(QPixmap(gImgDir + os.sep + 'texture-spirals.png'))
        pal = QPalette()
        # pal.setBrush(QPalette.Active, QPalette.Base, br)
        # pal.setColor(QPalette.Background, QColor('#FF8000'))
        pal.setColor(QPalette.ColorGroup.Inactive,
                     QPalette.ColorRole.ToolTipBase, QColor(EMBROIDERBLUE2))
        QToolTip.setPalette(QPalette(pal))
        self.action_Edit_SelectAll.setToolTip(
            'This is a <b>QWidget</b> widget')

        self.gCornerWidget.setDefaultAction(self.action_Edit_SelectAll)
        self.setCornerWidget(self.gCornerWidget)
        # We want to show the corner widget no matter what so...
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
예제 #14
0
 def initUI(self):
     self.addKeyHandler(16777216, self.escHandler)
     p = QPalette()
     p.setColor(QPalette.Background, QtGui.QColor(0, 0, 0))
     self.setPalette(p)
     self.showFullScreen()
예제 #15
0
    def _make_total_days_off_panel(self):

        widget = QFrame()
        widget.setObjectName('HorseRegularFrame')

        widget.setFrameShape(QFrame.Panel)
        widget.setFrameShadow(QFrame.Sunken)
        layout = QVBoxLayout()

        #layout.addWidget(QLabel(_("Days off to date")))
        self.day_off_total_duration_labels = dict()
        self.day_off_month_duration_labels = dict()
        self.day_off_labels = dict()

        self._day_off_table_model = QStandardItemModel(10, 3)
        self._day_off_table_model.setHorizontalHeaderLabels(
            [None, None, _("This\nmonth"),
             _("Before")])
        self.day_off_table_view = QTableView(None)
        self.day_off_table_view.setModel(self._day_off_table_model)

        # self.day_off_table_view.setHorizontalHeader(self.headers_view)
        self.day_off_table_view.verticalHeader().hide()
        self.day_off_table_view.setAlternatingRowColors(True)
        self.day_off_table_view.setEditTriggers(
            QAbstractItemView.NoEditTriggers)

        self.day_off_table_view.hide()

        row = 0
        for det in DayEventType.symbols():
            ndx = self._day_off_table_model.index(row, 0)
            self._day_off_table_model.setData(ndx, det.description,
                                              Qt.DisplayRole)

            ndx = self._day_off_table_model.index(row, 1)
            fg, bg = self.DAY_EVENT_PALETTE[det]
            self._day_off_table_model.setData(ndx, QBrush(bg),
                                              Qt.BackgroundRole)
            self._day_off_table_model.setData(ndx, QBrush(fg),
                                              Qt.TextColorRole)
            self._day_off_table_model.setData(ndx,
                                              DayEventType.short_code(det),
                                              Qt.DisplayRole)

            row += 1

        layout.addWidget(self.day_off_table_view)

        grid = QGridLayout()
        self.days_off_layout = grid
        grid.setColumnStretch(3, 1)
        row = 0

        grid.addWidget(QLabel(_('Year')), row, self.YEAR_EVENT_COLUMN)
        grid.addWidget(QLabel(_('Month')), row, self.MONTH_EVENT_COLUMN)
        row += 1

        for det in DayEventType.symbols():
            self.day_off_total_duration_labels[det] = QLabel("-")
            self.day_off_month_duration_labels[det] = QLabel("-")
            self.day_off_labels[det] = QLabel(det.description)

            hlayout = QHBoxLayout()

            sl = QLabel()
            fg, bg = self.DAY_EVENT_PALETTE[det]

            def to_html_rgb(color):
                i = color.red() * 256 * 256 + color.green() * 256 + color.blue(
                )
                return "#{:06X}".format(i)

            p = QPalette()
            p.setColor(QPalette.Window, QColor(bg))
            p.setColor(QPalette.WindowText, QColor(fg))
            sl.setPalette(p)
            sl.setAlignment(Qt.AlignCenter)
            sl.setStyleSheet("border: 2px solid black; background: {}".format(
                to_html_rgb(QColor(bg))))

            t = DayEventType.short_code(det)
            mainlog.debug(t)
            sl.setAutoFillBackground(True)
            sl.setText(t)

            grid.addWidget(sl, row, 0)
            grid.addWidget(self.day_off_labels[det], row, 1)
            grid.addWidget(self.day_off_total_duration_labels[det], row,
                           self.YEAR_EVENT_COLUMN)
            grid.addWidget(self.day_off_month_duration_labels[det], row,
                           self.MONTH_EVENT_COLUMN)

            hlayout.addStretch()

            row += 1

        layout.addLayout(grid)
        layout.addStretch()

        self.day_off_table_view.resizeColumnsToContents()
        # self.day_off_table_view.setMinimumWidth( self.day_off_table_view.width())
        # self.day_off_table_view.resize( self.day_off_table_view.minimumWidth(),
        #                                 self.day_off_table_view.minimumHeight(),)

        widget.setLayout(layout)
        return widget
예제 #16
0
 def _bgcolor_changed(self):
     p = QPalette()
     p.setColor(QPalette.Base, self.bgcolor)
     self.control.setPalette(p)