def __init__(self, main_model, main_ctrl): """ Args: main_ctrl (auri.controllers.main_controller.MainController): main_model (auri.models.main_model.MainModel): """ self.model = main_model self.main_ctrl = main_ctrl super(MainView, self).__init__() self.main_layout = QtWidgets.QVBoxLayout() self.scrollable_layout = QtWidgets.QVBoxLayout() self.scrollable_layout.addStretch(1) self.category_combobox = QtWidgets.QComboBox() self.subcategory_combobox = QtWidgets.QComboBox() self.script_selector_dialog = ScriptSelectorView( self.model.scripts, self.model) self.script_selector = push_button("Scripts", self.open_script_selector) self.add_btn = push_button( "Add", partial(self.main_ctrl.add_selected_script, self)) self.main_ctrl.setup(self.category_combobox, self.subcategory_combobox, self.script_selector) self.setup_ui()
def create_scroll_area(): scroll_area = QtWidgets.QScrollArea() scroll_area.setWidgetResizable(1) scroll_area.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) scrollable_widget = QtWidgets.QWidget() scrollable_widget.setLayout(self.scrollable_layout) scroll_area.setWidget(scrollable_widget) return scroll_area
def __init__(self): super(AboutView, self).__init__() self.setWindowTitle("About Auri") self.setModal(1) self.setFixedSize(400, 300) self.main_layout = QtWidgets.QVBoxLayout() self.about_text = QtWidgets.QLabel() self.ok_btn = push_button("Ok", self.ok_pressed) # self.cancel_btn = push_button("Cancel", self.cancel_pressed) self.setup_ui() if get_application() is "standalone" or get_application() is "houdini": self.setStyleSheet(get_houdini_style())
def __init__(self, window_title="Message", message="ENTER A MESSAGE"): super(MessageBoxView, self).__init__() self.setWindowTitle(window_title) self.setModal(1) self.setMinimumWidth(250) self.setMinimumHeight(150) self.main_layout = QtWidgets.QVBoxLayout() self.message = QtWidgets.QLabel(message) self.ok_btn = push_button("Ok", self.ok_pressed) self.setup_ui() if get_application() is "standalone" or get_application() is "houdini": self.setStyleSheet(get_houdini_style())
def setup_ui(self): new_name_layout = QtWidgets.QHBoxLayout() new_name_label = QtWidgets.QLabel("New name:") self.new_name.setText(self.script_view.module_name) new_name_layout.addWidget(new_name_label) new_name_layout.addWidget(self.new_name) self.main_layout.addLayout(new_name_layout) self.main_layout.addStretch(1) self.main_layout.addWidget(self.ok_btn) self.main_layout.addWidget(self.cancel_btn) self.setLayout(self.main_layout)
def __init__(self, scripts, main_model): """ Args: main_model (auri.models.main_model.MainModel): """ self.model = main_model self.scripts = scripts super(ScriptSelectorView, self).__init__() self.setWindowTitle("Script Selection") self.setModal(1) self.main_layout = QtWidgets.QVBoxLayout() self.script_list = QtWidgets.QListView() self.ok_btn = push_button("Ok", self.ok_pressed) self.cancel_btn = push_button("Cancel", self.cancel_pressed) self.setup_ui() if get_application() is "standalone" or get_application() is "houdini": self.setStyleSheet(get_houdini_style())
def setup_parts_ui(self): def create_category_combobox(): self.category_combobox.setModel(self.model.categories) self.category_combobox.currentIndexChanged.connect( self.main_ctrl.category_changed) self.category_combobox.currentIndexChanged.connect( lambda: self.add_btn.setDisabled(self.model.add_btn_disabled)) self.model.selected_category = self.category_combobox.currentText() return self.category_combobox def create_subcategory_combobox(): self.subcategory_combobox.setModel(self.model.subcategories) self.subcategory_combobox.currentIndexChanged.connect( self.main_ctrl.subcategory_changed) self.subcategory_combobox.currentIndexChanged.connect( lambda: self.add_btn.setDisabled(self.model.add_btn_disabled)) self.model.selected_subcategory = self.subcategory_combobox.currentText( ) return self.subcategory_combobox def create_script_selector(): return self.script_selector def create_name_textbox(): name_textbox = QtWidgets.QLineEdit() # Replace spaces with underscores def name_fixup(): old_cursor_pos = name_textbox.cursorPosition() name_textbox.setText(name_textbox.text().replace(" ", "_")) name_textbox.setCursorPosition(old_cursor_pos) name_textbox.setPlaceholderText("Name") # name_validator = QtGui.QRegExpValidator(QtCore.QRegExp("^[a-zA-Z][a-zA-Z\d#_ ]*")) # name_textbox.setValidator(name_validator) name_textbox.textChanged.connect(name_fixup) name_textbox.textChanged.connect(self.main_ctrl.name_changed) name_textbox.textChanged.connect( lambda: self.add_btn.setDisabled(self.model.add_btn_disabled)) return name_textbox def create_add_btn(): self.add_btn.setDisabled(1) return self.add_btn parts_layout = QtWidgets.QHBoxLayout() parts_grp = grpbox("Parts", parts_layout) parts_layout.addWidget(create_category_combobox()) parts_layout.addWidget(create_subcategory_combobox()) parts_layout.addWidget(create_script_selector()) parts_layout.addWidget(create_name_textbox()) parts_layout.addWidget(create_add_btn()) parts_grp.setLayout(parts_layout) self.main_layout.addWidget(parts_grp)
def __init__(self, script_view, project_model, main_model): """ Args: script_view (auri.views.script_module_view.ScriptModuleView): project_model (auri.models.project_model.ProjectModel): main_model (auri.models.main_model.MainModel): """ self.script_view = script_view self.project_model = project_model self.main_model = main_model super(EditScriptView, self).__init__() self.setWindowTitle("Edit Script") self.setModal(1) self.setMinimumWidth(250) self.setMinimumHeight(150) self.main_layout = QtWidgets.QVBoxLayout() self.new_name = QtWidgets.QLineEdit() self.ok_btn = push_button("Ok", self.ok_pressed) self.cancel_btn = push_button("Cancel", self.cancel_pressed) self.message_box = None self.setup_ui()
def setup_properties_ui(self): def create_scroll_area(): scroll_area = QtWidgets.QScrollArea() scroll_area.setWidgetResizable(1) scroll_area.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) scrollable_widget = QtWidgets.QWidget() scrollable_widget.setLayout(self.scrollable_layout) scroll_area.setWidget(scrollable_widget) return scroll_area properties_layout = QtWidgets.QVBoxLayout() properties_grp = grpbox("Properties", properties_layout) properties_layout.addWidget(create_scroll_area()) self.main_layout.addWidget(properties_grp)
def create_name_textbox(): name_textbox = QtWidgets.QLineEdit() # Replace spaces with underscores def name_fixup(): old_cursor_pos = name_textbox.cursorPosition() name_textbox.setText(name_textbox.text().replace(" ", "_")) name_textbox.setCursorPosition(old_cursor_pos) name_textbox.setPlaceholderText("Name") # name_validator = QtGui.QRegExpValidator(QtCore.QRegExp("^[a-zA-Z][a-zA-Z\d#_ ]*")) # name_textbox.setValidator(name_validator) name_textbox.textChanged.connect(name_fixup) name_textbox.textChanged.connect(self.main_ctrl.name_changed) name_textbox.textChanged.connect( lambda: self.add_btn.setDisabled(self.model.add_btn_disabled)) return name_textbox
def setup_build_area(self): def create_execute_all_btn(): execute_all_btn = push_button("Execute All", self.main_ctrl.execute_all) return execute_all_btn def create_prebuild_all_btn(): prebuild_all_btn = push_button("Prebuild All", self.main_ctrl.prebuild_all) return prebuild_all_btn build_layout = QtWidgets.QHBoxLayout() build_grp = grpbox("Build", build_layout) build_layout.addWidget(create_prebuild_all_btn()) build_layout.addWidget(create_execute_all_btn()) self.main_layout.addWidget(build_grp) pass
def new_project_action(self): action = QtWidgets.QAction("&New Project", self) action.triggered.connect(self.common_ctrl.new_project) action.setShortcut("Ctrl+N") action.setStatusTip("Clear current project") return action
def grpbox(title, lyt=None): if lyt is None: lyt = QtWidgets.QVBoxLayout() g = QtWidgets.QGroupBox(title=title) g.setLayout(lyt) return g
def save_project_as_action(self): action = QtWidgets.QAction("Save Project &As", self) action.triggered.connect(self.common_ctrl.save_project_as) action.setShortcut("Ctrl+Shift+S") action.setStatusTip("Save current project as") return action
def import_project_action(self): action = QtWidgets.QAction("Import Project", self) action.triggered.connect(partial(self.common_ctrl.open_project, True)) action.setShortcut("Ctrl+I") action.setStatusTip("Import & append a project to the currect project") return action
def push_button(text, signal=None): assert isinstance(text, str) btn = QtWidgets.QPushButton(text) if signal is not None: btn.clicked.connect(signal) return btn
def prebuild_all_action(self): action = QtWidgets.QAction("Pre&build All", self) action.triggered.connect(self.main_ctrl.prebuild_all) action.setShortcut("Ctrl+B") action.setStatusTip("Launch the Prebuild function of every scripts") return action
def refresh_action(self): action = QtWidgets.QAction("&Refresh", self) action.triggered.connect(self.common_ctrl.refresh) action.setShortcut("Ctrl+R") action.setStatusTip("Refresh categories & scripts") return action
def bootstrap_standalone(): app = QtWidgets.QApplication(sys.argv) win = BootstrapView() win.setStyleSheet(get_houdini_style()) app.exec_()
def execute_all_action(self): action = QtWidgets.QAction("&Execute All", self) action.triggered.connect(self.main_ctrl.execute_all) action.setShortcut("Ctrl+E") action.setStatusTip("Launch the Execute function of every scripts") return action
def about_action(self): action = QtWidgets.QAction("&About", self) action.triggered.connect(self.main_ctrl.show_about) action.setShortcut("Ctrl+Alt+A") action.setStatusTip("Show the About window") return action
def __init__(self, category, subcategory, script, module_name, main_model): """ Args: main_model (auri.models.main_model.MainModel): module_name (str): script (str): category (str): """ self.main_model = main_model self.category = category self.subcategory = subcategory self.script = script self.module_name = module_name super(ScriptModuleView, self).__init__() # Create the script module view & controller exec "import auri.scripts.{0}.{1}.{2} as the_script; reload(the_script); the_view = the_script.View(); the_ctrl = the_view.ctrl".format( category, subcategory, script) the_ctrl.model.module_name = module_name self.the_view = the_view self.model = the_ctrl.model self.the_ctrl = the_ctrl grp_title = "{0} - {1} - {2} - {3}".format(category, subcategory, script, module_name) self.setTitle(grp_title) # Create the shell to hold the view script_layout = QtWidgets.QGridLayout() self.setLayout(script_layout) # Create the basic buttons btns_layout = QtWidgets.QHBoxLayout() btns_size = QtCore.QSize(24, 24) self.fold_btn = QtWidgets.QToolButton() self.fold_btn.setText("FOLD") self.fold_btn.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Maximum) self.up_btn = QtWidgets.QToolButton() up_icon = QtGui.QIcon() up_icon.addPixmap(QtGui.QPixmap(get_auri_icon("Arrow_Up.png"))) self.up_btn.setIcon(up_icon) self.up_btn.setIconSize(btns_size) self.up_btn.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Maximum) self.down_btn = QtWidgets.QToolButton() down_icon = QtGui.QIcon() down_icon.addPixmap(QtGui.QPixmap(get_auri_icon("Arrow_Down.png"))) self.down_btn.setIcon(down_icon) self.down_btn.setIconSize(btns_size) self.down_btn.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Maximum) self.edit_btn = QtWidgets.QToolButton() self.edit_btn.setText("EDIT") self.edit_btn.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Maximum) self.duplicate_btn = QtWidgets.QToolButton() duplicate_icon = QtGui.QIcon() duplicate_icon.addPixmap(QtGui.QPixmap(get_auri_icon("Duplicate.png"))) self.duplicate_btn.setIcon(duplicate_icon) self.duplicate_btn.setIconSize(btns_size) self.duplicate_btn.setSizePolicy( QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Maximum) self.delete_btn = QtWidgets.QToolButton() delete_icon = QtGui.QIcon() delete_icon.addPixmap(QtGui.QPixmap(get_auri_icon("Delete.png"))) self.delete_btn.setIcon(delete_icon) self.delete_btn.setIconSize(btns_size) self.delete_btn.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Maximum) # Add the buttons btns_layout.addWidget(self.fold_btn) btns_layout.addWidget(self.up_btn) btns_layout.addWidget(self.down_btn) btns_layout.addWidget(self.edit_btn) btns_layout.addWidget(self.duplicate_btn) btns_layout.addWidget(self.delete_btn) script_layout.addLayout(btns_layout, 0, 0) # Add the view script_layout.addWidget(the_view, 1, 0)
def open_project_action(self): action = QtWidgets.QAction("&Open Project", self) action.triggered.connect(self.common_ctrl.open_project) action.setShortcut("Ctrl+O") action.setStatusTip("Open a project") return action