def main(filepath): if not check_dependencies(): sys.exit(1) set_app_user_model_id() from PySide2.QtWidgets import QApplication from PySide2.QtGui import QFontDatabase from .logic import GlobalInfo from .ui.css import CSS from .ui.main_window import MainWindow from .config import FONT_LOCATION app = QApplication(sys.argv) # Load fonts QFontDatabase.addApplicationFont(os.path.join(FONT_LOCATION, "SourceCodePro-Regular.ttf")) GlobalInfo.gui_thread = threading.get_ident() # apply the CSS app.setStyleSheet(CSS.global_css()) MainWindow(file_to_open=filepath if filepath else sys.argv[1] if len(sys.argv) > 1 else None) app.exec_()
def fonts(self): '''Add fonts to the Qt Font Database.''' QFontDatabase.addApplicationFont(u':/fonts/OpenSans-Bold.ttf') QFontDatabase.addApplicationFont(u':/fonts/OpenSans-ExtraBold.ttf') QFontDatabase.addApplicationFont(u':/fonts/OpenSans-Regular.ttf') QFontDatabase.addApplicationFont(u':/fonts/OpenSans-SemiBold.ttf') QFontDatabase.addApplicationFont(u':/fonts/OpenSans-SemiBold.ttf')
def __init__(self): super(MainWindow, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) QFontDatabase.addApplicationFont('../resources/fonts/source code pro/SourceCodePro-Regular.ttf') self.nodes = [] self.nodes_list_widget = NodesListWidget(self) self.ui.nodes_scrollArea.setWidget(self.nodes_list_widget) # shortcuts save_shortcut = QShortcut(QKeySequence.Save, self) save_shortcut.activated.connect(self.save_triggered) import_nodes_shortcut = QShortcut(QKeySequence('Ctrl+i'), self) import_nodes_shortcut.activated.connect(self.import_nodes_triggered) # UI self.ui.splitter.setSizes([200, 850]) self.setWindowTitle('Ryven NodeManager') self.setWindowIcon(QIcon('resources/pics/program_icon2.png')) self.load_stylesheet('dark') self.ui.add_new_node_pushButton.clicked.connect(self.add_new_node_pushButton_clicked) self.ui.import_nodes_pushButton.clicked.connect(self.import_nodes_triggered) self.ui.clear_nodes_pushButton.clicked.connect(self.clear_button_clicked) self.ui.save_pushButton.clicked.connect(self.save_triggered)
def __init__(self, config): super(MainWindow, self).__init__() QFontDatabase.addApplicationFont('fonts/poppins/Poppins-Medium.ttf') QFontDatabase.addApplicationFont('fonts/source code pro/SourceCodePro-Regular.ttf') self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.splitter.setSizes([120, 800]) self.setWindowTitle('pyScript') self.setWindowIcon(QIcon('stuff/pics/program_icon.png')) self.load_stylesheet('dark') self.ui.scripts_tab_widget.removeTab(0) self.ui.actionImport_Nodes.triggered.connect(self.on_import_nodes_triggered) self.ui.actionSave_Project.triggered.connect(self.on_save_project_triggered) self.ui.actionDesignDark_Std.triggered.connect(self.on_dark_std_design_triggered) self.ui.actionDesignDark_Tron.triggered.connect(self.on_dark_tron_design_triggered) self.ui.actionEnableDebugging.triggered.connect(self.on_enable_debugging_triggered) self.ui.actionDisableDebugging.triggered.connect(self.on_disable_debugging_triggered) self.ui.actionSave_Pic_Viewport.triggered.connect(self.on_save_scene_pic_viewport_triggered) self.ui.actionSave_Pic_Whole_Scene_scaled.triggered.connect(self.on_save_scene_pic_whole_triggered) # Shortcuts save_shortcut = QShortcut(QKeySequence.Save, self) save_shortcut.activated.connect(self.on_save_project_triggered) self.custom_nodes = [] self.all_nodes = [SetVariable_Node(), GetVariable_Node()] # holds NI subCLASSES for imported nodes: self.all_node_instance_classes = { self.all_nodes[0]: SetVar_NodeInstance, self.all_nodes[1]: GetVar_NodeInstance } # (key: node obj, val: NI subclass) (used in Flow) # {node : {str: PortInstanceWidget-subclass}} (used in PortInstance) self.custom_node_input_widget_classes = {} # clear temp folder for f in os.listdir('temp'): os.remove('temp/'+f) self.scripts = [] self.scripts_list_widget = ScriptsListWidget(self, self.scripts) self.ui.scripts_scrollArea.setWidget(self.scripts_list_widget) self.ui.add_new_script_pushButton.clicked.connect(self.create_new_script_button_pressed) self.ui.new_script_name_lineEdit.returnPressed.connect(self.create_new_script_le_return_pressed) self.design_style = 'dark std' if config['config'] == 'create plain new project': self.try_to_create_new_script() elif config['config'] == 'open project': self.import_required_packages(config['required packages']) self.parse_project(config['content']) self.resize(1500, 800)
def __init__(self, *args, **kwargs): super(MenuWindow, self).__init__(*args, **kwargs) # Loading Fonts QFontDatabase.addApplicationFont("fonts/BebasNeue-Light.ttf") # Window Settings self.setFixedSize(1280, 720) self.setWindowTitle("Systeme d'apprentissage base sur les reseaux de neurones") #background = QPixmap("images/menu") #palette = QPalette() #palette.setBrush(QPalette.Background, background) #self.setAttribute(Qt.WA_StyledBackground, True) #self.setPalette(palette) self.setAutoFillBackground(True) background = QLabel(self) movie = QMovie("images/menu") background.setMovie(movie) self.setCentralWidget(background) movie.start() # Stylesheet Settings styleFile = QFile( "stylesheets/menu.qss" ) styleFile.open( QFile.ReadOnly ) style = str( styleFile.readAll() ) self.setStyleSheet( style ) # Title Settings self.title = QLabel("Neural networks based learning system", self) self.title.setFont(QFont("BebasNeue", 45, QFont.Bold)) self.title.setAlignment(Qt.AlignCenter) self.title.setGeometry(0, 60, 1280, 120) # Button Settings self.buttons = [] for x in range(5) : self.buttons.append(x) self.buttons[x] = QPushButton(self) self.buttons[x].setCursor(Qt.PointingHandCursor) self.buttons[x].setObjectName("select") self.buttons[x].setFont(QFont("BebasNeue", 15, QFont.Bold)) self.buttons[x].setGeometry(400, 210 + x * 100, 550, 80) #self.buttons[x].clicked.connect(lambda : self.notifyMe(x)) self.buttons[0].setText("Image preprocessing") self.buttons[1].setText("Text preprocessing") self.buttons[2].setText("Learning") self.buttons[3].setText("Testing") self.buttons[4].setText("Quit") #app = QApplication(sys.argv) #window = MenuWindow() #window.show() #app.exec_()
def add_fonts(): """""" fonts_path = os.path.join(os.path.dirname(__file__), 'fonts') for font in ['roboto']: for font in filter(lambda s: s.endswith('.ttf'), os.listdir(os.path.join(fonts_path, font))): QFontDatabase.addApplicationFont(os.path.join(fonts_path, font))
def __init__(self): super(LoadGameWidget, self).__init__() centralWidget = QWidget() mainLayout = QVBoxLayout(centralWidget) self.setLayout(mainLayout) QFontDatabase.addApplicationFont("images/adobekaiti.ttf")
def add_fonts(): """""" fonts_path = os.path.join(os.path.dirname(__file__), 'fonts') for font_dir in ['roboto']: for font in filter(lambda s: s.endswith('.ttf'), os.listdir(os.path.join(fonts_path, font_dir))): try: QFontDatabase.addApplicationFont( os.path.join(fonts_path, font_dir, font)) except: # snake_case, true_property QFontDatabase.add_application_font( os.path.join(fonts_path, font_dir, font))
def main(filepath=None): if not check_dependencies(): sys.exit(1) set_app_user_model_id() from PySide2.QtWidgets import QApplication, QSplashScreen from PySide2.QtGui import QFontDatabase, QPixmap, QIcon from PySide2.QtCore import Qt from .config import FONT_LOCATION, IMG_LOCATION app = QApplication(sys.argv) app.setApplicationDisplayName("angr management") app.setApplicationName("angr management") # Make + display splash screen splashscreen_location = os.path.join(IMG_LOCATION, 'angr-splash.png') splash_pixmap = QPixmap(splashscreen_location) splash = QSplashScreen(splash_pixmap, Qt.WindowStaysOnTopHint) icon_location = os.path.join(IMG_LOCATION, 'angr.png') splash.setWindowIcon(QIcon(icon_location)) splash.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint) splash.setEnabled(False) splash.show() time.sleep(0.05) app.processEvents() from .logic import GlobalInfo from .ui.css import CSS from .ui.main_window import MainWindow # Load fonts QFontDatabase.addApplicationFont( os.path.join(FONT_LOCATION, "SourceCodePro-Regular.ttf")) GlobalInfo.gui_thread = threading.get_ident() # apply the CSS app.setStyleSheet(CSS.global_css()) file_to_open = filepath if filepath else sys.argv[1] if len( sys.argv) > 1 else None main_window = MainWindow() splash.finish(main_window) if file_to_open is not None: main_window.load_file(file_to_open) app.exec_()
class FontManager: """Stores various font parameters used by the app""" monospace = 'monospace' if not isinstance(TheApp, Mock): # Changes the default monospace font to one a bit less wide than Courier New font_path = pkg_resources.resource_filename( __name__, 'resources/fonts/NK57 Monospace/nk57-monospace-sc-rg.ttf') if font_path: monospace = QFontDatabase.addApplicationFont(font_path) monospace = QFontDatabase.applicationFontFamilies(monospace)[0] REAL_FONT_FACES = { FontFace.serif: 'Times New Roman', FontFace.sans: 'Helvetica', FontFace.monospace: monospace, } #: Converts the enumed font faces to actual font families that Qt will accept FONT_SCALES = { FontFace.serif: None, FontFace.sans: None, FontFace.monospace: None, } #: Stores scaling factors used to make fonts all the same width for a given font point size FONT_CACHE = {} #: Stores previously called fonts METRICS_CACHE = {} #: Stores metrics used to get font widths per font size
def main(argv): """Launches Spine Db Editor as it's own application. Args: argv (list): Command line arguments """ if not pyside2_version_check(): return 1 try: urls = argv[1:] except IndexError: return 2 app = QApplication(argv) status = QFontDatabase.addApplicationFont( ":/fonts/fontawesome5-solid-webfont.ttf") if status < 0: logging.warning( "Could not load fonts from resources file. Some icons may not render properly." ) locale.setlocale(locale.LC_NUMERIC, 'C') settings = QSettings("SpineProject", "Spine Toolbox") db_mngr = SpineDBManager(settings, None) editor = MultiSpineDBEditor(db_mngr, {url: None for url in urls}, create=True) editor.show() return_code = app.exec_() return return_code
def main(): """Creates main window GUI and starts main event loop.""" logging.basicConfig( stream=sys.stderr, level=logging.DEBUG, format='%(asctime)s %(levelname)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S', ) if not pyside2_version_check(): return 1 parser = _make_argument_parser() args = parser.parse_args() if args.execute_only: return headless_main(args) app = QApplication(sys.argv) app.setApplicationName("Spine Toolbox") status = QFontDatabase.addApplicationFont( ":/fonts/fontawesome5-solid-webfont.ttf") if status < 0: logging.warning( "Could not load fonts from resources file. Some icons may not render properly." ) window = ToolboxUI() window.show() window.init_project(args.project) # Enter main event loop and wait until exit() is called return_code = app.exec_() return return_code
def add_to_font_db(cls, font_key): font_id = QFontDatabase.addApplicationFont( Resource.icon_paths[font_key]) cls.font_storage[font_key] = font_id LOGGER.debug('Font loaded and added to db: %s', QFontDatabase.applicationFontFamilies(font_id)) return QFont(QFontDatabase.applicationFontFamilies(font_id)[0], 8)
def initDb(): monoRegular = os.path.join(utility.viewResourcesDir(), "fonts", "FiraCode_2", "FiraCode-Regular.ttf") monoLight = os.path.join(utility.viewResourcesDir(), "fonts", "FiraCode_2", "FiraCode-Light.ttf") regular = os.path.join(utility.viewResourcesDir(), "fonts", "Open_Sans", "OpenSans-Regular.ttf") lightItalic = os.path.join(utility.viewResourcesDir(), "fonts", "Open_Sans", "OpenSans-LightItalic.ttf") semibold = os.path.join(utility.viewResourcesDir(), "fonts", "Open_Sans", "OpenSans-SemiBold.ttf") QFontDatabase.addApplicationFont(regular) QFontDatabase.addApplicationFont(lightItalic) QFontDatabase.addApplicationFont(semibold) QFontDatabase.addApplicationFont(monoRegular) QFontDatabase.addApplicationFont(monoLight)
def __init__(self, page_width, page_height, crop_margin_width=0 * mm): self.page_width = page_width self.page_height = page_height self.margin_width = crop_margin_width self.include_crop_marks = bool(crop_margin_width) QApplication(['my-q-application']) f = QFontDatabase.addApplicationFont( '../../fonts/OldStandard-Regular.ttf') f = QFontDatabase.addApplicationFont('OldStandard-Italic.ttf') f = QFontDatabase.addApplicationFont('OldStandard-Bold.ttf') f = QFontDatabase.addApplicationFont('fonts/Inconsolata-Regular.ttf') f = QFontDatabase.addApplicationFont('fonts/UbuntuMono-R.ttf') f = QFontDatabase.addApplicationFont('../../fonts/GenBasB.ttf') f = QFontDatabase.addApplicationFont('../../fonts/GenBasR.ttf') #f = QFontDatabase.addApplicationFont('../../fonts/Inconsolata-Regular.ttf') # print(f) names = QFontDatabase.applicationFontFamilies(f) # print(names) self.writer = QPdfWriter('book.pdf') size = QSizeF(as_mm(2 * crop_margin_width + page_width), as_mm(2 * crop_margin_width + page_height)) print(size) self.writer.setPageSizeMM(size) margins = QMarginsF(as_mm(crop_margin_width), as_mm(crop_margin_width), as_mm(crop_margin_width), as_mm(crop_margin_width)) print(margins) self.writer.setPageMargins(margins, QPageLayout.Millimeter) self.painter = QPainter(self.writer) if self.include_crop_marks: self.draw_crop_marks()
def _register_fonts(self): QFontDatabase.addApplicationFont( self.get_resource(join("fonts", "FiraSans-Medium.otf"))) QFontDatabase.addApplicationFont( self.get_resource(join("fonts", "FiraSans-Regular.otf"))) QFontDatabase.addApplicationFont( self.get_resource(join("fonts", "ZillaSlab-Regular.otf")))
def setup_application_font(): try: id = QFontDatabase.addApplicationFont(GlobalFiles.MyFontPath) _fontstr = QFontDatabase.applicationFontFamilies(id)[0] _font = QFont(_fontstr, 10) app.setFont(_font) except Exception as e: warning_dialog = WarningDialog( window_title="Missing Fonts", info_message="Can't find 'OpenSans' font at " "../Resources/Fonts/OpenSans.ttf\n" + "application will use default font") warning_dialog.execute()
def setFontPath(cls, filename): """Set font from a font file and return it :return: QFont or False if the file is not loaded """ db = QFontDatabase() font_id = db.addApplicationFont(filename) if font_id == -1: logging.error("FIconEngine:setFontPath:: cannot load font icon.") return False cls.font = QFont(db.applicationFontFamilies(font_id)[0]) return cls.font
def __init__(self): super().__init__() self.title = 'Quandenser-pipeline' self.setWindowIcon(QIcon('images/logo.png')) QFontDatabase.addApplicationFont("fonts/rockwell.ttf") self.resize(1000, 800) # Check file integrety check_corrupt(config_path) self.paths = {} self.paths['config'] = f"{config_path}" self.paths['ui'] = f"{config_path}/ui.config" self.paths['nf'] = f"{config_path}/nf.config" self.paths['sh'] = f"{config_path}/run_quandenser.sh" self.paths['pipe'] = f"{config_path}/PIPE" self.paths['jobs'] = f"{config_path}/jobs.txt" # Open pipe and read self.pipe_parser = custom_config_parser() self.pipe_parser.load(self.paths['pipe']) check_running(config_path) self.pipe_parser.write( 'exit_code', '2', isString=False ) # Add error code 2. If we manage to load, change to 1 # To restore settings of window self.settings_obj = QtCore.QSettings(self.paths['ui'], QtCore.QSettings.IniFormat) # Restore window's previous geometry from file self.setMinimumWidth(300) self.setMinimumHeight(200) self.initUI() if os.path.exists(self.paths['ui']): self.restoreGeometry(self.settings_obj.value("windowGeometry")) self.restoreState(self.settings_obj.value("State_main")) children = self.children() for child in children: self.recurse_children(child, save=False) self.show()
def __init__(self, page_width, page_height, margin_width=0): self.page_width = page_width self.page_height = page_height self.margin_width = margin_width self.include_crop_marks = bool(margin_width) QApplication(['my-q-application']) f = QFontDatabase.addApplicationFont('OldStandard-Regular.ttf') f = QFontDatabase.addApplicationFont('OldStandard-Italic.ttf') f = QFontDatabase.addApplicationFont('OldStandard-Bold.ttf') names = QFontDatabase.applicationFontFamilies(f) print(names) self.writer = QPdfWriter('book.pdf') size = QSizeF((2 * margin_width + page_width) * mm, (2 * margin_width + page_height) * mm) self.writer.setPageSizeMM(size) margins = QMarginsF(margin_width, margin_width, margin_width, margin_width) self.writer.setPageMargins(margins) self.painter = QPainter(self.writer) if self.include_crop_marks: self.draw_crop_marks()
def main(): app = QApplication(sys.argv) app.setWindowIcon(QIcon(':/icons/app.svg')) fontDB = QFontDatabase() fontDB.addApplicationFont(':/fonts/Roboto-Regular.ttf') app.setFont(QFont('Roboto')) f = QFile(':/style.qss') f.open(QFile.ReadOnly | QFile.Text) app.setStyleSheet(QTextStream(f).readAll()) f.close() translator = QTranslator() translator.load(':/translations/' + QLocale.system().name() + '.qm') app.installTranslator(translator) mw = MainWindow() mw.show() sys.exit(app.exec_())
def main(argv): """Launches Data Store view as it's own application. Args: argv (list): Command line arguments """ if not pyside2_version_check(): return 0 if not spinedb_api_version_check(): return 0 try: path = argv[1] except IndexError: return 0 app = QApplication(argv) QFontDatabase.addApplicationFont(":/fonts/fontawesome5-solid-webfont.ttf") locale.setlocale(locale.LC_NUMERIC, 'C') url = f"sqlite:///{path}" db_mngr = SpineDBManager(SimpleLogger(), None) tree = DataStoreForm(db_mngr, (url, "main")) tree.show() return_code = app.exec_() return return_code
def main(argv): """Launches Data Store view as it's own application. Args: argv (list): Command line arguments """ if not pyside2_version_check(): return 1 try: file_path = argv[1] except IndexError: return 0 app = QApplication(argv) QFontDatabase.addApplicationFont(":/fonts/fontawesome5-solid-webfont.ttf") locale.setlocale(locale.LC_NUMERIC, 'C') url = f"sqlite:///{file_path}" settings = QSettings("SpineProject", "Spine Toolbox") logger = SimpleLogger() db_mngr = SpineDBManager(settings, logger, None) codename = os.path.splitext(os.path.basename(file_path))[0] db_mngr.show_data_store_form({url: codename}, logger) return_code = app.exec_() return return_code
def __load_custom_fonts(cls) -> None: """Loads custom fonts - must be called after the QApplication object has been constructed""" font_list = [ ':/third_party/fonts/Roboto/Roboto-Black.ttf', ':/third_party/fonts/Roboto/Roboto-BlackItalic.ttf', ':/third_party/fonts/Roboto/Roboto-Bold.ttf', ':/third_party/fonts/Roboto/Roboto-BoldItalic.ttf', ':/third_party/fonts/Roboto/Roboto-Italic.ttf', ':/third_party/fonts/Roboto/Roboto-Light.ttf', ':/third_party/fonts/Roboto/Roboto-LightItalic.ttf', ':/third_party/fonts/Roboto/Roboto-Medium.ttf', ':/third_party/fonts/Roboto/Roboto-MediumItalic.ttf', ':/third_party/fonts/Roboto/Roboto-Regular.ttf', ':/third_party/fonts/Roboto/Roboto-Thin.ttf', ':/third_party/fonts/Roboto/Roboto-ThinItalic.ttf', ] for font in font_list: assert QFontDatabase.addApplicationFont( font) != -1, "ERROR: could not load font: %s" % font
def __init__(self, disk_usage, node_status, node_substatus): """ Constructor """ super(TableModel, self).__init__() self._data = [] self._node_id_vs_row_number = {} self._icons = {} # Initialize icons for icon_id, icon_path in list(self._icon_paths.items()): if not icon_path: continue self._icons[icon_id] = QIcon(icon_path) # set font for arrow symbols font_id = QFontDatabase.addApplicationFont(":/fonts/symbol-signs.otf") font_family = QFontDatabase.applicationFontFamilies(font_id)[0] self._arrow_font = QFont(font_family, QFont().pointSize()+5) # Add the node itself node_ostype = get_platform() node_osname, is_server = get_os_name_and_is_server() # show "Downloading share" instead of "Syncing" if share is downlosded status = 30 if node_status == 3 and node_substatus == SUBSTATUS_SHARE \ else node_status self_info = { 'id': 'itself', 'node_ostype': node_ostype, 'node_osname': node_osname, 'node_devicetype': 'desktop', 'node_name': get_device_name(), 'is_online': node_status not in self.OFFLINE_STATUSES, 'is_itself': True, 'disk_usage': disk_usage, 'download_speed': 0., 'node_status': status, 'upload_speed': 0., } QTimer.singleShot(10, lambda: self._add_row(self_info))
def add_fonts(): """""" fonts_path = os.path.join(os.path.dirname(__file__), 'fonts') for font in os.listdir(fonts_path): QFontDatabase.addApplicationFont(os.path.join(fonts_path, font))
def getPlaylists(self): self.m_appLogic.GetPlaylists() @Slot(int) def addToPlaylist(self, index): self.m_appLogic.AddToPlaylist(index, self.m_selectedIndex) if __name__ == '__main__': sys.argv += ['--style', 'material'] QApplication.setAttribute(Qt.AA_EnableHighDpiScaling) app = QApplication(sys.argv) fdb = QFontDatabase() fdb.addApplicationFont("fonts/FiraSans-Regular.ttf") appFont = QFont("Fira Sans") app.setFont(appFont) QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps) engine = QQmlApplicationEngine() # Expose the list to the Qml code listViewModel = QStringListModel() playlistListViewModel = QStringListModel() appLogic = AppLogic(listViewModel, playlistListViewModel) backend = Backend(appLogic) appLogic.LoadArtists()
def __init__(self, config): super(MainWindow, self).__init__() QFontDatabase.addApplicationFont( 'resources/fonts/poppins/Poppins-Medium.ttf') QFontDatabase.addApplicationFont( 'resources/fonts/source code pro/SourceCodePro-Regular.ttf') self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.splitter.setSizes([120, 800]) self.setWindowTitle('Ryven') self.setWindowIcon(QIcon('resources/pics/program_icon2.png')) self.load_stylesheet('dark') self.ui.scripts_tab_widget.removeTab(0) # menu actions self.flow_design_actions = [] self.setup_menu_actions() # shortcuts save_shortcut = QShortcut(QKeySequence.Save, self) save_shortcut.activated.connect(self.on_save_project_triggered) import_nodes_shortcut = QShortcut(QKeySequence('Ctrl+i'), self) import_nodes_shortcut.activated.connect(self.on_import_nodes_triggered) # clear temp folder if not os.path.exists('temp'): os.mkdir('temp') for f in os.listdir('temp'): os.remove('temp/' + f) # GENERAL ATTRIBUTES self.scripts = [] self.custom_nodes = [] self.all_nodes = [ SetVariable_Node(), GetVariable_Node(), Val_Node(), Result_Node() ] self.package_names = [] # holds NI subCLASSES for imported nodes: self.all_node_instance_classes = { self.all_nodes[0]: SetVar_NodeInstance, self.all_nodes[1]: GetVar_NodeInstance, self.all_nodes[2]: Val_NodeInstance, self.all_nodes[3]: Result_NodeInstance } # (key: node obj, val: NI subclass) (used in Flow) # custom subclasses for input widgets # {node : {str: PortInstanceWidget-subclass}} (used in PortInstance) self.custom_node_input_widget_classes = {} # UI self.scripts_list_widget = ScriptsListWidget(self, self.scripts) self.ui.scripts_scrollArea.setWidget(self.scripts_list_widget) self.ui.add_new_script_pushButton.clicked.connect( self.create_new_script_button_pressed) self.ui.new_script_name_lineEdit.returnPressed.connect( self.create_new_script_LE_return_pressed) if config['config'] == 'create plain new project': self.try_to_create_new_script() elif config['config'] == 'open project': print('importing packages...') self.import_packages(config['required packages']) print('loading project...') self.parse_project(config['content']) print('finished') print(''' CONTROLS placing nodes: right mouse selecting components: left mouse panning: middle mouse saving: ctrl+s ''') Design.set_flow_theme() Design.set_flow_theme() # temporary # the double call is just a temporary fix for an issue I will address in a future release. # Problem: because the signal emitted when setting a flow theme is directly connected to the according slots # in NodeInstance as well as NodeInstance_TitleLabel, the NodeInstance's slot (which starts an animation which # uses the title label's current and theme dependent color) could get called before the title # label's slot has been called to reinitialize this color. This results in wrong color end points for the # title label when activating animations. # This is pretty nasty since I cannot think of a nice fix for this issue other that not letting the slot # methods be called directly from the emitted signal but instead through a defined procedure like before. # maybe this will be necessary due to scheduling issues when loading flows # for s in self.scripts: # s.flow.viewport().update() self.resize(1500, 800)
def __init__(self, *args, **kwargs): super(TestingWindow, self).__init__(*args, **kwargs) # Loading Fonts QFontDatabase.addApplicationFont("fonts/BebasNeue-Light.ttf") # Window Settings self.setFixedSize(1280, 720) self.setWindowTitle("TestingWindow") background = QPixmap("images/testing") palette = QPalette() palette.setBrush(QPalette.Background, background) self.setAttribute(Qt.WA_StyledBackground, True) self.setPalette(palette) self.setAutoFillBackground(True) # Stylesheet Settings styleFile = QFile("stylesheets/testing.qss") styleFile.open(QFile.ReadOnly) style = str(styleFile.readAll()) self.setStyleSheet(style) # Title Settings self.__title = QLabel("Testing", self) self.__title.setFont(QFont("BebasNeue", 45, QFont.Bold)) self.__title.setAlignment(Qt.AlignCenter) self.__title.setGeometry(0, 30, 1280, 100) # Button Settings self.buttons = [] for x in range(4): self.buttons.append(x) self.buttons[x] = QPushButton(self) self.buttons[x].setCursor(Qt.PointingHandCursor) self.buttons[x].setObjectName("select") self.buttons[x].setFont(QFont("BebasNeue", 10, QFont.Bold)) self.buttons[x].setGeometry(80, 100 + x * 120, 80, 80) # Connecting buttons self.buttons[0].clicked.connect(self.loadNetwork) self.buttons[1].clicked.connect(self.loadTestFile) self.buttons[2].clicked.connect(self.startTest) # Buttons Icons self.buttons[0].setIcon(QIcon("images/brain_icon")) self.buttons[0].setIconSize(QSize(35, 35)) self.buttons[1].setIcon(QIcon("images/upload_icon")) self.buttons[1].setIconSize(QSize(35, 35)) self.buttons[2].setIcon(QIcon("images/test_icon")) self.buttons[2].setIconSize(QSize(35, 35)) self.buttons[3].setIcon(QIcon("images/goback_icon")) self.buttons[3].setIconSize(QSize(35, 35)) # Return Button self.buttons[3].setText("Back") self.buttons[3].setObjectName("retour") self.buttons[3].setGeometry(1100, 620, 120, 120) self.buttons[3].setIcon(QIcon("images/goback_icon")) self.buttons[3].setIconSize(QSize(35, 35)) # Labels Settings self.__labels = [] for x in range(3): self.__labels.append(x) self.__labels[x] = QLabel(self) self.__labels[x].setGeometry(200, 110 + x * 120, 300, 80) self.__labels[x].setFont(QFont("BebasNeue", 20, QFont.Bold)) self.__labels[0].setText("Load a neural network") self.__labels[1].setText("Load the test file") self.__labels[2].setText("Start the test") # Main #app = QApplication(sys.argv) #window = TestingWindow() #window.show() #app.exec_()
from PySide2.QtGui import QPixmap, QFont, QFontDatabase from PySide2.QtWidgets import QApplication, QSplashScreen #from PySide2.QtCore import Qt, QCoreApplication #from PySide2.QtGui import QPixmap, QFont, QFontDatabase, QApplication, QSplashScreen if __name__ == '__main__': #QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts) #QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling) multiprocessing.freeze_support() app = QApplication(sys.argv) app.setOrganizationName('Bioinformatics and Integrative Genomics') app.setOrganizationDomain('http://big.cdu.edu.cn') app.setApplicationName('Krait') #set font family QFontDatabase.addApplicationFont(":/fonts/roboto.ttf") QFontDatabase.addApplicationFont(":/fonts/robotomono.ttf") #support windows 7, 10 taskbar icon import ctypes if os.name == 'nt': myappid = 'BIG.Krait.ssr.1.0' ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) splash_img = QPixmap(":/icons/splash.png") splash = QSplashScreen(splash_img) splash.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.SplashScreen | Qt.FramelessWindowHint) splash.setStyleSheet("font-family:Roboto; font-size: 14px;") splash.setEnabled(False) splash.show()
from states.transitions.find_project_to_loading import FindProjectToLoadingTransition except: logging.exception("A critical error occurred while initializing main") sys.exit(1) def _load_theme_from_settings(app: QApplication): theme = locator.get_static("SettingsService").get_theme() if theme and theme in QStyleFactory.keys(): app.setStyle(theme) logging.info("Paragon version: Alpha 14") logging.info("Starting application...") application = QApplication(sys.argv) QFontDatabase.addApplicationFont("Assets/FOT-ChiaroStd-B.otf") state_machine = StateMachine() locator.register_static("SettingsService", SettingsService()) locator.register_static("StateMachine", state_machine) _load_theme_from_settings(application) state_machine.add_state(SelectProjectState()) state_machine.add_state(FindProjectState()) state_machine.add_state(LoadingState()) state_machine.add_state(MainState()) state_machine.add_transition( MainStateToSelectProjectTransition("Main", "SelectProject")) state_machine.add_transition( FindProjectToLoadingTransition("FindProject", "Loading")) state_machine.add_transition( SelectProjectToLoadingTransition("SelectProject", "Loading")) state_machine.add_transition(ReloadProjectTransition("Main", "Loading"))