Exemple #1
0
 def roi_saved(self, new_rtss):
     """ Create a new ROI in Structure Tab and notify user """
     new_roi_name = self.new_roi_name_line_edit.text()
     self.signal_roi_manipulated.emit((new_rtss, {"draw": new_roi_name}))
     QMessageBox.about(self.manipulate_roi_window_instance, "Saved",
                       "New contour successfully created!")
     self.close()
    def save_options(self):
        """
        Saves options selected in the first time welcome window.
        """
        self.filepath = self.first_time_welcome_input_box.text()
        self.csv_path = self.clinical_data_csv_input_box.text()
        if self.filepath == "" and self.csv_path == "":
            QMessageBox.about(self, "Unable to proceed",
                              "No directories selected.")
        elif not os.path.exists(self.filepath) or not \
                os.path.exists(self.csv_path):
            QMessageBox.about(self, "Unable to proceed",
                              "Directories do not exist")
        else:
            config = Configuration()
            try:
                config.update_default_directory(self.filepath)

                # Update CSV path if it exists
                if self.csv_path != "" and os.path.exists(self.csv_path):
                    config.update_clinical_data_csv_dir(self.csv_path)
            except SqlError:
                config.set_up_config_db()
                QMessageBox.critical(
                    self, "Config file error",
                    "Failed to access configuration file.\nPlease try again.")
            else:
                self.configured.emit(self.filepath)
Exemple #3
0
    def on_search_complete(self, dicom_structure):
        """
        Executes once the directory search is complete.
        :param dicom_structure: DICOMStructure object constructed by the
        directory search.
        """
        self.open_patient_directory_choose_button.setEnabled(True)
        self.open_patient_window_stop_button.setVisible(False)
        self.open_patient_window_patients_tree.clear()

        # dicom_structure will be None if function was interrupted.
        if dicom_structure is None:
            return

        for patient_item in dicom_structure.get_tree_items_list():
            self.open_patient_window_patients_tree.addTopLevelItem(
                patient_item)
            patient_item.setExpanded(True)  # Display all studies
            # Display all image sets
            for i in range(patient_item.childCount()):
                study = patient_item.child(i)
                study.setExpanded(True)

        if len(dicom_structure.patients) == 0:
            QMessageBox.about(self, "No files found",
                              "Selected directory contains no DICOM files.")
 def about(self):
     QMessageBox.about(
         self, "About Dock Widgets",
         "The <b>Dock Widgets</b> example demonstrates how to use "
         "Qt's dock widgets. You can enter your own text, click a "
         "customer to add a customer name and address, and click "
         "standard paragraphs to add them.")
 def on_rois_deleted(self, new_rtss):
     self.deleting_rois_structure_tuple.emit((new_rtss, {
         "delete":
         self.regions_of_interest_to_delete
     }))
     QMessageBox.about(self, "Saved",
                       "Regions of interest successfully deleted!")
     self.close()
 def roi_saved(self, new_rtss):
     """
         Function to call save ROI and display progress
     """
     self.signal_roi_drawn.emit((new_rtss, {"draw": self.ROI_name}))
     QMessageBox.about(self.draw_roi_window_instance, "Saved",
                       "New contour successfully created!")
     self.closeWindow()
Exemple #7
0
 def about(self):
     QMessageBox.about(
         self, "About Baloviewer",
         """<p align='center'><b>Baloviewer</b></p>
                       <p align='center'>An Image Viewer</p>
                       <p align='center'>Copyright © 2019 Baloby</p>
                       <p align='center'>Licence: GNU General Public License Version 3</p>"""
     )
Exemple #8
0
 def loadSettings(self):
     try:
         self.settings = Settings('user.json')
     except:
         QMessageBox.about(
             None, "Corrupt data",
             "It looks like your TritonAuth data has become corrupted. Please restore an earlier backup to resolve this issue."
         )
         sys.exit()
def open_about(parent) -> None:
    text = f"""
<strong>Jabba's Image Viewer {cfg.VERSION}</strong>

<a href="https://github.com/jabbalaci/JiVE-Image-Viewer">https://github.com/jabbalaci/JiVE-Image-Viewer</a>

Laszlo Szathmary (Jabba Laci), 2018--2020
[email protected]
""".strip().replace("\n", "<br>")
    QMessageBox.about(parent, "About", text)
    def onTransferRoiError(self, exception):
        """
        This function is triggered when there is an error in the
        ROI transferring process.

        :param exception: exception thrown
        """
        QMessageBox.about(self.progress_window, "Unable to transfer ROIs",
                          "Please check your image set and ROI data.")
        self.progress_window.close()
