def make_gui(self): self.window = Viewer() self.window.setWindowTitle("VistaMed test applocation") self.window.setGeometry(QtCore.QRect(100, 100, 900, 600)) self.settings_window = SettingsWindow() self.window.show()
class MainWindow(QtGui.QApplication): def __init__(self): QtGui.QApplication.__init__(self, sys.argv) self.make_gui() self.set_signals() sys.exit(self.exec_()) def make_gui(self): self.window = Viewer() self.window.setWindowTitle("VistaMed test applocation") self.window.setGeometry(QtCore.QRect(100, 100, 900, 600)) self.settings_window = SettingsWindow() self.window.show() def set_signals(self): self.window.open_settings_signal.connect(self.open_settings) self.window.reload_database_signal.connect(self.reload_database) self.window.close_application_signal.connect(self.close_application) self.settings_window.new_data_already_signal.connect( self.new_data_already) def new_data_already(self): self.window.table.load_data( default=False, settings=self.settings_window.get_settings()) def open_settings(self): self.settings_window.show() def reload_database(self): new_data = self.settings_window.get_settings() if str() in new_data.values(): print('Empty settings. New settings not installed.') else: self.window.table.load_data(default=False, settings=new_data) def close_application(self): self.quit()
def __windowInit(self, name, reArray=None, root=None): if not root: root = self.__root if name == 'start': return StartModule(root=root, windowManager=self) elif name == 'order': return Order(root=root, windowManager=self, database=self.__database, rawArray=reArray) elif name == 'history': return History(root=root, database=self.__database, windowManager=self) elif name == 'settings': return SettingsWindow(root=root, windowManager=self) else: print('No such window name')
def __init__(self): """ generate other windows, floppy output control and create the gui """ super(MainWindow, self).__init__() #debug pygame.midi.init() #debug self.mout = pygame.midi.Output(pygame.midi.get_default_output_id()) self.midi_in = MidiIn(self.cb_midi_event) self.midi_fin = MidiFileIn(self.cb_midi_event_list) self.fout = FloppyOut() self.settingswindow = SettingsWindow(self.midi_in, self.fout) self.init_ui() self.midi_in.start_midi_polling()
def on_settings(self, event): settings = SettingsWindow(self) settings.Show(True) # Finally show the frame
def settings_open(self): if not self.setting_window_active: self.setting_window = SettingsWindow() self.setting_window.show()
class StartWindow(QMainWindow): def __init__(self, database_path): self.database_path = database_path QMainWindow.__init__(self) # init special variables self.top_menu = None self.setting_window_active = False self.newproject_window_active = False self.database_con = Database(self.database_path) self.setFixedSize(QSize(560, 410)) self.setWindowTitle("CR Helper") self.central_widget = QWidget(self) self.setCentralWidget(self.central_widget) self.statusBar() x = Update_Projects(database=self.database_path) self.recent_Projects = x.update_database() self.menubar_create() hbox_layout = QHBoxLayout(self) vbox_left = QVBoxLayout() vbox_right = QVBoxLayout() self.central_widget.setLayout(hbox_layout) # Recent projects left tab recent_projects_group = QGroupBox("Recent projects") recent_projects_group.setLayout(vbox_left) # Take fixed size from window and resize group groupbox_style = """QGroupBox {background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E0E0E0, stop: 1 #FFFFFF); border: 1px solid gray; border-radius: 5px; padding: 5px; margin-top: 0.3ex; font-family: Calibri; font-size: 12px; } QGroupBox:title {subcontrol-origin: border; subcontrol-position: top center; padding: 0 3px; } """ recent_projects_group.setStyleSheet(groupbox_style) recent_projects_group.setMinimumSize(self.width() / 2, self.height() / 2) # todo replace this to select from database print(self.recent_Projects) for i in self.recent_Projects.keys(): project = RecentProjectLabel(i, self.recent_Projects[i], self.central_widget) vbox_left.addWidget(project) vbox_left.addStretch(1) x_but = Button("Test button", self.action_open, self.central_widget) vbox_right.addWidget(x_but) hbox_layout.addWidget(recent_projects_group) hbox_layout.addLayout(vbox_left) hbox_layout.addLayout(vbox_right) hbox_layout.addStretch(1) self.show() def create_recent(self, projects): if len(projects) == 0: list_project = "No recent projects" else: list_project = [] for project in projects.keys(): link_to_project = QAction(str(project), self) list_project.append(link_to_project) return list_project def settings_open(self): if not self.setting_window_active: self.setting_window = SettingsWindow() self.setting_window.show() def newproject_open(self): if not self.newproject_window_active: self.newproject_window = NewProjectWindow( database_path=self.database_path) self.newproject_window.show() def action_open(self): print(self.minimumHeight()) def menubar_create(self): self.top_menu = self.menuBar() project_menubar = self.top_menu.addMenu("&File") project_menubar.addAction( Action("&New project", self.newproject_open, "Ctrl+N", "Create new CR Project", parent=self)) project_menubar.addAction( Action("&Open project", self.action_open, "Ctrl+O", "Open project", parent=self)) recent_projects_menubar = project_menubar.addMenu("Recent Project") recent_projects = self.create_recent(self.recent_Projects) if isinstance(recent_projects, str): recent_projects_menubar.addAction(recent_projects) elif isinstance(recent_projects, list): for recent in recent_projects: recent_projects_menubar.addAction(recent) project_menubar.addSeparator() project_menubar.addAction( Action(text="&Settings", connect=self.settings_open, statustip="Settings for application", parent=self)) project_menubar.addSeparator() project_menubar.addAction( Action(text="&Exit", connect=qApp.quit, statustip="Exit Application", parent=self))
class MainWindow(QtGui.QMainWindow): """ The mainwindow containing options to fine tune things and start everything up. """ def cb_midi_event_list(self, event_list): # parsing the events # ================== # only note on, note off and pitch wheel range are # important for us, so the other midi events are just ignored. # status, data1, data2, tick event_str = None channel = None for event in event_list: status = event.statusmsg tick = event.tick if event.name == "Note Off": status += event.channel # due to buggy python-midi lib channel = status - 0x80 + 1 midi_note = event.data[0] velocity = event.data[1] event_str = "Chan %s Note off" % channel self.fout.stop_note(channel) self.mout.note_off(midi_note, velocity, channel - 1) # only for debugging. remove later!!! elif event.name == "Note On": status += event.channel # due to buggy python-midi lib channel = status - 0x90 + 1 midi_note = event.data[0] velocity = event.data[1] event_str = "Chan %s Note on" % channel if velocity > 0: self.mout.note_on(midi_note, velocity, channel - 1) # only for debugging. remove later!!! self.fout.play_note(channel, midi_note) else: self.mout.note_on(midi_note, velocity, channel - 1) # only for debugging. remove later!!! self.fout.stop_note(channel) # a volume of 0 is the same as note off elif event.name == "Set Tempo": self.midi_fin.set_bpm(event.bpm) elif event.name == "Program Change": # Chan Program change (change instrument) if self.mout is not None: self.mout.set_instrument(event.data[0], event.channel) # elif status >= 0xE0 and status <= 0xEF: # pitch bend (TODO: don't ignore!) # channel = status - 0xE0 + 1 # velocity = event.data[1] # pitch_value = 128 * velocity # event_str = "Chan %s pitch bend with value %s and" % (channel, pitch_value) else: event_str = "unknown event (0x%0X)" % (status) if event_str != None: pass #print "%s with note %s and velocity %s @ %s" % (event_str, midi_note, velocity, tick) # used for live midi def cb_midi_event(self, status, data1, data2, tick): # parsing the events # ================== # only note on, note off and pitch wheel range are # important for us, so the other midi events are just ignored. event_str = None channel = None if status >= 0x80 and status <= 0x8F: # Note Off channel = status - 0x80 + 1 midi_note = data1 velocity = data2 event_str = "Chan %s Note off" % channel self.fout.stop_note(channel) #self.mout.note_off(midi_note, velocity, channel - 1) # only for debugging. remove later!!! elif status >= 0x90 and status <= 0x9F: # Note On channel = status - 0x90 + 1 midi_note = data1 velocity = data2 event_str = "Chan %s Note on" % channel if velocity > 0: #self.mout.note_on(midi_note, velocity, channel - 1) # only for debugging. remove later!!! self.fout.play_note(channel, midi_note) else: #self.mout.note_on(midi_note, velocity, channel - 1) # only for debugging. remove later!!! self.fout.stop_note(channel) # a volume of 0 is the same as note off elif status >= 0xA0 and status <= 0xAF: # Polyphonic Aftertouch (ignore) return elif status >= 0xB0 and status <= 0xBF: # Chan Control mode change (ignore) return elif status >= 0xC0 and status <= 0xCF: # Chan Program change (ignore) return #self.mout.set_instrument(event.data, event.channel) elif status >= 0xD0 and status <= 0xDF: # Channel Aftertouch (ignore) return elif status >= 0xE0 and status <= 0xEF: # pitch bend (TODO: don't ignore!) channel = status - 0xE0 + 1 velocity = data2 pitch_value = 128 * velocity event_str = "Chan %s pitch bend with value %s and" % (channel, pitch_value) else: event_str = "unknown event (0x%0X)" % (status) print "%s with note %s and velocity %s @ %s" % (event_str, data1, data2, tick) return if event_str != None: pass #print "%s with note %s and velocity %s @ %s" % (event_str, midi_note, velocity, tick) def __init__(self): """ generate other windows, floppy output control and create the gui """ super(MainWindow, self).__init__() #debug pygame.midi.init() #debug self.mout = pygame.midi.Output(pygame.midi.get_default_output_id()) self.midi_in = MidiIn(self.cb_midi_event) self.midi_fin = MidiFileIn(self.cb_midi_event_list) self.fout = FloppyOut() self.settingswindow = SettingsWindow(self.midi_in, self.fout) self.init_ui() self.midi_in.start_midi_polling() def setFloatNum(self, float_num): self.lab_freq.setText( "%.2f" % (float_num / 100.0) ) def init_ui(self): """ create the gui and connect actions """ self.resize(480, 320) self.setWindowTitle('FlyFi - Floppy-Fidelity') self.setWindowIcon(QtGui.QIcon('images/flyfi-logo.png')) self.center() self.statusBar().showMessage('Ready') act_exit = QtGui.QAction(QtGui.QIcon('images/exit.png'), '&Exit', self) act_exit.setShortcut('Ctrl+Q') act_exit.setStatusTip('Exit application') act_exit.triggered.connect(QtCore.QCoreApplication.instance().quit) act_settings = QtGui.QAction(QtGui.QIcon('images/settings.png'), '&Settings', self) act_settings.setShortcut('Ctrl+S') act_settings.setStatusTip('Configure FlyFi') act_settings.triggered.connect(self.cb_open_settings_window) menubar = self.menuBar() file_menu = menubar.addMenu('&File') file_menu.addAction(act_settings) file_menu.addAction(act_exit) toolbar = self.addToolBar('Toolbar') toolbar.addAction(act_settings) toolbar.addAction(act_exit) # midi player openMidiButton = QtGui.QPushButton("Open Midi") openMidiButton.clicked.connect(self.showFileDialog) playButton = QtGui.QPushButton("Play") playButton.clicked.connect(self.playMidiFile) hbox = QtGui.QHBoxLayout() hbox.addWidget(openMidiButton) hbox.addWidget(playButton) hbox.addStretch(1) vbox = QtGui.QVBoxLayout() vbox.addLayout(hbox) vbox.addStretch(1) centralwidget = QtGui.QWidget() centralwidget.setLayout(vbox) self.setCentralWidget(centralwidget) def showFileDialog(self): fname, _ = QtGui.QFileDialog.getOpenFileName(self, 'Open file') self.midi_fin.open_midi_file(fname) def playMidiFile(self): self.midi_fin.play() def center(self): """ center the window on the screen """ frame_geo = self.frameGeometry() desktop_center = QtGui.QDesktopWidget().availableGeometry().center() frame_geo.moveCenter(desktop_center) self.move(frame_geo.topLeft()) def cb_open_settings_window(self): self.settingswindow.show() self.settingswindow.cb_update_serial_ports()
def __settings_window(self, *args): settings = SettingsWindow() settings.connect('destroy', Gtk.main_quit) settings.show_all() Gtk.main()
class ButtonPanel(QtGui.QWidget): logPackageRequested = QtCore.pyqtSignal() def __init__(self, msgLog): super(ButtonPanel, self).__init__() self.msgLog = msgLog self.streamWindow = None self.settingsWindow = None self.streamButton = QtGui.QPushButton() self.streamButton.setIcon(QtGui.QIcon('../img/stream.ico')) self.streamButton.setIconSize(QtCore.QSize(48, 48)) self.streamButton.setToolTip('Launch Stream Window') self.streamButton.clicked.connect(self.launchStreamWindow) self.snapshotButton = QtGui.QPushButton() self.snapshotButton.setIcon(QtGui.QIcon('../img/snapshot.ico')) self.snapshotButton.setIconSize(QtCore.QSize(48, 48)) self.snapshotButton.setToolTip('Take a Snapshot') self.snapshotButton.clicked.connect(self.takeSnapshot) self.startRecordingButton = QtGui.QPushButton() self.startRecordingButton.setIcon( QtGui.QIcon('../img/startRecording.ico')) self.startRecordingButton.setIconSize(QtCore.QSize(48, 48)) self.startRecordingButton.setToolTip('Start Recording') self.startRecordingButton.clicked.connect(self.startRecording) self.stopRecordingButton = QtGui.QPushButton() self.stopRecordingButton.setIcon( QtGui.QIcon('../img/stopRecording.ico')) self.stopRecordingButton.setIconSize(QtCore.QSize(48, 48)) self.stopRecordingButton.setToolTip('Stop Recording') self.stopRecordingButton.clicked.connect(self.stopRecording) self.transferButton = QtGui.QPushButton() self.transferButton.setIcon(QtGui.QIcon('../img/transfer.ico')) self.transferButton.setIconSize(QtCore.QSize(48, 48)) self.transferButton.setToolTip('Transfer Experiment') self.transferButton.clicked.connect(self.transferExperiment) self.plotButton = QtGui.QPushButton() self.plotButton.setIcon(QtGui.QIcon('../img/plot.ico')) self.plotButton.setIconSize(QtCore.QSize(48, 48)) self.plotButton.setToolTip('Launch Plot Window') self.plotButton.clicked.connect(self.plotData) self.impedanceButton = QtGui.QPushButton() self.impedanceButton.setIcon(QtGui.QIcon('../img/impedance.png')) self.impedanceButton.setIconSize(QtCore.QSize(48, 48)) self.impedanceButton.setToolTip('Run Impedance Test') self.impedanceButton.clicked.connect(self.handleImpedanceStart) self.settingsButton = QtGui.QPushButton() self.settingsButton.setIcon(QtGui.QIcon('../img/settings.png')) self.settingsButton.setIconSize(QtCore.QSize(48, 48)) self.settingsButton.setToolTip('Configure Settings') self.settingsButton.clicked.connect(self.configureSettings) self.logPackageLabel = QtGui.QLabel( 'Zip error logs (for bug reporting)') self.logPackageButton = QtGui.QPushButton('Zip logs') self.logPackageButton.pressed.connect(self.logPackageRequested) layout = QtGui.QVBoxLayout() logPackageLayout = QtGui.QGridLayout() logPackageLayout.addWidget(self.logPackageLabel, 0, 0) logPackageLayout.addWidget(self.logPackageButton, 0, 1) layout.addLayout(logPackageLayout) gridLayout = QtGui.QGridLayout() gridLayout.addWidget(self.streamButton, 0, 0) gridLayout.addWidget(self.snapshotButton, 0, 1) gridLayout.addWidget(self.startRecordingButton, 1, 0) gridLayout.addWidget(self.stopRecordingButton, 1, 1) gridLayout.addWidget(self.transferButton, 2, 0) gridLayout.addWidget(self.plotButton, 2, 1) gridLayout.addWidget(self.impedanceButton, 3, 0) gridLayout.addWidget(self.settingsButton, 3, 1) layout.addLayout(gridLayout) self.subprocessThreads = [] self.setLayout(layout) def runImpedanceTest(self): dlg = ImpedanceDialog() if dlg.exec_(): params = dlg.getParams() self.impedanceProgressDialog = QtGui.QProgressDialog( 'Impedance Testing Progress', 'Cancel', 0, 10) self.impedanceProgressDialog.setAutoReset(False) self.impedanceProgressDialog.setMinimumDuration(0) self.impedanceProgressDialog.setModal(False) self.impedanceProgressDialog.setWindowTitle( 'Impedance Testing Progress') self.impedanceProgressDialog.setWindowIcon( QtGui.QIcon('../img/round_logo_60x60.png')) self.impedanceThread = ImpedanceThread(params) self.impedanceThread.progressUpdated.connect( self.impedanceProgressDialog.setValue) self.impedanceThread.maxChanged.connect( self.impedanceProgressDialog.setMaximum) self.impedanceThread.textChanged.connect( self.impedanceProgressDialog.setLabelText) self.impedanceThread.finished.connect( self.impedanceProgressDialog.reset) self.impedanceThread.msgPosted.connect(self.postStatus) self.impedanceThread.dataReady.connect( self.launchImpedancePlotWindow) self.impedanceProgressDialog.canceled.connect( self.impedanceThread.handleCancel) self.impedanceProgressDialog.show() self.impedanceThread.start() def configureSettings(self): self.settingsWindow = SettingsWindow() self.settingsWindow.show() def launchStreamWindow(self): dlg = StreamPickDialog() if dlg.exec_(): streamChoice = dlg.getChoice() if streamChoice == 'default': self.streamWindow = StreamWindow() self.streamWindow.msgPosted.connect(self.postStatus) self.streamWindow.show() else: self.msgLog.post(str("the following streaming script chosen:" + "\n" + str(streamChoice)), log=self.msgLog.actionLog) self.streamHandler = StreamHandler(streamChoice) self.streamHandler.msgPosted.connect(self.postStatus) self.streamHandler.run() def takeSnapshot(self): dlg = SnapshotDialog() if dlg.exec_(): params = dlg.getParams() self.msgLog.post(str("the following snapshot params requested:" + "\n" + str(params)), log=self.msgLog.actionLog) self.snapshotThread = SnapshotThread(params) self.snapshotProgressDialog = QtGui.QProgressDialog( 'Taking Snapshot..', 'Cancel', 0, 0) self.snapshotProgressDialog.setModal(True) self.snapshotProgressDialog.setWindowTitle('Snapshot Progress') self.snapshotProgressDialog.setWindowIcon( QtGui.QIcon('../img/round_logo_60x60.png')) self.snapshotProgressDialog.canceled.connect( self.snapshotThread.handleCancel) self.snapshotThread.msgPosted.connect( self.postStatus) # TODO see others self.snapshotThread.finished.connect( self.snapshotProgressDialog.reset) # necessary? self.snapshotThread.finished.connect(self.handleSnapshotFinished) self.snapshotProgressDialog.show() self.snapshotThread.start() def handleSnapshotFinished(self, params): finalAction = params['whenFinished'][0] if finalAction == -3: # "willowgui data explorer" self.launchPlotWindow(params['filename']) elif finalAction == -4: # custom script sat = SnapshotAnalysisThread(params) sat.msgPosted.connect(self.postStatus) self.subprocessThreads.append( sat) # necessary to prevent garbage collection sat.start() def startRecording(self): try: hwif.startRecording() self.msgLog.post('Started recording.') except hwif.AlreadyError: self.msgLog.post('Already recording.') except hwif.hwifError as e: self.msgLog.post(e.message) def stopRecording(self): try: hwif.stopRecording() self.msgLog.post('Stopped recording.') except hwif.AlreadyError: self.msgLog.post('Already not recording.') except hwif.hwifError as e: self.msgLog.post(e.message) def handleImpedanceStart(self): try: if hwif.isRecording(): self.msgLog.post( 'Cannot check impedance while recording. Please complete recording and try again.' ) return elif hwif.isStreaming(): self.msgLog.post( 'Halting current data stream to perform impedance test.') self.streamWindow.stopStreaming() self.runImpedanceTest() else: self.runImpedanceTest() except hwif.hwifError as e: self.msgLog.post(e.message) def handleDiskFillup(self): try: hwif.stopRecording() sampleIndex = hwif.getSataBSI() self.msgLog.post( 'Disk fillup detected! Recording stopped at sample index %d' % sampleIndex) except hwif.AlreadyError: self.msgLog.post('Already not recording.') except hwif.hwifError as e: self.msgLog.post(e.message) def transferExperiment(self): dlg = TransferDialog() if dlg.exec_(): params = dlg.getParams() self.msgLog.post(str("the following transfer params requested:" + "\n" + str(params)), log=self.msgLog.actionLog) self.transferThread = TransferThread(params) self.transferProgressDialog = QtGui.QProgressDialog( 'Transferring Experiment..', 'Cancel', 0, 0) self.transferProgressDialog.setWindowTitle('Transfer Progress') self.transferProgressDialog.setWindowIcon( QtGui.QIcon('../img/round_logo_60x60.png')) self.transferProgressDialog.canceled.connect( self.transferThread.handleCancel) self.transferThread.statusUpdated.connect(self.postStatus) self.transferThread.finished.connect( self.transferProgressDialog.reset) self.transferProgressDialog.show() self.transferThread.start() def postStatus(self, msg): self.msgLog.post(msg) def plotData(self): filename = QtGui.QFileDialog.getOpenFileName(self, 'Import Data File', config.dataDir) if filename: filename = str(filename) self.msgLog.post(str("imported:" + "\n" + filename), log=self.msgLog.actionLog) if isCalibrationFile(filename): self.msgLog.post("(calibration file)", log=self.msgLog.actionLog) self.launchImpedancePlotWindow(filename) elif isSnapshotFile(filename): self.msgLog.post("(snapshot file)", log=self.msgLog.actionLog) dlg = SnapshotImportDialog() if dlg.exec_(): params = dlg.getParams() if params['customScript']: # TODO make this consistent with the original SAI routines params['filename'] = filename params['whenFinished'] = (-4, params['customScript']) sat = SnapshotAnalysisThread(params) sat.msgPosted.connect(self.postStatus) self.subprocessThreads.append( sat) # necessary to prevent garbage collection sat.start() else: self.launchPlotWindow(filename) else: self.msgLog.post("(experiment file)", log=self.msgLog.actionLog) self.launchPlotWindow(filename) def launchPlotWindow(self, filename): self.plotWindow = DataExplorerWindow(filename) self.plotWindow.show() def launchImpedancePlotWindow(self, filename): self.impedancePlotWindow = ImpedancePlotWindow(str(filename)) self.impedancePlotWindow.show()
def configureSettings(self): self.settingsWindow = SettingsWindow() self.settingsWindow.show()
def show_settings(self): """ Uruchomienie panelu konfiguracyjnego. """ self.settings_window = SettingsWindow() self.settings_window.show()
class AlgorithmsManager: """ Kontroler odpowiadający za obsługę algorytmu. Parametry: main_widget - referencja do głównego widget'u. """ def __init__(self, main_widget: QWidget): self.algorithms = [] self.main_widget = main_widget self.combobox = self.main_widget.top_widget self.control_panel_top = self.main_widget.middle_widget.right_widget.top_control_panel self.control_panel_bottom = self.main_widget.middle_widget.right_widget.bottom_control_panel self.center = self.main_widget.middle_widget.left_widget self.manager = None self.current_index = 0 self.current_algorithm = None self.description_button = None self.visualisation_button = None self.questions_button = None self.codes_button = None self.settings_window = None self.setup_algorithms() def setup_algorithms(self): """ Wczytuje algorytmy. """ self.algorithms = [] self.combobox.clear() for algorithm_class in Algorithms.AlgorythmsClasses: algorithm = algorithm_class() self.algorithms.append(algorithm) self.algorithms.sort(key=lambda algo: algo.difficulty) for algorithm in self.algorithms: self.combobox.add_algorithms(algorithm.title, algorithm.difficulty) self.main_widget.top_widget.currentIndexChanged.connect( self.on_change_algorithm) self.reset() self.set_algorithm(0) def setup_control_panel(self): """ Inicjalizuje panel kontrolny. """ self.control_panel_top.clear() self.control_panel_bottom.clear() self.description_button = self.control_panel_top.add_button( "Opis", Paths.icon("bookmark.png")) self.description_button.clicked.connect(self.show_description) self.description_button.set_hint("Wyświetlenie opisu algorytmu.") self.visualisation_button = self.control_panel_top.add_button( "Wizualizacja", Paths.icon("eye.png")) self.visualisation_button.clicked.connect(self.show_visualisation) self.visualisation_button.set_hint( "Wizualizacja podstawowych operacji na rzecz danego algorytmu.") self.codes_button = self.control_panel_top.add_button( "Kody źródłowe", Paths.icon("code.png")) self.codes_button.clicked.connect(self.show_codes) self.codes_button.set_hint("Przejście do panelu z kodami źródłowymi.") self.questions_button = self.control_panel_top.add_button( "Pytania", Paths.icon("question_mark.png")) self.questions_button.clicked.connect(self.show_questions) self.questions_button.set_hint( "Panel weryfikujący zdobytą przez użytkownika wiedzę.") self.questions_button = self.control_panel_top.add_button( "Ustawienia", Paths.icon("settings.png")) self.questions_button.clicked.connect(self.show_settings) self.questions_button.set_hint( "Panel pozwalający dostosować użytkowanie aplikacji.") def on_change_algorithm(self, index): """ Zdarzenie zmiany algorytmu. Ustawia wybrany algorytm. Parametry: index - numer algorytmu. """ self.set_algorithm(index) pass def set_algorithm(self, index): """ Aktywuje dany algorytm. Parametry: index - numer algorytmu. """ self.current_index = index self.current_algorithm = self.algorithms[index] self.reset() self.show_description() def show_description(self): """ Wyświetla opis algorytmu """ self.reset() self.manager = DescriptionManager(self.main_widget, self.current_algorithm) def show_visualisation(self): """ Uruchamia zarządcę odpowiedzialnego za wizualizacje algorytmu. """ self.reset() self.manager = VisualisationManager(self.main_widget, self.current_algorithm) def show_questions(self): """ Uruchamia zarządcę odpowiedzialnego za pytania testowe. """ if len(self.current_algorithm.test_questions) > 0: self.reset() self.manager = QuestionsManager(self.main_widget, self.current_algorithm) def show_settings(self): """ Uruchomienie panelu konfiguracyjnego. """ self.settings_window = SettingsWindow() self.settings_window.show() def show_codes(self): """ Uruchamia zarządcę odpowiedzialnego za wyświetlanie implementacji. """ if len(self.current_algorithm.codes) > 0: self.reset() self.manager = CodesManager(self.main_widget, self.current_algorithm) def reset(self): """ Przywraca stan programu do stanu początkowego. """ self.setup_control_panel() self.center.clear_widget() self.manager = None pass
def settings_window(self): settingsWindow= SettingsWindow() settingsWindow.show() settingsWindow.exec_()
def settings_pressed(self, *args, **kwargs): SettingsWindow(self.root)
#!/usr/bin/env python3 import sys from GameWindow import GameWindow from SettingsWindow import SettingsWindow from PyQt5.QtWidgets import QApplication if __name__ == '__main__': currentExitCode = GameWindow.EXIT_CODE_CHANGE_MODE while currentExitCode == GameWindow.EXIT_CODE_CHANGE_MODE: app = QApplication(sys.argv) window = SettingsWindow() currentExitCode = app.exec_() app = None sys.exit(currentExitCode)