def top_bar(self, buttons_grid=QGridLayout(), extra_text=None): ''' params:- buttons_grid : QGridLayout : Buttons to be added to the right of the topbar returns:- QGridLayout : Layout for a top bar that is called by children screens that want one ''' spacer = QLabel() spacer.setFixedSize(10, 40) spacer.setStyleSheet("background-color: {};".format( config.bar_colour())) # Creates a bar for the top a of a screen title = QLabel(self.name if extra_text == None else self.name + ' - ' + extra_text) title.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) title.setFixedHeight(40) title.setStyleSheet( "font-size: {}; qproperty-alignment: AlignJustify; font-family: {}; background-color: {}; font-weight: bold;" .format(config.title_font_size(), config.title_font_family(), config.bar_colour())) screen = QGridLayout() screen.addWidget(spacer, 0, 0) screen.addWidget(title, 0, 1) screen.addLayout(buttons_grid, 0, 2) return screen
def side_bar(self): # Menu Button also uses context menu to change screens self.menu_button = QPushButton('Menu') self.menu_button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.menu_button.setFixedSize(40, 40) self.menu_button.setStyleSheet("background-color: {}".format( config.bar_colour())) self.menu_button.clicked.connect(self.contextMenuEvent) # Fill up the rest of the bar with a label sidebar = QLabel('') sidebar.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) sidebar.setFixedWidth(40) sidebar.setStyleSheet("background-color: {}".format( config.bar_colour())) screen = QGridLayout() screen.setContentsMargins(0, 0, 0, 0) screen.setSpacing(0) # screen.setColumnStretch(1, 1) screen.setRowStretch(1, 1) screen.addWidget(self.menu_button, 0, 0) screen.addWidget(sidebar, 1, 0) return screen
def get_layout(self): ''' returns:- QGridLayout : Anything that needs to be displayed as a screen, this is used in tandom with the screen class to make inheritance of the menu bar ''' # View Options server_filter = QLabel('Server Type Filter:') server_filter.setFixedSize(100, 40) server_filter.setStyleSheet("background-color: {};".format( config.bar_colour())) server_filter.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.view_standalone_check = QCheckBox(text='Standalone') self.view_standalone_check.setFixedSize(80, 20) self.view_standalone_check.setStyleSheet( "background-color: {};".format(config.bar_colour())) self.view_standalone_check.setChecked(True) self.view_alwayson_check = QCheckBox(text='AlwaysON') self.view_alwayson_check.setFixedSize(80, 20) self.view_alwayson_check.setStyleSheet("background-color: {};".format( config.bar_colour())) self.view_alwayson_check.setChecked(True) self.view_failover_check = QCheckBox(text='Failover') self.view_failover_check.setFixedSize(80, 20) self.view_failover_check.setStyleSheet("background-color: {};".format( config.bar_colour())) self.view_failover_check.setChecked(True) # Search On Cluster Nodes self.search_clusternodes_check = QComboBox() self.search_clusternodes_check.setFixedSize(80, 40) self.search_clusternodes_check.addItems(['Instances', 'Hosts']) self.search_clusternodes_check.currentTextChanged.connect( lambda: self.button_search_options(self.search_clusternodes_check. currentText())) # Decommission Options self.search_hoststate_check = QComboBox() self.search_hoststate_check.addItems( ['Either', 'Decommissioned', 'Commissioned']) self.search_hoststate_check.setFixedSize(170, 20) self.search_hoststate_check.setCurrentText('Commissioned') self.search_serverstate_check = QComboBox() self.search_serverstate_check.addItems( ['Either', 'Decommissioned', 'Commissioned']) self.search_serverstate_check.setFixedSize(170, 20) self.search_serverstate_check.setCurrentText('Commissioned') # Decommision labels hoststate = QLabel('Host Filter:') hoststate.setFixedSize(80, 20) hoststate.setStyleSheet("background-color: {};".format( config.bar_colour())) hoststate.setAlignment(Qt.AlignRight | Qt.AlignVCenter) serverstate = QLabel('Server Filter:') serverstate.setFixedSize(80, 20) serverstate.setStyleSheet("background-color: {};".format( config.bar_colour())) serverstate.setAlignment(Qt.AlignRight | Qt.AlignVCenter) # Editable line edit_host = QLabel('Host Name:') edit_host.setFixedSize(70, 20) edit_host.setStyleSheet("background-color: {};".format( config.bar_colour())) edit_host.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.search_line_edit_host = QLineEdit() self.search_line_edit_host.setFixedSize(170, 20) edit_instance = QLabel('Instance Name:') edit_instance.setFixedSize(80, 20) edit_instance.setStyleSheet("background-color: {};".format( config.bar_colour())) edit_instance.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.search_line_edit_instance = QLineEdit() self.search_line_edit_instance.setFixedSize(170, 20) edit_cluster = QLabel('Cluster Name:') edit_cluster.setFixedSize(80, 20) edit_cluster.setStyleSheet("background-color: {};".format( config.bar_colour())) edit_cluster.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.search_line_edit_cluster = QLineEdit() self.search_line_edit_cluster.setFixedSize(170, 20) self.search_line_edit_host.returnPressed.connect(lambda: self.search( self.search_line_edit_host.text(), self.view_standalone_check.isChecked(), self.view_alwayson_check.isChecked(), self.view_failover_check.isChecked(), True, True, True, self.search_hoststate_check.currentText(), self.search_serverstate_check.currentText(), self.search_clusternodes_check.currentText(), self.search_line_edit_instance.text(), self.search_line_edit_cluster.text(), 'host Name' if self.search_clusternodes_check.currentText() == 'Hosts' else 'Host/Listener Name')) self.search_line_edit_instance.returnPressed.connect( lambda: self.search( self.search_line_edit_host.text(), self.view_standalone_check.isChecked(), self.view_alwayson_check.isChecked(), self.view_failover_check.isChecked(), True, True, True, self.search_hoststate_check.currentText(), self.search_serverstate_check.currentText(), self.search_clusternodes_check.currentText(), self.search_line_edit_instance.text(), self.search_line_edit_cluster.text(), 'host Name' if self.search_clusternodes_check.currentText() == 'Hosts' else 'Host/Listener Name')) self.search_line_edit_cluster.returnPressed.connect( lambda: self.search( self.search_line_edit_host.text(), self.view_standalone_check.isChecked(), self.view_alwayson_check.isChecked(), self.view_failover_check.isChecked(), True, True, True, self.search_hoststate_check.currentText(), self.search_serverstate_check.currentText(), self.search_clusternodes_check.currentText(), self.search_line_edit_instance.text(), self.search_line_edit_cluster.text(), 'host Name' if self.search_clusternodes_check.currentText() == 'Hosts' else 'Host/Listener Name')) label40 = QLabel() label40.setFixedSize(5, 40) label40.setStyleSheet("background-color: {};".format( config.bar_colour())) # Topbar buttons <- All buttons needed top_bar_buttons = QGridLayout() top_bar_buttons.addWidget(self.search_clusternodes_check, 0, 2, 2, 1) top_bar_buttons.addWidget(server_filter, 0, 1, 2, 1) top_bar_buttons.addWidget(label40, 0, 3, 2, 1) searchoptions = QGridLayout() searchoptions.addWidget(self.view_standalone_check, 0, 2) searchoptions.addWidget(self.view_failover_check, 0, 4) searchoptions.addWidget(self.view_alwayson_check, 0, 6) searchoptions.addWidget(hoststate, 0, 8) searchoptions.addWidget(self.search_hoststate_check, 0, 9) searchoptions.addWidget(serverstate, 0, 11) searchoptions.addWidget(self.search_serverstate_check, 0, 12) searchbarline = QGridLayout() searchbarline.addWidget(edit_host, 0, 0) searchbarline.addWidget(self.search_line_edit_host, 0, 1) searchbarline.addWidget(edit_instance, 0, 3) searchbarline.addWidget(self.search_line_edit_instance, 0, 4) searchbarline.addWidget(edit_cluster, 0, 6) searchbarline.addWidget(self.search_line_edit_cluster, 0, 7) top_bar_buttons.addLayout(searchbarline, 1, 4) top_bar_buttons.addLayout(searchoptions, 0, 4) # Scrollable area <- Blank table self.scroll = QScrollArea() self.scroll.setWidgetResizable(True) self.change_table(self.blank_table()) # Screen <- Topbar and Scroll blank table screen = QGridLayout() screen.setRowStretch(1, 1) screen.addWidget(self.scroll, 1, 0) screen.addLayout(super().top_bar(top_bar_buttons), 0, 0) return screen