Beispiel #1
0
    def __init__(self, parent=None, label="Renamer", text=""):
        super(GetNameWidget, self).__init__(parent)
        self.result = ""
        self.line = LineEdit(label="Rename", placeholder_text=text)

        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(self.line)

        button_layout = QtWidgets.QHBoxLayout()
        # button_group = QtGui.QButtonGroup()
        layout.addLayout(button_layout)

        # sets the default button at confirm
        button = QtWidgets.QPushButton("Confirm")
        button.setDefault(True)
        button.setFocus()

        # adds the cancel button
        cancel = QtWidgets.QPushButton("Cancel")
        button.clicked.connect(self.rename_call)
        cancel.clicked.connect(self.close_ui)
        button_layout.addWidget(button)
        button_layout.addWidget(cancel)

        self.setWindowTitle(label)
        self.setLayout(layout)
Beispiel #2
0
    def add_build_slider(self):
        """
        adds the new button.
        :return: <QTWidgets.QPushButton>
        """
        h_layout = QtWidgets.QHBoxLayout()

        label = QtWidgets.QLabel("Build: ")
        label.setSizePolicy(QtWidgets.QSizePolicy.Minimum,
                            QtWidgets.QSizePolicy.Minimum)

        # set slider options
        self.build_slider = QtWidgets.QSlider()
        self.build_slider.setTickInterval(1)
        self.build_slider.setMinimum(0)
        self.build_slider.setMaximum(1)
        self.build_slider.setSliderPosition(0)
        self.build_slider.setOrientation(QtCore.Qt.Horizontal)
        self.build_slider.setSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                        QtWidgets.QSizePolicy.Minimum)
        # slider.setStyleSheet(ui_stylesheets.slider_stylesheet)

        h_layout.addWidget(label)
        h_layout.addWidget(self.build_slider)

        self.connect_slider(self.build_slider)
        return h_layout
Beispiel #3
0
 def build(self):
     """
     builds the widget box
     :return: <QtWidget>
     """
     main_layout = QtWidgets.QHBoxLayout(self)
     self.widgets["labelWidget"] = QtWidgets.QLabel(self.label)
     self.widgets["lineEdit"] = QtWidgets.QLineEdit()
     self.widgets["lineEdit"].setPlaceholderText(self.placeholder_text)
     main_layout.addWidget(self.widgets["labelWidget"])
     main_layout.addWidget(self.widgets["lineEdit"])
     self.setLayout(main_layout)
     return self.widgets
Beispiel #4
0
 def build(self):
     """
     builds the widget with stuff.
     :return: <bool> True for success.
     """
     self.widgets['label'] = QtWidgets.QLabel("Intentionally Empty")
     self.widgets['instructions'] = QtWidgets.QVBoxLayout()
     self.widgets['updateButton'] = QtWidgets.QPushButton("Update")
     self.main_layout.addLayout(self.widgets['instructions'])
     self.widgets['instructions'].insertStretch(0)
     self.widgets['instructions'].addWidget(self.widgets['label'])
     self.main_layout.addWidget(self.widgets['updateButton'])
     return True
Beispiel #5
0
    def build_instructions(self, data):
        """
        build instructions.
        :return: <bool> True for success.
        """

        # labels first
        if 'label' in data:
            labels = data['label']
            for item in labels:
                label = ui_tools.AttributeLabel(label=item)
                self.widgets['instructions'].addWidget(label)
                self.info_widgets[item] = label

        # build divider
        divider = QtWidgets.QLabel("Information: ")
        self.widgets['instructions'].addWidget(divider)
        self.widgets['instructions'].insertStretch(len(self.info_widgets) + 1)

        # then comes the editable content
        if 'line-edit' in data:
            line_edits = data['line-edit']
            for item in line_edits:
                line_edit = ui_tools.LineEdit(label=item)
                self.widgets['instructions'].addWidget(line_edit)
                self.info_widgets[item] = line_edit
        return True
Beispiel #6
0
    def add_module(self, *args):
        """
        adds the module to the list widget.
        :param args: <list> incoming arguments
        :return: <QtWidgets.QWidget>
        """
        module_name = args[0]
        information = {}

        if len(args) > 1:
            information = args[1]

        item = QtWidgets.QListWidgetItem()
        widget = ModuleWidget(module_name=module_name,
                              list_widget=self.module_form.list,
                              item=item,
                              parent=self,
                              information=information)

        # makes sure the modules are shown correctly in the list widget
        item.setSizeHint(widget.sizeHint())

        # add a widget to the list
        self.module_form.list.addItem(item)
        self.module_form.list.setItemWidget(item, widget)
        return widget
