Exemplo n.º 1
0
    def change_profile_section(self):

        profile_groupBox, profile_layout = GroupGrid("Change Profile")

        profile_layout.addWidget(Label({'txt': 'First Name'}), 0, 0, 1, 2)
        profile_layout.addWidget(Label({'txt': 'Last Name'}), 1, 0, 1, 2)
        profile_layout.addWidget(Label({'txt': 'Your Title'}), 2, 0, 1, 2)
        profile_layout.addWidget(Label({'txt': 'Email'}), 3, 0, 1, 2)
        profile_layout.addWidget(Label({'txt': 'Phone Number'}), 4, 0, 1, 2)

        self.firstnameField             = LineEdit()
        self.lastnameField              = LineEdit()
        self.titleField                 = LineEdit()
        self.emailField                 = LineEdit()
        self.phoneField                 = LineEdit()

        change_profile_btn = Button({'txt': "Update Profile", 'cl': self.update_profile})

        profile_layout.addWidget(self.firstnameField, 0, 2, 1, 4)
        profile_layout.addWidget(self.lastnameField, 1, 2, 1, 4)
        profile_layout.addWidget(self.titleField, 2, 2, 1, 4)
        profile_layout.addWidget(self.emailField, 3, 2, 1, 4)
        profile_layout.addWidget(self.phoneField, 4, 2, 1, 4)
        profile_layout.addWidget(change_profile_btn, 5, 0, 1, 6)

        return profile_groupBox
Exemplo n.º 2
0
    def __init__(self, parent=None):
        super(ServerConfig, self).__init__(parent)

        serverLabel             = Label({'txt':"Server:"})
        serverCombo             = ComboBox({'items': ['Local: {}'.format(__localServer__), 'Global: {}'.format(__globalServer__)]})
        serverLayout            = HBoxLayout({'addWidget': [serverLabel, serverCombo]})
        serverConfigLayout      = VBoxLayout({'addLayout': [serverLayout]})
        serverConfigGroup       = GroupBox("Server configuration", [serverConfigLayout], 'setLayout')

        projectLabel            = Label({'txt': "Set Project:"})
        projectPath             = LineEdit()
        projectBtn              = Button({'txt': 'Set Path'})
        projectLayout           = HBoxLayout({'addWidget': [projectLabel, projectPath, projectBtn]})
        projectConfigLayout     = VBoxLayout({'addLayout': [projectLayout]})
        projectConfigGroup      = GroupBox("Project configuration", [projectConfigLayout], 'setLayout')

        teamtLabel              = Label({'txt': "Set Team:"})
        teamPath                = LineEdit()
        teamBtn                 = Button({'txt': 'Set Team'})
        teamLayout              = HBoxLayout({'addWidget': [teamtLabel, teamPath, teamBtn]})
        teamConfigLayout        = VBoxLayout({'addLayout': [teamLayout]})
        TeamConfigGroup         = GroupBox("Project configuration", [teamConfigLayout], 'setLayout')

        mainLayout              = VBoxLayout({'addWidget': [serverConfigGroup, projectConfigGroup, TeamConfigGroup], 'addStretch': 1})

        self.setLayout(mainLayout)
Exemplo n.º 3
0
    def change_location_section(self):

        location_groupBox, location_layout = GroupGrid("Change Location")

        location_layout.addWidget(Label({'txt': 'Address Line 1'}), 0, 0, 1, 2)
        location_layout.addWidget(Label({'txt': 'Address Line 2'}), 1, 0, 1, 2)
        location_layout.addWidget(Label({'txt': 'Postal'}), 2, 0, 1, 2)
        location_layout.addWidget(Label({'txt': 'City'}), 3, 0, 1, 2)
        location_layout.addWidget(Label({'txt': 'Country'}), 4, 0, 1, 2)

        self.address1Field              = LineEdit()
        self.address2Field              = LineEdit()
        self.postalField                = LineEdit()
        self.cityField                  = LineEdit()
        self.countryField               = LineEdit()

        change_location_btn = Button({'txt': "Update Location", 'cl': self.update_location})

        location_layout.addWidget(self.address1Field, 0, 2, 1, 4)
        location_layout.addWidget(self.address2Field, 1, 2, 1, 4)
        location_layout.addWidget(self.postalField, 2, 2, 1, 4)
        location_layout.addWidget(self.cityField, 3, 2, 1, 4)
        location_layout.addWidget(self.countryField, 4, 2, 1, 4)
        location_layout.addWidget(change_location_btn, 5, 0, 1, 6)

        return location_groupBox
Exemplo n.º 4
0
    def location_section(self):
        self.conSection, conGrid = GroupGrid("Location")

        conGrid.addWidget(Label({'txt': "Address Line 1"}), 0, 0, 1, 2)
        conGrid.addWidget(Label({'txt': "Address Line 2"}), 1, 0, 1, 2)
        conGrid.addWidget(Label({'txt': "Postal"}), 2, 0, 1, 2)
        conGrid.addWidget(Label({'txt': "City"}), 3, 0, 1, 2)
        conGrid.addWidget(Label({'txt': "Country"}), 4, 0, 1, 2)

        self.addressLine1 = LineEdit()
        self.addressLine2 = LineEdit()
        self.postalCode = LineEdit()
        self.city = LineEdit()
        self.country = LineEdit()

        conGrid.addWidget(self.addressLine1, 0, 2, 1, 4)
        conGrid.addWidget(self.addressLine2, 1, 2, 1, 4)
        conGrid.addWidget(self.city, 2, 2, 1, 4)
        conGrid.addWidget(self.postalCode, 3, 2, 1, 4)
        conGrid.addWidget(self.country, 4, 2, 1, 4)
Exemplo n.º 5
0
    def profile_section(self):
        self.prfSection, profile_grid = GroupGrid("Profile")

        profile_grid.addWidget(Label({'txt': 'First Name'}), 0, 0, 1, 2)
        profile_grid.addWidget(Label({'txt': 'Last Name'}), 1, 0, 1, 2)
        profile_grid.addWidget(Label({'txt': 'Your Title'}), 2, 0, 1, 2)
        profile_grid.addWidget(Label({'txt': 'Email'}), 3, 0, 1, 2)
        profile_grid.addWidget(Label({'txt': 'Phone Number'}), 4, 0, 1, 2)

        self.titleField = LineEdit()
        self.firstnameField = LineEdit()
        self.lastnameField = LineEdit()
        self.emailField = LineEdit()
        self.phoneField = LineEdit()

        profile_grid.addWidget(self.firstnameField, 0, 2, 1, 4)
        profile_grid.addWidget(self.lastnameField, 1, 2, 1, 4)
        profile_grid.addWidget(self.titleField, 2, 2, 1, 4)
        profile_grid.addWidget(self.emailField, 3, 2, 1, 4)
        profile_grid.addWidget(self.phoneField, 4, 2, 1, 4)
Exemplo n.º 6
0
    def security_section(self):

        self.serSection, questions_grid = GroupGrid("Security Question")

        self.ques1 = ComboBox(
            {'items': [str(i) for i in QUESTIONS.split('\n')]})
        self.answ2 = LineEdit()

        self.ques2 = ComboBox(
            {'items': [str(i) for i in QUESTIONS.split('\n')]})
        self.answ1 = LineEdit()

        questions_grid.addWidget(Label({'txt': 'Question 1'}), 0, 0, 1, 3)
        questions_grid.addWidget(Label({'txt': 'Answer 1'}), 1, 0, 1, 3)
        questions_grid.addWidget(Label({'txt': 'Question 2'}), 2, 0, 1, 3)
        questions_grid.addWidget(Label({'txt': 'Answer 2'}), 3, 0, 1, 3)

        questions_grid.addWidget(self.ques1, 0, 3, 1, 6)
        questions_grid.addWidget(self.answ1, 1, 3, 1, 6)
        questions_grid.addWidget(self.ques2, 2, 3, 1, 6)
        questions_grid.addWidget(self.answ2, 3, 3, 1, 6)
