def __init__(self): super(MainWindow, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) # self.setAcceptDrops(True) self.scene = QGraphicsScene() self.originalImage = QImage() self.originalPixmap = QGraphicsPixmapItem() self.originalMat = None self.processedPixmap = QGraphicsPixmapItem() self.processedMat = None self.processedImage = QImage() self.filename = "" self.current_plugin_file = "" self.currentPlugin = None self.currentPluginGui = None self.load_settings() self.populate_plugin_menu() self.populate_languages_menu() self.populate_themes_menu() self.ui.graphicsView.setScene(self.scene) self.scene.addItem(self.originalPixmap) self.scene.addItem(self.processedPixmap) self.ui.graphicsView.setViewportUpdateMode( QGraphicsView.FullViewportUpdate) QApplication.instance().setStyle(QStyleFactory().keys()[2])
def generate_styles(self): """ Generates a list of available QStyles and returns it :return: """ available_styles = {} qsf = QStyleFactory() # Populate the QStyle dict for style in qsf.keys(): available_styles[style] = qsf.create(style) del qsf self.styles = available_styles
adicionales = [] for empresa in licitacion.empresas: for oferta in empresa.conjunto_ofertas.ofertas: ofertas.append(oferta) for adicional in empresa.adicionales: if not adicional.es_nulo(): adicionales.append(adicional) return datos_licitacion(licitacion, lotes, empresas, ofertas, adicionales) if __name__ == '__main__': app = QApplication(sysargv) #app.setAttribute(Qt.AA_NativeWindows, True) #print(QStyleFactory.keys()) app.setStyle(QStyleFactory().create("Fusion")) fuente = QFont() #fuente.setFamily("Cantarell") #fuente.setFamily("Candara") fuente.setFamily("Verdana") fuente.setPointSize(10) app.setFont(fuente) app.setWindowIcon(QIcon("iconos/auction.png")) pantalla_principal = PantallaPrincipal() splash = SplashScreen() splash.finish(pantalla_principal) while pantalla_principal.exec() == QDialog.Accepted: accion = pantalla_principal.obtener_accion() if accion == PantallaPrincipal.A_CREAR: print("Crear") licitador = crear_nueva_licitacion(
def __init__(self, filename=None, parent=None, name=None): """ Constructor @param filename name of a UI file to load @param parent parent widget of this window (QWidget) @param name name of this window (string) """ self.mainWidget = None self.currentFile = QDir.currentPath() super(UIPreviewer, self).__init__(parent) if not name: self.setObjectName("UIPreviewer") else: self.setObjectName(name) self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet")) self.resize(QSize(600, 480).expandedTo(self.minimumSizeHint())) self.statusBar() self.setWindowIcon(UI.PixmapCache.getIcon("eric.png")) self.setWindowTitle(self.tr("UI Previewer")) self.cw = QWidget(self) self.cw.setObjectName("centralWidget") self.UIPreviewerLayout = QVBoxLayout(self.cw) self.UIPreviewerLayout.setContentsMargins(6, 6, 6, 6) self.UIPreviewerLayout.setSpacing(6) self.UIPreviewerLayout.setObjectName("UIPreviewerLayout") self.styleLayout = QHBoxLayout() self.styleLayout.setContentsMargins(0, 0, 0, 0) self.styleLayout.setSpacing(6) self.styleLayout.setObjectName("styleLayout") self.styleLabel = QLabel(self.tr("Select GUI Theme"), self.cw) self.styleLabel.setObjectName("styleLabel") self.styleLayout.addWidget(self.styleLabel) self.styleCombo = QComboBox(self.cw) self.styleCombo.setObjectName("styleCombo") self.styleCombo.setEditable(False) self.styleCombo.setToolTip(self.tr("Select the GUI Theme")) self.styleLayout.addWidget(self.styleCombo) self.styleCombo.addItems(sorted(QStyleFactory().keys())) currentStyle = Preferences.Prefs.settings.value('UIPreviewer/style') if currentStyle is not None: self.styleCombo.setCurrentIndex(int(currentStyle)) styleSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.styleLayout.addItem(styleSpacer) self.UIPreviewerLayout.addLayout(self.styleLayout) self.previewSV = QScrollArea(self.cw) self.previewSV.setObjectName("preview") self.previewSV.setFrameShape(QFrame.NoFrame) self.previewSV.setFrameShadow(QFrame.Plain) self.previewSV.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.UIPreviewerLayout.addWidget(self.previewSV) self.setCentralWidget(self.cw) self.styleCombo.activated[str].connect(self.__guiStyleSelected) self.__initActions() self.__initMenus() self.__initToolbars() self.__updateActions() # defere loading of a UI file until we are shown self.fileToLoad = filename
from Client.src import src, resource pyqt = os.path.dirname(PyQt5.__file__) QApplication.addLibraryPath(os.path.join(pyqt, "plugins")) app = QApplication(sys.argv + ["--disable-web-security"]) id = QFontDatabase.addApplicationFont( str(resource("AlegreyaSans-Regular.ttf"))) family = QFontDatabase.applicationFontFamilies(id)[0] font = QFont(family) font.setPixelSize(14) font.setStyleName('Regular') app.setFont(font) app.setStyle(QStyleFactory().create('Fusion')) app.setApplicationName("СПбГУТ - Учет посещений") from BisitorLogger.client import init as LoggerInit LoggerInit() old_hook = sys.excepthook def catch_exceptions(exception_type, exception, tb): from Domain.Exception import BisitorException if isinstance(exception, BisitorException): exception.show(exception.window) else: from PyQt5.QtWidgets import QMessageBox import traceback QMessageBox().critical(
def run(): """Run the application""" # import faulthandler # faulthandler.enable() parser = argparse.ArgumentParser(prog="pyxrf", description="Command line arguments") parser.add_argument( "-l", "--loglevel", default="INFO", type=str, dest="loglevel", choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], help="Logger level. Set to 'DEBUG' in order to see debug information.", ) parser.add_argument( "-ct", "--color-theme", default="DEFAULT", type=str, dest="color_theme", choices=["DEFAULT", "DARK"], help="Color theme: DARK theme is only for debugging purposes.", ) args = parser.parse_args() # Setup the Logger logger.setLevel(args.loglevel) formatter = logging.Formatter( fmt="%(asctime)s : %(levelname)s : %(message)s") stream_handler = logging.StreamHandler() stream_handler.setFormatter(formatter) stream_handler.setLevel(args.loglevel) logger.addHandler(stream_handler) # Suppress warnings except if the program is run in debug mode if args.loglevel != "DEBUG": sys.tracebacklimit = 0 gpc = GlobalProcessingClasses() gpc.initialize() app = QApplication(sys.argv) # The default font looks bad on Windows, so one of the following (commonly available) # fonts will be selected in the listed order windows_font_selection = ["Verdana", "Microsoft Sans Serif", "Segoe UI"] available_font_families = list(QFontDatabase().families()) selected_font_family = None current_os = platform.system() if current_os == "Linux": style = "Fusion" elif current_os == "Windows": style = "Fusion" # Select font for font_family in windows_font_selection: if font_family in available_font_families: selected_font_family = font_family break elif current_os == "Darwin": style = "Fusion" available_styles = list(QStyleFactory().keys()) if style not in available_styles: logger.info(f"Current OS: {current_os}") logger.info( f"Style '{style}' is not in the list of available styles {available_styles}." ) app.setStyle(style) app.setApplicationName("PyXRF") # app.setStyleSheet('QWidget {font: "Roboto Mono"; font-size: 14px}') # app.setStyleSheet('QWidget {font-size: 14px}') if args.color_theme == "DARK": # Custom palette for Dark Mode palette = QPalette() palette.setColor(QPalette.Window, QColor(53, 53, 53)) palette.setColor(QPalette.WindowText, Qt.white) palette.setColor(QPalette.Base, QColor(25, 25, 25)) palette.setColor(QPalette.AlternateBase, QColor(53, 53, 53)) palette.setColor(QPalette.ToolTipBase, Qt.white) palette.setColor(QPalette.ToolTipText, Qt.white) palette.setColor(QPalette.Text, Qt.white) palette.setColor(QPalette.Button, QColor(53, 53, 53)) palette.setColor(QPalette.ButtonText, Qt.white) palette.setColor(QPalette.BrightText, Qt.red) palette.setColor(QPalette.Link, QColor(42, 130, 218)) palette.setColor(QPalette.Highlight, QColor(42, 130, 218)) palette.setColor(QPalette.HighlightedText, Qt.black) app.setPalette(palette) # Set font font = app.font() font.setPixelSize(14) if selected_font_family: logger.info( f"Replacing the default font with '{selected_font_family}'") font.setFamily(selected_font_family) app.setFont(font) # The style sheet replicates the default behavior of QToolTip on Ubuntu. # It may be helpful if some strange color theme is used. app.setStyleSheet("QToolTip {color: #000000; background-color: #FFFFCC; " "border-style: solid; border-radius: 3px; " "border-color: #444444; border-width: 1px;}") main_window = MainWindow(gpc=gpc) main_window.show() sys.exit(app.exec_())