Beispiel #7
0
    def update_call(self):
        """
        information update when the update button is clicked.
        :return: <bool> True for success. <bool> False for failure.
        """
        if self.parent.module_form.is_build_toggled:
            QtWidgets.QMessageBox().warning(
                self, "Could not update.",
                "Please revert back to guides (Turn off build).")
            return False

        # get information
        self.get_information()

        # update the selected widget information data
        if self.information:
            self.parent.set_selected_module_name(self.information["name"])

            # update the widgets' published attributes
            self.parent.update_selected_item_attributes(self.information)
            debug_print("Updating module: %s with data: %s " %
                        (self.information["name"], self.information))

        # update each module's guide positions (if any)
        self.parent.update_guide_position_data()

        # trigger the update function for each of the modules loaded in the UI
        update_data_modules()

        # save the dictionary data into the chosen creature file
        creature_name = self.parent.get_selected_creature_name()
        if creature_name:
            save_blueprint(creature_name, get_module_data())
        return True
Beispiel #8
0
 def rename_call(self):
     self.result = self.line.widgets['lineEdit'].text()
     if self.result:
         self.deleteLater()
     else:
         QtWidgets.QMessageBox().information(
             self, "Empty field.", "Please fill in the edit field.")
Beispiel #9
0
 def add_icon():
     """
     adds an empty 6`x6x icon.
     :return: <QtGui.QPixmap>
     """
     label = QtWidgets.QLabel()
     pix = QPixmap(buttons["empty"])
     label.setPixmap(pix)
     return label, pix
Beispiel #10
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        # add the widgets to the layouts.
        self.main_widget = QtWidgets.QWidget(self)
        self.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                           QtWidgets.QSizePolicy.Expanding)
        self.main_layout = QtWidgets.QHBoxLayout(self)

        self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)

        # add the two widgets to the main layout
        horizontal_split = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
        self.main_layout.addWidget(horizontal_split)

        self.module_form = ModuleForm(parent=self)
        self.information_form = InformationForm(parent=self)
        horizontal_split.addWidget(self.module_form)
        horizontal_split.addWidget(self.information_form)

        # set up the right click menu box
        self.module_form.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
        self.add_menu_actions(self.module_form)

        # add a menu bar
        self.menu_bar_data = self.setup_menu_bar()

        # resize the main window
        self.setMinimumSize(self.HEIGHT, self.WIDTH)

        # connect triggers
        self.connect_menu_options()
        self.connect_blueprint_options()
        self.connect_utilities_options()

        # add main layout
        self.main_widget.setLayout(self.main_layout)
        self.setCentralWidget(self.main_widget)
        self.setWindowTitle(title)

        self.setStyleSheet(ui_stylesheets.dark_orange_stylesheet)
        self.setObjectName(object_name)
Beispiel #11
0
 def add_module_list(self):
     """
     adds a module list to the widget.
     :return: <QtWidgets.QListWidget>
     """
     list = QtWidgets.QListWidget(self)
     list.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                        QtWidgets.QSizePolicy.Expanding)
     list.setMinimumHeight(self.parent.HEIGHT - 50)
     list.setMinimumWidth(self.parent.WIDTH - 50)
     return list
Beispiel #12
0
 def add_menu_actions(self, widget):
     """
     adds menu actions.
     """
     actions = {}
     for mod in proper_modules:
         actions[mod] = QtWidgets.QAction(self)
         actions[mod].setText(mod)
         actions[mod].triggered.connect(partial(self.add_module, mod))
         widget.addAction(actions[mod])
     return actions
Beispiel #13
0
    def __init__(self, parent=None):
        super(InformationForm, self).__init__(parent)

        # define variables
        self.parent = parent
        self.main_layout = QtWidgets.QVBoxLayout(self)
        self.widgets = {}

        self.build()

        self.resize(40, 100)
        self.setLayout(self.main_layout)
        self.connect_buttons()
Beispiel #14
0
    def add_actions(self, label):
        """
        executes a rename call.
        :param label:
        :return:
        """
        select = QtWidgets.QAction(label)
        select.setText("Select")

        rename = QtWidgets.QAction(label)
        rename.setText("Rename")

        remove = QtWidgets.QAction(label)
        remove.setText("Remove")

        label.setContextMenuPolicy(Qt.ActionsContextMenu)
        rename.triggered.connect(self.rename_call)
        remove.triggered.connect(self.remove_item_call)
        select.triggered.connect(self.select_call)
        label.addAction(rename)
        label.addAction(remove)
        label.addAction(select)
Beispiel #15
0
    def __init__(self, parent=None):
        super(ModuleForm, self).__init__(parent)
        self.resize(200, 400)
        self.parent = parent

        # set the toggle back at default
        self.build = 0

        self.vertical_layout = QtWidgets.QVBoxLayout(self)
        self.combo_layout = QtWidgets.QHBoxLayout()

        self.creature_combo = QtWidgets.QComboBox(self)
        self.fill_blueprints()

        self.creature_label = QtWidgets.QLabel("Select Blueprint: ")
        self.combo_layout.addWidget(self.creature_label)
        self.combo_layout.addWidget(self.creature_combo)
        self.vertical_layout.addLayout(self.combo_layout)

        self.list = self.add_module_list()
        slider_layout = self.add_build_slider()

        # connect buttons
        # self.button.clicked.connect(self.finish_all_call)

        self.vertical_layout.addLayout(slider_layout)
        self.vertical_layout.addWidget(self.list)
        self.setLayout(self.vertical_layout)

        self.setMinimumWidth(self.parent.WIDTH / 2)

        # connect the widget
        self.list.itemClicked.connect(parent.select_item)

        # connect the combo changer
        self.creature_combo.currentIndexChanged.connect(
            self.creature_selected_call)
Beispiel #16
0
    def __init__(self, parent=None, list_items=()):
        super(ModulesList, self).__init__(parent)
        self.selected_item = None

        self.list_items = list_items

        vertical_layout = QtWidgets.QVBoxLayout()
        self.list_widget = QtWidgets.QListWidget()
        vertical_layout.addWidget(self.list_widget)

        horizontal_layout = QtWidgets.QHBoxLayout()
        self.ok_button = QtWidgets.QPushButton("Ok")
        self.cancel_button = QtWidgets.QPushButton("Cancel")
        horizontal_layout.addWidget(self.ok_button)
        horizontal_layout.addWidget(self.cancel_button)

        vertical_layout.addLayout(horizontal_layout)

        self.list_widget.addItems(self.list_items)

        self.create_connections()

        self.setLayout(vertical_layout)
        self.setWindowTitle("Modules List")
Beispiel #17
0
 def toggle_build_call(self, args):
     """
     toggles the build call.
     :param args: <int> incoming set integer.
     :return:
     """
     self.build = 0
     if self.get_selected_blueprint():
         if args == 1:
             self.build = 1
             self.finish_all_call()
         elif args == 0:
             self.build = 0
             self.create_all_call()
     else:
         QtWidgets.QMessageBox().warning(self,
                                         "Creature Blueprint Not Saved.",
                                         "Please save creature blueprint.")
         self.reset_slider(args)
Beispiel #18
0
 def add_version(self):
     """
     adds a QComboBox.
     :return: <QtGui.QComboBox>
     """
     return QtWidgets.QComboBox()
