def on_design_action_triggered(self): index = self.flow_design_actions.index(self.sender()) Design.set_flow_theme(Design.flow_themes[index])
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 on_performance_mode_changed(self, action): if action == self.action_set_performance_mode_fast: Design.set_performance_mode('fast') else: Design.set_performance_mode('pretty')