Exemple #11
0
    def on_rois_deleted(self, new_rtss):
        """

        This function is triggered when ROIs are deleted
        :param new_rtss: the new rtss after ROIs are deleted

        """
        self.deleting_rois_structure_tuple.\
            emit((new_rtss, {"delete": self.regions_of_interest_to_delete}))
        QMessageBox.about(self, "Saved", "Regions of interest successfully "
                                         "deleted!")
        self.close()
 def onPreviewClicked(self):
     """
     function triggered when Preview button is clicked
     """
     if hasattr(self, 'drawingROI') and self.drawingROI and len(
             self.drawingROI.target_pixel_coords) > 0:
         alpha = float(self.input_alpha_value.text())
         polygon_list = calculate_concave_hull_of_points(
             self.drawingROI.target_pixel_coords, alpha)
         self.drawingROI.draw_contour_preview(polygon_list)
     else:
         QMessageBox.about(self.draw_roi_window_instance, "Not Enough Data",
                           "Please ensure you have drawn your ROI first.")
Exemple #13
0
 def connect_to_device(self, port):
     if port == "":
         QMessageBox.about(
             self.main_window,
             "Connection failed",
             "Could not connect to device. No port is selected.",
         )
     elif port not in self.get_ports_names():
         QMessageBox.about(
             self.main_window,
             "Connection failed",
             f"Could not connect to device. Port {port} not available. Refresh and try again.",
         )
     else:
         self.device.connect(port)
Exemple #14
0
 def on_loading_error(self, exception):
     """
     Error handling for progress window.
     """
     if type(exception[1]) == ImageLoading.NotRTSetError:
         QMessageBox.about(self.progress_window,
                           "Unable to open selection",
                           "Selected files cannot be opened as they are not"
                           " a DICOM-RT set.")
         self.progress_window.close()
     elif type(exception[1]) == ImageLoading.NotAllowedClassError:
         QMessageBox.about(self.progress_window,
                           "Unable to open selection",
                           "Selected files cannot be opened as they contain"
                           " unsupported DICOM classes.")
         self.progress_window.close()
Exemple #15
0
 def on_loading_error(self, error_code):
     """
     Error handling for progress window.
     """
     if error_code == 0:
         QMessageBox.about(
             self.progress_window, "Unable to open selection",
             "Selected files cannot be opened as they are not a DICOM-RT set."
         )
         self.progress_window.close()
     elif error_code == 1:
         QMessageBox.about(
             self.progress_window, "Unable to open selection",
             "Selected files cannot be opened as they contain unsupported DICOM classes."
         )
         self.progress_window.close()
    def patient_B_initial_roi_double_clicked(self, item):
        """
        This function is triggered when a roi in patient B's roi list is
        double-clicked.
        """
        roi_to_add = item.data(Qt.UserRole)
        transferred_roi_name = roi_to_add['name']

        # If the clicked roi is already transferred, return
        if transferred_roi_name in self.moving_to_fixed_rois.keys():
            QMessageBox.about(self, "Transfer Failed",
                              "Chosen ROI has already been transferred!")
            return

        # Create a set to store all current roi names in target patient
        # including both initial rois name and added roi names so far
        patient_A_current_roi_name_list = set()

        for item in self.moving_to_fixed_rois.values():
            patient_A_current_roi_name_list.add(item)

        for idx in self.fixed_image_initial_rois:
            patient_A_current_roi_name_list.add(
                self.fixed_image_initial_rois[idx]['name'])

        # Check if clicked roi name has duplicate in
        # target patient's roi names list
        if transferred_roi_name in patient_A_current_roi_name_list:
            # if add suffix is ticked, iteratively try adding suffix
            # from _A to _Z, stop when no duplicate found
            if self.add_suffix:
                transferred_roi_name = generate_non_duplicated_name(
                    transferred_roi_name, patient_A_current_roi_name_list)
            else:
                QMessageBox.about(
                    self, "Transfer Failed", "Duplicated ROI name. "
                    "Please consider adding suffix.")
                return

        # Add clicked roi to transferred list
        self.moving_to_fixed_rois[roi_to_add['name']] = transferred_roi_name
        roi_label = QListWidgetItem(transferred_roi_name)
        roi_label.setForeground(Qt.red)
        roi_label.setData(Qt.UserRole, roi_to_add)
        self.patient_B_rois_to_A_list_widget.addItem(roi_label)
        self.save_button.setDisabled(False)
    def saveROIList(self):
        """
            Function triggered when saving ROI list
        """
        roi_list = ROI.convert_hull_list_to_contours_data(
            self.drawn_roi_list, self.patient_dict_container)
        if len(roi_list) == 0:
            QMessageBox.about(self.draw_roi_window_instance, "No ROI Detected",
                              "Please ensure you have drawn your ROI first.")
            return

        # The list of points will need to be converted into a
        # single-dimensional array, as RTSTRUCT contour data is stored in
        # such a way. i.e. [x, y, z, x, y, z, x, y, z, ..., ...] Create a
        # popup window that modifies the RTSTRUCT and tells the user that
        # processing is happening.
        connectSaveROIProgress(self, roi_list, self.dataset_rtss,
                               self.ROI_name, self.roi_saved)
