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 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 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 __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)