def build(self): manager = ScreenManager() manager.add_widget(Login(name='login_window')) manager.add_widget(Registration(name='register_window')) manager.add_widget(HomeWindow(name='home_window')) manager.add_widget(SettingsWindow(name='settings')) manager.add_widget(GroupWindow(name='group_window')) manager.add_widget(NewGroupWindow(name='new_group_window')) manager.add_widget(ActivityWindow(name='activity_window')) manager.add_widget(NewActivityWindow(name='new_activity_window')) manager.add_widget(JoinGroupWindow(name='join_group_window')) manager.add_widget(ActivityDetailWindow(name='activity_detail_window')) manager.add_widget(PaymentWindow(name='payment_window')) manager.add_widget(MyTransactionWindow(name='my_transaction_window')) manager.add_widget(ApprovalsWindow(name='approvals_window')) manager.add_widget(AddResourcesWindow(name='new_resource_window')) manager.add_widget(ResourcesWindow(name='resources_window')) manager.add_widget( ResourcesHistoryWindow(name='resources_history_window')) manager.add_widget( DonationsHistoryWindow(name='donations_history_window')) self.theme_cls.primary_palette = 'Blue' self.theme_cls.theme_style = "Light" self.title = "Aaksathe" return manager
class Window(QWidget): def __init__(self): super().__init__() uic.loadUi('main.ui', self) self.toolButton: QToolButton = self.toolButton self.toolButton.clicked.connect(self.openSettings) w0, h0 = self.width() // 4, self.height() // 4 self.ps = PointSet([[w0, h0], [w0, h0 * 3], [w0 * 3, h0 * 3]]) self.moving = False self.current_point = None self.repaint() def paintEvent(self, event: QPaintEvent): painter = QPainter() painter.begin(self) self.ps.draw(painter) painter.end() def mousePressEvent(self, event: QMouseEvent): if event.button() == Qt.LeftButton: if self.ps.get_point(event.x(), event.y()) is None: self.ps.add(event.x(), event.y()) self.current_point = self.ps.get_point(event.x(), event.y()) self.moving = True if event.button() == Qt.RightButton: removee = self.ps.get_point(event.x(), event.y()) if removee is not None and len(self.ps.points) > 3: Color.pop(removee.idx) self.ps.points.pop(removee.idx) def mouseReleaseEvent(self, event: QMouseEvent): self.moving = False self.repaint() def mouseMoveEvent(self, event: QMouseEvent): if self.moving: self.current_point.set(x=event.x(), y=event.y()) self.repaint() def in_ball(self, x, y): return (x - self.ball_x)**2 + (y - self.ball_y)**2 <= self.ball_r**2 def openSettings(self): self.stg = SettingsWindow(self.repaint) self.stg.show()
class Main(object): def __init__(self): self.logger = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) self.settings = Settings() try: self.settings.load() except IOError: self.logger.warn("Error reading configuration file") self.logger.info("Creating default configuration file") self.settings.store() menu_list = [{'text': "_Settings", 'callback': self.on_settings_click}] self.app_ind = AppIndicator(self.settings, menu_list) def _start(self): self.xively = XivelyClient(self.settings, self.on_data_update) self.xively.update() def on_data_update(self, data): self.app_ind.set_data(" ".join((data, "°C"))) def on_settings_click(self, widget): self.logger.info("Settings is clicked") self.settings_win = SettingsWindow(self.settings, self.on_settings_result) self.settings_win.show_all() def on_settings_result(self, result): if result: self.logger.info("Applying settings") self.settings.store() del self.xively self._start() def run(self): self._start() Gtk.main()
def __init__(self): super().__init__( ) # Inherit everything from the Qt "QMainWindow" class # Instantiate class in settings.py which contains the settings UI AND the persistent QSettings values self.config = SettingsWindow() set_style( ) # Pulled in from misc_functions, simply sets background and foreground colors for plots # Call setup methods below self.initUI() self.initThreads(self.config) self.p1.keyPressed.connect( self.t.on_key) # Connect keyPresses on signal plot to Param Tree
def open_settings(self, active=0): settings_window = SettingsWindow() settings_window.tabs.setCurrentIndex(active) settings_window.exec() self.plot_canvas.core.redraw() self.update_dimensions()
def create_settings(self): """Prompt the user for required settings for the application to run""" settings_window = SettingsWindow(self, "settings", curses.LINES, curses.COLS, 0, 0) settings_window.populate()
def handleSettingsWindow(self): self.settingsWindow = SettingsWindow(self)
def openSettings(self): self.stg = SettingsWindow(self.repaint) self.stg.show()
class MainDialog(QMainWindow, gui.Ui_MainWindow): connected = False DATA = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'DATA') modulesBank = {} clients = {} def __init__(self, reactor, plugins, plugins_dir, parent=None): super(MainDialog, self).__init__(parent) self.reactor = reactor self.setupUi(self) self.settings = Settings(self) self.anim = QPropertyAnimation(self, 'windowOpacity') self.anim.setDuration(1000) self.anim.setStartValue(0) self.anim.setEndValue(self.settings.moderatOpacity) self.anim.start() self.clientsTable.horizontalHeader().setStyleSheet('background: none;') # Multi Lang self.translate = Translate(self) self.MString = lambda _word: self.translate.word(_word) self.theme = Theme(self) # Init Log Dir if not os.path.exists(self.DATA): os.makedirs(self.DATA) self.assets = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'assets') self.flags = os.path.join(self.assets, 'flags') self.plugins = plugins self.plugins_dir = plugins_dir self.directServerRunning = False self.filter = Filter(self) # Setup Settings self.set_config() self.pagination = pagination.Pagination(self) self.tables = tables.updateClientsTable(self) # Init UI self.ui = ui.updateUi(self) # Init Tray self.tray = tray.ModeratTrayIcon(self) self.rmenu = rmenu.moderatRightClickMenu(self) # Session ID self.session_id = None # Privileges self.privs = 0 # Checkers self.moderators_checker = None self.clients_checker = None # Create Protocol self.create_server_protocol() self.create_moderator_protocol() # Init Triggers triggers.ModeratTriggers(self) # Init Shortcuts shortcuts.ModeratShortcuts(self) # Create Actions Object self.action = Actions(self) # Create Modes Object self.modes = Modes(self) self.onlineLoading = loading.Loading(self.clientsTabs) self.onlineLoading.hide() self.showMaximized() def set_config(self): self.translate.__init__(self) self.theme.__init__(self) self.setStyleSheet(self.theme.stylesheet) self.setWindowOpacity(self.settings.moderatOpacity / 100) self.setWindowTitle(self.MString('TITLE')) self.menuRemote_Server.setTitle(self.MString('REMOTE_SERVER')) self.actionConnect.setText(self.MString('CONNECT')) self.actionDisconnect.setText(self.MString('DISCONNECT')) self.actionExit.setText(self.MString('EXIT')) self.menuLocal_Server.setTitle(self.MString('LOCAL_SERVER')) self.actionStartServer.setText(self.MString('START_SERVER')) self.actionStopServer.setText(self.MString('STOP_SERVER')) self.menuFilter.setTitle(self.MString('FILTERS')) self.actionSetupFilters.setText(self.MString('SETUP_FILTERS')) self.menuSettings.setTitle(self.MString('SETTINGS_TITLE')) self.actionRunSettings.setText(self.MString('RUN_SETTINGS')) self.clientsTabs.setTabText(0, self.MString('CLIENTS_TAB_ONLINE')) self.clientsTabs.setTabText(1, self.MString('CLIENTS_TAB_DIRECT')) self.clientsTabs.setTabText(2, self.MString('CLIENTS_TAB_OFFLINE')) self.clientsTabs.setTabText(3, self.MString('CLIENTS_TAB_MODERATORS')) # HEADERS self.clientsTable.horizontalHeaderItem(0).setText( self.MString('HEADER_IP_ADDRESS')) self.clientsTable.horizontalHeaderItem(1).setText( self.MString('HEADER_ID')) self.clientsTable.horizontalHeaderItem(2).setText( self.MString('HEADER_USER')) self.clientsTable.horizontalHeaderItem(3).setText( self.MString('HEADER_ALIAS')) self.clientsTable.horizontalHeaderItem(4).setText( self.MString('HEADER_ACTIVE_WINDOW_TITLE')) self.offlineClientsTable.horizontalHeaderItem(0).setText( self.MString('HEADER_MODERATOR')) self.offlineClientsTable.horizontalHeaderItem(1).setText( self.MString('HEADER_ID')) self.offlineClientsTable.horizontalHeaderItem(2).setText( self.MString('HEADER_ALIAS')) self.offlineClientsTable.horizontalHeaderItem(3).setText( self.MString('HEADER_IP_ADDRESS')) self.offlineClientsTable.horizontalHeaderItem(4).setText( self.MString('HEADER_LAST_ONLINE')) self.moderatorsTable.horizontalHeaderItem(0).setText( self.MString('MODERATORS_HEADER_ID')) self.moderatorsTable.horizontalHeaderItem(1).setText( self.MString('MODERATORS_HEADER_ONLINE')) self.moderatorsTable.horizontalHeaderItem(2).setText( self.MString('MODERATORS_HEADER_OFFLINE')) self.moderatorsTable.horizontalHeaderItem(3).setText( self.MString('MODERATORS_HEADER_PRIVILEGES')) self.moderatorsTable.horizontalHeaderItem(4).setText( self.MString('MODERATORS_HEADER_STATUS')) self.moderatorsTable.horizontalHeaderItem(5).setText( self.MString('MODERATORS_HEADER_LASTONLINE')) self.directClientsTable.horizontalHeaderItem(0).setText( self.MString('HEADER_IP_ADDRESS')) self.directClientsTable.horizontalHeaderItem(1).setText( self.MString('HEADER_ID')) self.directClientsTable.horizontalHeaderItem(2).setText( self.MString('HEADER_MARK')) # END HEADERS #self.filterButton.filterButton.setText(self.MString('SIDEBAR_FILTER')) # Header Refresh self.clientsTable.setColumnHidden(0, not self.settings.headerIpAddress) self.clientsTable.setColumnHidden(1, not self.settings.headerClientId) self.clientsTable.setColumnHidden(2, not self.settings.headerUser) self.clientsTable.setColumnHidden(3, not self.settings.headerAlias) self.clientsTable.setColumnHidden(4, not self.settings.headerTitle) self.clientsTable.resizeColumnsToContents() self.clientsTable.horizontalHeader().setStretchLastSection(True) # Offline Header Refresh self.offlineClientsTable.setColumnHidden( 0, not self.settings.offlineHeaderClientId) self.offlineClientsTable.setColumnHidden( 1, not self.settings.offlineHeaderAlias) self.offlineClientsTable.setColumnHidden( 2, not self.settings.offlineHeaderIpAddress) self.offlineClientsTable.setColumnHidden( 3, not self.settings.offlineHeaderLastOnline) self.offlineClientsTable.resizeColumnsToContents() self.offlineClientsTable.horizontalHeader().setStretchLastSection(True) # Direct Header Refresh self.directClientsTable.setColumnHidden( 0, not self.settings.directHeaderIpAddress) self.directClientsTable.setColumnHidden( 1, not self.settings.directHeaderClientId) self.directClientsTable.setColumnHidden( 2, not self.settings.directHeaderComment) self.directClientsTable.resizeColumnsToContents() self.directClientsTable.horizontalHeader().setStretchLastSection(True) # Menu self.viewLogsButton.setHidden(not self.settings.menuLogViewer) self.noteButton.setHidden(not self.settings.menuNote) self.setAliasButton.setHidden(not self.settings.menuAlias) self.updateSourceButton.setHidden(not self.settings.menuUpdate) self.shellButton.setHidden(not self.settings.menuShell) self.explorerButton.setHidden(not self.settings.menuExplorer) self.scriptingButton.setHidden(not self.settings.menuScripting) self.screenshotButton.setHidden(not self.settings.menuScreenshot) self.webcamButton.setHidden(not self.settings.menuWebcam) # Offline Menu self.viewOfflineLogsButton.setHidden( not self.settings.offlineMenuLogViewer) self.setOfflineAliasButton.setHidden( not self.settings.offlineMenuAlias) self.removeClientButton.setHidden(not self.settings.offlineMenuRemove) # Direct Menu self.directShellButton.setHidden(not self.settings.directMenuShell) self.directExplorerButton.setHidden( not self.settings.directMenuExplorer) self.directScriptingButton.setHidden( not self.settings.directMenuScripting) self.directScreenshotButton.setHidden( not self.settings.directMenuScreenshot) self.directWebcamButton.setHidden(not self.settings.directMenuWebcam) def show_settings_window(self): self.settingsWindow = SettingsWindow(self) self.settingsWindow.show() def create_server_protocol(self): ''' Create Server Protocol :return: ''' self.server = ModeratServerFactory(self) def on_server_started(self): ''' On Server Started :return: ''' self.directServer = self.reactor.listenTCP( self.settings.directServerPort, self.server) self.directServerRunning = True self.ui.on_server_started() self.tray.info( self.MString('TRAY_SERVER_STARTED'), u'{} - {}'.format(self.MString('TRAY_LISTEN_PORT'), self.settings.directServerPort)) def on_server_stopped(self): ''' On Server Stopped :return: ''' if self.directServerRunning: self.directServer.stopListening() self.directServerRunning = False self.ui.on_server_stopped() self.tray.info(self.MString('TRAY_SERVER_STOPPED')) def create_moderator_protocol(self): self.moderator = SocketModeratorFactory( self.on_moderator_connect_success, self.on_moderator_connect_fail, self.on_moderator_receive) # Update Direct Connections Tables def update_direct_table(self): ''' Rearrange Direct Clients :param clients: :return: ''' self.tables.update_direct_clients() # Start Connect To Server def on_connect_to_server(self): ''' Try Connect To Server :return: ''' self.connection = self.reactor.connectTCP( self.settings.serverIpAddress, self.settings.serverPort, self.moderator) def on_moderator_connect_success(self): ''' On Moderator Connected To Server :return: ''' self.connected = True self.action.login() def on_moderator_connect_fail(self, reason): ''' On Moderator Disconnected From Server :param reason: :return: ''' if not type(reason) is bool: message.error(self, self.MString('MSGBOX_ERROR'), str(reason.value)) self.connected = False self.action.disconnect() def on_moderator_receive(self, data): ''' Data Received From Server :param data: :return: ''' self.modes.check_mode(data) def send_message(self, message, mode, _to='', session_id='', module_id='', p2p=False): if p2p: if self.directServerRunning: self.server.send_msg(_to, message, mode, session_id, module_id) else: self.moderator.send_msg(message, mode, _to, session_id, module_id) def set_alias(self): ''' Set Alias For Client :return: ''' self.action.set_alias() def remove_client(self): ''' Remove Client :return: ''' self.action.remove_client() def set_logs_settings(self): ''' Set Client Log Settings :return: ''' self.action.set_log_settings() @connected_to_server def update_source(self): ''' Update Clients Source :return: Restart client ''' self.action.update_source() def execute_module(self, module): ''' execute module :param module: :return: ''' self.action.execute_module(module) # TODO: TEMP def usb_spreading(self): self.action.usb_spreading() @is_administrator def set_moderator(self): ''' Set Moderator For Client :return: ''' self.action.administrator_set_moderator() @connected_to_server @is_administrator def get_moderators(self): ''' Get Moderators Information :return: ''' self.action.administrator_get_moderators() @connected_to_server @is_administrator def create_moderator(self): ''' Create New Moderator :return: ''' self.action.administrator_create_moderator() @connected_to_server @is_administrator def change_moderator_password(self): ''' Change Moderator Password :return: ''' self.action.administrator_change_moderator_password() @connected_to_server @is_administrator def change_moderator_privilege(self): ''' Change Moderator Privileges :return: ''' self.action.administrator_change_moderator_privilege() @connected_to_server @is_administrator def remove_moderator(self): ''' Remove Moderator :return: ''' self.action.administrator_remove_moderator() @connected_to_server def check_clients(self): ''' Update Clients Information :return: ''' self.action.get_clients() def send_signal(self, data): ''' Send Received Data To Module :param data: :return: ''' self.action.signal_received(data) def start_p2p(self): self.action.send_p2p_start() def filter_by_ip_address(self): self.action.filter_by_ip_address() def filter_by_alias(self): self.action.filter_by_alias() def filter_by_moderator(self): self.action.filter_by_moderator() def resizeEvent(self, event): self.onlineLoading.resize(self.clientsTabs.size()) event.accept() def closeEvent(self, *args, **kwargs): ''' Moderat Close Event Detected :param args: :param kwargs: :return: ''' self.action.close_moderat() os._exit(1)
def show_settings_window(self): self.settingsWindow = SettingsWindow(self) self.settingsWindow.show()
def open_settings(): settings = SettingsWindow(root)
def main(): with open('ClientSettings.txt') as f: data = ast.literal_eval(f.read()) colors = data['Colors'] figure_colors = [Color([color]) for color in colors['FigureColors']] background = Color([colors['FontColors'][0], colors['FontColors'][1]]) border = Color([colors['BorderColors'][0], colors['BorderColors'][1]]) cell_size = 43 x, y = data['Resolution'] left, top = 10, 10 size = 2 * left + x * (cell_size + 1) + 1, 2 * top + y * (cell_size + 1) + 1 figure_x, figure_y = 4, 4 figure_left, figure_top = size[0], top size = size[0] + left + figure_x * (cell_size + 1) + 1, size[1] buttons_x, buttons_y = 4, 1 buttons_left, buttons_top = figure_left, figure_top + top + figure_y * (cell_size + 1) pygame.init() screen = pygame.display.set_mode(size) pygame.display.set_caption('TETRIS') main_board = MainBoard(x, y, screen, left, top, cell_size, background, border) figure_board = FigureBoard(figure_x, figure_y, screen, figure_left, figure_top, cell_size, background, border, figure_colors) buttons_board = ButtonsBoard(buttons_x, buttons_y, screen, buttons_left, buttons_top, cell_size, background, border) points_x, points_y = figure_x * (cell_size + 1) + 1, 55 points_left, points_top = figure_left, figure_top + top + figure_y * (cell_size + 1) + top + buttons_y * ( cell_size + 1) timer_x, timer_y = points_x, 55 timer_left, timer_top = figure_left, figure_top + top + figure_y * (cell_size + 1) + top + buttons_y * ( cell_size + 1) + points_y + top status_x, status_y = points_x, 55 status_left, status_top = figure_left, figure_top + top + figure_y * (cell_size + 1) + top + buttons_y * ( cell_size + 1) + points_y + top + timer_y + top points_info = InfoWindow(points_x, points_y, screen, points_left, points_top, border, border, border, 'points:') timer = InfoWindow(timer_x, timer_y, screen, timer_left, timer_top, border, border, border, 'timer:') status_bar = InfoWindow(status_x, status_y, screen, status_left, status_top, border, border, border, 'status:') running = True buttons_board.game_running = False clock = pygame.time.Clock() delta_t = 0 lock = data['Speed'] timer_t = 0 while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1: cell = buttons_board.get_cell(event.pos) if cell is None: pass else: cell = cell[0] if cell == 0: if not buttons_board.game_running: buttons_board.game_running = True restart(main_board, figure_board) timer_t = 0 elif cell == 1: if buttons_board.game_running: buttons_board.game_running = False elif cell == 2: ex = SettingsWindow() ex.show() elif cell == 3: background.switch_color() border.switch_color() if event.type == pygame.KEYDOWN and main_board.figure and buttons_board.game_running: if event.key == pygame.K_LEFT and main_board.can_move(x=-1): main_board.x -= 1 if event.key == pygame.K_RIGHT and main_board.can_move(x=1): main_board.x += 1 if event.key == pygame.K_UP: figure = transpose(main_board.figure) if main_board.can_move(figure=figure): main_board.figure = figure if event.key == pygame.K_DOWN: if main_board.can_move(y=1): main_board.y += 1 main_board.update() t = clock.tick() if buttons_board.game_running: delta_t += t timer_t += t if delta_t > lock: delta_t = 0 if main_board.figure and main_board.can_move(y=1): main_board.y += 1 main_board.update() else: next_figure(main_board, figure_board) if main_board.can_move(): main_board.update() else: buttons_board.game_running = False screen.fill(background.color) main_board.render() figure_board.render() buttons_board.render() points_info.draw(str(main_board.points)) timer.draw(str(timer_t // 1000)) status_bar.draw({True: 'on', False: 'off'}[buttons_board.game_running]) pygame.display.flip() pygame.quit()
def on_settings_click(self, widget): self.logger.info("Settings is clicked") self.settings_win = SettingsWindow(self.settings, self.on_settings_result) self.settings_win.show_all()
def setupUi(self, Form, username=None, userid=1, host='192.168.2.171', simid=None, reset=False): self.host = host self.username = username self.userid = userid self.simid = simid self.readonly = (simid is not None) self.showsettings = False self.currentindex = 0 self.usedefaultsettings = True self.db = connector.connect(host=self.host, user="******", passwd="Sequal1234", database="simulation", use_pure=True) self.db.autocommit = True self.simrunning = False # self.esrunning = False if not reset: self.thread = None self.thread = QThread() self.cppath = getcwd() + "\\cutplans\\" self.logpath = getcwd() + "\\logs\\" self.shifts = 2 self.simShift = 1 index = [] for i in range(1, self.shifts + 1): index.append(str(i)) index.append("Total") cols = [ "RunTime", "LogsCut", "Production", "LogVolume", "Recovery", "LogRate", "Uptime", "MSLDT", "BSLDT", "TSLDT", "SawdustVol" ] self.results = DataFrame(index=index, columns=cols) # self.OpenExtendSim() Form.setObjectName("Form") Form.resize(900, 750) Form.setMinimumSize(QSize(900, 750)) Form.setStyleSheet("background-color: rgb(255, 255, 255);\n" "color: rgb(0, 115, 119);") if Form.layout() is not None: QWidget().setLayout(Form.layout()) self.verticalLayout = QVBoxLayout(Form) self.verticalLayout.setObjectName("verticalLayout") ss = \ """ QToolButton { 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)); color: white; border: None; border-radius: 2px; font: 11pt "Tahoma"; padding: 5px; margin-right: 20px; } """ self.detailsLayout = QHBoxLayout() self.closeButton = QToolButton(Form) self.closeButton.setObjectName("closeButton") self.closeButton.setStyleSheet(ss) self.closeButton.setCursor(QCursor(Qt.PointingHandCursor)) icon1 = QIcon("images/close.png") self.closeButton.setIcon(icon1) self.closeButton.setVisible(self.readonly) self.detailsLayout.addWidget(self.closeButton) self.nameLabel = QLabel(Form) self.nameLabel.setText("Name: ") self.nameLabel.setStyleSheet( "QLabel {" "background: none; font: 15pt \"Tahoma\";font-weight: bold;" "}") self.detailsLayout.addWidget(self.nameLabel) self.nameTextbox = QLineEdit(Form) self.nameTextbox.setText("Simulation") self.nameTextbox.setStyleSheet( "QLineEdit {\n" "background: none; font: 15pt \"Tahoma\";" "border: 1px solid rgb(0,115,119);\n" "}\n" "QLineEdit:disabled {border: none;}") self.detailsLayout.addWidget(self.nameTextbox) h = self.nameTextbox.size().height() self.closeButton.setMinimumSize(QSize(h, h)) self.closeButton.setIconSize(QSize(h - 10, h - 10)) self.PlayButton = QToolButton(Form) self.PlayButton.setObjectName("PlayButton") self.PlayButton.setStyleSheet(ss) self.PlayButton.setMinimumSize(QSize(h, h)) self.PlayButton.setCursor(QCursor(Qt.PointingHandCursor)) icon1 = QIcon("images/play.png") self.PlayButton.setIcon(icon1) self.PlayButton.setIconSize(QSize(h - 10, h - 10)) self.PlayButton.setVisible(False) self.detailsLayout.addWidget(self.PlayButton) hSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.detailsLayout.addItem(hSpacer) self.CreateNewButton = QToolButton(Form) self.CreateNewButton.setObjectName("CreateNewButton") self.CreateNewButton.setStyleSheet(ss) self.CreateNewButton.setMinimumSize(QSize(h, h)) self.CreateNewButton.setText("Create New") self.CreateNewButton.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) icon1 = QIcon("images/new.png") self.CreateNewButton.setIcon(icon1) self.CreateNewButton.setIconSize(QSize(h - 10, h - 10)) self.CreateNewButton.setCursor(QCursor(Qt.PointingHandCursor)) self.CreateNewButton.setVisible(False) self.detailsLayout.addWidget(self.CreateNewButton) self.SettingsButton = QToolButton(Form) self.SettingsButton.setObjectName("SettingsButton") self.SettingsButton.setStyleSheet(ss) self.SettingsButton.setMinimumSize(QSize(h, h)) self.SettingsButton.setCursor(QCursor(Qt.PointingHandCursor)) icon1 = QIcon("images/settings.png") self.SettingsButton.setIcon(icon1) self.SettingsButton.setIconSize(QSize(h - 10, h - 10)) self.detailsLayout.addWidget(self.SettingsButton) self.detailsLayout.setSpacing(5) self.verticalLayout.addLayout(self.detailsLayout) self.mainhorilayout = QHBoxLayout() self.ResultsArea = QScrollArea(Form) self.ResultsWidget = ResultsWidget() self.ResultsWidget.setupUi(self.ResultsArea) self.ResultsWidget.setObjectName("ResultsWidget") self.ResultsArea.setWidget(self.ResultsWidget) self.ResultsArea.setWidgetResizable(True) self.ResultsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.ResultsArea.setFrameShape(QFrame.NoFrame) self.mainhorilayout.addWidget(self.ResultsArea) self.StackedWidget = QWidget(Form) self.StackedLayout = QStackedLayout(self.StackedWidget) self.CutplanArea = QScrollArea(self.StackedWidget) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.CutplanArea.sizePolicy().hasHeightForWidth()) self.CutplanArea.setSizePolicy(sizePolicy) self.CutplanArea.setMinimumSize(QSize(0, 250)) self.CutplanArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # self.CutplanArea.setSizeAdjustPolicy( # QAbstractScrollArea.AdjustToContents) self.CutplanArea.setWidgetResizable(True) self.CutplanArea.setFrameShape(QFrame.NoFrame) self.CutplanArea.setObjectName("CutplanArea") self.CPWidget = QWidget() self.Cutplans = CutplanWidget() self.Cutplans.setupUi(self.CPWidget) self.Cutplans.setObjectName("Cutplans") self.CutplanArea.setWidget(self.CPWidget) self.StackedLayout.addWidget(self.CutplanArea) self.StackedLayout.setSpacing(0) self.StackedLayout.setContentsMargins(0, 0, 0, 0) self.StackedWidget.setStyleSheet('background-color:rhba(0,0,0,0);') self.StackedWidget.setMaximumWidth(250) self.AddWindow = AddCutplanDialog(self.StackedWidget) self.AddWindow.setupUi(None, "support/cpquery.sql", self.Cutplans.host) self.StackedLayout.addWidget(self.AddWindow) self.SettingsWidget = QWidget(self.StackedWidget) self.SettingsUI = SettingsWindow(self.SettingsWidget) self.SettingsUI.setupUi(self.SettingsWidget) self.GetDefaultSettings() self.StackedLayout.addWidget(self.SettingsWidget) self.StackedLayout.setCurrentIndex(0) self.mainhorilayout.addWidget(self.StackedWidget) self.verticalLayout.addLayout(self.mainhorilayout) self.verticalLayout.setContentsMargins(50, 30, 50, 30) self.verticalLayout.setSpacing(50) self.timer = QTimer(self) self.timer.setInterval(100) self.timer.timeout.connect(self.UpdateGUI) self.PlayButton.clicked.connect(self.OnPlay) self.SettingsButton.clicked.connect(self.OnSettings) self.Cutplans.newcutplans.connect(self.ThreadSetup) self.Cutplans.AddButton.clicked.connect(self.AddClick) self.Cutplans.cploadfinish.connect(self.showPlayButton) self.AddWindow.buttonBox.rejected.connect(self.AddReject) self.AddWindow.buttonBox.accepted.connect(self.AddAccept) self.SettingsUI.buttonbox.accepted.connect(self.GetSettings) self.SettingsUI.buttonbox.rejected.connect(self.SendSettings) self.retranslateUi(Form) QMetaObject.connectSlotsByName(Form)
class SimulationPage(QWidget): def setupUi(self, Form, username=None, userid=1, host='192.168.2.171', simid=None, reset=False): self.host = host self.username = username self.userid = userid self.simid = simid self.readonly = (simid is not None) self.showsettings = False self.currentindex = 0 self.usedefaultsettings = True self.db = connector.connect(host=self.host, user="******", passwd="Sequal1234", database="simulation", use_pure=True) self.db.autocommit = True self.simrunning = False # self.esrunning = False if not reset: self.thread = None self.thread = QThread() self.cppath = getcwd() + "\\cutplans\\" self.logpath = getcwd() + "\\logs\\" self.shifts = 2 self.simShift = 1 index = [] for i in range(1, self.shifts + 1): index.append(str(i)) index.append("Total") cols = [ "RunTime", "LogsCut", "Production", "LogVolume", "Recovery", "LogRate", "Uptime", "MSLDT", "BSLDT", "TSLDT", "SawdustVol" ] self.results = DataFrame(index=index, columns=cols) # self.OpenExtendSim() Form.setObjectName("Form") Form.resize(900, 750) Form.setMinimumSize(QSize(900, 750)) Form.setStyleSheet("background-color: rgb(255, 255, 255);\n" "color: rgb(0, 115, 119);") if Form.layout() is not None: QWidget().setLayout(Form.layout()) self.verticalLayout = QVBoxLayout(Form) self.verticalLayout.setObjectName("verticalLayout") ss = \ """ QToolButton { 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)); color: white; border: None; border-radius: 2px; font: 11pt "Tahoma"; padding: 5px; margin-right: 20px; } """ self.detailsLayout = QHBoxLayout() self.closeButton = QToolButton(Form) self.closeButton.setObjectName("closeButton") self.closeButton.setStyleSheet(ss) self.closeButton.setCursor(QCursor(Qt.PointingHandCursor)) icon1 = QIcon("images/close.png") self.closeButton.setIcon(icon1) self.closeButton.setVisible(self.readonly) self.detailsLayout.addWidget(self.closeButton) self.nameLabel = QLabel(Form) self.nameLabel.setText("Name: ") self.nameLabel.setStyleSheet( "QLabel {" "background: none; font: 15pt \"Tahoma\";font-weight: bold;" "}") self.detailsLayout.addWidget(self.nameLabel) self.nameTextbox = QLineEdit(Form) self.nameTextbox.setText("Simulation") self.nameTextbox.setStyleSheet( "QLineEdit {\n" "background: none; font: 15pt \"Tahoma\";" "border: 1px solid rgb(0,115,119);\n" "}\n" "QLineEdit:disabled {border: none;}") self.detailsLayout.addWidget(self.nameTextbox) h = self.nameTextbox.size().height() self.closeButton.setMinimumSize(QSize(h, h)) self.closeButton.setIconSize(QSize(h - 10, h - 10)) self.PlayButton = QToolButton(Form) self.PlayButton.setObjectName("PlayButton") self.PlayButton.setStyleSheet(ss) self.PlayButton.setMinimumSize(QSize(h, h)) self.PlayButton.setCursor(QCursor(Qt.PointingHandCursor)) icon1 = QIcon("images/play.png") self.PlayButton.setIcon(icon1) self.PlayButton.setIconSize(QSize(h - 10, h - 10)) self.PlayButton.setVisible(False) self.detailsLayout.addWidget(self.PlayButton) hSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.detailsLayout.addItem(hSpacer) self.CreateNewButton = QToolButton(Form) self.CreateNewButton.setObjectName("CreateNewButton") self.CreateNewButton.setStyleSheet(ss) self.CreateNewButton.setMinimumSize(QSize(h, h)) self.CreateNewButton.setText("Create New") self.CreateNewButton.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) icon1 = QIcon("images/new.png") self.CreateNewButton.setIcon(icon1) self.CreateNewButton.setIconSize(QSize(h - 10, h - 10)) self.CreateNewButton.setCursor(QCursor(Qt.PointingHandCursor)) self.CreateNewButton.setVisible(False) self.detailsLayout.addWidget(self.CreateNewButton) self.SettingsButton = QToolButton(Form) self.SettingsButton.setObjectName("SettingsButton") self.SettingsButton.setStyleSheet(ss) self.SettingsButton.setMinimumSize(QSize(h, h)) self.SettingsButton.setCursor(QCursor(Qt.PointingHandCursor)) icon1 = QIcon("images/settings.png") self.SettingsButton.setIcon(icon1) self.SettingsButton.setIconSize(QSize(h - 10, h - 10)) self.detailsLayout.addWidget(self.SettingsButton) self.detailsLayout.setSpacing(5) self.verticalLayout.addLayout(self.detailsLayout) self.mainhorilayout = QHBoxLayout() self.ResultsArea = QScrollArea(Form) self.ResultsWidget = ResultsWidget() self.ResultsWidget.setupUi(self.ResultsArea) self.ResultsWidget.setObjectName("ResultsWidget") self.ResultsArea.setWidget(self.ResultsWidget) self.ResultsArea.setWidgetResizable(True) self.ResultsArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.ResultsArea.setFrameShape(QFrame.NoFrame) self.mainhorilayout.addWidget(self.ResultsArea) self.StackedWidget = QWidget(Form) self.StackedLayout = QStackedLayout(self.StackedWidget) self.CutplanArea = QScrollArea(self.StackedWidget) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.CutplanArea.sizePolicy().hasHeightForWidth()) self.CutplanArea.setSizePolicy(sizePolicy) self.CutplanArea.setMinimumSize(QSize(0, 250)) self.CutplanArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # self.CutplanArea.setSizeAdjustPolicy( # QAbstractScrollArea.AdjustToContents) self.CutplanArea.setWidgetResizable(True) self.CutplanArea.setFrameShape(QFrame.NoFrame) self.CutplanArea.setObjectName("CutplanArea") self.CPWidget = QWidget() self.Cutplans = CutplanWidget() self.Cutplans.setupUi(self.CPWidget) self.Cutplans.setObjectName("Cutplans") self.CutplanArea.setWidget(self.CPWidget) self.StackedLayout.addWidget(self.CutplanArea) self.StackedLayout.setSpacing(0) self.StackedLayout.setContentsMargins(0, 0, 0, 0) self.StackedWidget.setStyleSheet('background-color:rhba(0,0,0,0);') self.StackedWidget.setMaximumWidth(250) self.AddWindow = AddCutplanDialog(self.StackedWidget) self.AddWindow.setupUi(None, "support/cpquery.sql", self.Cutplans.host) self.StackedLayout.addWidget(self.AddWindow) self.SettingsWidget = QWidget(self.StackedWidget) self.SettingsUI = SettingsWindow(self.SettingsWidget) self.SettingsUI.setupUi(self.SettingsWidget) self.GetDefaultSettings() self.StackedLayout.addWidget(self.SettingsWidget) self.StackedLayout.setCurrentIndex(0) self.mainhorilayout.addWidget(self.StackedWidget) self.verticalLayout.addLayout(self.mainhorilayout) self.verticalLayout.setContentsMargins(50, 30, 50, 30) self.verticalLayout.setSpacing(50) self.timer = QTimer(self) self.timer.setInterval(100) self.timer.timeout.connect(self.UpdateGUI) self.PlayButton.clicked.connect(self.OnPlay) self.SettingsButton.clicked.connect(self.OnSettings) self.Cutplans.newcutplans.connect(self.ThreadSetup) self.Cutplans.AddButton.clicked.connect(self.AddClick) self.Cutplans.cploadfinish.connect(self.showPlayButton) self.AddWindow.buttonBox.rejected.connect(self.AddReject) self.AddWindow.buttonBox.accepted.connect(self.AddAccept) self.SettingsUI.buttonbox.accepted.connect(self.GetSettings) self.SettingsUI.buttonbox.rejected.connect(self.SendSettings) self.retranslateUi(Form) QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): _translate = QCoreApplication.translate Form.setWindowTitle(_translate("Form", "Form")) def ThreadSetup(self, show): self.PlayButton.setVisible(False) self.cpid = 0 self.cpfinish = False for i in range(self.results.shape[0]): for j in range(self.results.shape[1]): self.results.iloc[i, j] = 0 def showPlayButton(self): if not self.readonly: self.PlayButton.setVisible(True) def AddClick(self): self.Cutplans.onClick2() if self.Cutplans.addData is not None: self.AddWindow.addData = self.Cutplans.addData else: self.AddWindow.addData = DataFrame( columns=['ID', 'Log Count', 'Description']) self.AddWindow.onDateChange() self.AddWindow.RTVSetUp() self.StackedLayout.setCurrentIndex(1) self.currentindex = 1 def AddReject(self): self.StackedLayout.setCurrentIndex(0) self.currentindex = 0 def AddAccept(self): self.Cutplans.addData = self.AddWindow.addData self.StackedLayout.setCurrentIndex(0) self.currentindex = 0 self.Cutplans.AddCP() def OnPlay(self): self.PlayButton.setVisible(False) self.Cutplans.AddButton.setVisible(False) self.nameTextbox.setDisabled(True) self.simrunning = True self.cpfinish = False self.SendData() self.timer.start() # if self.esrunning: # # self.esa.RunSim() # self.timer.start() def SendData(self): try: cursor = self.db.cursor() except connector.Error: self.db = connector.connect(host=self.host, user="******", passwd="Sequal1234", database="simulation", use_pure=True) self.db.autocommit = True cursor = self.db.cursor() f = open('support\\initResults.sql', 'r') query = f.read() cursor.execute(query) # Simulations query query = "INSERT INTO simulations (Name, UserID) VALUES " \ "(\'" + self.nameTextbox.text() + "\', " + str(self.userid) + ");" cursor.execute(query) cursor.execute("SELECT LAST_INSERT_ID();") (sid, ) = cursor.fetchone() self.simid = sid # check for downtime setting if sum(self.downtime_setting) == 0: # all downtime off dt = 0 elif sum(self.downtime_setting) == len(self.downtime_setting): # all downtime on dt = 1 else: # custom downtime so insert downtime into downtimesettings dt = 2 temp = self.SettingsUI.downtimeCBtexts.copy() temp.insert(0, 'SimID') tstr = str(temp).replace('\'', '').replace('[', '(').replace(']', ')') query = "INSERT INTO DowntimeSettings " + tstr temp = self.downtime_setting.copy() temp.insert(0, self.simid) tstr = str(temp).replace('[', '(').replace(']', ')') query = query + " VALUES " + tstr + ";" cursor.execute(query) # check for cutback default setting defcb = self.SettingsUI.defaultcutbacks cbtext = self.SettingsUI.cutbackCBtexts cb = True for tstr in defcb: if not self.cutback_setting[cbtext.index(tstr)]: cb = False if cb and sum(self.cutback_setting) == len(defcb): cb = 1 else: cb = 0 temp = cbtext.copy() temp.insert(0, 'SimID') tstr = str(temp).replace('\'', '`').replace('[', '(').replace(']', ')') query = "INSERT INTO CutbackSettings " + tstr temp = self.cutback_setting.copy() temp.insert(0, self.simid) tstr = str(temp).replace('[', '(').replace(']', ')') query = query + " VALUES " + tstr + ";" cursor.execute(query) # SimHistory Query f = open('support\\simHistQuery.sql', 'r') sqltext = f.read() query = sqltext.replace('@SimID', str(self.simid)) query = query.replace('@Name', str(self.nameTextbox.text())) query = query.replace('@UserID', str(self.userid)) query = query.replace('@LogGap', str(self.loggap_setting)) query = query.replace('@Downtime', str(dt)) query = query.replace('@NumBins', str(self.numbins_setting)) query = query.replace('@LineSpeed', str(self.linespeed_setting)) query = query.replace('@Cutbacks', str(cb)) cursor.execute(query) # Cutplans Query f = open('support\\simQuery.sql', 'r') sqltext = f.read() for i in range(self.Cutplans.addData.shape[0]): sqltext_full = sqltext.replace("@SimID", str(sid)) sqltext_full = sqltext_full.replace( "@CutplanID", str(self.Cutplans.addData.ID[i])) sqltext_full = sqltext_full.replace( "@Description", str(self.Cutplans.addData.Description[i])) sqltext_full = sqltext_full.replace( "@NumLogs", str(self.Cutplans.addData['Log Count'][i])) cursor.execute(sqltext_full) def GetDefaultSettings(self): self.loggap_setting = self.SettingsUI.default[0] self.downtime_setting = [] for cb in self.SettingsUI.downtimeCBs: self.downtime_setting.append(cb.isChecked()) self.numbins_setting = self.SettingsUI.default[2] self.linespeed_setting = self.SettingsUI.default[3] self.cutback_setting = [] for cb in self.SettingsUI.cutbackCBs: self.cutback_setting.append(cb.isChecked()) def GetSettings(self): s = self.SettingsUI if s.loggapAuto.isChecked(): self.loggap_setting = -1 else: self.loggap_setting = s.loggapTB.value() self.downtime_setting = [] for cb in s.downtimeCBs: self.downtime_setting.append(cb.isChecked()) self.numbins_setting = s.numbinsTB.value() if s.highspeedRB.isChecked(): self.linespeed_setting = 55.0 elif s.lowspeedRB.isChecked(): self.linespeed_setting = 35.0 elif s.autospeedRB.isChecked(): self.linespeed_setting = -1.0 else: self.linespeed_setting = s.customspeedTB.value() self.cutback_setting = [] for cb in s.cutbackCBs: self.cutback_setting.append(cb.isChecked()) self.usedefaultsettings = not s.resetbutton.isVisible() self.showsettings = False speed = int(self.linespeed_setting) if speed == -1: speed = 55 self.Cutplans.speedsetting = speed self.Cutplans.onClick2() self.Cutplans.AddCP() self.StackedLayout.setCurrentIndex(self.currentindex) def SendSettings(self): s = self.SettingsUI if self.loggap_setting == -1: s.loggapAuto.setChecked(True) else: s.loggapAuto.setChecked(False) s.loggapTB.setValue(self.loggap_setting) for i in range(len(s.downtimeCBs)): s.downtimeCBs[i].setChecked(self.downtime_setting[i]) s.numbinsTB.setValue(self.numbins_setting) if self.linespeed_setting == 55.0: s.highspeedRB.setChecked(True) elif self.linespeed_setting == 35.0: s.lowspeedRB.setChecked(True) elif self.linespeed_setting == -1.0: s.autospeedRB.setChecked(True) else: s.customspeedRB.setChecked(True) s.customspeedTB.setValue(self.linespeed_setting) for i in range(len(s.cutbackCBs)): s.cutbackCBs[i].setChecked(self.cutback_setting[i]) if self.usedefaultsettings: s.resetbutton.setVisible(False) self.showsettings = False self.StackedLayout.setCurrentIndex(self.currentindex) def OnSettings(self): if not self.showsettings: self.SettingsUI.resetbutton.setVisible(not self.usedefaultsettings) self.StackedLayout.setCurrentIndex(2) self.showsettings = True def UpdateGUI(self): if not self.cpfinish: f = open('support\\cpProgress.sql', 'r') sqltext = f.read().replace('@SimID', str(self.simid)) try: cursor = self.db.cursor() except connector.Error: self.db = connector.connect(host=self.host, user="******", passwd="Sequal1234", database="simulation", use_pure=True) self.db.autocommit = True cursor = self.db.cursor() complete = 0 for i in range(self.Cutplans.addData.shape[0]): query = sqltext.replace('@CPID', str(self.Cutplans.addData.ID[i])) cursor.execute(query) (v, ) = cursor.fetchone() self.Cutplans.CPProgress[i].setValue(v) if v >= 100: complete += 1 if complete == self.Cutplans.addData.shape[0]: self.cpfinish = True else: f = open('support\\getResults.sql', 'r') sqltext = f.read() self.results = read_sql(sqltext, self.db) self.ResultsWidget.updateResults(self.results) if self.results['RunTime'][2] >= 17.66: self.timer.stop() self.simrunning = False self.setupPostSimulation() def setupPostSimulation(self): self.Cutplans.AddButton.setVisible(False) self.nameTextbox.setDisabled(True) self.CreateNewButton.setVisible(True) ss = " 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" \ " height: 25px;\n" \ " border: None;\n" \ " border-radius: 2px;\n" \ " \n" \ " font: 11pt \"Tahoma\";\n" \ " width: 70px;" # SETTINGS READ ONLY self.SettingsUI.buttonbox.setStandardButtons(QDialogButtonBox.Cancel) for w in self.SettingsUI.buttonbox.children(): if w.metaObject().className() == "QPushButton": w.setCursor(QCursor(Qt.PointingHandCursor)) w.setStyleSheet(ss) self.SettingsUI.setupReadOnly() self.CheckCPErrors() def setupReadOnly(self, loadcp=True): self.closeButton.setVisible(True) self.Cutplans.AddButton.setVisible(False) qry = "SELECT * FROM simulation.fullresults Where SimID = " + str( self.simid) data = read_sql(qry, self.db) self.nameTextbox.setText(data["SimName"][0]) self.nameTextbox.setDisabled(True) qry = "SELECT CutplanID as ID, NumLogs as \"Log Count\" From " + \ "cutplans WHERE SimID = " + str(self.simid) self.results = data.iloc[:, 3:15].copy() self.results.columns = [ 'RunTime', 'LogsCut', 'Production', 'LogVolume', 'Recovery', 'LogRate', 'Uptime', 'MSLDT', 'BSLDT', 'TSLDT', 'Sawdust', 'Shift' ] self.results.loc[self.results.index[0], 'Shift'] = self.results.shape[0] self.results = self.results.sort_values(by=['Shift']) self.results['Sawdust'] = self.results['Sawdust'] / \ self.results['LogVolume'] self.ResultsWidget.updateResults(self.results) if loadcp: cpdata = read_sql(qry, self.db) self.Cutplans.AddCP(addData=cpdata, errors=self.CheckCPErrors()) qry = "SELECT * From SimHistory Where SimID = " + str(self.simid) + ";" settings = read_sql(qry, self.db) self.loggap_setting = settings.LogGap[0] dt = settings.Downtime[0] if dt == 0: self.downtime_setting = [] for i in range(len(self.SettingsUI.downtimeCBs)): self.downtime_setting.append(False) elif dt == 1: self.downtime_setting = [] for i in range(len(self.SettingsUI.downtimeCBs)): self.downtime_setting.append(True) else: qry = "SELECT * FROM DowntimeSettings Where SimID = " + str( self.simid) + ";" dt = read_sql(qry, self.db) for i in range(len(self.SettingsUI.downtimeCBs)): x = (dt.iloc[0, i + 1] == 1) self.SettingsUI.downtimeCBs[i].setChecked(x) self.SettingsUI.numbinsTB.setValue(settings.NumBins[0]) if settings.LineSpeed[0] == 55.0: self.SettingsUI.highspeedRB.setChecked(True) elif settings.LineSpeed[0] == 35.0: self.SettingsUI.lowspeedRB.setChecked(True) elif settings.LineSpeed[0] == -1.0: self.SettingsUI.autospeedRB.setChecked(True) else: self.SettingsUI.customspeedRB.setChecked(True) self.SettingsUI.customspeedTB.setValue(settings.LineSpeed[0]) if settings.Downtime[0] == 0: qry = "SELECT * FROM CutbackSettings Where SimID = " + str( self.simid) + ";" cb = read_sql(qry, self.db) for i in range(len(self.SettingsUI.downtimeCBs)): x = (cb.iloc[0, i + 1] == 1) self.SettingsUI.downtimeCBs[i].setChecked(x) self.SettingsUI.buttonbox.setStandardButtons(QDialogButtonBox.Cancel) for w in self.SettingsUI.buttonbox.children(): if w.metaObject().className() == "QPushButton": w.setCursor(QCursor(Qt.PointingHandCursor)) self.SettingsUI.setupReadOnly() def CheckCPErrors(self): with open('support\\cpErrors.sql', 'r') as f: query = f.read().replace('@SimID', str(self.simid)) cperrors = read_sql(query, self.db) return cperrors