Exemple #18
0
    def helpText(self):
        print("Button clicked, Hello!")
        Qmsgb = QMessageBox.about(
            self.window, 'rule',
            '''        游戏规则很简单,就是猜数字游戏,直到猜对位置,随机给出四个数,且不重复。
根据系统的提示,猜对数字和数字位置则为A,猜对数字而没猜对位置则为B。\n
如:如果给出的数字为5246,你猜的数为5678,则会报出1A1B,因为5是位
置和数字都猜对了,另一个是6只猜对了数字没猜对位置,其他是位置和数字
都没猜对,所以为0A0B。\n
聪明的你明白规则了吗?明白了咱们就开始吧''')
 def save_default_dir(self):
     self.filepath = self.first_time_welcome_input_box.text()
     if self.filepath == "":
         QMessageBox.about(self, "Unable to proceed",
                           "No directory selected.")
     elif not os.path.exists(self.filepath):
         QMessageBox.about(self, "Unable to proceed",
                           "Directory does not exist")
     else:
         config = Configuration()
         try:
             config.update_default_directory(self.filepath)
         except SqlError:
             config.set_up_config_db()
             QMessageBox.critical(
                 self, "Config file error",
                 "Failed to access configuration file.\nPlease try again.")
         else:
             self.configured.emit(self.filepath)
    def set_selected_roi_name(self, roi_name):
        """
        function to set selected roi name
        :param roi_name: roi name selected
        """
        roi_exists = False

        patient_dict_container = PatientDictContainer()
        existing_rois = patient_dict_container.get("rois")
        number_of_rois = len(existing_rois)

        # Check to see if the ROI already exists
        for key, value in existing_rois.items():
            if roi_name in value['name']:
                roi_exists = True

        if roi_exists:
            QMessageBox.about(self.draw_roi_window_instance,
                              "ROI already exists in RTSS",
                              "Would you like to continue?")

        self.ROI_name = roi_name
        self.roi_name_line_edit.setText(self.ROI_name)
 def onTransferRoiFinished(self, result):
     """
     This function is triggered when ROI transferring process is finished.
     """
     # emit changed dataset to structure_modified function and
     # auto_save_roi function
     if result[0] is True:
         if len(self.fixed_to_moving_rois) > 0:
             self.signal_roi_transferred_to_moving_container.emit(
                 (self.moving_dict_container.get("dataset_rtss"), {
                     "transfer": None
                 }))
         if len(self.moving_to_fixed_rois) > 0:
             self.signal_roi_transferred_to_fixed_container.emit(
                 (self.patient_dict_container.get("dataset_rtss"), {
                     "transfer": None
                 }))
         self.progress_window.close()
         QMessageBox.about(self.transfer_roi_window_instance, "Saved",
                           "ROIs are successfully transferred!")
     else:
         QMessageBox.about(self.transfer_roi_window_instance, "Cancelled",
                           "ROIs Transfer is cancelled.")
     self.closeWindow()
    def onDrawClicked(self):
        """
        Function triggered when the Draw button is pressed from the menu.
        """
        pixmaps = self.patient_dict_container.get("pixmaps_axial")

        if self.min_pixel_density_line_edit.text() == "" \
                or self.max_pixel_density_line_edit.text() == "":
            QMessageBox.about(self.draw_roi_window_instance, "Not Enough Data",
                              "Not all values are specified or correct.")
        else:
            # Getting most updated selected slice
            id = self.current_slice

            dt = self.patient_dict_container.dataset[id]
            dt.convert_pixel_data()

            # Path to the selected .dcm file
            location = self.patient_dict_container.filepaths[id]
            self.ds = pydicom.dcmread(location)

            min_pixel = self.min_pixel_density_line_edit.text()
            max_pixel = self.max_pixel_density_line_edit.text()

            # If they are number inputs
            if min_pixel.isdecimal() and max_pixel.isdecimal():

                min_pixel = int(min_pixel)
                max_pixel = int(max_pixel)

                if min_pixel >= max_pixel:
                    QMessageBox.about(
                        self.draw_roi_window_instance, "Incorrect Input",
                        "Please ensure maximum density is "
                        "atleast higher than minimum density.")

                self.drawingROI = Drawing(
                    pixmaps[id], dt._pixel_array.transpose(), min_pixel,
                    max_pixel, self.patient_dict_container.dataset[id],
                    self.draw_roi_window_instance, self.slice_changed,
                    self.current_slice, self.drawing_tool_radius,
                    self.keep_empty_pixel, set())
                self.slice_changed = True
                self.dicom_view.view.setScene(self.drawingROI)
                self.enable_cursor_radius_change_box()
            else:
                QMessageBox.about(self.draw_roi_window_instance,
                                  "Not Enough Data",
                                  "Not all values are specified or correct.")
