def set_start_and_stop(self, global_layout): grid = QVBoxLayout() row_1 = QHBoxLayout() row_2 = QHBoxLayout() self.start_button = QPushButton('Start', self) self.start_button.clicked.connect(self.start_server) self.start_button.setFont(self.fonts) self.start_button.setIcon( QIcon(absolute_path(solve_path('static/images/play.png')))) self.stop_button = QPushButton('Stop', self) self.stop_button.clicked.connect(self.stop_server) self.stop_button.setIcon( QIcon(absolute_path(solve_path('static/images/pause.png')))) self.reset_button = QPushButton( self.get_translation('Reset admin password')) self.reset_button.clicked.connect(self.reset_admin_pass) self.start_button.setToolTip(self.get_translation('Start the server')) self.stop_button.setToolTip(self.get_translation('Stop the server')) self.stop_button.setEnabled(False) self.stop_button.setFont(self.fonts) row_1.addWidget(self.start_button) row_1.addWidget(self.stop_button) row_2.addWidget(self.reset_button) grid.addLayout(row_1) grid.addLayout(row_2) global_layout.addLayout(grid)
def start_server(self): current = self.select_ips_ports_change() self.Process = RunnerThread(current[1].split(',')[1], current[0], self.app) self.Process.setTerminationEnabled(True) if not self.Process.isRunning(): try: self.Processport = current[0] self.start_button.setEnabled(False) self.stop_button.setEnabled(True) self.select_ip.setEnabled(False) self.select_port.setEnabled(False) self.status_icon = QIcon(absolute_path(solve_path('static/images/play.png'))) self.status_icon = self.status_icon.pixmap(70, 70, QIcon.Active, QIcon.On) self.status_icon_container.setPixmap(self.status_icon) current = self.select_ips_ports_change() address = self.get_translation('Server is <u>Running</u> <br> On : ') address += "<a href='http://" address += current[1].split(',')[1] + ":" + current[0] address += "'> http://" + current[1].split(',')[1] + ":" + current[0] address += "</a>" self.status_label.setText(address) self.status_label.setFont(self.font) self.Process.start() self.currently_running = True except Exception: self.before_exit() else: self.before_exit()
def set_start_and_stop(self, global_layout): horizontal_layout = QHBoxLayout() self.start_button = QPushButton('Start', self) self.start_button.clicked.connect(self.start_server) self.start_button.setFont(self.fonts) self.start_button.setIcon(QIcon(absolute_path(solve_path('static/images/play.png')))) self.stop_button = QPushButton('Stop', self) self.stop_button.clicked.connect(self.stop_server) self.stop_button.setIcon(QIcon(absolute_path(solve_path('static/images/pause.png')))) self.start_button.setToolTip(self.get_translation('Start the server')) self.stop_button.setToolTip(self.get_translation('Stop the server')) self.stop_button.setEnabled(False) self.stop_button.setFont(self.fonts) horizontal_layout.addWidget(self.start_button) horizontal_layout.addWidget(self.stop_button) global_layout.addLayout(horizontal_layout)
def set_status(self, global_layout): font = self.font self.status_icon = QIcon( absolute_path(solve_path('static/images/pause.png'))) self.status_icon_container = QLabel('Icond', self) self.status_icon = self.status_icon.pixmap(70, 70, QIcon.Active, QIcon.On) self.status_icon_container.setPixmap(self.status_icon) self.status_icon_container.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignHCenter) self.status_icon_container.setFont(font) self.status_label = QLabel('Texted', self) self.status_label.setText( self.get_translation('Server is <u> Not running </u> <br>')) self.status_label.setOpenExternalLinks(True) self.status_label.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignHCenter) self.status_label.setFont(font) self.status_label.setToolTip( self.get_translation('Status of the server')) self.status_icon_container.setToolTip( self.get_translation('Status of the server')) global_layout.addStretch() global_layout.addWidget(self.status_icon_container) global_layout.addWidget(self.status_label) global_layout.addStretch()
def __init__(self, app=None): super(MainWindow, self).__init__() self.app = app global_layout = QVBoxLayout(self) icon_path = absolute_path(solve_path('static/images/favicon.png')) # NOTE: need to use objective message boxes instead of functions to set font self.font = QFont("static/gfonts/Amiri-Regular.ttf", 12, QFont.Bold) self.fonts = QFont("static/gfonts/Amiri-Regular.ttf", 10, QFont.Bold) # Language support variable self.current_language = 'en' self.currently_running = False icon = QIcon(icon_path) self.initiate(icon) self.set_center() self.set_languages_list(global_layout) self.set_about(icon_path, global_layout) self.set_ips_and_ports(global_layout) self.set_status(global_layout) self.set_start_and_stop(global_layout) self.setLayout(global_layout) selected_ip_and_port = self.select_ips_ports_change() self.Process = RunnerThread(selected_ip_and_port[1].split(',')[1], selected_ip_and_port[0], self.app) self.activateWindow() self.show()