Exemplo n.º 7
0
    def buildUI(self):

        loginGrp, loginGrid = GroupGrid('Sign in')

        self.userTF = LineEdit()
        self.pwTF = LineEdit({'fn': 'password'})
        self.userCB = CheckBox('Remember me?')

        forgot_pw_btn = Button({
            'txt':
            'Forgot your password?',
            'cl':
            partial(self.signals.emit, 'showLayout', 'ForgotPassword', 'show')
        })
        login_btn = Button({'txt': 'Log in', 'cl': self.signInClicked})
        cancel_btn = Button({'txt': 'Cancel', 'cl': QApplication.quit})

        signupGrp, signupGrid = GroupGrid('Sign up')
        signupBtn = Button({
            'txt':
            'Sign up',
            'cl':
            partial(self.signals.emit, 'showLayout', 'SignUp', 'show')
        })

        loginGrid.addWidget(usernameLabel, 0, 0, 1, 2)
        loginGrid.addWidget(passwordLabel, 1, 0, 1, 2)
        loginGrid.addWidget(self.userTF, 0, 2, 1, 4)
        loginGrid.addWidget(self.pwTF, 1, 2, 1, 4)
        loginGrid.addWidget(self.userCB, 2, 1, 1, 2)
        loginGrid.addWidget(login_btn, 2, 3, 1, 3)
        loginGrid.addWidget(forgot_pw_btn, 3, 0, 1, 3)
        loginGrid.addWidget(cancel_btn, 3, 3, 1, 3)

        signupGrid.addWidget(Label({'txt': SIGNUP}), 0, 0, 1, 6)
        signupGrid.addWidget(signupBtn, 1, 0, 1, 6)

        self.layout.addWidget(loginGrp, 0, 0, 1, 1)
        self.layout.addWidget(signupGrp, 1, 0, 1, 1)
Exemplo n.º 8
0
    def buildUI(self):

        officeBtns = []
        keys = ['TextEditor', 'NoteReminder']
        for key in keys:
            if key in self.appInfo:
                btn = Button({'icon':key, 'tt': self.appInfo[key][2], 'fix': BTNICONSIZE, 'ics': ICONBTNSIZE, 'emit2':[self.signals.showLayout.emit, [FIX_KEYS[key], 'show']]})
                officeBtns.append(btn)

        for key in CONFIG_OFFICE:
            if key in self.appInfo:
                btn = Button({'icon': key, 'tt': self.appInfo[key][2], 'fix': BTNICONSIZE, 'ics': ICONBTNSIZE, 'emit1': [self.signals.executing.emit, self.appInfo[key][2]]})
                officeBtns.append(btn)

        devBtns = []
        for key in CONFIG_DEV:
            if key in self.appInfo:
                btn = Button({'icon': key, 'tt': self.appInfo[key][2], 'fix': BTNICONSIZE, 'ics': ICONBTNSIZE, 'emit1': [self.signals.executing.emit, self.appInfo[key][2]]})
                devBtns.append(btn)

        pyuiBtn = []
        for key in CONFIG_TOOLS:
            if key in self.appInfo:
                btn = Button({'icon': key, 'tt': self.appInfo[key][2], 'fix': BTNICONSIZE, 'ics': ICONBTNSIZE, 'emit2': [self.signals.showLayout.emit, [FIX_KEYS[key], 'show']]})
                pyuiBtn.append(btn)

        extraBtns = []
        for key in CONFIG_EXTRA:
            if key in self.appInfo:
                btn = Button({'icon': key, 'tt': self.appInfo[key][2], 'fix': BTNICONSIZE, 'ics': ICONBTNSIZE, 'emit2': [self.signals.executing.emit, key]})
                extraBtns.append(btn)

        sec1Grp = GroupBox("Office", officeBtns, "IconGrid")
        sec2Grp = GroupBox("Dev", devBtns, "IconGrid")
        sec3Grp = GroupBox("Tools", pyuiBtn, "IconGrid")
        sec4Grp = GroupBox("Extra", extraBtns, "IconGrid")

        self.findEdit = LineEdit()
        findBtn = Button({'txt':"Find Tool"})

        sec5Grp = GroupBox("Find Tool")
        sec5Grid = GridLayout()
        sec5Grid.addWidget(self.findEdit, 0, 0, 1, 7)
        sec5Grid.addWidget(findBtn, 0, 7, 1, 2)
        sec5Grp.setLayout(sec5Grid)

        self.layout.addWidget(sec1Grp, 0, 0, 2, 3)
        self.layout.addWidget(sec2Grp, 2, 0, 2, 3)
        self.layout.addWidget(sec3Grp, 0, 3, 4, 3)
        self.layout.addWidget(sec4Grp, 0, 6, 4, 3)
        self.layout.addWidget(sec5Grp, 4, 0, 1, 9)
Exemplo n.º 9
0
    def step2_layout(self):

        step2_groupBox = GroupBox("Step 2")
        step2_layout = VBoxLayout()
        step2_groupBox.setLayout(step2_layout)

        self.question1 = Label({'txt': "Question 1"})
        self.question2 = Label({'txt': "Question 2"})

        self.answer1 = LineEdit()
        self.answer2 = LineEdit()

        step2_btn_box = QDialogButtonBox(QDialogButtonBox.Ok
                                         | QDialogButtonBox.Cancel)
        step2_btn_box.accepted.connect(self.on_step2_btn_clicked)
        step2_btn_box.rejected.connect(self.close)

        step2_layout.addWidget(self.question1)
        step2_layout.addWidget(self.answer1)
        step2_layout.addWidget(self.question2)
        step2_layout.addWidget(self.answer2)
        step2_layout.addWidget(step2_btn_box)

        return step2_groupBox
Exemplo n.º 10
0
    def account_section(self):
        self.accSection, account_grid = GroupGrid("Account")
        self.userField = LineEdit()
        self.pwField = LineEdit({'fn': 'password'})
        self.cfpwField = LineEdit({'fn': 'password'})

        account_grid.addWidget(Label({'txt': 'User Name'}), 0, 0, 1, 2)
        account_grid.addWidget(Label({'txt': 'Password'}), 1, 0, 1, 2)
        account_grid.addWidget(Label({'txt': 'Confirm Password'}), 2, 0, 1, 2)

        account_grid.addWidget(self.userField, 0, 3, 1, 4)
        account_grid.addWidget(self.pwField, 1, 3, 1, 4)
        account_grid.addWidget(self.cfpwField, 2, 3, 1, 4)
Exemplo n.º 11
0
    def buildUI(self):

        self.layout = GridLayout(self)
        self.lineInput = LineEdit()
        self.lineInput.textChanged.connect(self.getText)

        self.suggessLabel = Label()

        searchBtn = Button({'txt': 'Translate', 'cl': self.btn_clicked})
        yesBtn = Button({'txt': 'Yes', 'cl': self.btn_clicked})
        noBtn = Button({'txt': 'No', 'cl': self.btn_clicked})

        self.answer = QTextEdit()
        self.answer.setPlainText(" ")

        self.layout.addWidget(self.lineInput, 0, 0, 1, 3)
        self.layout.addWidget(self.suggessLabel, 1, 0, 1, 3)
        self.layout.addWidget(searchBtn, 2, 0, 1, 1)
        self.layout.addWidget(yesBtn, 2, 1, 1, 1)
        self.layout.addWidget(noBtn, 2, 2, 1, 1)
        self.layout.addWidget(self.answer, 3, 0, 4, 3)

        self.setLayout(self.layout)
Exemplo n.º 12
0
    def change_pass_section(self):

        password_groupBox, password_layout = GroupGrid('Change Password')

        self.old_pass                   = LineEdit({'echo': 'password'})
        self.new_pass                   = LineEdit({'echo': 'password'})
        self.confirm_pass               = LineEdit({'echo': 'password'})
        change_pass_btn                 = Button({'txt': 'Change Password', 'cl': self.update_password})

        password_layout.addWidget(Label({'txt': 'Old Password'}), 0, 0, 1, 2)
        password_layout.addWidget(Label({'txt': 'New Password'}), 1, 0, 1, 2)
        password_layout.addWidget(Label({'txt': 'Confirm Password'}), 2, 0, 1, 2)
        password_layout.addWidget(self.old_pass, 0, 2, 1, 4)
        password_layout.addWidget(self.new_pass, 1, 2, 1, 4)
        password_layout.addWidget(self.confirm_pass, 2, 2, 1, 4)
        password_layout.addWidget(change_pass_btn, 3, 0, 1, 6)

        return password_groupBox
