Advertisement
EXTREMEXPLOIT

Old QComboBox & QMenu

Jan 7th, 2021
661
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1.     def addPythonVersions(self, pythonVersions):
  2.         """
  3.        Adding a list of Python Versions to the QComboBox and to the QMenu.
  4.        :param pythonVersions: This can be a list or a single string.
  5.        :return: Returns True if everything went good.
  6.        """
  7.         try:
  8.             nextItemIndex = len(self.pythonVersions)
  9.             if type(pythonVersions) is list:
  10.                 for newItem in pythonVersions:
  11.                     self.pythonVersions.insertItem(nextItemIndex, newItem)
  12.                     self.actionPython_Version.addAction(newItem)
  13.             else:
  14.                 self.pythonVersions.insertItem(nextItemIndex, pythonVersions)
  15.                 self.actionPython_Version.addAction(pythonVersions)
  16.         except Exception as ErrorCode:
  17.             raise PythonVersionError(f'Error while adding the python versions to QComboBox:\n{ErrorCode}')
  18.             return False
  19.         else:
  20.             self.pythonVersions.setCurrentIndex(0) # Setting the last Python Version as the default option.
  21.             return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement