def buildUI(self): browseButton = Button({'txt': "&Browse...", 'cl': self.browse}) findButton = Button({'txt': "&Find", 'cl': self.find}) self.fileComboBox = self.createComboBox("*") self.textComboBox = self.createComboBox() self.directoryComboBox = self.createComboBox(QDir.currentPath()) fileLabel = Label({'txt': "Named:"}) textLabel = Label({'txt': "Containing text: "}) directoryLabel = Label({'txt': "In directory: "}) self.filesFoundLabel = Label() self.createFilesTable() buttonsLayout = QHBoxLayout() buttonsLayout.addStretch() buttonsLayout.addWidget(findButton) self.layout = QGridLayout() self.layout.addWidget(fileLabel, 0, 0) self.layout.addWidget(self.fileComboBox, 0, 1, 1, 2) self.layout.addWidget(textLabel, 1, 0) self.layout.addWidget(self.textComboBox, 1, 1, 1, 2) self.layout.addWidget(directoryLabel, 2, 0) self.layout.addWidget(self.directoryComboBox, 2, 1) self.layout.addWidget(browseButton, 2, 2) self.layout.addWidget(self.filesTable, 3, 0, 1, 3) self.layout.addWidget(self.filesFoundLabel, 4, 0) self.layout.addLayout(buttonsLayout, 5, 0, 1, 3) self.setLayout(self.layout) self.resize(700, 300)
def buildUI(self): self.scrollArea = QScrollArea() self.scrollArea.setWidgetResizable(True) TXT = """ {0} Version will start from v13 and never change number 13. Current stage: Test Beta. Warning: Not stable, a lot of bugs. Status: Under developing """.format(VERSION) self.content = Label({'txt': TXT, 'alg': 'left', 'link': True}) self.content.setGeometry(0, 0, 450, 150) self.scrollArea.setWidget(self.content) closeBtn = Button({ 'txt': 'Close', 'tt': 'Close window', 'cl': partial(self.showLayout.emit, self.key, 'hide') }) self.layout.addWidget(self.scrollArea, 0, 0, 8, 4) self.layout.addWidget(closeBtn, 8, 3, 1, 1)
class About(QWidget): key = 'about' showLayout = pyqtSignal(str, str) def __init__(self, parent=None): super(About, self).__init__(parent) self.setWindowIcon(IconPth(32, 'About')) self.layout = QGridLayout() self.buildUI() self.setLayout(self.layout) self.resize(800, 600) def buildUI(self): self.scrollArea = QScrollArea() self.scrollArea.setWidgetResizable(True) self.content = Label({'txt': ABOUT, 'alg': 'left', 'link': True}) self.content.setGeometry(0, 0, 800, 600) self.scrollArea.setWidget(self.content) closeBtn = Button({ 'txt': 'Close', 'tt': 'Close window', 'cl': partial(self.showLayout.emit, self.key, 'hide') }) self.layout.addWidget(self.scrollArea, 0, 0, 8, 4) self.layout.addWidget(closeBtn, 8, 3, 1, 1) def closeEvent(self, event): self.showLayout.emit(self.key, 'hide') event.ignore()
def __init__(self, parent): super(PreviewForm, self).__init__(parent) self.encodingComboBox = QComboBox() encodingLabel = Label({'txt': "&Encoding:"}) encodingLabel.setBuddy(self.encodingComboBox) self.textEdit = QTextEdit() self.textEdit.setLineWrapMode(QTextEdit.NoWrap) self.textEdit.setReadOnly(True) buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.encodingComboBox.activated.connect(self.updateTextEdit) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) mainLayout = QGridLayout() mainLayout.addWidget(encodingLabel, 0, 0) mainLayout.addWidget(self.encodingComboBox, 0, 1) mainLayout.addWidget(self.textEdit, 1, 0, 1, 2) mainLayout.addWidget(buttonBox, 2, 0, 1, 2) self.setLayout(mainLayout) self.setWindowTitle("Choose Encoding") self.resize(400, 300)
def buildUI(self): loginGrp, loginGrid = GroupGrid('Sign in') self.userTF = LineEdit() self.pwTF = LineEdit({'fm': 'password'}) self.userCB = QCheckBox('Remember me?') forgot_pw_btn = Button({'txt': 'Forgot your password?', 'cl': partial(self.showLayout.emit, 'forgotpw', 'show')}) login_btn = Button({'txt': 'Log in', 'cl': self.signInClicked}) cancel_btn = Button({'txt': 'Cancel', 'cl': QApplication.quit}) loginGrid.addWidget(Label({'txt': 'Username'}), 0, 0, 1, 2) loginGrid.addWidget(Label({'txt': 'Password'}), 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) signupGrp, signupGrid = GroupGrid('Sign up') signupBtn = Button({'txt':'Sign up', 'emit2': [self.showLayout.emit, ['signup', 'show']]}) 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 buildUI(self): version = Label({'txt': VERSION, 'alg': 'right'}) copyR = Label({'txt': COPYRIGHT, 'alg': 'right'}) self.layout.addWidget(version, 0, 0, 1, 9) self.layout.addWidget(copyR, 1, 0, 1, 9) 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 new avatar', 'cl': self.setAvaClicked}) avatar_grid.addWidget(self.userAvatar, 0, 0, 2, 2) avatar_grid.addWidget(set_avatarBtn, 2, 0, 1, 2)
def buildUI(self): self.scrollArea = QScrollArea() self.scrollArea.setWidgetResizable(True) self.content = Label({'txt':CONTRIBUTING, 'alg':'left', 'link': True}) self.content.setGeometry(0, 0, 350, 400) self.scrollArea.setWidget(self.content) closeBtn = Button({'txt': 'Close', 'tt': 'Close window', 'cl': partial(self.showLayout.emit, self.key, 'hide')}) self.layout.addWidget(self.scrollArea, 0, 0, 8, 4) self.layout.addWidget(closeBtn, 8, 3, 1, 1)
def __init__(self, settings, parent=None): super(SettingInput, self).__init__(parent) self.settings = settings self.formatComboBox = ComboBox({'items': ["INI", "Native"]}) self.scopeComboBox = ComboBox({'items': ["User", "System"]}) self.organizationComboBox = ComboBox({'items': ['DAMGteam'], 'editable': True}) self.applicationComboBox = ComboBox({'items': ['PLM'], 'editable': True, 'curIndex': 0}) for cb in [self.formatComboBox, self.scopeComboBox, self.organizationComboBox, self.applicationComboBox]: cb.currentIndexChanged.connect(self.updateLocationsTable) formatLabel = Label({'txt': "&Format: ", 'setBuddy': self.formatComboBox}) scopeLabel = Label({'txt': "&Scope:", 'setBuddy': self.scopeComboBox}) organizationLabel = Label({'txt': "&Organization:", 'setBuddy': self.organizationComboBox}) applicationLabel = Label({'txt': "&Application:", 'setBuddy': self.applicationComboBox}) grpBox = QGroupBox("Setting Locations") grid = QGridLayout() grpBox.setLayout(grid) self.locationsTable = QTableWidget() self.locationsTable.setSelectionMode(QAbstractItemView.SingleSelection) self.locationsTable.setSelectionBehavior(QAbstractItemView.SelectRows) self.locationsTable.setEditTriggers(QAbstractItemView.NoEditTriggers) self.locationsTable.setColumnCount(2) self.locationsTable.setHorizontalHeaderLabels(("Location", "Access")) self.locationsTable.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch) self.locationsTable.horizontalHeader().resizeSection(1, 180) self.locationsTable.setMinimumHeight(180) self.formatComboBox.activated.connect(self.updateLocationsTable) self.scopeComboBox.activated.connect(self.updateLocationsTable) self.organizationComboBox.lineEdit().editingFinished.connect(self.updateLocationsTable) self.applicationComboBox.lineEdit().editingFinished.connect(self.updateLocationsTable) self.layout = QGridLayout() grid.addWidget(formatLabel, 1, 0) grid.addWidget(self.formatComboBox, 1, 1) grid.addWidget(scopeLabel, 2, 0) grid.addWidget(self.scopeComboBox, 2, 1) grid.addWidget(organizationLabel, 3, 0) grid.addWidget(self.organizationComboBox, 3, 1) grid.addWidget(applicationLabel, 4, 0) grid.addWidget(self.applicationComboBox, 4, 1) grid.addWidget(self.locationsTable, 0, 2, 6, 4) self.updateLocationsTable() self.layout.addWidget(grpBox) self.setLayout(self.layout)
def account_section(self): self.accSection, account_grid = GroupGrid("Account") self.userField = LineEdit() self.pwField = LineEdit({'fm': 'password'}) self.cfpwField = LineEdit({'fm': '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 __init__(self, section, name="", parent=None): super(ItemWidget, self).__init__(parent) self.section = section self.item = Label({'txt': name}) button = Button({ 'txt': "Edit", 'stt': "Edit character name", 'cl': self.setText }) layout = QHBoxLayout() layout.addWidget(self.item) layout.addWidget(button) self.setLayout(layout)
class Version(QWidget): key = 'version' showLayout = pyqtSignal(str, str) def __init__(self, parent=None): super(Version, self).__init__(parent) self.setWindowIcon(IconPth(32, 'Version')) self.layout = QGridLayout() self.buildUI() self.setLayout(self.layout) self.resize(450, 150) def buildUI(self): self.scrollArea = QScrollArea() self.scrollArea.setWidgetResizable(True) TXT = """ {0} Version will start from v13 and never change number 13. Current stage: Test Beta. Warning: Not stable, a lot of bugs. Status: Under developing """.format(VERSION) self.content = Label({'txt': TXT, 'alg': 'left', 'link': True}) self.content.setGeometry(0, 0, 450, 150) self.scrollArea.setWidget(self.content) closeBtn = Button({ 'txt': 'Close', 'tt': 'Close window', 'cl': partial(self.showLayout.emit, self.key, 'hide') }) self.layout.addWidget(self.scrollArea, 0, 0, 8, 4) self.layout.addWidget(closeBtn, 8, 3, 1, 1) def closeEvent(self, event): self.showLayout.emit(self.key, 'hide') event.ignore()
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 step1_layout(self): step1_groupBox = QGroupBox("Step 1") step1_layout = QFormLayout() step1_groupBox.setLayout(step1_layout) self.user_account = QLineEdit() self.user_email = QLineEdit() step1_btn_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) step1_btn_box.accepted.connect(self.on_step1_btn_clicked) step1_btn_box.rejected.connect(self.close) step1_layout.addRow(Label({'txt': "Username: "******"Email adress: "}), self.user_email) step1_layout.addRow(step1_btn_box) return step1_groupBox
def __init__(self, layout=None, parent=None): super(TabContent, self).__init__(parent) if layout is None: layout = QGridLayout() layout.addWidget(Label()) self.layout = layout self.buildUI() self.setLayout(self.layout)
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 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 __init__(self, title="Section Title", subLayout=None, parent=None): super(AutoSectionLayoutGrp, self).__init__(parent) self.setTitle(title) if subLayout is None: self.layout = QGridLayout() self.layout.addWidget(Label({'txt': WAIT_LAYOUT_COMPLETE}), 0, 0, 1, 1) else: self.layout = subLayout self.buildUI() self.setLayout(self.layout)
class ItemWidget(QWidget): def __init__(self, section, name="", parent=None): super(ItemWidget, self).__init__(parent) self.section = section self.item = Label({'txt': name}) button = Button({ 'txt': "Edit", 'stt': "Edit character name", 'cl': self.setText }) layout = QHBoxLayout() layout.addWidget(self.item) layout.addWidget(button) self.setLayout(layout) def setText(self): text, ok = QInputDialog.getText(self, "Change To", "{0} name:".format(self.section), QLineEdit.Normal, self.item.text()) if ok and text != "": self.item.setText(text)
def step2_layout(self): step2_groupBox = QGroupBox("Step 2") step2_layout = QVBoxLayout() step2_groupBox.setLayout(step2_layout) self.question1 = Label({'txt': "Question 1"}) self.question2 = Label({'txt': "Question 2"}) self.answer1 = QLineEdit() self.answer2 = QLineEdit() 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
def buildUI(self): self.lineInput = QLineEdit() self.suggessLabel = Label() searchBtn = Button({'txt': 'Translate', 'cl': self.translate}) yesBtn = Button({'txt': 'Yes', 'cl': self.translate}) noBtn = Button({'txt': 'No', 'cl': self.translate}) self.answer = QTextEdit() 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)
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 __init__(self, parent=None): super(ServerStatus, self).__init__(parent) self.logger = SetLogger(self) self.server = ServerCfg() self.server.listen(QHostAddress(__serverUrl__), 9000) self.serverOpen = self.server.isListening() self.connected = get_app_icon(16, 'Connected') self.disconnected = get_app_icon(16, 'Disconnected') self.networkStatus = QLabel() self.networkStatus.setMaximumWidth(20) self.networkStatus.setPixmap(QPixmap(self.connected)) self.addWidget(self.networkStatus, 0, 0, 1, 1) self.onlineStage.connect(self.connection_status) self.onlineStage.emit(self.serverOpen) self.txt = Label({'txt': "Connecting"}) self.buildUI()
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 = QLineEdit("DAMG team project") self.prjShort = QLineEdit("damg") self.prjPth = QLineEdit("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 = QLineEdit("1") self.numOfChar.setValidator(QIntValidator()) self.numOfChar.textChanged.connect(partial(self.populate_lst, "char")) self.numOfEnv = QLineEdit("1") self.numOfEnv.setValidator(QIntValidator()) self.numOfEnv.textChanged.connect(partial(self.populate_lst, "env")) self.numOfProp = QLineEdit("1") self.numOfProp.setValidator(QIntValidator()) self.numOfProp.textChanged.connect(partial(self.populate_lst, "prop")) self.numOfSeq = QLineEdit("1") self.numOfSeq.setValidator(QIntValidator()) 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) self.applySetting()
class ForgotPassword(QWidget): key = 'forgotPW' showLayout = pyqtSignal(str, str) def __init__(self): super(ForgotPassword, self).__init__() self.setContentsMargins(0,0,0,0) self.layout = QVBoxLayout() self.buildUI() self.setLayout(self.layout) def buildUI(self): self.step1_form = self.step1_layout() self.step2_form = self.step2_layout() self.step2_form.setVisible(False) self.layout.addWidget(self.step1_form) self.layout.addWidget(self.step2_form) def step1_layout(self): step1_groupBox = QGroupBox("Step 1") step1_layout = QFormLayout() step1_groupBox.setLayout(step1_layout) self.user_account = QLineEdit() self.user_email = QLineEdit() step1_btn_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) step1_btn_box.accepted.connect(self.on_step1_btn_clicked) step1_btn_box.rejected.connect(self.close) step1_layout.addRow(Label({'txt': "Username: "******"Email adress: "}), self.user_email) step1_layout.addRow(step1_btn_box) return step1_groupBox def step2_layout(self): step2_groupBox = QGroupBox("Step 2") step2_layout = QVBoxLayout() step2_groupBox.setLayout(step2_layout) self.question1 = Label({'txt': "Question 1"}) self.question2 = Label({'txt': "Question 2"}) self.answer1 = QLineEdit() self.answer2 = QLineEdit() 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 def on_step1_btn_clicked(self): question1 = "What is the question 1" question2 = "What is the question 2" self.question1.setText(question1) self.question2.setText(question2) self.step1_form.setDisabled(True) self.step2_form.setVisible(True) # username = self.user_account.text() # # if len(username) == 0: # QMessageBox.critical(self, 'Failed', mess.USER_BLANK) # else: # checkUserExists = usql.check_data_exists(username) # if not checkUserExists: # QMessageBox.critical(self, 'Failed', mess.USER_NOT_EXSIST) # question1, question2 = usql.query_user_security_question(username) # # self.question1.setText(question1) # self.question2.setText(question2) # # self.step1_form.setDisabled(True) # self.step2_form.setVisible(True) def on_step2_btn_clicked(self): pass def closeEvent(self, event): self.showLayout.emit(self.key, 'hide') event.ignore()
class FindFiles(QWidget): key = 'findFile' showLayout = pyqtSignal(str, str) def __init__(self, parent=None): super(FindFiles, self).__init__(parent) self.setWindowIcon(IconPth(32, "FindFiles")) central_widget = QWidget(self) self.layout = QGridLayout(self) central_widget.setLayout(self.layout) self.buildUI() def buildUI(self): browseButton = Button({'txt': "&Browse...", 'cl': self.browse}) findButton = Button({'txt': "&Find", 'cl': self.find}) self.fileComboBox = self.createComboBox("*") self.textComboBox = self.createComboBox() self.directoryComboBox = self.createComboBox(QDir.currentPath()) fileLabel = Label({'txt': "Named:"}) textLabel = Label({'txt': "Containing text: "}) directoryLabel = Label({'txt': "In directory: "}) self.filesFoundLabel = Label() self.createFilesTable() buttonsLayout = QHBoxLayout() buttonsLayout.addStretch() buttonsLayout.addWidget(findButton) self.layout = QGridLayout() self.layout.addWidget(fileLabel, 0, 0) self.layout.addWidget(self.fileComboBox, 0, 1, 1, 2) self.layout.addWidget(textLabel, 1, 0) self.layout.addWidget(self.textComboBox, 1, 1, 1, 2) self.layout.addWidget(directoryLabel, 2, 0) self.layout.addWidget(self.directoryComboBox, 2, 1) self.layout.addWidget(browseButton, 2, 2) self.layout.addWidget(self.filesTable, 3, 0, 1, 3) self.layout.addWidget(self.filesFoundLabel, 4, 0) self.layout.addLayout(buttonsLayout, 5, 0, 1, 3) self.setLayout(self.layout) self.resize(700, 300) def browse(self): directory = QFileDialog.getExistingDirectory(self, "Find Files", QDir.currentPath()) if directory: if self.directoryComboBox.findText(directory) == -1: self.directoryComboBox.addItem(directory) self.directoryComboBox.setCurrentIndex(self.directoryComboBox.findText(directory)) @staticmethod def updateComboBox(comboBox): if comboBox.findText(comboBox.currentText()) == -1: comboBox.addItem(comboBox.currentText()) def find(self): self.filesTable.setRowCount(0) fileName = self.fileComboBox.currentText() text = self.textComboBox.currentText() path = self.directoryComboBox.currentText() self.updateComboBox(self.fileComboBox) self.updateComboBox(self.textComboBox) self.updateComboBox(self.directoryComboBox) self.currentDir = QDir(path) if not fileName: fileName = "*" files = self.currentDir.entryList([fileName], QDir.Files | QDir.NoSymLinks) if text: files = self.findFiles(files, text) self.showFiles(files) def findFiles(self, files, text): progressDialog = QProgressDialog(self) progressDialog.setCancelButtonText("&Cancel") progressDialog.setRange(0, files.count()) progressDialog.setWindowTitle("Find Files") foundFiles = [] for i in range(files.count()): progressDialog.setValue(i) progressDialog.setLabelText("Searching file number %d of %d..." % (i, files.count())) QApplication.processEvents() if progressDialog.wasCanceled(): break inFile = QFile(self.currentDir.absoluteFilePath(files[i])) if inFile.open(QIODevice.ReadOnly): stream = QTextStream(inFile) while not stream.atEnd(): if progressDialog.wasCanceled(): break line = stream.readLine() if text in line: foundFiles.append(files[i]) break progressDialog.close() return foundFiles def showFiles(self, files): for fn in files: file = QFile(self.currentDir.absoluteFilePath(fn)) size = QFileInfo(file).size() fileNameItem = QTableWidgetItem(fn) fileNameItem.setFlags(fileNameItem.flags() ^ Qt.ItemIsEditable) sizeItem = QTableWidgetItem("%d KB" % (int((size + 1023) / 1024))) sizeItem.setTextAlignment(Qt.AlignVCenter | Qt.AlignRight) sizeItem.setFlags(sizeItem.flags() ^ Qt.ItemIsEditable) row = self.filesTable.rowCount() self.filesTable.insertRow(row) self.filesTable.setItem(row, 0, fileNameItem) self.filesTable.setItem(row, 1, sizeItem) self.filesFoundLabel.setText("%d file(s) found (Double click on a file to open it)" % len(files)) def createComboBox(self, text=""): comboBox = QComboBox() comboBox.setEditable(True) comboBox.addItem(text) comboBox.setSizePolicy(SiPoExp, SiPoPre) return comboBox def createFilesTable(self): self.filesTable = QTableWidget(0, 2) self.filesTable.setSelectionBehavior(QAbstractItemView.SelectRows) self.filesTable.setHorizontalHeaderLabels(("File Name", "Size")) self.filesTable.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch) self.filesTable.verticalHeader().hide() self.filesTable.setShowGrid(False) self.filesTable.cellActivated.connect(self.openFileOfItem) def openFileOfItem(self, row, column): item = self.filesTable.item(row, 0) QDesktopServices.openUrl(QUrl(self.currentDir.absoluteFilePath(item.text()))) def hideEvent(self, event): # self.specs.showState.emit(False) pass def closeEvent(self, event): self.showLayout.emit(self.key, 'hide') event.ignore()
class SignUp(QWidget): key = 'signup' showLayout = pyqtSignal(str, str) updataAvatar = pyqtSignal(str) def __init__(self, parent=None): super(SignUp, self).__init__(parent) self.logger = SetLogger(self) self.setWindowIcon(IconPth(32, "SignUp")) self.resize(450, 900) self.layout = QGridLayout() self.buildUI() self.setLayout(self.layout) self.reg = PObj(self) 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 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({'fm': 'password'}) self.cfpwField = LineEdit({'fm': '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': self.cacelBtnClicked}) 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.initialize() def createBtnClicked(self): if self.check_all_conditions(): data = self.generate_user_data() QMessageBox.information(self, "Failed", WAIT_LAYOUT_COMPLETE, QMessageBox.Ok) return def cacelBtnClicked(self): self.close() self.showLayout.emit('login', 'show') 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 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_icon('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 showEvent(self, event): self.showLayout.emit('login', 'hide') def hideEvent(self, event): # self.specs.showState.emit(False) pass def closeEvent(self, event): self.showLayout.emit(self.key, 'hide') event.ignore() def applySetting(self): pass