Exemplo n.º 13
0
class UserSetting(Widget):

    key = 'UserSetting'
    query = QuerryDB()

    def __init__(self, parent=None):

        super(UserSetting, self).__init__(parent)

        # self.setWindowIcon(AppIcon(32, "UserSetting"))
        self.layout = GridLayout()
        self.buildUI()
        self.setLayout(self.layout)

    def buildUI(self):

        password_section = self.change_pass_section()
        avatar_section = self.change_avatar_section()
        profile_section = self.change_profile_section()
        location_setion = self.change_location_section()

        self.layout.addWidget(avatar_section, 0, 0, 1, 1)
        self.layout.addWidget(password_section, 0, 1 , 1, 1)
        self.layout.addWidget(profile_section, 1, 0, 1, 1)
        self.layout.addWidget(location_setion, 1, 1, 1, 1)

    def change_avatar_section(self):

        try:
            self.username, token, cookie, remember = self.query.query_table('curUser')
        except (ValueError, IndexError):
            self.username = '******'

        avatar_groupBox, avatar_layout = GroupGrid('Change Avatar')

        self.avatar = Label()
        self.avatar.setPixmap(QPixmap.fromImage(QImage(get_avatar_image(self.username))))
        self.avatar.setScaledContents(True)
        self.avatar.setFixedSize(100, 100)

        change_avatar_btn = Button({'txt':'Change Avatar', 'cl': self.update_avatar})
        avatar_layout.addWidget(self.avatar)
        avatar_layout.addWidget(change_avatar_btn)

        return avatar_groupBox

    def change_pass_section(self):

        password_groupBox, password_layout = GroupGrid('Change Password')

        self.old_pass                   = LineEdit({'echo': 'password'})
        self.new_pass                   = LineEdit({'echo': 'password'})
        self.confirm_pass               = LineEdit({'echo': 'password'})
        change_pass_btn                 = Button({'txt': 'Change Password', 'cl': self.update_password})

        password_layout.addWidget(Label({'txt': 'Old Password'}), 0, 0, 1, 2)
        password_layout.addWidget(Label({'txt': 'New Password'}), 1, 0, 1, 2)
        password_layout.addWidget(Label({'txt': 'Confirm Password'}), 2, 0, 1, 2)
        password_layout.addWidget(self.old_pass, 0, 2, 1, 4)
        password_layout.addWidget(self.new_pass, 1, 2, 1, 4)
        password_layout.addWidget(self.confirm_pass, 2, 2, 1, 4)
        password_layout.addWidget(change_pass_btn, 3, 0, 1, 6)

        return password_groupBox

    def change_profile_section(self):

        profile_groupBox, profile_layout = GroupGrid("Change Profile")

        profile_layout.addWidget(Label({'txt': 'First Name'}), 0, 0, 1, 2)
        profile_layout.addWidget(Label({'txt': 'Last Name'}), 1, 0, 1, 2)
        profile_layout.addWidget(Label({'txt': 'Your Title'}), 2, 0, 1, 2)
        profile_layout.addWidget(Label({'txt': 'Email'}), 3, 0, 1, 2)
        profile_layout.addWidget(Label({'txt': 'Phone Number'}), 4, 0, 1, 2)

        self.firstnameField             = LineEdit()
        self.lastnameField              = LineEdit()
        self.titleField                 = LineEdit()
        self.emailField                 = LineEdit()
        self.phoneField                 = LineEdit()

        change_profile_btn = Button({'txt': "Update Profile", 'cl': self.update_profile})

        profile_layout.addWidget(self.firstnameField, 0, 2, 1, 4)
        profile_layout.addWidget(self.lastnameField, 1, 2, 1, 4)
        profile_layout.addWidget(self.titleField, 2, 2, 1, 4)
        profile_layout.addWidget(self.emailField, 3, 2, 1, 4)
        profile_layout.addWidget(self.phoneField, 4, 2, 1, 4)
        profile_layout.addWidget(change_profile_btn, 5, 0, 1, 6)

        return profile_groupBox

    def change_location_section(self):

        location_groupBox, location_layout = GroupGrid("Change Location")

        location_layout.addWidget(Label({'txt': 'Address Line 1'}), 0, 0, 1, 2)
        location_layout.addWidget(Label({'txt': 'Address Line 2'}), 1, 0, 1, 2)
        location_layout.addWidget(Label({'txt': 'Postal'}), 2, 0, 1, 2)
        location_layout.addWidget(Label({'txt': 'City'}), 3, 0, 1, 2)
        location_layout.addWidget(Label({'txt': 'Country'}), 4, 0, 1, 2)

        self.address1Field              = LineEdit()
        self.address2Field              = LineEdit()
        self.postalField                = LineEdit()
        self.cityField                  = LineEdit()
        self.countryField               = LineEdit()

        change_location_btn = Button({'txt': "Update Location", 'cl': self.update_location})

        location_layout.addWidget(self.address1Field, 0, 2, 1, 4)
        location_layout.addWidget(self.address2Field, 1, 2, 1, 4)
        location_layout.addWidget(self.postalField, 2, 2, 1, 4)
        location_layout.addWidget(self.cityField, 3, 2, 1, 4)
        location_layout.addWidget(self.countryField, 4, 2, 1, 4)
        location_layout.addWidget(change_location_btn, 5, 0, 1, 6)

        return location_groupBox

    def update_password(self):

        old_pass = text_to_hex(self.old_pass.text())
        new_pass = text_to_hex(self.new_pass.text())
        confirm_pass = text_to_hex(self.confirm_pass.text())

        if len(old_pass) == 0 or len(new_pass) == 0 or len(confirm_pass) == 0:
            MessageBox(self, title='Failed', level='critical', message=PW_BLANK, btn='ok')
            return
        elif new_pass is not confirm_pass:
            MessageBox(self, title='Failed', level='critical', message=PW_UNMATCH, btn='ok')
            return
        else:
            # checkPass = func.check_pw_match(self.username, old_pass)
            # if not checkPass:
            #     QMessageBox.critical(self, 'Failed', "Password not match")
            #     return
            # else:
            #     newpass = func.encode(self.newPassword.text())
            #     func.update_password(self.unix, newpass)
            #     QMessageBox.information(self, 'Updated', PW_CHANGED)
            pass

    def update_avatar(self):

        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        imgsDir = os.path.join(os.getenv(__envKey__), 'avatar')
        fileName, _ = QFileDialog.getOpenFileName(self, "Your Avatar", imgsDir, "All Files (*);;Img Files (*.jpg)",
                                                  options=options)
        if fileName:
            baseFileName = self.username + '.avatar.jpg'
            desPth = os.path.join(imgsDir, baseFileName)

            if desPth == fileName:
                pass
            elif os.path.exists(desPth):
                if os.path.exists(desPth + '.showLayout_old'):
                    os.remove(desPth + '.showLayout_old')

                os.rename(desPth, desPth + '.showLayout_old')
                resize_image(fileName, desPth)
                shutil.copy2(fileName, desPth)
                image = QPixmap.fromImage(QImage(desPth))
                self.avatar.setPixmap(image)
                self.avatar.update()
                self.settings.setValue(self.username, desPth)
                self.updateAvatar.emit(True)

    def update_profile(self):
        pass

    def update_location(self):
        pass
