コード例 #1
0
 def __init__(self):
     super(LoadDialog, self).__init__()
     self.ui = Ui_Dialog()
     self.ui.setupUi(self)
     self.detox_filenames()
     self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
     self.ui.listWidget.itemSelectionChanged.connect(self.selected_episode)
     self.accepted.connect(self.pressed_ok)
     self.episode_data = None
     self.okay = False
     for k, v in hashes.friendly_names.items():
         item = QListWidgetItem()
         path1 = (os.path.dirname(os.path.realpath(__file__)) +
                  "/saved_changes/" + k + ".json")
         path2 = (os.path.dirname(os.path.realpath(__file__)) + "/labels/" +
                  k + ".txt")
         if os.path.exists(path1):
             item.setData(32, path1)
             progress = import_export.check_progress(path1)
             item.setText(v + " (" + str(progress) + "% complete)")
             if progress == 100:
                 item.setBackgroundColor(QColor(20, 180, 20))
             else:
                 item.setBackgroundColor(QColor(180, 64, 20))
         elif os.path.exists(path2):
             item.setData(32, path2)
             item.setText(v)
         else:
             continue
         self.ui.listWidget.addItem(item)
コード例 #2
0
ファイル: main_window.py プロジェクト: Idir0825/PyNotes
    def color_changer(self, item: QtWidgets.QListWidgetItem):
        """
        Change the background color of the item in the list, and its foreground color depending on the background color
        :param item: A list widget item, the one that is currently selected
        """

        item.setBackgroundColor(QtGui.QColor(*item.note.color))
        if item.note.color not in [(255, 255, 255), [255, 255, 255],
                                   (202, 207, 210), [202, 207, 210]]:
            item.setForeground(QtGui.QColor("#FFFFFF"))
        else:
            item.setForeground(QtGui.QColor(*(0, 0, 0)))

        item.set_background_color()