choose_cd_dialog.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/usr/bin/env python3
  2. """
  3. Copyright © 2024 Noah Vogt <noah@noahvogt.com>
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. """
  15. from PyQt5.QtWidgets import ( # pylint: disable=no-name-in-module
  16. QApplication,
  17. QDialog,
  18. QVBoxLayout,
  19. QRadioButton,
  20. QPushButton,
  21. QMessageBox,
  22. QButtonGroup,
  23. QScrollArea,
  24. QWidget,
  25. )
  26. from PyQt5.QtGui import QColor, QIcon # pylint: disable=all
  27. from utils import (
  28. get_yyyy_mm_dd_date,
  29. make_sure_file_exists,
  30. is_valid_cd_record_checkfile,
  31. log,
  32. )
  33. from input import get_cachefile_content, validate_cd_record_config
  34. import config as const
  35. def stop_cd_recording() -> None:
  36. cachefile_content = get_cachefile_content(const.CD_RECORD_CACHEFILE)
  37. yyyy_mm_dd = get_yyyy_mm_dd_date()
  38. if is_valid_cd_record_checkfile(cachefile_content, yyyy_mm_dd):
  39. pass
  40. class RadioButtonDialog(QDialog):
  41. def __init__(self):
  42. super().__init__()
  43. self.setWindowTitle("Choose a CD to Burn")
  44. master_layout = QVBoxLayout(self)
  45. scroll_area = QScrollArea()
  46. scroll_area.setWidgetResizable(True)
  47. master_layout.addWidget(scroll_area)
  48. scroll_content = QWidget()
  49. scroll_area.setWidget(scroll_content)
  50. scroll_area_layout = QVBoxLayout(scroll_content)
  51. self.radio_button_group = QButtonGroup(self)
  52. self.radio_buttons = []
  53. for i in range(1, 101):
  54. radio_button = QRadioButton(f"Radio Button {i}")
  55. if i == 1:
  56. radio_button.setChecked(True)
  57. self.radio_buttons.append(radio_button)
  58. self.radio_button_group.addButton(radio_button)
  59. scroll_area_layout.addWidget(radio_button)
  60. ok_button = QPushButton("OK")
  61. ok_button.clicked.connect(self.accept)
  62. master_layout.addWidget(ok_button)
  63. def accept(self):
  64. selected_button = self.radio_button_group.checkedButton()
  65. if selected_button:
  66. QMessageBox.information(
  67. self, "Selection", f"You selected: {selected_button.text()}"
  68. )
  69. super().accept()
  70. else:
  71. QMessageBox.warning(
  72. self,
  73. "No Selection",
  74. "Please select an option before proceeding.",
  75. )
  76. def main() -> None:
  77. validate_cd_record_config()
  78. make_sure_file_exists(const.CD_RECORD_CACHEFILE)
  79. app = QApplication([])
  80. dialog = RadioButtonDialog()
  81. if dialog.exec_() == QDialog.Accepted:
  82. print("Dialog accepted.")
  83. if __name__ == "__main__":
  84. main()