Exemplo n.º 14
0
    def buildUI(self):
        self.layout = QGridLayout(self)

        self.pendingAdditiveOperator            = ''
        self.pendingMultiplicativeOperator      = ''
        self.sumInMemory                        = 0.0
        self.sumSoFar                           = 0.0
        self.factorSoFar                        = 0.0
        self.waitingForOperand                  = True

        self.display = LineEdit({'txt': '0'})
        self.display.setReadOnly(True)
        self.display.setAlignment(Qt.AlignRight)

        for i in range(self.NumDigitButtons):
            self.digitButtons.append(self.createButton(str(i), self.digitClicked))

        self.pointButton            = self.createButton(".", self.pointClicked)
        self.changeSignButton       = self.createButton(u"\N{PLUS-MINUS SIGN}",  self.changeSignClicked)
        self.backspaceButton        = self.createButton("Backspace", self.backspaceClicked)
        self.clearButton            = self.createButton("Clear", self.clear)
        self.clearAllButton         = self.createButton("Clear All", self.clearAll)
        self.clearMemoryButton      = self.createButton("MC", self.clearMemory)
        self.readMemoryButton       = self.createButton("MR", self.readMemory)
        self.setMemoryButton        = self.createButton("MS", self.setMemory)
        self.addToMemoryButton      = self.createButton("M+", self.addToMemory)
        self.divisionButton         = self.createButton(u"\N{DIVISION SIGN}", self.multiplicativeOperatorClicked)
        self.timesButton            = self.createButton(u"\N{MULTIPLICATION SIGN}", self.multiplicativeOperatorClicked)
        self.minusButton            = self.createButton("-", self.additiveOperatorClicked)
        self.plusButton             = self.createButton("+", self.additiveOperatorClicked)
        self.squareRootButton       = self.createButton("Sqrt", self.unaryOperatorClicked)
        self.powerButton            = self.createButton(u"x\N{SUPERSCRIPT TWO}", self.unaryOperatorClicked)
        self.reciprocalButton       = self.createButton("1/x", self.unaryOperatorClicked)
        self.equalButton            = self.createButton("=", self.equalClicked)

        self.layout.addWidget(self.display, 0,0,1,6)
        self.layout.addWidget(self.backspaceButton, 1,0,1,2)
        self.layout.addWidget(self.clearButton, 1,2,1,2)
        self.layout.addWidget(self.clearAllButton, 1,4,1,2)
        self.layout.addWidget(self.clearMemoryButton,2,0)
        self.layout.addWidget(self.readMemoryButton,3,0)
        self.layout.addWidget(self.setMemoryButton,4,0)
        self.layout.addWidget(self.addToMemoryButton,5,0)

        for i in range(1, self.NumDigitButtons):
            row = ((9 - i) / 3) + 2
            column = ((i - 1) % 3) + 1
            self.layout.addWidget(self.digitButtons[i], row, column)

        self.layout.addWidget(self.digitButtons[0],5,1)
        self.layout.addWidget(self.pointButton,5,2)
        self.layout.addWidget(self.changeSignButton,5,3)
        self.layout.addWidget(self.divisionButton,2,4)
        self.layout.addWidget(self.timesButton,3,4)
        self.layout.addWidget(self.minusButton,4,4)
        self.layout.addWidget(self.plusButton,5,4)
        self.layout.addWidget(self.squareRootButton,2,5)
        self.layout.addWidget(self.powerButton,3,5)
        self.layout.addWidget(self.reciprocalButton,4,5)
        self.layout.addWidget(self.equalButton,5,5)

        self.display.setMaxLength(15)
        font = self.display.font()
        font.setPointSize(font.pointSize() + 8)
        self.display.setFont(font)

        self.setLayout(self.layout)
Exemplo n.º 15
0
class SignIn(Widget):

    key = 'SignIn'
    _login = False

    def __init__(self, parent=None):

        super(SignIn, self).__init__(parent)

        self.setWindowIcon(AppIcon(32, "SignIn"))
        self.setFixedSize(400, 300)
        self.setWindowTitle('Sign In')

        self.layout = GridLayout()
        self.buildUI()
        self.setLayout(self.layout)

    def buildUI(self):

        loginGrp, loginGrid = GroupGrid('Sign in')

        self.userTF = LineEdit()
        self.pwTF = LineEdit({'fn': 'password'})
        self.userCB = CheckBox('Remember me?')

        forgot_pw_btn = Button({
            'txt':
            'Forgot your password?',
            'cl':
            partial(self.signals.emit, 'showLayout', 'ForgotPassword', 'show')
        })
        login_btn = Button({'txt': 'Log in', 'cl': self.signInClicked})
        cancel_btn = Button({'txt': 'Cancel', 'cl': QApplication.quit})

        signupGrp, signupGrid = GroupGrid('Sign up')
        signupBtn = Button({
            'txt':
            'Sign up',
            'cl':
            partial(self.signals.emit, 'showLayout', 'SignUp', 'show')
        })

        loginGrid.addWidget(usernameLabel, 0, 0, 1, 2)
        loginGrid.addWidget(passwordLabel, 1, 0, 1, 2)
        loginGrid.addWidget(self.userTF, 0, 2, 1, 4)
        loginGrid.addWidget(self.pwTF, 1, 2, 1, 4)
        loginGrid.addWidget(self.userCB, 2, 1, 1, 2)
        loginGrid.addWidget(login_btn, 2, 3, 1, 3)
        loginGrid.addWidget(forgot_pw_btn, 3, 0, 1, 3)
        loginGrid.addWidget(cancel_btn, 3, 3, 1, 3)

        signupGrid.addWidget(Label({'txt': SIGNUP}), 0, 0, 1, 6)
        signupGrid.addWidget(signupBtn, 1, 0, 1, 6)

        self.layout.addWidget(loginGrp, 0, 0, 1, 1)
        self.layout.addWidget(signupGrp, 1, 0, 1, 1)

    def forgetPwClicked(self):
        if __name__ == '__main__':
            from ui.subUI.Funcs.ForgotPassword import ForgotPassword
            self.forgotPW = ForgotPassword()
            self.forgotPW.show()
        else:
            self.signals.showLayout('ForgotPassword', 'show')

    def signInClicked(self):
        username = str(self.userTF.text())
        pass_word = str(self.pwTF.text())

        if username == "" or username is None:
            MessageBox(self, 'Login Failed', 'critical', USER_BLANK)
            return
        elif pass_word == "" or pass_word is None:
            MessageBox(self, 'Login Failed', 'critical', PW_BLANK)
            return

        password = str(pass_word)

        r = requests.post(__localServerAutho__,
                          verify=False,
                          data={
                              'user': username,
                              'pwd': password
                          })

        if r.status_code == 200:
            for i in r.headers['set-cookie'].split(";"):
                if 'connect.sid=' in i:
                    cookie = i.split('connect.sid=')[-1]
                    break
                else:
                    cookie = "No value"
                    continue

            token = r.json()['token']
            check = self.userCB.checkState()

            RemoveDB("curUser")
            UpdateDB("curUser", [username, token, cookie, str2bool(check)])
            self.signals.emit('loginChanged', True)
        else:
            RemoveDB("curUser")
            MessageBox(self, 'Login Failed', 'critical', PW_WRONG)
            return

    def loginChanged(self, login):
        self._login = login

    @property
    def login(self):
        return self._login

    @login.setter
    def login(self, newVal):
        self._login = newVal