Exemple #23
0
    def CheckNum(self):
        '''

        '''
        #enter check
        print(self.window.LEditNum.text())
        FourNumStr = self.window.LEditNum.text()
        str1 = re.findall(r'\d+', FourNumStr)
        if (not self.IsInputNumOK(FourNumStr)):
            QMessageBox.about(self.window, 'error', 'please enter again')
            return
        FourNum = []
        for num in str1:
            FourNum.append(int(num))
        Num1 = FourNum

        #compare and output
        [a, b] = self.ABNum(self.Num0, Num1)

        abstr = str(a) + 'A' + str(b) + 'B'
        entercell = QTableWidgetItem(FourNumStr)

        resultcell = QTableWidgetItem(abstr)
        self.window.tableWidget.setItem(7 - self.life, 0, entercell)
        self.window.tableWidget.setItem(7 - self.life, 1, resultcell)
        self.window.LEditResult.setReadOnly(False)
        self.window.LEditResult.setText(abstr)
        self.window.LEditResult.setReadOnly(True)

        if (self.ABNum(self.Num0, Num1)[0] == 4):
            print("Win")
            QMessageBox.about(self.window, 'win', 'game win\n')
            self.gameInit()
            return

        self.life = self.life - 1
        self.window.lcdNumber.display(self.life)
        if (self.life == 0):
            QMessageBox.about(self.window, 'lose',
                              'game lose\nplease try again')
            self.gameInit
Exemple #24
0
 def slot_show_about_dialog(self):
     QMessageBox.about(self, 'The Little Hat',
                       'The Little Hat\nVersion: 0.0')  # TODO