Beispiel #19
0
    def setup_menu_bar(self):
        """
        creates a menu bar for this main window
        :return: <bool> True for success.
        """
        menu_data = {}
        menu_bar = QtWidgets.QMenuBar()
        menu_data["options"] = menu_bar.addMenu("&Module Options")
        menu_data["blueprintOptions"] = menu_bar.addMenu("&Blueprint Options")
        menu_data["utilities"] = menu_bar.addMenu("&Utilities")

        # create utility
        menu_data["printData"] = QtWidgets.QAction("&Print Module Data")
        menu_data["reloadModules"] = QtWidgets.QAction("&Reload Rig Modules")

        # create regular option actions
        menu_data["updateModules"] = QtWidgets.QAction("Update Modules")
        menu_data["addModule"] = QtWidgets.QAction("Add Module")
        menu_data["clearModules"] = QtWidgets.QAction("Clear Modules")

        # create blueprint option actions
        menu_data["setBlueprintPath"] = QtWidgets.QAction(
            "S&et Blueprint Path")
        # menu_data["saveBlueprint"] = QtWidgets.QAction("Save &Blueprint")
        menu_data["saveNewBlueprint"] = QtWidgets.QAction(
            "Save &New Blueprint")
        menu_data["removeBlueprint"] = QtWidgets.QAction("&Remove Blueprint")
        menu_data["openBlueprintDir"] = QtWidgets.QAction(
            "&Open Blueprint Dir")
        menu_data["openBlueprintFile"] = QtWidgets.QAction(
            "Open Blueprint &File")

        # utility actions
        menu_data["utilities"].addAction(menu_data["printData"])
        menu_data["utilities"].addAction(menu_data["reloadModules"])

        # blueprint options
        menu_data["blueprintOptions"].addAction(menu_data["setBlueprintPath"])
        # menu_data["blueprintOptions"].addAction(menu_data["saveBlueprint"])
        menu_data["blueprintOptions"].addAction(menu_data["saveNewBlueprint"])
        menu_data["blueprintOptions"].addAction(menu_data["removeBlueprint"])
        menu_data["blueprintOptions"].addAction(menu_data["openBlueprintDir"])
        menu_data["blueprintOptions"].addAction(menu_data["openBlueprintFile"])

        # set actions
        menu_data["options"].addAction(menu_data["updateModules"])
        menu_data["options"].addAction(menu_data["addModule"])
        menu_data["options"].addAction(menu_data["clearModules"])
        self.setMenuBar(menu_bar)
        return menu_data
Beispiel #20
0
 def add_delete_button():
     """
     adds a push button.
     :return: <QtWidgets.QPushButton>
     """
     return QtWidgets.QPushButton("Remove")
Beispiel #21
0
 def add_build_button():
     """
     adds a push button.
     :return: <QtWidgets.QPushButton>
     """
     return QtWidgets.QPushButton("Build")
Beispiel #22
0
 def add_text(self, name):
     """
     adds a QLabel text widget.
     :return: <QtWidgets.QLabel>
     """
     return QtWidgets.QLabel(name)
Beispiel #23
0
    def __init__(self,
                 parent=None,
                 module_name="",
                 list_widget=None,
                 item=None,
                 information=None):
        super(ModuleWidget, self).__init__(parent)
        # initialize the module main layout
        self.main_layout = QtWidgets.QHBoxLayout()
        self.main_layout.setSizeConstraint(QtWidgets.QLayout.SetFixedSize)
        self.setLayout(self.main_layout)

        # initialize widget variables
        self.icon = None
        self.q_text = None
        self.q_pix = None
        self.build_button = None
        self.delete_button = None
        self.version_combo = None
        self.name_label = None
        self.dialog = None
        self.module = None

        # initialize important variables
        self.list_widget = list_widget
        self.item = item
        self.parent = parent
        self.version = 0000

        self.module_name = module_name
        self.module_data = self.find_module_data(module_name)
        self.module_index = get_module_count(module_name)

        # set the information data dictionary of the module to pass data down to modules
        if information:
            if "name" in information:
                self.name = information["name"]
            if "creature" not in information:
                information[
                    "creature"] = parent.module_form.get_selected_blueprint()
            if "creature_directory" not in information:
                information["creature_directory"] = blueprint_utils.build_dir(
                    information["creature"])
        else:
            self.name = '{}_{}'.format(module_name, self.module_index)

        # debug print
        debug_print("{}\n".format(self.name))
        debug_print(information)

        # build the module widgets
        self.build()
        self.initialize_versions()

        # create the connections
        self.connect_buttons()

        # activate this module
        self.create_module(information=information)

        debug_print(self.module.PUBLISH_ATTRIBUTES)

        # initialize the attributes
        # Python never implicitly copies the objects, when set, it is referred to the exact same module.
        self.module_attributes = dict(self.module.PUBLISH_ATTRIBUTES)

        # update the class published attribute with the name given
        self.update_attribute('name', self.name)
Beispiel #24
0
    def __init__(self, parent=None):
        super(ModuleDialog, self).__init__(parent)

        # class variables
        self.vertical_layout = QtWidgets.QVBoxLayout(self)
        self.vertical_layout.addStretch(1)