Exemplo n.º 16
0
class SignUp(Widget):

    key = 'SignUp'

    def __init__(self, parent=None):
        super(SignUp, self).__init__(parent)

        self.setWindowIcon(AppIcon(32, "SignUp"))

        self.layout = GridLayout()
        self.buildUI()
        self.setLayout(self.layout)

    def buildUI(self):
        self.avatar_section()
        self.account_section()
        self.profile_section()
        self.location_section()
        self.security_section()
        self.buttons_section()

        self.layout.addWidget(Label({'txt': "ALL FIELD ARE REQUIRED!!!"}), 0,
                              0, 1, 6)
        self.layout.addWidget(self.avaSection, 1, 0, 1, 2)
        self.layout.addWidget(self.accSection, 1, 2, 1, 4)
        self.layout.addWidget(self.prfSection, 2, 0, 1, 6)
        self.layout.addWidget(self.conSection, 3, 0, 1, 6)
        self.layout.addWidget(self.serSection, 4, 0, 1, 6)
        self.layout.addWidget(self.btnSection, 5, 0, 1, 6)

        self.applySetting()

    def avatar_section(self):
        self.avaSection, avatar_grid = GroupGrid("Avatar")

        self.userAvatar = Label({
            'pxm': 'default',
            'scc': True,
            'sfs': [100, 100]
        })

        set_avatarBtn = Button({
            'txt': 'Set Avatar',
            'tt': 'Choose a showLayout_new avatar',
            'cl': self.setAvaClicked
        })

        avatar_grid.addWidget(self.userAvatar, 0, 0, 2, 2)
        avatar_grid.addWidget(set_avatarBtn, 2, 0, 1, 2)

    def account_section(self):
        self.accSection, account_grid = GroupGrid("Account")
        self.userField = LineEdit()
        self.pwField = LineEdit({'fn': 'password'})
        self.cfpwField = LineEdit({'fn': 'password'})

        account_grid.addWidget(Label({'txt': 'User Name'}), 0, 0, 1, 2)
        account_grid.addWidget(Label({'txt': 'Password'}), 1, 0, 1, 2)
        account_grid.addWidget(Label({'txt': 'Confirm Password'}), 2, 0, 1, 2)

        account_grid.addWidget(self.userField, 0, 3, 1, 4)
        account_grid.addWidget(self.pwField, 1, 3, 1, 4)
        account_grid.addWidget(self.cfpwField, 2, 3, 1, 4)

    def profile_section(self):
        self.prfSection, profile_grid = GroupGrid("Profile")

        profile_grid.addWidget(Label({'txt': 'First Name'}), 0, 0, 1, 2)
        profile_grid.addWidget(Label({'txt': 'Last Name'}), 1, 0, 1, 2)
        profile_grid.addWidget(Label({'txt': 'Your Title'}), 2, 0, 1, 2)
        profile_grid.addWidget(Label({'txt': 'Email'}), 3, 0, 1, 2)
        profile_grid.addWidget(Label({'txt': 'Phone Number'}), 4, 0, 1, 2)

        self.titleField = LineEdit()
        self.firstnameField = LineEdit()
        self.lastnameField = LineEdit()
        self.emailField = LineEdit()
        self.phoneField = LineEdit()

        profile_grid.addWidget(self.firstnameField, 0, 2, 1, 4)
        profile_grid.addWidget(self.lastnameField, 1, 2, 1, 4)
        profile_grid.addWidget(self.titleField, 2, 2, 1, 4)
        profile_grid.addWidget(self.emailField, 3, 2, 1, 4)
        profile_grid.addWidget(self.phoneField, 4, 2, 1, 4)

    def location_section(self):
        self.conSection, conGrid = GroupGrid("Location")

        conGrid.addWidget(Label({'txt': "Address Line 1"}), 0, 0, 1, 2)
        conGrid.addWidget(Label({'txt': "Address Line 2"}), 1, 0, 1, 2)
        conGrid.addWidget(Label({'txt': "Postal"}), 2, 0, 1, 2)
        conGrid.addWidget(Label({'txt': "City"}), 3, 0, 1, 2)
        conGrid.addWidget(Label({'txt': "Country"}), 4, 0, 1, 2)

        self.addressLine1 = LineEdit()
        self.addressLine2 = LineEdit()
        self.postalCode = LineEdit()
        self.city = LineEdit()
        self.country = LineEdit()

        conGrid.addWidget(self.addressLine1, 0, 2, 1, 4)
        conGrid.addWidget(self.addressLine2, 1, 2, 1, 4)
        conGrid.addWidget(self.city, 2, 2, 1, 4)
        conGrid.addWidget(self.postalCode, 3, 2, 1, 4)
        conGrid.addWidget(self.country, 4, 2, 1, 4)

    def security_section(self):

        self.serSection, questions_grid = GroupGrid("Security Question")

        self.ques1 = ComboBox(
            {'items': [str(i) for i in QUESTIONS.split('\n')]})
        self.answ2 = LineEdit()

        self.ques2 = ComboBox(
            {'items': [str(i) for i in QUESTIONS.split('\n')]})
        self.answ1 = LineEdit()

        questions_grid.addWidget(Label({'txt': 'Question 1'}), 0, 0, 1, 3)
        questions_grid.addWidget(Label({'txt': 'Answer 1'}), 1, 0, 1, 3)
        questions_grid.addWidget(Label({'txt': 'Question 2'}), 2, 0, 1, 3)
        questions_grid.addWidget(Label({'txt': 'Answer 2'}), 3, 0, 1, 3)

        questions_grid.addWidget(self.ques1, 0, 3, 1, 6)
        questions_grid.addWidget(self.answ1, 1, 3, 1, 6)
        questions_grid.addWidget(self.ques2, 2, 3, 1, 6)
        questions_grid.addWidget(self.answ2, 3, 3, 1, 6)

    def buttons_section(self):
        self.btnSection, btn_grid = GroupGrid()

        self.user_agree_checkBox = CheckBox(txt=USER_CHECK_REQUIRED)
        okBtn = Button({
            'txt': 'Create Account',
            'tt': 'Confirm to create an account',
            'cl': self.createBtnClicked
        })
        cancelBtn = Button({
            'txt':
            'Cancel',
            'tt':
            'Go back to Login stage',
            'cl':
            partial(self.signals.emit, 'showLayout', 'SignIn', 'SignIn')
        })
        quitBtn = Button({
            'txt': 'Quit',
            'tt': 'Quit the application',
            'cl': QApplication.quit
        })

        btn_grid.addWidget(self.user_agree_checkBox, 0, 0, 1, 6)
        btn_grid.addWidget(okBtn, 1, 0, 1, 2)
        btn_grid.addWidget(cancelBtn, 1, 2, 1, 2)
        btn_grid.addWidget(quitBtn, 1, 4, 1, 2)

    def setAvaClicked(self):
        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        self.rawAvatarPth, _ = QFileDialog.getOpenFileName(
            self,
            "Your Avatar",
            os.path.join('imgs', 'avatar'),
            "All Files (*);;Img Files (*.jpg)",
            options=options)

        if self.rawAvatarPth:
            self.userAvatar.setPixmap(
                QPixmap.fromImage(QImage(self.rawAvatarPth)))
            self.userAvatar.update()

    def createBtnClicked(self):
        if self.check_all_conditions():
            data = self.generate_user_data()
            MessageBox(self, "Failed", "information", WAIT_LAYOUT_COMPLETE,
                       'ok')
            return

    def collect_input(self):
        username = str(self.userField.text())
        password = str(self.pwField.text())
        confirm = str(self.cfpwField.text())
        firstname = str(self.firstnameField.text())
        lastname = str(self.lastnameField.text())
        email = str(self.emailField.text())
        phone = str(self.phoneField.text())
        address1 = str(self.addressLine1.text())
        address2 = str(self.addressLine2.text())
        postal = str(self.postalCode.text())
        city = str(self.city.text())
        country = str(self.country.text())
        answer1 = str(self.answ1.text())
        answer2 = str(self.answ2.text())
        return [
            username, password, confirm, firstname, lastname, email, phone,
            address1, address2, postal, city, country, answer1, answer2
        ]

    def check_all_conditions(self):
        if self.check_all_field_blank():
            if self.check_user_agreement():
                if self.check_pw_matching():
                    return True
        else:
            return False

    def check_all_field_blank(self):
        regInput = self.collect_input()
        secName = [
            "Username", "Password", "Confirm Password", "Firstname",
            "Lastname", "Email", "Phone", "Address line 1", "Address line 2",
            "Postal", "City", "Country", "Answer 1", "Answer 2"
        ]
        for section in regInput:
            if check_blank(section):
                return True
            else:
                QMessageBox.information(
                    self, "Fail", secName[regInput.index(section)] + "Blank",
                    QMessageBox.Ok)
                break

    def check_user_agreement(self):
        return self.user_agree_checkBox.checkState()

    def applySetting(self):
        self.resize(450, 900)

    def generate_user_data(self):
        regInput = self.collect_input()
        question1 = str(self.ques1.currentText())
        question2 = str(self.ques2.currentText())
        title = str(self.titleField.text()) or "Guess"

        token = getToken()
        timelog = getTime()
        sysInfo = get_user_location()
        productID = sysInfo['Product ID']
        ip, cityIP, countryIP = get_local_pc_info()
        unix = getUnix()
        datelog = getDate()
        pcOS = sysInfo['os']
        pcUser = sysInfo['pcUser']
        pcPython = sysInfo['python']

        if not os.path.exists(self.rawAvatarPth):
            avatar = get_avatar_image('default')
        else:
            avatar = self.rawAvatarPth

        data = [
            regInput[0], regInput[1], regInput[3], regInput[4], title,
            regInput[5], regInput[6], regInput[7], regInput[8], regInput[9],
            regInput[10], regInput[11], token, timelog, productID, ip, cityIP,
            countryIP, unix, question1, regInput[12], question2, regInput[13],
            datelog, pcOS, pcUser, pcPython, avatar
        ]
        return data

    def check_pw_matching(self):
        password = str(self.pwField.text())
        confirm = str(self.cfpwField.text())
        check_pass = check_match(password, confirm)
        if not check_pass:
            QMessageBox.information(self, "Warning", PW_UNMATCH,
                                    QMessageBox.Retry)
            return False
        return True

    def loginChanged(self, login):
        self._login = login

    @property
    def login(self):
        return self._login

    @login.setter
    def login(self, newVal):
        self._login = newVal
