class DatePopup(QDialog): def __init__(self): super(Qt.Popup, self).__init__() self.setSizeGripEnabled(False) self.resize(260, 230) self.widget = QWidget(self) self.widget.setObjectName(QtCore.QString.fromUtf8("self.widget")) self.widget.setGeometry(QRect(0, 10, 258, 215)) self.verticalLayout = QVBoxLayout(self.widget) self.verticalLayout.setObjectName( QtCore.QString.fromUtf8("self.verticalLayout")) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.calendarWidget = QCalendarWidget(self.widget) self.calendarWidget.setObjectName( QtCore.QString.fromUtf8("calendarWidget")) self.verticalLayout.addWidget(self.calendarWidget) self.buttonBox = QDialogButtonBox(self.widget) self.buttonBox.setObjectName(QtCore.QString.fromUtf8("self.buttonBox")) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.verticalLayout.addWidget(self.buttonBox) QObject.self.buttonBox.accepted.connect(self.accept) QObject.self.buttonBox.rejected.connect(self.reject) def selected_date(self): return self.calendarWidget.selectedDate()
class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(400, 300) self.calendarWidget = QCalendarWidget(Dialog) self.calendarWidget.setGeometry(QRect(50, 60, 312, 173)) self.calendarWidget.setObjectName("calendarWidget") self.OkButton = QPushButton(Dialog) self.OkButton.setGeometry(QRect(240, 240, 113, 32)) self.OkButton.setObjectName("OkButton") self.cancelButton = QPushButton(Dialog) self.cancelButton.setGeometry(QRect(120, 240, 113, 32)) self.cancelButton.setObjectName("cancelButton") self.label = QLabel(Dialog) self.label.setGeometry(QRect(30, 10, 331, 31)) self.label.setObjectName("label") def show_config(self, data): Echo.SendData("dir") i = 1 self.OkButton.clicked.connect(lambda checked, i=2: self.show_config(data))
class Ui_PostX_Calendar(object): def setupUi(self, PostX_Calendar): PostX_Calendar.setObjectName(_fromUtf8("PostX_Calendar")) PostX_Calendar.resize(500, 300) palette = QPalette() brush = QBrush(QColor(245, 245, 225)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.WindowText, brush) brush = QBrush(QColor(59, 58, 55)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Button, brush) brush = QBrush(QColor(88, 87, 82)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Light, brush) brush = QBrush(QColor(73, 72, 68)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Midlight, brush) brush = QBrush(QColor(29, 29, 27)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Dark, brush) brush = QBrush(QColor(39, 38, 36)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Mid, brush) brush = QBrush(QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Text, brush) brush = QBrush(QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.BrightText, brush) brush = QBrush(QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.ButtonText, brush) brush = QBrush(QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Base, brush) brush = QBrush(QColor(59, 58, 55)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Window, brush) brush = QBrush(QColor(0, 0, 74)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Shadow, brush) brush = QBrush(QColor(29, 29, 27)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.AlternateBase, brush) brush = QBrush(QColor(255, 255, 220)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.ToolTipBase, brush) brush = QBrush(QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.ToolTipText, brush) brush = QBrush(QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.WindowText, brush) brush = QBrush(QColor(59, 58, 55)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Button, brush) brush = QBrush(QColor(88, 87, 82)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Light, brush) brush = QBrush(QColor(73, 72, 68)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Midlight, brush) brush = QBrush(QColor(29, 29, 27)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Dark, brush) brush = QBrush(QColor(39, 38, 36)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Mid, brush) brush = QBrush(QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Text, brush) brush = QBrush(QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.BrightText, brush) brush = QBrush(QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.ButtonText, brush) brush = QBrush(QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Base, brush) brush = QBrush(QColor(59, 58, 55)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Window, brush) brush = QBrush(QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Shadow, brush) brush = QBrush(QColor(29, 29, 27)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.AlternateBase, brush) brush = QBrush(QColor(255, 255, 220)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.ToolTipBase, brush) brush = QBrush(QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.ToolTipText, brush) brush = QBrush(QColor(29, 29, 27)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.WindowText, brush) brush = QBrush(QColor(59, 58, 55)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Button, brush) brush = QBrush(QColor(88, 87, 82)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Light, brush) brush = QBrush(QColor(73, 72, 68)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Midlight, brush) brush = QBrush(QColor(29, 29, 27)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Dark, brush) brush = QBrush(QColor(39, 38, 36)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Mid, brush) brush = QBrush(QColor(29, 29, 27)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Text, brush) brush = QBrush(QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.BrightText, brush) brush = QBrush(QColor(29, 29, 27)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.ButtonText, brush) brush = QBrush(QColor(59, 58, 55)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Base, brush) brush = QBrush(QColor(59, 58, 55)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Window, brush) brush = QBrush(QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Shadow, brush) brush = QBrush(QColor(59, 58, 55)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.AlternateBase, brush) brush = QBrush(QColor(255, 255, 220)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.ToolTipBase, brush) brush = QBrush(QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.ToolTipText, brush) PostX_Calendar.setPalette(palette) PostX_Calendar.setWindowOpacity(1.0) self.horizontalLayout = QHBoxLayout(PostX_Calendar) self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.calendarWidget = QCalendarWidget(PostX_Calendar) palette = QPalette() brush = QBrush(QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.WindowText, brush) brush = QBrush(QColor(97, 97, 97)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Button, brush) brush = QBrush(QColor(146, 146, 146)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Light, brush) brush = QBrush(QColor(121, 121, 121)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Midlight, brush) brush = QBrush(QColor(48, 48, 48)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Dark, brush) brush = QBrush(QColor(64, 64, 64)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Mid, brush) brush = QBrush(QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Text, brush) brush = QBrush(QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.BrightText, brush) brush = QBrush(QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.ButtonText, brush) brush = QBrush(QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Base, brush) brush = QBrush(QColor(97, 97, 97)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Window, brush) brush = QBrush(QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Shadow, brush) brush = QBrush(QColor(48, 48, 48)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.AlternateBase, brush) brush = QBrush(QColor(255, 255, 220)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.ToolTipBase, brush) brush = QBrush(QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.ToolTipText, brush) brush = QBrush(QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.WindowText, brush) brush = QBrush(QColor(97, 97, 97)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Button, brush) brush = QBrush(QColor(146, 146, 146)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Light, brush) brush = QBrush(QColor(121, 121, 121)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Midlight, brush) brush = QBrush(QColor(48, 48, 48)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Dark, brush) brush = QBrush(QColor(64, 64, 64)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Mid, brush) brush = QBrush(QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Text, brush) brush = QBrush(QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.BrightText, brush) brush = QBrush(QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.ButtonText, brush) brush = QBrush(QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Base, brush) brush = QBrush(QColor(97, 97, 97)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Window, brush) brush = QBrush(QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.Shadow, brush) brush = QBrush(QColor(48, 48, 48)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.AlternateBase, brush) brush = QBrush(QColor(255, 255, 220)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.ToolTipBase, brush) brush = QBrush(QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Inactive, QPalette.ToolTipText, brush) brush = QBrush(QColor(48, 48, 48)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.WindowText, brush) brush = QBrush(QColor(97, 97, 97)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Button, brush) brush = QBrush(QColor(146, 146, 146)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Light, brush) brush = QBrush(QColor(121, 121, 121)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Midlight, brush) brush = QBrush(QColor(48, 48, 48)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Dark, brush) brush = QBrush(QColor(64, 64, 64)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Mid, brush) brush = QBrush(QColor(48, 48, 48)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Text, brush) brush = QBrush(QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.BrightText, brush) brush = QBrush(QColor(48, 48, 48)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.ButtonText, brush) brush = QBrush(QColor(97, 97, 97)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Base, brush) brush = QBrush(QColor(97, 97, 97)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Window, brush) brush = QBrush(QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.Shadow, brush) brush = QBrush(QColor(97, 97, 97)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.AlternateBase, brush) brush = QBrush(QColor(255, 255, 220)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.ToolTipBase, brush) brush = QBrush(QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QPalette.Disabled, QPalette.ToolTipText, brush) self.calendarWidget.setPalette(palette) font = QFont() font.setFamily(_fromUtf8("Monospace")) font.setPointSize(12) font.setStyleStrategy(QFont.PreferAntialias) self.calendarWidget.setFont(font) self.calendarWidget.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) self.calendarWidget.setFirstDayOfWeek(QtCore.Qt.Monday) self.calendarWidget.setGridVisible(True) self.calendarWidget.setHorizontalHeaderFormat( QCalendarWidget.ShortDayNames) self.calendarWidget.setDateEditEnabled(True) self.calendarWidget.setObjectName(_fromUtf8("calendarWidget")) self.horizontalLayout.addWidget(self.calendarWidget) self.retranslateUi(PostX_Calendar) QtCore.QMetaObject.connectSlotsByName(PostX_Calendar) def retranslateUi(self, PostX_Calendar): PostX_Calendar.setWindowTitle( _translate("PostX_Calendar", "PostX-Calendar-QT5", None)) PostX_Calendar.setToolTip( _translate("PostX_Calendar", "PostX-Calendar", None)) self.calendarWidget.setToolTip( _translate("PostX_Calendar", "PostX-Calendar", None))
class AddCutplanDialog(QWidget): def setupUi(self, adddata=None, sqlfile=None, host=None): now = datetime.now() if host is None: self.host = '' else: self.host = host if adddata is None: self.addData = DataFrame( columns=['ID', 'Log Count', 'Description']) else: self.addData = adddata self.availData = None self.addPD = None self.avalPD = None # SQL if sqlfile is None: self.sqlfile = "support\\cpquery.sql" else: self.sqlfile = sqlfile # SERVER CONNECT QApplication.setOverrideCursor( QCursor(Qt.WaitCursor)) self.conn = connect(LogScanner) QApplication.restoreOverrideCursor() self.setObjectName("Dialog") # self.setWindowIcon(QIcon('images/icon.ico')) self.resize(250, 900) self.setStyleSheet( "#Dialog {\n" " background-color: white;\n" "}") self.installEventFilter(self) self.horizontalLayout = QVBoxLayout(self) self.horizontalLayout.setObjectName("horizontalLayout") self.calendarWidget = QCalendarWidget(self) font = QFont() font.setFamily("Tahoma") font.setPointSize(10) self.calendarWidget.setFont(font) self.calendarWidget.setStyleSheet( "#qt_calendar_prevmonth {\n" " qproperty-icon: url(\"images/prev.png\");\n" "}\n" "\n" "#qt_calendar_nextmonth {\n" " qproperty-icon: url(\"images/next.png\");\n" "}\n" "\n" "#qt_calendar_navigationbar {\n" " background-color: qlineargradient(spread:pad, x1:0, y1:0, " "x2:1, y2:1, stop:0 rgb(192, 221, 221), stop:1 rgb(180, 233, " "197));\n" "}\n" "\n" "#qt_calendar_monthbutton {\n" " color: rgb(0,115,119);\n" " font-size: 15px;\n" "}\n" "\n" "#qt_calendar_yearbutton {\n" " color: rgb(0,115,119);\n" " font-size: 15px;\n" "}\n" "\n" "QCalendarWidget QMenu {\n" " background-color: white;\n" " color: rgb(0,115,119);\n" "}\n" "\n" "QCalendarWidget QMenu::item:selected {\n" " background-color: rgb(192, 221, 221);\n" " color: rgb(0,115,119);\n" "}\n" "\n" "QCalendarWidget QSpinBox {\n" " color: rgb(0,115,119);\n" " selection-background-color: rgb(0, 115, 119);\n" " selection-color: white;\n" "}\n" "\n" "#qt_calendar_calendarview:enabled {\n" " background-color: rgb(192, 221, 221);\n" " alternate-background-color: white;\n" " color: rgb(0, 115, 119);\n" " selection-background-color: rgb(0, 115, 119);\n" " selection-color: white;\n" "}\n" "\n" "#qt_calendar_calendarview:disabled {\n" " color: #44acb0;\n" "}\n" "\n" "") btn = self.calendarWidget.findChild( QToolButton, "qt_calendar_prevmonth") btn.setCursor(QCursor(Qt.PointingHandCursor)) btn = self.calendarWidget.findChild( QToolButton, "qt_calendar_nextmonth") btn.setCursor(QCursor(Qt.PointingHandCursor)) self.calendarWidget.setVerticalHeaderFormat( QCalendarWidget.NoVerticalHeader) self.calendarWidget.setObjectName("calendarWidget") self.calendarWidget.setMinimumDate(QDate(2016, 1, 1)) self.calendarWidget.setMaximumDate( QDate(now.year, now.month, now.day)) btn = self.calendarWidget.findChild( QSpinBox, "qt_calendar_yearedit") btn.setAlignment(Qt.AlignCenter) btn.setButtonSymbols(QSpinBox.NoButtons) self.horizontalLayout.addWidget(self.calendarWidget) self.leftTV = QTableView(self) self.leftTV.setStyleSheet( "QTableView {" "border: 1px solid rgb(192, 221, 221);" "gridline-color: rgb(192, 221, 221);" "selection-background-color: rgb(192, 221, 221);" "selection-color: rgb(0,115,119);" "}" "QTableView::item::selected:!active {" "selection-color: rgb(0,115,119);" "}" ) self.leftTV.setObjectName("leftTV") self.leftTV.horizontalHeader().setDefaultSectionSize(65) self.leftTV.horizontalHeader().setStretchLastSection(True) self.leftTV.horizontalHeader().setStyleSheet( "QHeaderView::section {" "height: 25px;" "border: 1px outset rgb(192, 221, 221);" "background-color: white;" "selection-background-color: white;" "}" ) scrollbarss = """ QScrollBar:vertical { border: none; background: white; width: 5px; margin: 0 0 0 0; } QScrollBar::handle:vertical { background: rgb(192, 221, 221); border-radius: 2px; min-height: 20px; } QScrollBar::add-line:vertical { border: none; background: none; height: 0; subcontrol-position: none; subcontrol-origin: none; } QScrollBar::sub-line:vertical { border: none; background: none; height: 0; subcontrol-position: none; subcontrol-origin: none; } QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical { border: none; width: 0; height: 0; background: none; } QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { background: none; } QScrollBar:horizontal { border: none; background: white; height: 5px; margin: 0 0 0 0; } QScrollBar::handle:horizontal { background: rgb(192, 221, 221); border-radius: 2px; min-width: 20px; } QScrollBar::add-line:horizontal { border: none; background: none; width: 0; } QScrollBar::sub-line:horizontal { border: none; background: none; width: 0; } QScrollBar::left-arrow:horizontal, QScrollBar::right-arrow:horizontal { border: none; width: 0; height: 0; background: none; } QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal { background: none; } """ self.leftTV.verticalScrollBar().setStyleSheet(scrollbarss) self.leftTV.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.leftTV.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.leftFilter = HoverFilter() self.leftTV.horizontalHeader().installEventFilter(self.leftFilter) lcDelegate = LogCountDelegate() self.leftTV.setItemDelegateForColumn(1, lcDelegate) self.horizontalLayout.addWidget(self.leftTV) self.middleButtonsLayout = QHBoxLayout() self.middleButtonsLayout.setObjectName("middleButtonsLayout") self.addButton = QToolButton(self) self.addButton.setObjectName("addButton") buttonStyle = \ "QToolButton {\n"\ " background-color: qlineargradient(spread:pad, x1:0, y1:0, "\ "x2:1, y2:1, stop:0 rgba(0, 115, 119, 255), stop:1 rgb(4, 147, "\ "131));\n"\ " color: white;\n"\ " border: None;"\ " border-radius: 2px;"\ " font: 11pt \"Tahoma\";"\ "}" self.addButton.setStyleSheet(buttonStyle) self.addButton.setCursor( QCursor(Qt.PointingHandCursor)) self.middleButtonsLayout.addWidget(self.addButton) self.deleteButton = QToolButton(self) font = QFont() font.setPointSize(10) self.deleteButton.setFont(font) self.deleteButton.setObjectName("deleteButton") self.deleteButton.setStyleSheet(buttonStyle) self.deleteButton.setCursor( QCursor(Qt.PointingHandCursor)) self.middleButtonsLayout.addWidget(self.deleteButton) self.horizontalLayout.addLayout(self.middleButtonsLayout) self.rightTV = QTableView(self) self.rightTV.setStyleSheet( "QTableView {" "border: 1px solid rgb(192, 221, 221);" "gridline-color: rgb(192, 221, 221);" "selection-background-color: rgb(192, 221, 221);" "selection-color: rgb(0,115,119);" "}" "QTableView::item::selected:!active {" "selection-color: rgb(0,115,119);" "}" ) self.rightTV.setObjectName("rightTV") self.rightTV.verticalScrollBar().setStyleSheet(scrollbarss) self.rightTV.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.rightTV.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.rightTV.horizontalHeader().setDefaultSectionSize(65) self.rightTV.horizontalHeader().setStretchLastSection(True) self.rightTV.horizontalHeader().setStyleSheet( "QHeaderView::section {" "height: 25px;" "border: 1px outset rgb(192, 221, 221);" "background-color: white;" "selection-background-color: white;" "}" ) self.rightFilter = HoverFilter() self.rightTV.horizontalHeader().installEventFilter(self.rightFilter) lcDelegate = LogCountDelegate() self.rightTV.setItemDelegateForColumn(1, lcDelegate) self.horizontalLayout.addWidget(self.rightTV) # self.horizontalLayout.addLayout(self.vertlayoutl) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setStyleSheet( "QDialogButtonBox QPushButton {\n" " background-color: ;\n" " background-color: qlineargradient(spread:pad, x1:0, y1:0, " "x2:1, y2:1, stop:0 rgba(0, 115, 119, 255), stop:1 rgb(4, 147, " "131));\n" " color: white;\n" " width: 70px;\n" " height: 25px;\n" " border: None;\n" " border-radius: 2px;\n" " \n" " font: 11pt \"Tahoma\";\n" "}") self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons( QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.buttonBox.setObjectName("buttonBox") for w in self.buttonBox.children(): if w.metaObject().className() == "QPushButton": w.setCursor(QCursor(Qt.PointingHandCursor)) self.horizontalLayout.addWidget(self.buttonBox) # DATA SET UP # self.onDateChange() # self.RTVSetUp() # EVENTS self.calendarWidget.selectionChanged.connect(self.onDateChange) self.addButton.clicked.connect(self.addFunction) self.deleteButton.clicked.connect(self.deleteFunction) self.retranslateUi(self) # self.buttonBox.button(QDialogButtonBox.Ok).clicked.connect( # self.accept) # self.buttonBox.rejected.connect(self.reject) QMetaObject.connectSlotsByName(self) def eventFilter(self, object, event): if object is self and event.type() == QEvent.KeyPress: if event.key() in (Qt.Key_Return, Qt.Key_Enter,): return True return super(AddCutplanDialog, self).eventFilter(object, event) def onDateChange(self): f = open(self.sqlfile, 'r') sqltext = f.read() selDate = self.calendarWidget.selectedDate().toPyDate() date1 = datetime(selDate.year, selDate.month, selDate.day, 4, 0, 0, 0) date2 = date1 + timedelta(1) sqltext = sqltext.replace( '@date1', str(date1)).replace('@date2', str(date2)) self.availData = read_sql(sqltext, self.conn) self.LTVSetUp() def LTVSetUp(self): self.availPD = PandasModel( self.availData ) for i in range(self.addData.shape[0]): for j in range(self.availData.shape[0]): if self.addData.ID[i] == self.availData.ID[j]: self.availPD.setCompleted(j) self.leftTV.setModel(self.availPD) self.leftTV.setSelectionBehavior(QTableView.SelectRows) self.leftTV.verticalHeader().setVisible(False) self.leftTV.setColumnWidth(0, 45) self.availPD.dataChanged.connect(self.updateAvailPD) def RTVSetUp(self): self.addPD = PandasModel( self.addData ) self.rightTV.setModel(self.addPD) self.rightTV.setSelectionBehavior(QTableView.SelectRows) self.rightTV.verticalHeader().setVisible(False) self.rightTV.setColumnWidth(0, 45) self.addPD.dataChanged.connect(self.updateAddPD) def updateAvailPD(self, index, index2): self.availData.iloc[index.row(), index.column()] = \ self.availPD._df.iloc[index.row(), index.column()] def updateAddPD(self, index, index2): self.addData.iloc[index.row(), index.column()] = \ self.addPD._df.iloc[index.row(), index.column()] def addFunction(self): sm = self.leftTV.selectionModel() if sm.hasSelection(): for r in sm.selectedRows(): if not self.availPD._completed[r.row()]: data = self.availData.iloc[r.row()] self.addData = self.addData.append(data, ignore_index=True) self.availPD.setCompleted(r.row()) self.RTVSetUp() def deleteFunction(self): sm = self.rightTV.selectionModel() if sm.hasSelection(): for r in sm.selectedRows(): for i in range(self.availData.shape[0]): if self.availData.ID[i] == self.addData.ID[r.row()]: self.availPD.setCompleted(i, False) self.addData = self.addData.drop(index=r.row()) self.addData = self.addData.reset_index().drop(columns='index') self.RTVSetUp() def retranslateUi(self, Dialog): _translate = QCoreApplication.translate Dialog.setWindowTitle(_translate("Dialog", "Add Cutplans")) self.addButton.setText(_translate("Dialog", "Add ▼")) self.deleteButton.setText(_translate("Dialog", "▲ Remove"))
class ui_excute(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(511, 475) self.centralwidget = QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.envComboBox = QComboBox(self.centralwidget) self.envComboBox.setGeometry(QtCore.QRect(160, 30, 111, 21)) self.envComboBox.setObjectName("envComboBox") self.typeComboBox = QComboBox(self.centralwidget) self.typeComboBox.setGeometry(QtCore.QRect(160, 80, 111, 21)) self.typeComboBox.setObjectName("typeComboBox") self.label = QLabel(self.centralwidget) self.label.setGeometry(QtCore.QRect(40, 30, 91, 16)) self.label.setObjectName("label") self.label_2 = QLabel(self.centralwidget) self.label_2.setGeometry(QtCore.QRect(40, 80, 91, 16)) self.label_2.setObjectName("label_2") self.label_3 = QLabel(self.centralwidget) self.label_3.setGeometry(QtCore.QRect(40, 130, 91, 16)) self.label_3.setObjectName("label_3") self.pushButton = QPushButton(self.centralwidget) self.pushButton.setGeometry(QtCore.QRect(410, 365, 81, 41)) self.pushButton.setObjectName("pushButton") self.pushButton_1 = QPushButton(self.centralwidget) self.pushButton_1.setGeometry(QtCore.QRect(30, 365, 81, 41)) self.pushButton_1.setObjectName("checkPushButton") self.textBrowser = QTextBrowser(self.centralwidget) self.textBrowser.setGeometry(QtCore.QRect(160, 350, 240, 90)) self.textBrowser.setObjectName("textBrowser") self.calendarWidget = QCalendarWidget(self.centralwidget) self.calendarWidget.setGeometry(QtCore.QRect(160, 130, 271, 200)) self.calendarWidget.setGridVisible(True) self.calendarWidget.setHorizontalHeaderFormat( QCalendarWidget.ShortDayNames) self.calendarWidget.setVerticalHeaderFormat( QCalendarWidget.NoVerticalHeader) self.calendarWidget.setNavigationBarVisible(True) self.calendarWidget.setDateEditEnabled(True) self.calendarWidget.setObjectName("calendarWidget") MainWindow.setCentralWidget(self.centralwidget) self.statusbar = QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) for i in list_env: self.envComboBox.insertItem(list_env.index(i), i) for i in list_job_type: self.typeComboBox.insertItem(list_job_type.index(i), i) self.pushButton.clicked.connect(self.excutejob) self.pushButton_1.clicked.connect(self.checkScanJob) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "定时任务执行工具")) self.label.setText(_translate("MainWindow", "定时任务环境:")) self.label_2.setText(_translate("MainWindow", "定时任务类型:")) self.label_3.setText(_translate("MainWindow", "定时任务日期:")) self.pushButton.setText(_translate("MainWindow", "执行")) self.pushButton_1.setText(_translate("MainWindow", "服务扫描检查")) def checkScanJob(self): table = dic_env[self.envComboBox.currentText()]['tablename'] last_create_time = lastCreatTime(table) if ('beginTime' in globals()): if last_create_time > beginTime: QTextBrowser.append(self.textBrowser, "服务扫描任务已经执行完毕!") else: QTextBrowser.append(self.textBrowser, "服务扫描任务仍在执行,请稍后再检查!") else: QTextBrowser.append(self.textBrowser, "请先执行服务扫描任务") def excutejob(self): #获取参数 job_env = self.envComboBox.currentText() job_type = dic_job_type[self.typeComboBox.currentText()] job_name = self.typeComboBox.currentText() date = self.calendarWidget.selectedDate() job_date = date.toString(Qt.ISODate) ip = dic_env[job_env]['ip'] username = dic_env[job_env]['username'] password = dic_env[job_env]['password'] # 连接SSH try: ssh = paramiko.SSHClient() key = paramiko.AutoAddPolicy() ssh.set_missing_host_key_policy(key) ssh.connect(ip, 22, username, password, timeout=5) # 执行Job命令 job_command = 'export app_name="cs-expertsystem-job";app_job="cs-expertsystem-job-crontab";port=' + str( port ) + ';parameter=' + job_type + ';parameter2=' + job_date + ';PATH=/usr/java/jdk1.8.0_73/bin:$PATH;JAVA_HOME=/usr/java/jdk1.8.0_73;mkdir -p /yazuo_apps/logs/$app_name/;chmod a+x /yazuo_apps/$app_name/current/$app_name.jar;java -server -Xms512m -Xmx512m -XX:MaxPermSize=128m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintClassHistogram -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:/yazuo_apps/logs/$app_name/gc_log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=100 -XX:GCLogFileSize=10240K -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/yazuo_apps/logs/$app_name/heap_dump.hprof -Dfile.encoding=UTF-8 -Dapp_home=/yazuo_apps/$app_name/current -jar /yazuo_apps/$app_name/current/$app_name.jar $parameter $parameter2 --server.port=$port --spring.application.name=$app_name --logging.path=/yazuo_apps/logs/$app_name/ --logging.file=/yazuo_apps/logs/$app_name/info.log --task.name=$app_job --server.tomcat.accesslog.suffix=.log >/yazuo_apps/logs/$app_name/console.log 2>&1' stdin, stdout, stderr = ssh.exec_command(job_command) ssh.close() msg = job_name + '(' + job_date + ") 定时任务发送完毕!" QTextBrowser.setText(self.textBrowser, msg) except: QTextBrowser.setText(self.textBrowser, "执行失败!") # 获取日志文件 t = paramiko.Transport((ip, 22)) t.connect(username=username, password=password) sftp = paramiko.SFTPClient.from_transport(t) beginString = job_type + '任务开始时间' cmpleteString = job_type + '执行完毕时间' time.sleep(1) try: state = 0 time.sleep(5) for i in range(1, 120): time.sleep(5) sftp.get('/yazuo_apps/logs/cs-expertsystem-job/console.log', os.getcwd() + '/\\console.log') log_content = open('console.log', 'r', encoding='UTF-8') log_string = log_content.read() log_content.close() if state == 0: if beginString in log_string: state = 1 if job_type == 'ScanBizOpportunityJob': break if state == 1: if cmpleteString in log_string: state = 2 break if state == 0: QTextBrowser.append(self.textBrowser, "未检测到任务开始执行") if state == 1 and job_type == 'ScanBizOpportunityJob': mat = re.search(beginString + r'.{21}', log_string) global beginTime beginTime = datetime.datetime.strptime( mat.group(0)[-19:], '%Y-%m-%d %H:%M:%S') print(beginTime) QTextBrowser.append(self.textBrowser, "请点击 服务扫描查询 按钮来检查是否执行完毕") if state == 1 and job_type != 'ScanBizOpportunityJob': mat = re.search(beginString + r'.{21}', log_string) QTextBrowser.append( self.textBrowser, job_type + mat.group(0)[-27:] + " 但未检测到执行结束") if state == 2: mat = re.search(beginString + r'.{21}', log_string) mat1 = re.search(cmpleteString + r'.{21}', log_string) QTextBrowser.append(self.textBrowser, job_name + mat.group(0)[-27:]) QTextBrowser.append(self.textBrowser, job_name + mat1.group(0)[-27:]) except: QTextBrowser.append(self.textBrowser, "获取日志失败,可能未执行成功")