Exemple #25
0
class MineSweeper(QMainWindow):
	def __init__(self):
		super().__init__()

		self.undiscovered_color: str = "#000000"
		self.discovered_color: str = "#d9d9d9"
		self.win_timer_color: str = "#e30e0e"
		self.lose_timer_color: str = "#0cc431"


		self.curr_time = QTime(00,00,00)
		self.timer = QTimer()
		self.timer.timeout.connect(self.time)
		self.timer_already_started = False

		self.solved: bool = False
		
		self.player_ended: bool = False

		self.theme: str = "dark"

		self.list_of_mines: list = []

		self.difficulty_slider_default_value: int = 2
		self.number_of_mines: int = mines_number(NUMBER_OF_LABELS, self.difficulty_slider_default_value)


		self.create_GUI()

	def create_GUI(self) -> None:
		self.setWindowTitle("MineSweeper 1.1")

		self.win_massage = QMessageBox(self)
		self.win_massage.setText("Gratuluji, dokázal jsi nalézt všechny miny")

		self.setMouseTracking(True)

		centralWidget = QWidget(self)
		centralWidget.setStyleSheet("background: white")
		self.setCentralWidget(centralWidget)
		self.setFixedSize(X_WINDOW_SIZE + 20, Y_WINDOW_SIZE)

		layout = QGridLayout(centralWidget)
		layout.setSpacing(0)
		layout.setContentsMargins(0, 0, 0, 0)
		centralWidget.setLayout(layout)

		self.list_of_labels: list = []

		self.list_of_mines = generate_mines(self.number_of_mines, X_SIZE, Y_SIZE)

		# RESET BUTTON
		self.reset_button = QPushButton(centralWidget)
		self.reset_button.setText("RESET")
		self.reset_button.clicked.connect(self.reset)
		self.reset_button.setStyleSheet("margin: 3px")
		self.reset_button.setMinimumSize(0, 50)

		# TIMER LABEL
		self.timer_label = QLabel(centralWidget)
		self.timer_label.setText(f"{self.curr_time.minute():0>2}:{self.curr_time.second():0>2}")
		self.timer_label.setAlignment(Qt.AlignHCenter)
		self.timer_label.setStyleSheet("font: 34px")

		# DIFFICULTY SLIDER
		self.difficulty_slider = QSlider(centralWidget)
		self.difficulty_slider.setOrientation(Qt.Horizontal)
		self.difficulty_slider.setFixedHeight(30)
		self.difficulty_slider.setRange(1, 10)
		self.difficulty_slider.setTickInterval(1)
		self.difficulty_slider.setValue(self.difficulty_slider_default_value)
		self.difficulty_slider.valueChanged.connect(self.difficulty_label_set)
		self.difficulty_slider.sliderReleased.connect(self.new_mines_set)

		# DIFFICULTY LABEL
		self.difficulty_label = QLabel(centralWidget)
		self.difficulty_label.setText(str(self.difficulty_slider_default_value))
		self.difficulty_label.setAlignment(Qt.AlignCenter)
		self.difficulty_label.setStyleSheet("font: 20px")
		
		

		for i in range(Y_SIZE):
			row = []
			for j in range(X_SIZE):
				if (i, j) in self.list_of_mines:
					mine = True
				else:
					mine = False

				label = Chunk(j, i, mine)
				label.setFixedSize(FIELD_SQUARE_SIZE, FIELD_SQUARE_SIZE)
				label.setStyleSheet(f"background: {self.undiscovered_color}; border: 1px solid grey")
				layout.addWidget(label, i, j)
				row.append(label)
			self.list_of_labels.append(row)


		self.color_theme_combobox = QComboBox(centralWidget)
		self.color_theme_combobox.addItem("Dark theme", "dark")
		self.color_theme_combobox.addItem("Light theme", "light")
		self.color_theme_combobox.addItem("Color theme", "colorful")
		self.color_theme_combobox.currentIndexChanged.connect(self.theme_change)
		self.color_theme_combobox.setMinimumHeight(FIELD_SQUARE_SIZE * 2)
		if self.theme == "dark":
			self.color_theme_combobox.setCurrentIndex(0)
		elif self.theme == "light":
			self.color_theme_combobox.setCurrentIndex(1)
		else:
			self.color_theme_combobox.setCurrentIndex(2)
		layout.addWidget(self.color_theme_combobox, Y_SIZE - 2, X_SIZE, 2, 1)

		layout.addWidget(self.timer_label, 0, X_SIZE, 3, 1)
		layout.addWidget(self.reset_button, 2, X_SIZE, 3, 1)
		layout.addWidget(self.difficulty_slider, Y_SIZE, 1, 1, X_SIZE - 2)
		layout.addWidget(self.difficulty_label, Y_SIZE, X_SIZE, 1, 1)

		self.mines_number_surroundings_calculate()

	def theme_change(self) -> None:
		if self.color_theme_combobox.currentData() == "light":
			self.undiscovered_color = LIGHT_THEME["undiscovered_color"]
			self.discovered_color = LIGHT_THEME["discovered_color"]
			self.win_timer_color = LIGHT_THEME["win_timer_color"]
			self.lose_timer_color = LIGHT_THEME["lose_timer_color"]
			self.theme = "light"
	
		if self.color_theme_combobox.currentData() == "dark":	
			self.undiscovered_color = DARK_THEME["undiscovered_color"]
			self.discovered_color = DARK_THEME["discovered_color"]
			self.win_timer_color = DARK_THEME["win_timer_color"]
			self.lose_timer_color = DARK_THEME["lose_timer_color"]
			self.theme = "dark"

		if self.color_theme_combobox.currentData() == "colorful":	
			self.undiscovered_color = COLOR_THEME["undiscovered_color"]
			self.discovered_color = COLOR_THEME["discovered_color"]
			self.win_timer_color = COLOR_THEME["win_timer_color"]
			self.lose_timer_color = COLOR_THEME["lose_timer_color"]
			self.theme = "colorful"

		for y in range(Y_SIZE):
			for x in range(X_SIZE):	 
				if self.list_of_labels[y][x].marked:
					pass

				elif not self.list_of_labels[y][x].discovered:
					self.list_of_labels[y][x].setStyleSheet(f"background: {self.undiscovered_color}; border: 1px solid grey")

				elif self.list_of_labels[y][x].discovered:
					self.list_of_labels[y][x].setStyleSheet(f"background: {self.discovered_color}; border: 1px solid grey")
		
	def difficulty_label_set(self):
		self.difficulty_label.setText(str(self.difficulty_slider.value()))

	def mousePressEvent(self, QMouseEvent) -> None:
		if not self.player_ended:

			y = QMouseEvent.pos().x()
			x = QMouseEvent.pos().y()

			if not (x > X_GRID_SIZE or y > Y_GRID_SIZE):

				x = closest_smaller_number(x, Y_POSSIBLE_VALUES)
				y = closest_smaller_number(y, X_POSSIBLE_VALUES)

				x = int(x // FIELD_SQUARE_SIZE)
				y = int(y // FIELD_SQUARE_SIZE)

				if QMouseEvent.button() == Qt.LeftButton:
					if self.list_of_labels[x][y].mine:				
						self.stop_timer()
						if not self.player_ended:
							self.list_of_labels[x][y].discovered = True
							self.list_of_labels[x][y].setStyleSheet(f"background: {self.discovered_color}; border: 1px solid grey")
							self.list_of_labels[x][y].setPixmap(QPixmap("C:/Data/python/miny/pracovní verze/pictures/bomb_small.png"))
							self.win_massage.about(self, "PROHRA", "Tentokrát se to bohužel nepovedlo, snad to vyjde příště.")
					
						self.player_ended = True
					else:
						if not self.timer_already_started:
							self.start_timer()

						self.timer_already_started = True
						self.list_of_labels[x][y].discovered = True
						self.list_of_labels[x][y].setStyleSheet(f"background: {self.discovered_color}; border: 1px solid grey")

						self.reveal_area(y, x)

					self.solved_check()

				else:
					if not self.list_of_labels[x][y].discovered:
						if self.list_of_labels[x][y].marked:
							self.list_of_labels[x][y].setStyleSheet(f"background: {self.undiscovered_color}; border: 1px solid grey")
							self.list_of_labels[x][y].marked = False

						else:
							self.list_of_labels[x][y].setStyleSheet("background: orange; border: 1px solid grey")
							self.list_of_labels[x][y].marked = True

	def mines_number_surroundings_calculate(self) -> None:
		for x in range(X_SIZE):
			for y in range(Y_SIZE):
				self.list_of_labels[x][y].mines_number_surroundings = 0
				for i in range(x - 1, x + 2):
					for j in range(y - 1, y + 2):
						try:
							if self.list_of_labels[i][j].mine and i >= 0 and j >= 0:
								if not (i == x and j == y):
									self.list_of_labels[x][y].mines_number_surroundings += 1
						except IndexError:
							pass

	def new_mines_set(self):
		self.number_of_mines = mines_number(NUMBER_OF_LABELS, self.difficulty_slider.value())
		self.list_of_mines = generate_mines(self.number_of_mines, X_SIZE, Y_SIZE)
		for y in range(Y_SIZE):
			for x in range(X_SIZE):
				if (y, x) in self.list_of_mines:
					self.list_of_labels[y][x].mine = True
				else:
					self.list_of_labels[y][x].mine = False

		self.mines_number_surroundings_calculate()
		self.label_set()

	def label_set(self) -> None:
		for y in range(Y_SIZE):
			for x in range(X_SIZE):
				if self.list_of_labels[y][x].discovered:
					if self.list_of_labels[y][x].mines_number_surroundings == 0:
						pass
					else:
						self.list_of_labels[y][x].setText(str(self.list_of_labels[y][x].mines_number_surroundings))

	def reveal_area(self, x: int, y: int) -> None:
		if self.list_of_labels[y][x].mines_number_surroundings == 0:		
			try:
				extract = self.list_of_labels[y - 1][x]

				if not extract.mine and Y_SIZE > y - 1 >= 0 and not extract.discovered:
					self.list_of_labels[y - 1][x].setStyleSheet(f"background: {self.discovered_color}; border: 1px solid grey")
					self.list_of_labels[y - 1][x].discovered = True
					if extract.mines_number_surroundings == 0:
						self.reveal_area(x, y - 1)

			except IndexError:
				pass

			try:
				extract = self.list_of_labels[y + 1][x]

				if not extract.mine and Y_SIZE > y + 1 >= 0 and not extract.discovered:
					self.list_of_labels[y + 1][x].setStyleSheet(f"background: {self.discovered_color}; border: 1px solid grey")
					self.list_of_labels[y + 1][x].discovered = True
					if extract.mines_number_surroundings == 0:
						self.reveal_area(x, y + 1)

			except IndexError:
				pass

			try:
				extract = self.list_of_labels[y][x + 1]

				if not extract.mine and X_SIZE > x + 1 >= 0 and not extract.discovered:
					self.list_of_labels[y][x + 1].setStyleSheet(f"background: {self.discovered_color}; border: 1px solid grey")
					self.list_of_labels[y][x + 1].discovered = True
					if extract.mines_number_surroundings == 0:
						self.reveal_area(x + 1, y)

			except IndexError:
				pass

			try:
				extract = self.list_of_labels[y][x - 1]

				if not extract.mine and X_SIZE - 1 > x  - 1 >= 0 and not extract.discovered:
					self.list_of_labels[y][x - 1].setStyleSheet(f"background: {self.discovered_color}; border: 1px solid grey")
					self.list_of_labels[y][x - 1].discovered = True
					if extract.mines_number_surroundings == 0:
						self.reveal_area(x - 1, y)

			except IndexError:
				pass

		self.label_set()

	def solved_check(self) -> None:
		for element in self.list_of_labels:
			for part in element:
				if not part.mine and not part.discovered:
					return

		self.solved = True
		self.stop_timer()

		if not self.player_ended:
			self.player_ended = True
			self.win_massage.about(self, "VÝHRA", f"Gratuluji, zvládl/a jsi vyřešit tento problém. Zvládl/a jsi to za {self.curr_time.minute():0>2}:{self.curr_time.second():0>2}")

	# TIMER FUNCIONS
	def start_timer(self) -> None:
		self.difficulty_slider.setDisabled(True)
		self.timer.start(1000)
		
	def stop_timer(self) -> None:
		self.timer.stop()
		if not self.solved:
			self.timer_label.setStyleSheet(f"font: 34px; color: {self.win_timer_color}")
		else:
			self.timer_label.setStyleSheet(f"font: 34px; color: {self.lose_timer_color}")

	def time(self) -> None:
		self.curr_time = self.curr_time.addSecs(1)
		self.timer_label.setText(f"{self.curr_time.minute():0>2}:{self.curr_time.second():0>2}")

	#RESET
	def reset(self) -> None:
		self.timer = QTimer()
		self.curr_time = QTime(00,00,00)
		self.timer.timeout.connect(self.time)
		self.solved = False
		self.timer_already_started = False
		self.player_ended = False
		self.difficulty_slider.setDisabled(False)
		self.difficulty_slider_default_value = self.difficulty_slider.value()
		self.create_GUI()
 def about(self):
     QMessageBox.about(
         self, self.tr("About Books"),
         self.tr(
             "<p>The <b>Books</b> example shows how to use Qt SQL classes "
             "with a model/view framework."))
Exemple #27
0
 def about(self):
     QMessageBox.about(self, "About Settings Editor",
             "The <b>Settings Editor</b> example shows how to access "
             "application settings using Qt.")
Exemple #28
0
 def show_no_connection_message(self):
     QMessageBox.about(
         self.main_window,
         "Device not connected",
         "No device is connected. Connect a device first.",
     )
Exemple #29
0
 def show_message_box(self):
     reply = QMessageBox.about(self, 'Message', "lel")
Exemple #30
0
 def show_version(self):
     QMessageBox.about(self, "about", "version 0.0.1a")