Exemplo n.º 17
0
    def __init__(self, parent=None):
        super(TaskInfo, self).__init__(parent)

        self.parent = parent

        self.addWidget(Label({'txt': 'Task Name: '}), 0, 0, 1, 1)
        self.taskName = LineEdit()
        self.addWidget(self.taskName, 0, 1, 1, 3)

        self.addWidget(Label({'txt': 'Task ID: '}), 1, 0, 1, 1)
        self.taskID = LineEdit()
        self.addWidget(self.taskID, 1, 1, 1, 3)

        self.addWidget(Label({'txt': 'Project ID: '}), 2, 0, 1, 1)
        self.projectID = LineEdit()
        self.addWidget(self.projectID, 2, 1, 1, 3)

        self.addWidget(Label({'txt': 'Project Name: '}), 3, 0, 1, 1)
        self.projectName = LineEdit()
        self.addWidget(self.projectName, 3, 1, 1, 3)

        self.addWidget(Label({'txt': 'Organisation ID: '}), 4, 0, 1, 1)
        self.organisationID = LineEdit()
        self.addWidget(self.organisationID, 4, 1, 1, 3)

        self.addWidget(Label({'txt': 'Organisation Name: '}), 5, 0, 1, 1)
        self.organisationName = LineEdit()
        self.addWidget(self.organisationName, 5, 1, 1, 3)

        self.addWidget(Label({'txt': 'Duetime'}), 7, 0, 1, 1)
        self.addWidget(Label({'txt': 'Hour'}), 6, 1, 1, 1)
        self.addWidget(Label({'txt': 'Minute'}), 6, 2, 1, 1)
        self.addWidget(Label({'txt': 'Second'}), 6, 3, 1, 1)
        self.addWidget(Label({'txt': 'Duedate'}), 9, 0, 1, 1)
        self.addWidget(Label({'txt': 'Day'}), 8, 1, 1, 1)
        self.addWidget(Label({'txt': 'Month'}), 8, 2, 1, 1)
        self.addWidget(Label({'txt': 'Year'}), 8, 3, 1, 1)

        self.year = LineEdit()
        self.month = LineEdit()
        self.day = LineEdit()
        self.hour = LineEdit()
        self.minute = LineEdit()
        self.second = LineEdit()

        for le in [
                self.year, self.month, self.day, self.hour, self.minute,
                self.second
        ]:
            le.setValidator(QIntValidator())

        self.addWidget(self.hour, 7, 1, 1, 1)
        self.addWidget(self.minute, 7, 2, 1, 1)
        self.addWidget(self.second, 7, 3, 1, 1)
        self.addWidget(self.day, 9, 1, 1, 1)
        self.addWidget(self.month, 9, 2, 1, 1)
        self.addWidget(self.year, 9, 3, 1, 1)
Exemplo n.º 18
0
class NewProject(Widget):

    info = {}
    key = 'NewProject'

    def __init__(self, parent=None):
        super(NewProject, self).__init__(parent)
        # self.setWindowIcon(AppIcon(32, "NewProject"))

        self.layout = GridLayout(self)
        self.buildUI()
        self.setLayout(self.layout)

    def buildUI(self):

        MESSAGE = "DUE TO THE POSSIBILITY OF USING RENDER FARM SERVICE, PLEAE SET PROJECT PATH TO E DRIVE\n " \
                  "IF YOU DO NOT USE RENDER FARM, DRIVE E IS STILL PREFER."

        TITLE = "SET UP NEW PROJECT"

        # Title
        headGrp, headGrid = self.styleGB()
        headGrid.addWidget(Label({'txt': TITLE}))

        # Project Info
        prjInfGrp, prjInfGrid   = self.styleGB("Project Info")
        self.prjLong            = LineEdit({'txt': "DAMG team project"})
        self.prjShort           = LineEdit({'txt': "damg"})
        self.prjPth             = LineEdit({'txt': "E:/"})

        setPthBtn = Button({'txt': "Set Path", 'stt': "Set project path", 'cl': self.onSetPthBtnClicked})

        prjInfGrid.addWidget(Label({'txt': "Project Name"}), 0, 0, 1, 1)
        prjInfGrid.addWidget(self.prjLong, 0, 1, 1, 1)
        prjInfGrid.addWidget(Label({'txt': "Abbreviated as"}), 0, 2, 1, 1)
        prjInfGrid.addWidget(self.prjShort, 0, 3, 1, 1)
        prjInfGrid.addWidget(setPthBtn, 1, 0, 1, 1)
        prjInfGrid.addWidget(self.prjPth, 1, 1, 1, 3)

        # Notice!!!
        noticeGrp, noticeGrid = self.styleGB("NOTE!!!")
        noticeGrid.addWidget(Label({'txt': MESSAGE}), 0, 0, 1, 4)

        # Project details
        prjDetailGrp, prjDetailGrid = self.styleGB("Project Details")

        self.prjMode = QComboBox()
        self.prjMode.addItem("Studio Mode")
        self.prjMode.addItem("Group Mode")

        self.numOfChar = LineEdit({'txt': "1", 'validator': 'int'})
        self.numOfChar.textChanged.connect(partial(self.populate_lst, "char"))

        self.numOfEnv = LineEdit({'txt': "1", 'validator': 'int'})
        self.numOfEnv.textChanged.connect(partial(self.populate_lst, "env"))

        self.numOfProp = LineEdit({'txt': "1", 'validator': 'int'})
        self.numOfProp.textChanged.connect(partial(self.populate_lst, "prop"))

        self.numOfSeq = LineEdit({'txt': "1", 'validator': 'int'})
        self.numOfSeq.textChanged.connect(partial(self.populate_lst, "seq"))

        prjDetailGrid.addWidget(Label({'txt':"Project Mode"}), 0,0,1,1)
        prjDetailGrid.addWidget(self.prjMode, 0, 1, 1, 1)
        prjDetailGrid.addWidget(Label({'txt':"Character: "}), 1,0,1,1)
        prjDetailGrid.addWidget(self.numOfChar, 2, 0, 1, 1)
        prjDetailGrid.addWidget(Label({'txt':"Environment: "}), 1,1,1,1)
        prjDetailGrid.addWidget(self.numOfEnv, 2, 1, 1, 1)
        prjDetailGrid.addWidget(Label({'txt':"Props: "}), 1,2,1,1)
        prjDetailGrid.addWidget(self.numOfProp, 2, 2, 1, 1)
        prjDetailGrid.addWidget(Label({'txt':"Sequences: "}), 1,3,1,1)
        prjDetailGrid.addWidget(self.numOfSeq, 2, 3, 1, 1)

        # Asset details
        charGrp, self.charLst = self.styleGBLst("Character List")
        envGrp, self.envLst = self.styleGBLst("Environment List")
        propGrp, self.propLst = self.styleGBLst("Props List")

        # Shot details
        seqGrp, self.seqLst = self.styleGBLst("Sequences List")

        # Buttons
        btnGrp, btnGrid = self.styleGB()

        prjLstBtn = Button({'txt': "Project List", 'stt': "Project List"})
        crewLstBtn = Button({'txt': "Crews List", 'stt': "Crews List"})
        newPrjBtn = Button({'txt': "Create Project", 'stt': "Create New Project"})
        cancelBtn = Button({'txt': "Cancel", 'stt': "Cancel"})

        btnGrid.addWidget(prjLstBtn, 0, 0)
        btnGrid.addWidget(crewLstBtn, 0, 1)
        btnGrid.addWidget(newPrjBtn, 0, 2)
        btnGrid.addWidget(cancelBtn, 0, 3)

        self.layout.addWidget(headGrp, 0, 0, 1, 4)
        self.layout.addWidget(prjInfGrp, 1, 0, 2, 4)
        self.layout.addWidget(noticeGrp, 3, 0, 1, 4)
        self.layout.addWidget(prjDetailGrp, 5,0,3,4)
        self.layout.addWidget(charGrp, 8,0,1,1)
        self.layout.addWidget(envGrp, 8,1,1,1)
        self.layout.addWidget(propGrp, 8,2,1,1)
        self.layout.addWidget(seqGrp, 8,3,1,1)
        self.layout.addWidget(btnGrp, 9,0,1,4)

        sections = ["char", "env", "prop", "seq"]
        for section in sections:
            self.populate_lst(section)

    def getZ(self, value):
        if value < 10:
            z = 1
        elif value < 100:
            z = 2
        elif value < 1000:
            z = 3
        else:
            z = 4
        return z

    def styleGB(self, title="", tl="grid"):
        if title == "":
            grpBox = QGroupBox()
        else:
            grpBox = QGroupBox(title)

        if tl.lower() == "grid":
            layout = GridLayout()
        elif tl.lower() == "hbox":
            layout = HBoxLayout()
        elif tl.lower() == "vbox":
            layout = VBoxLayout()

        grpBox.setLayout(layout)

        return grpBox, layout

    def styleGBLst(self, title=""):
        grpBox, hbox = self.styleGB(title, "hbox")
        listWidget = QListWidget()
        hbox.addWidget(listWidget)

        return grpBox, listWidget

    def onSetPthBtnClicked(self):
        opts = QFileDialog.DontResolveSymlinks | QFileDialog.ShowDirsOnly
        dir = QFileDialog.getExistingDirectory(self, "Set production path", self.prjPth.text(), options=opts)

        if dir:
            self.prjPth.setText(dir)
        else:
            self.logger.debug("You should set a valid path")

    def populate_lst(self, name="char"):
        if name.lower() == "char":
            lst = self.charLst
            value = int(self.numOfChar.text())
        elif name.lower() == "env":
            lst = self.envLst
            value = int(self.numOfEnv.text())
        elif name.lower() == "prop":
            lst = self.propLst
            value = int(self.numOfProp.text())
        elif name.lower() == "seq":
            lst = self.seqLst
            value = int(self.numOfSeq.text())
        else:
            lst = None
            value = 0

        lst.clear()
        z = self.getZ(value)

        for i in range(value):
            item = QListWidgetItem(lst)
            itemWidget = ItemWidget(name.lower(), "{0}_{1}".format(name.lower(), str(i+1).zfill(z)))
            item.setSizeHint(itemWidget.sizeHint())
            lst.addItem(item)
            lst.setItemWidget(item, itemWidget)
Exemplo n.º 19
0
    def buildUI(self):

        MESSAGE = "DUE TO THE POSSIBILITY OF USING RENDER FARM SERVICE, PLEAE SET PROJECT PATH TO E DRIVE\n " \
                  "IF YOU DO NOT USE RENDER FARM, DRIVE E IS STILL PREFER."

        TITLE = "SET UP NEW PROJECT"

        # Title
        headGrp, headGrid = self.styleGB()
        headGrid.addWidget(Label({'txt': TITLE}))

        # Project Info
        prjInfGrp, prjInfGrid   = self.styleGB("Project Info")
        self.prjLong            = LineEdit({'txt': "DAMG team project"})
        self.prjShort           = LineEdit({'txt': "damg"})
        self.prjPth             = LineEdit({'txt': "E:/"})

        setPthBtn = Button({'txt': "Set Path", 'stt': "Set project path", 'cl': self.onSetPthBtnClicked})

        prjInfGrid.addWidget(Label({'txt': "Project Name"}), 0, 0, 1, 1)
        prjInfGrid.addWidget(self.prjLong, 0, 1, 1, 1)
        prjInfGrid.addWidget(Label({'txt': "Abbreviated as"}), 0, 2, 1, 1)
        prjInfGrid.addWidget(self.prjShort, 0, 3, 1, 1)
        prjInfGrid.addWidget(setPthBtn, 1, 0, 1, 1)
        prjInfGrid.addWidget(self.prjPth, 1, 1, 1, 3)

        # Notice!!!
        noticeGrp, noticeGrid = self.styleGB("NOTE!!!")
        noticeGrid.addWidget(Label({'txt': MESSAGE}), 0, 0, 1, 4)

        # Project details
        prjDetailGrp, prjDetailGrid = self.styleGB("Project Details")

        self.prjMode = QComboBox()
        self.prjMode.addItem("Studio Mode")
        self.prjMode.addItem("Group Mode")

        self.numOfChar = LineEdit({'txt': "1", 'validator': 'int'})
        self.numOfChar.textChanged.connect(partial(self.populate_lst, "char"))

        self.numOfEnv = LineEdit({'txt': "1", 'validator': 'int'})
        self.numOfEnv.textChanged.connect(partial(self.populate_lst, "env"))

        self.numOfProp = LineEdit({'txt': "1", 'validator': 'int'})
        self.numOfProp.textChanged.connect(partial(self.populate_lst, "prop"))

        self.numOfSeq = LineEdit({'txt': "1", 'validator': 'int'})
        self.numOfSeq.textChanged.connect(partial(self.populate_lst, "seq"))

        prjDetailGrid.addWidget(Label({'txt':"Project Mode"}), 0,0,1,1)
        prjDetailGrid.addWidget(self.prjMode, 0, 1, 1, 1)
        prjDetailGrid.addWidget(Label({'txt':"Character: "}), 1,0,1,1)
        prjDetailGrid.addWidget(self.numOfChar, 2, 0, 1, 1)
        prjDetailGrid.addWidget(Label({'txt':"Environment: "}), 1,1,1,1)
        prjDetailGrid.addWidget(self.numOfEnv, 2, 1, 1, 1)
        prjDetailGrid.addWidget(Label({'txt':"Props: "}), 1,2,1,1)
        prjDetailGrid.addWidget(self.numOfProp, 2, 2, 1, 1)
        prjDetailGrid.addWidget(Label({'txt':"Sequences: "}), 1,3,1,1)
        prjDetailGrid.addWidget(self.numOfSeq, 2, 3, 1, 1)

        # Asset details
        charGrp, self.charLst = self.styleGBLst("Character List")
        envGrp, self.envLst = self.styleGBLst("Environment List")
        propGrp, self.propLst = self.styleGBLst("Props List")

        # Shot details
        seqGrp, self.seqLst = self.styleGBLst("Sequences List")

        # Buttons
        btnGrp, btnGrid = self.styleGB()

        prjLstBtn = Button({'txt': "Project List", 'stt': "Project List"})
        crewLstBtn = Button({'txt': "Crews List", 'stt': "Crews List"})
        newPrjBtn = Button({'txt': "Create Project", 'stt': "Create New Project"})
        cancelBtn = Button({'txt': "Cancel", 'stt': "Cancel"})

        btnGrid.addWidget(prjLstBtn, 0, 0)
        btnGrid.addWidget(crewLstBtn, 0, 1)
        btnGrid.addWidget(newPrjBtn, 0, 2)
        btnGrid.addWidget(cancelBtn, 0, 3)

        self.layout.addWidget(headGrp, 0, 0, 1, 4)
        self.layout.addWidget(prjInfGrp, 1, 0, 2, 4)
        self.layout.addWidget(noticeGrp, 3, 0, 1, 4)
        self.layout.addWidget(prjDetailGrp, 5,0,3,4)
        self.layout.addWidget(charGrp, 8,0,1,1)
        self.layout.addWidget(envGrp, 8,1,1,1)
        self.layout.addWidget(propGrp, 8,2,1,1)
        self.layout.addWidget(seqGrp, 8,3,1,1)
        self.layout.addWidget(btnGrp, 9,0,1,4)

        sections = ["char", "env", "prop", "seq"]
        for section in sections:
            self.populate_lst(section)
Exemplo n.º 20
0
class Calculator(Widget):

    key = 'Calculator'
    NumDigitButtons = 10
    digitButtons = DAMGLIST()

    def __init__(self, parent=None):
        super(Calculator, self).__init__(parent)

        self.setWindowIcon(AppIcon(32, 'Calculator'))
        self.setWindowTitle(self.key)
        self.buildUI()

    def buildUI(self):
        self.layout = QGridLayout(self)

        self.pendingAdditiveOperator            = ''
        self.pendingMultiplicativeOperator      = ''
        self.sumInMemory                        = 0.0
        self.sumSoFar                           = 0.0
        self.factorSoFar                        = 0.0
        self.waitingForOperand                  = True

        self.display = LineEdit({'txt': '0'})
        self.display.setReadOnly(True)
        self.display.setAlignment(Qt.AlignRight)

        for i in range(self.NumDigitButtons):
            self.digitButtons.append(self.createButton(str(i), self.digitClicked))

        self.pointButton            = self.createButton(".", self.pointClicked)
        self.changeSignButton       = self.createButton(u"\N{PLUS-MINUS SIGN}",  self.changeSignClicked)
        self.backspaceButton        = self.createButton("Backspace", self.backspaceClicked)
        self.clearButton            = self.createButton("Clear", self.clear)
        self.clearAllButton         = self.createButton("Clear All", self.clearAll)
        self.clearMemoryButton      = self.createButton("MC", self.clearMemory)
        self.readMemoryButton       = self.createButton("MR", self.readMemory)
        self.setMemoryButton        = self.createButton("MS", self.setMemory)
        self.addToMemoryButton      = self.createButton("M+", self.addToMemory)
        self.divisionButton         = self.createButton(u"\N{DIVISION SIGN}", self.multiplicativeOperatorClicked)
        self.timesButton            = self.createButton(u"\N{MULTIPLICATION SIGN}", self.multiplicativeOperatorClicked)
        self.minusButton            = self.createButton("-", self.additiveOperatorClicked)
        self.plusButton             = self.createButton("+", self.additiveOperatorClicked)
        self.squareRootButton       = self.createButton("Sqrt", self.unaryOperatorClicked)
        self.powerButton            = self.createButton(u"x\N{SUPERSCRIPT TWO}", self.unaryOperatorClicked)
        self.reciprocalButton       = self.createButton("1/x", self.unaryOperatorClicked)
        self.equalButton            = self.createButton("=", self.equalClicked)

        self.layout.addWidget(self.display, 0,0,1,6)
        self.layout.addWidget(self.backspaceButton, 1,0,1,2)
        self.layout.addWidget(self.clearButton, 1,2,1,2)
        self.layout.addWidget(self.clearAllButton, 1,4,1,2)
        self.layout.addWidget(self.clearMemoryButton,2,0)
        self.layout.addWidget(self.readMemoryButton,3,0)
        self.layout.addWidget(self.setMemoryButton,4,0)
        self.layout.addWidget(self.addToMemoryButton,5,0)

        for i in range(1, self.NumDigitButtons):
            row = ((9 - i) / 3) + 2
            column = ((i - 1) % 3) + 1
            self.layout.addWidget(self.digitButtons[i], row, column)

        self.layout.addWidget(self.digitButtons[0],5,1)
        self.layout.addWidget(self.pointButton,5,2)
        self.layout.addWidget(self.changeSignButton,5,3)
        self.layout.addWidget(self.divisionButton,2,4)
        self.layout.addWidget(self.timesButton,3,4)
        self.layout.addWidget(self.minusButton,4,4)
        self.layout.addWidget(self.plusButton,5,4)
        self.layout.addWidget(self.squareRootButton,2,5)
        self.layout.addWidget(self.powerButton,3,5)
        self.layout.addWidget(self.reciprocalButton,4,5)
        self.layout.addWidget(self.equalButton,5,5)

        self.display.setMaxLength(15)
        font = self.display.font()
        font.setPointSize(font.pointSize() + 8)
        self.display.setFont(font)

        self.setLayout(self.layout)

    def digitClicked(self):
        clickedButton = self.sender()
        digitValue = int(clickedButton.text())

        if self.display.text() == '0' and digitValue == 0.0:
            return

        if self.waitingForOperand:
            self.display.clear()
            self.waitingForOperand = False

        self.display.setText(self.display.text() + str(digitValue))

    def unaryOperatorClicked(self):
        clickedButton = self.sender()
        clickedOperator = clickedButton.text()
        operand = float(self.display.text())

        if clickedOperator == "Sqrt":
            if operand < 0.0:
                self.abortOperation()
                return

            result = math.sqrt(operand)
        elif clickedOperator == u"x\N{SUPERSCRIPT TWO}":
            result = math.pow(operand, 2.0)
        elif clickedOperator == "1/x":
            if operand == 0.0:
                self.abortOperation()
                return

            result = 1.0 / operand

        self.display.setText(str(result))
        self.waitingForOperand = True

    def additiveOperatorClicked(self):
        clickedButton = self.sender()
        clickedOperator = clickedButton.text()
        operand = float(self.display.text())

        if self.pendingMultiplicativeOperator:
            if not self.calculate(operand, self.pendingMultiplicativeOperator):
                self.abortOperation()
                return

            self.display.setText(str(self.factorSoFar))
            operand = self.factorSoFar
            self.factorSoFar = 0.0
            self.pendingMultiplicativeOperator = ''

        if self.pendingAdditiveOperator:
            if not self.calculate(operand, self.pendingAdditiveOperator):
                self.abortOperation()
                return

            self.display.setText(str(self.sumSoFar))
        else:
            self.sumSoFar = operand

        self.pendingAdditiveOperator = clickedOperator
        self.waitingForOperand = True

    def multiplicativeOperatorClicked(self):
        clickedButton = self.sender()
        clickedOperator = clickedButton.text()
        operand = float(self.display.text())

        if self.pendingMultiplicativeOperator:
            if not self.calculate(operand, self.pendingMultiplicativeOperator):
                self.abortOperation()
                return

            self.display.setText(str(self.factorSoFar))
        else:
            self.factorSoFar = operand

        self.pendingMultiplicativeOperator = clickedOperator
        self.waitingForOperand = True

    def equalClicked(self):
        operand = float(self.display.text())

        if self.pendingMultiplicativeOperator:
            if not self.calculate(operand, self.pendingMultiplicativeOperator):
                self.abortOperation()
                return

            operand = self.factorSoFar
            self.factorSoFar = 0.0
            self.pendingMultiplicativeOperator = ''

        if self.pendingAdditiveOperator:
            if not self.calculate(operand, self.pendingAdditiveOperator):
                self.abortOperation()
                return

            self.pendingAdditiveOperator = ''
        else:
            self.sumSoFar = operand

        self.display.setText(str(self.sumSoFar))
        self.sumSoFar = 0.0
        self.waitingForOperand = True

    def pointClicked(self):
        if self.waitingForOperand:
            self.display.setText('0')

        if "." not in self.display.text():
            self.display.setText(self.display.text() + ".")

        self.waitingForOperand = False

    def changeSignClicked(self):
        text = self.display.text()
        value = float(text)

        if value > 0.0:
            text = "-" + text
        elif value < 0.0:
            text = text[1:]

        self.display.setText(text)

    def backspaceClicked(self):
        if self.waitingForOperand:
            return

        text = self.display.text()[:-1]
        if not text:
            text = '0'
            self.waitingForOperand = True

        self.display.setText(text)

    def clear(self):
        # type: () -> object
        if self.waitingForOperand:
            return

        self.display.setText('0')
        self.waitingForOperand = True

    def clearAll(self):
        self.sumSoFar = 0.0
        self.factorSoFar = 0.0
        self.pendingAdditiveOperator = ''
        self.pendingMultiplicativeOperator = ''
        self.display.setText('0')
        self.waitingForOperand = True

    def clearMemory(self):
        self.sumInMemory = 0.0

    def readMemory(self):
        self.display.setText(str(self.sumInMemory))
        self.waitingForOperand = True

    def setMemory(self):
        self.equalClicked()
        self.sumInMemory = float(self.display.text())

    def addToMemory(self):
        self.equalClicked()
        self.sumInMemory += float(self.display.text())

    def createButton(self, text, member):
        button = ToolButton(text)
        button.clicked.connect(member)
        return button

    def abortOperation(self):
        self.clearAll()
        self.display.setText("####")

    def calculate(self, rightOperand, pendingOperator):
        if pendingOperator == "+":
            self.sumSoFar += rightOperand
        elif pendingOperator == "-":
            self.sumSoFar -= rightOperand
        elif pendingOperator == u"\N{MULTIPLICATION SIGN}":
            self.factorSoFar *= rightOperand
        elif pendingOperator == u"\N{DIVISION SIGN}":
            if rightOperand == 0.0:
                return False

            self.factorSoFar /= rightOperand

        return True