def __init__(self, parent=None): super().__init__(parent) regex = QRegExp(r"^M?M?M?(?:CM|CD|D?C?C?C?)" r"(?:XC|XL|L?X?X?X?)(?:IX|IV|V?I?I?I?)$") regex.setCaseSensitivity(Qt.CaseInsensitive) self.validator = QRegExpValidator(regex, self) self.setRange(1, 3999) self.lineEdit().textEdited.connect(self.fixCase)
def variationFromString(self, string, caseSense=True): rx = QRegExp(self.variationRegExpPattern) rx.setMinimal(False) rx.setCaseSensitivity(Qt.CaseInsensitive) if caseSense: rx.setCaseSensitivity(Qt.CaseSensitive) index = rx.indexIn(string) length = rx.matchedLength() match = string[index:index + length] return match
def __init__(self, username=None, usingExportDialog=False): QtGui.QDialog.__init__(self) self._clips = [] self._sequences = [] # The Dialog can work in two modes, as a popover from the Bin View or via the main App Export window self.usingExportDialog = usingExportDialog self.username = username # setGeometry(x_pos, y_pos, width, height) self.setGeometry(240, 160, 726, 552) self.setStyleSheet( 'QWidget {background-color: #3B3E4A;} QLineEdit {color: #D0D5DC; border-color:#6F757F; border-width: 1px; border-radius: 4px; border-style: solid;} QLabel {color: #D0D5DC;}' ) self.setWindowTitle("Frame.io Uploader") #self.setAttribute( Qt.WA_TranslucentBackground, True ) self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint) self.setMouseTracking(True) self.draggable = True self.dragging_threshold = 0 self.__mousePressPos = None self.__mouseMovePos = None layout = QtGui.QVBoxLayout(self) layout.setAlignment(Qt.AlignCenter) self.toolBar = QtGui.QToolBar() self.toolBar.setStyleSheet( 'QToolBar {background-color: #3B3E4A; border-width: 0px; border-radius: 0px; border-style: none; text-align: center}' ) self.toolBar.setIconSize(QSize(24, 24)) self.closeButton = QtGui.QPushButton("") self.closeButton.setStyleSheet('QPushButton {border: none;}') iconClose = QtGui.QIcon(os.path.join(gIconPath, "close.png")) self.closeButton.setIcon(iconClose) self.closeButton.clicked.connect(self.close) iconLogout = QtGui.QIcon(os.path.join(gIconPath, "logout.png")) self.logoutToolBarAction = createMenuAction("", self.logoutPressed, icon=iconLogout) self.logoutToolBarAction.setVisible(False) self.logoutToolBarAction.setToolTip("Click here to Log out") self.unconnectedIndicatorPixmap = QtGui.QPixmap( os.path.join(gIconPath, "logo-unconnected.png")) self.connectedIndicatorPixmap = QtGui.QPixmap( os.path.join(gIconPath, "logo-connected.png")) self.connectionIndicatorLabel = QtGui.QLabel("Unconnected") spacer = QtGui.QWidget() spacer.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.toolBar.addWidget(self.closeButton) self.toolBar.addWidget(spacer) self.toolBar.addWidget(self.connectionIndicatorLabel) self.toolBar.addAction(self.logoutToolBarAction) layout.addWidget(self.toolBar) pixmap = QtGui.QPixmap(os.path.join(gIconPath, "frameio.png")) lbl = QtGui.QLabel("") lbl.setPixmap(pixmap) lbl.setAlignment(Qt.AlignCenter) layout.addWidget(lbl) font = QtGui.QFont() font.setPointSize(20) self.topLabel = QtGui.QLabel("Sign In") self.topLabel.setFont(font) self.topLabel.setAlignment(Qt.AlignCenter) layout.addWidget(self.topLabel) self.statusLabel = QtGui.QLabel("") self.statusLabel.setAlignment(Qt.AlignCenter) layout.addWidget(self.statusLabel) self.stackView = QtGui.QStackedWidget(self) # Login Screen View self.loginView = QtGui.QWidget() self.loginViewLayout = QtGui.QVBoxLayout(self) self.loginViewLayout.setAlignment(Qt.AlignCenter) self.emailLineEdit = QtGui.QLineEdit() self.emailLineEdit.setPlaceholderText("E-mail") self.emailLineEdit.setFont(font) self.emailLineEdit.setAlignment(Qt.AlignCenter) self.emailLineEdit.setFixedWidth(370) self.emailLineEdit.setFixedHeight(60) if self.username: self.emailLineEdit.setText(self.username) # Validator for checking email address is valid namerx = QRegExp("\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b") namerx.setCaseSensitivity(Qt.CaseInsensitive) namerx.setPatternSyntax(QRegExp.RegExp) self.nameval = QtGui.QRegExpValidator(namerx, self) self.emailLineEdit.setValidator(self.nameval) self.loginViewLayout.addWidget(self.emailLineEdit) self.passwordLineEdit = QtGui.QLineEdit() self.passwordLineEdit.setStyleSheet('') self.passwordLineEdit.setPlaceholderText("Password") self.passwordLineEdit.setFont(font) self.passwordLineEdit.setAlignment(Qt.AlignCenter) self.passwordLineEdit.setFixedWidth(370) self.passwordLineEdit.setFixedHeight(60) self.passwordLineEdit.setEchoMode(QtGui.QLineEdit.Password) self.loginViewLayout.addWidget(self.passwordLineEdit) self.submitButton = QtGui.QPushButton("LET'S GO") self.submitButton.setFlat(True) self.submitButton.setFont(font) self.submitButton.clicked.connect(self._submitButtonPressed) self.submitButton.setStyleSheet( 'QPushButton {width: 370px; height: 60px; border-width: 0px; border-radius: 4px; border-style: solid; background-color: #83DEBD; color: white;}' 'QPushButton:hover{background-color: #9974BA; }' 'QPushButton:pressed{background-color: #404040; border-width: 1px}' ) self.loginViewLayout.addWidget(self.submitButton) self.loginView.setLayout(self.loginViewLayout) self.stackView.addWidget(self.loginView) ### TO-DO - handle uploading of Clips via drag-drop into a dropzone # self.uploadDropzoneView = QtGui.QWidget() # self.uploadDropzoneView.setAcceptDrops(True) # Not hooked up. # self.uploadDropzoneLayout = QtGui.QVBoxLayout(self) # self.uploadDropzoneLayout.setAlignment(Qt.AlignCenter) # pixmap = QtGui.QPixmap(os.path.join(gIconPath, "uploadDropzone-64px.png")) # uploadIcon = QtGui.QLabel("") # uploadIcon.setPixmap(pixmap) # uploadIcon.setAlignment(Qt.AlignCenter) # self.uploadDropzoneLayout.addWidget(uploadIcon) # self.uploadDropzoneLabel1 = QtGui.QLabel("Upload your files") # self.uploadDropzoneLabel1.setAlignment(Qt.AlignCenter) # self.uploadDropzoneLabel1.setFont(font) # self.uploadDropzoneLabel2 = QtGui.QLabel("Drag 'n Drop your files or Clips/Sequences here.") # self.uploadDropzoneLabel1.setAlignment(Qt.AlignCenter) # self.uploadDropzoneLayout.addWidget(self.uploadDropzoneLabel1) # font.setPointSize(16) # self.uploadDropzoneLabel2.setFont(font) # self.uploadDropzoneLayout.addWidget(self.uploadDropzoneLabel2) # self.uploadDropzoneView.setLayout(self.uploadDropzoneLayout) # self.stackView.addWidget(self.uploadDropzoneView) ### View to handle uploading of Clips and Timelines View self.uploadView = QtGui.QWidget() self.uploadView.setStyleSheet( 'QPushButton {width: 100px; height: 100px; border-width: 0px; border-radius: 50px; border-style: solid; background-color: #9974BA; color: white;}' ) self.uploadViewLayout = QtGui.QVBoxLayout(self) self.uploadViewLayout.setAlignment(Qt.AlignCenter) self.uploadTopButtonWidget = QtGui.QWidget() self.uploadTopButtonLayout = QtGui.QHBoxLayout(self) self.uploadTopButtonLayout.setAlignment(Qt.AlignCenter) self.uploadTimelineOptionButton = QtGui.QPushButton("Timeline") self.uploadClipOptionButton = QtGui.QPushButton("Clips") self.uploadTimelineOptionButton.setCheckable(True) self.uploadTimelineOptionButton.setChecked(False) self.uploadTimelineOptionButton.setFont(font) self.uploadClipOptionButton.setCheckable(True) self.uploadClipOptionButton.setChecked(False) self.uploadClipOptionButton.setFont(font) self.uploadTopButtonLayout.addWidget(self.uploadTimelineOptionButton) self.uploadTopButtonLayout.addWidget(self.uploadClipOptionButton) self.uploadTopButtonWidget.setLayout(self.uploadTopButtonLayout) self.uploadBottomButtonWidget = QtGui.QWidget() self.uploadBottomButtonLayout = QtGui.QHBoxLayout(self) self.uploadBottomButtonLayout.setAlignment(Qt.AlignCenter) self.uploadCancelButton = QtGui.QPushButton("Cancel") self.uploadCancelButton.setStyleSheet( 'QPushButton {width: 170px; height: 70px; border-width: 0px; border-radius: 4px; border-style: solid; background-color: #767C8E; color: white;}' ) self.uploadCancelButton.clicked.connect(self.close) self.uploadTaskButton = QtGui.QPushButton("Done") self.uploadTaskButton.setStyleSheet( 'QPushButton {width: 170px; height: 70px; border-width: 0px; border-radius: 4px; border-style: solid; color: white;}' ) self.uploadTaskButton.clicked.connect(self._uploadButtonPushed) font.setPointSize(20) self.uploadCancelButton.setFont(font) self.uploadTaskButton.setFont(font) self.uploadBottomButtonLayout.addWidget(self.uploadCancelButton) self.uploadBottomButtonLayout.addWidget(self.uploadTaskButton) self.uploadBottomButtonWidget.setLayout(self.uploadBottomButtonLayout) self.projectWidget = QtGui.QWidget() self.projectWidgetLayout = QtGui.QHBoxLayout(self) self.projectDropdown = QtGui.QComboBox() self.projectDropdown.setFont(font) self.projectDropdown.setEditable(True) self.projectDropdown.lineEdit().setAlignment(Qt.AlignCenter) self.projectDropdown.setEditable(False) self.projectDropdown.setStyleSheet( 'QComboBox {width: 350px; height: 50px; border-width: 0px; border-radius: 4px; border-style: solid; background-color: #4F535F; color: white;}' ) self.projectRefreshButton = QtGui.QPushButton("Refresh") self.projectRefreshButton.setStyleSheet( 'QPushButton {width: 50px; height: 50px; border-width: 0px; border-radius: 25px; border-style: solid; background-color: #767C8E; color: white;}' ) self.projectRefreshButton.clicked.connect(self._refreshProjectList) self.projectWidgetLayout.addWidget(self.projectDropdown) self.projectWidgetLayout.addWidget(self.projectRefreshButton) self.projectWidget.setLayout(self.projectWidgetLayout) self.uploadViewLayout.addWidget(self.projectWidget) self.uploadViewLayout.addWidget(self.uploadBottomButtonWidget) self.uploadView.setLayout(self.uploadViewLayout) self.stackView.addWidget(self.uploadView) sizeGrip = QtGui.QSizeGrip(self) sizeGrip.setStyleSheet("QSizeGrip { height:12px; }") layout.addWidget(self.stackView) layout.addWidget(sizeGrip, 0, Qt.AlignBottom | Qt.AlignRight) self.setMinimumSize(160, 160) self.setLayout(layout) self.emailLineEdit.setFocus()
def __init__(self, delegate, usingExportDialog=False): QtGui.QDialog.__init__(self) self._clips = [] self._sequences = [] self.filePathsForUpload = [] # The Main FrameIOPySide AppDelegate self.delegate = delegate # The Dialog can work in two modes, as a popover from the Bin View or via the main App Export window self.usingExportDialog = usingExportDialog self.email = "" # setGeometry(x_pos, y_pos, width, height) self.setGeometry(240, 160, 726, 552) self.setStyleSheet('QWidget {background-color: #3B3E4A;} QLineEdit {color: #D0D5DC; border-color:#6F757F; border-width: 1px; border-radius: 4px; border-style: solid;} QLabel {color: #D0D5DC;}') self.setWindowTitle("Frame.io Uploader") #self.setAttribute( Qt.WA_TranslucentBackground, True ) self.setWindowFlags( Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint ) self.setMouseTracking(True) self.draggable = True self.dragging_threshold = 0 self.__mousePressPos = None self.__mouseMovePos = None layout = QtGui.QVBoxLayout(self) layout.setAlignment(Qt.AlignCenter) self.toolBar = QtGui.QToolBar() self.toolBar.setStyleSheet('QToolBar {background-color: #3B3E4A; border-width: 0px; border-radius: 0px; border-style: none; text-align: center}') self.toolBar.setIconSize( QSize(24,24) ) self.closeButton = QtGui.QPushButton("") self.closeButton.setStyleSheet('QPushButton {border: none;}') iconClose = QtGui.QIcon(os.path.join(gIconPath, "close.png")) self.closeButton.setIcon(iconClose) self.closeButton.clicked.connect(self.close) iconLogout = QtGui.QIcon(os.path.join(gIconPath, "logout.png")) self.logoutToolBarAction = createMenuAction("", self.logoutPressed, icon=iconLogout) self.logoutToolBarAction.setVisible(False) self.logoutToolBarAction.setToolTip("Click here to Log out") self.unconnectedIndicatorPixmap = QtGui.QPixmap(os.path.join(gIconPath, "logo-unconnected.png")) self.connectedIndicatorPixmap = QtGui.QPixmap(os.path.join(gIconPath, "logo-connected.png")) self.connectionIndicatorLabel = QtGui.QLabel("Unconnected") spacer = QtGui.QWidget() spacer.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.toolBar.addWidget(self.closeButton) self.toolBar.addWidget(spacer) self.toolBar.addWidget(self.connectionIndicatorLabel) self.toolBar.addAction(self.logoutToolBarAction) layout.addWidget(self.toolBar) pixmap = QtGui.QPixmap(os.path.join(gIconPath, "frameio.png")) lbl = QtGui.QLabel("") lbl.setPixmap(pixmap) lbl.setAlignment(Qt.AlignCenter) layout.addWidget(lbl) font = QtGui.QFont() font.setPointSize(20) self.topLabel = QtGui.QLabel("Login") self.topLabel.setFont(font) self.topLabel.setAlignment(Qt.AlignCenter) layout.addWidget(self.topLabel) self.statusLabel = QtGui.QLabel("") self.statusLabel.setAlignment(Qt.AlignCenter) layout.addWidget(self.statusLabel) self.stackView = QtGui.QStackedWidget(self) # Login Screen View self.loginView = QtGui.QWidget() self.loginViewLayout = QtGui.QVBoxLayout(self) self.loginViewLayout.setAlignment(Qt.AlignCenter) self.emailLineEdit = QtGui.QLineEdit() self.emailLineEdit.setPlaceholderText("E-mail") self.emailLineEdit.setFont(font) self.emailLineEdit.setAlignment(Qt.AlignCenter) self.emailLineEdit.setFixedWidth(370) self.emailLineEdit.setFixedHeight(60) if self.email: self.emailLineEdit.setText(self.email) self.emailLineEdit.setText("") # Validator for checking email address is valid namerx = QRegExp("\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b") namerx.setCaseSensitivity(Qt.CaseInsensitive); namerx.setPatternSyntax(QRegExp.RegExp); self.nameval = QtGui.QRegExpValidator(namerx, self) self.emailLineEdit.setValidator(self.nameval) self.loginViewLayout.addWidget(self.emailLineEdit) self.passwordLineEdit = QtGui.QLineEdit() self.passwordLineEdit.setStyleSheet('') self.passwordLineEdit.setPlaceholderText("Password") self.passwordLineEdit.setFont(font) self.passwordLineEdit.setAlignment(Qt.AlignCenter) self.passwordLineEdit.setFixedWidth(370) self.passwordLineEdit.setFixedHeight(60) self.passwordLineEdit.setEchoMode(QtGui.QLineEdit.Password) # Initially hide the password field, as we typically log in as Google Auth self.passwordLineEdit.setVisible(False) self.loginViewLayout.addWidget(self.passwordLineEdit) self.submitButton = QtGui.QPushButton("LET'S GO") self.submitButton.setFlat(True) self.submitButton.setFont(font) self.submitButton.clicked.connect(self._submitButtonPressed) self.submitButton.setStyleSheet('QPushButton {width: 370px; height: 60px; border-width: 0px; border-radius: 4px; border-style: solid; background-color: #83DEBD; color: white;}' 'QPushButton:hover{background-color: #9974BA; }' 'QPushButton:pressed{background-color: #404040; border-width: 1px}') self.loginViewLayout.addWidget(self.submitButton) # This WebView is used for Google OAuth2 Login self.webView = QWebView(parent=self) self.loginViewLayout.addWidget(self.webView) self.webView.setVisible(False) self.loginView.setLayout(self.loginViewLayout) self.stackView.addWidget(self.loginView) ### TO-DO - handle uploading of Clips via drag-drop into a dropzone self.uploadFilesView = QtGui.QWidget() self.uploadFilesView.setAcceptDrops(True) # Not hooked up. self.uploadDropzoneLayout = QtGui.QVBoxLayout(self) self.uploadDropzoneLayout.setAlignment(Qt.AlignCenter) pixmap = QtGui.QPixmap(os.path.join(gIconPath, "uploadDropzone-64px.png")) uploadIcon = QtGui.QLabel("") uploadIcon.setPixmap(pixmap) uploadIcon.setAlignment(Qt.AlignCenter) self.uploadDropzoneLayout.addWidget(uploadIcon) self.uploadDropzoneLabel1 = QtGui.QLabel("Upload your files") self.uploadDropzoneLabel1.setAlignment(Qt.AlignCenter) self.uploadDropzoneLabel1.setFont(font) self.uploadDropzoneLabel2 = QtGui.QLabel("Or choose files from picker...") self.uploadDropzoneLabel1.setAlignment(Qt.AlignCenter) self.uploadDropzoneLayout.addWidget(self.uploadDropzoneLabel1) font.setPointSize(16) self.uploadDropzoneLabel2.setFont(font) self.uploadDropzoneLayout.addWidget(self.uploadDropzoneLabel2) self.selectFilesButton = QtGui.QPushButton("Choose Files...") self.selectFilesButton.clicked.connect(self.showFilePicker) self.uploadDropzoneLayout.addWidget(self.selectFilesButton) self.uploadFilesView.setLayout(self.uploadDropzoneLayout) self.stackView.addWidget(self.uploadFilesView) ### View to handle uploading into a Project self.projectUploadView = QtGui.QWidget() self.projectUploadView.setStyleSheet('QPushButton {width: 100px; height: 100px; border-width: 0px; border-radius: 50px; border-style: solid; background-color: #9974BA; color: white;}') self.projectUploadViewLayout = QtGui.QVBoxLayout(self) self.projectUploadViewLayout.setAlignment(Qt.AlignCenter) self.uploadTopButtonWidget = QtGui.QWidget() self.uploadTopButtonLayout = QtGui.QHBoxLayout(self) self.uploadTopButtonLayout.setAlignment(Qt.AlignCenter) self.uploadTimelineOptionButton = QtGui.QPushButton("Timeline") self.uploadClipOptionButton = QtGui.QPushButton("Clips") self.uploadTimelineOptionButton.setCheckable(True) self.uploadTimelineOptionButton.setChecked(False) self.uploadTimelineOptionButton.setFont(font) self.uploadClipOptionButton.setCheckable(True) self.uploadClipOptionButton.setChecked(False) self.uploadClipOptionButton.setFont(font) self.uploadTopButtonLayout.addWidget(self.uploadTimelineOptionButton) self.uploadTopButtonLayout.addWidget(self.uploadClipOptionButton) self.uploadTopButtonWidget.setLayout(self.uploadTopButtonLayout) self.uploadBottomButtonWidget = QtGui.QWidget() self.uploadBottomButtonLayout = QtGui.QHBoxLayout(self) self.uploadBottomButtonLayout.setAlignment(Qt.AlignCenter) self.uploadCancelButton = QtGui.QPushButton("Cancel") self.uploadCancelButton.setStyleSheet('QPushButton {width: 170px; height: 70px; border-width: 0px; border-radius: 4px; border-style: solid; background-color: #767C8E; color: white;}') self.uploadCancelButton.clicked.connect(self.close) self.uploadTaskButton = QtGui.QPushButton("Done") self.uploadTaskButton.setStyleSheet('QPushButton {width: 170px; height: 70px; border-width: 0px; border-radius: 4px; border-style: solid; color: white;}') self.uploadTaskButton.clicked.connect(self._uploadButtonPushed) font.setPointSize(20) self.uploadCancelButton.setFont(font) self.uploadTaskButton.setFont(font) self.uploadBottomButtonLayout.addWidget(self.uploadCancelButton) self.uploadBottomButtonLayout.addWidget(self.uploadTaskButton) self.uploadBottomButtonWidget.setLayout(self.uploadBottomButtonLayout) self.projectWidget = QtGui.QWidget() self.projectWidgetLayout = QtGui.QHBoxLayout(self) self.projectDropdown = QtGui.QComboBox() self.projectDropdown.setFont(font) self.projectDropdown.setEditable(True) self.projectDropdown.lineEdit().setAlignment(Qt.AlignCenter) self.projectDropdown.setEditable(False) self.projectDropdown.setStyleSheet('QComboBox {width: 350px; height: 50px; border-width: 0px; border-radius: 4px; border-style: solid; background-color: #4F535F; color: white;}') self.projectRefreshButton = QtGui.QPushButton("Refresh") self.projectRefreshButton.setStyleSheet('QPushButton {width: 50px; height: 50px; border-width: 0px; border-radius: 25px; border-style: solid; background-color: #767C8E; color: white;}') self.projectRefreshButton.clicked.connect(self._refreshProjectList) self.projectWidgetLayout.addWidget(self.projectDropdown) #self.projectWidgetLayout.addWidget(self.projectRefreshButton) self.projectWidget.setLayout(self.projectWidgetLayout) self.projectUploadViewLayout.addWidget(self.projectWidget) self.projectUploadViewLayout.addWidget(self.uploadBottomButtonWidget) self.projectUploadView.setLayout(self.projectUploadViewLayout) self.stackView.addWidget(self.projectUploadView) sizeGrip = QtGui.QSizeGrip(self) sizeGrip.setStyleSheet("QSizeGrip { height:12px; }") layout.addWidget(self.stackView) layout.addWidget(sizeGrip, 0, Qt.AlignBottom | Qt.AlignRight); self.setMinimumSize(160, 160) self.setLayout(layout) self.emailLineEdit.setFocus()
def __init__(self, delegate, username=None): super(FnFrameioWidget, self).__init__() global gIconPath self._clips = [] self._sequences = [] self.username = username # FrameioDelegate self.delegate = delegate #kwargs.get("delegate", None) # setGeometry(x_pos, y_pos, width, height) self.setGeometry(240, 160, 726, 552) self.setStyleSheet('QWidget {background-color: #3B3E4A;} QLineEdit {color: #D0D5DC; border-color:#6F757F; border-width: 1px; border-radius: 4px; border-style: solid;} QLabel {color: #D0D5DC;}') self.setWindowTitle("Frame.io Uploader") #self.setAttribute( Qt.WA_TranslucentBackground, True ) self.setWindowFlags( Qt.FramelessWindowHint ) self.setMouseTracking(True) self.draggable = True self.dragging_threshold = 0 self.__mousePressPos = None self.__mouseMovePos = None layout = QtGui.QVBoxLayout(self) layout.setAlignment(Qt.AlignCenter) self.toolBar = QtGui.QToolBar() self.toolBar.setStyleSheet('QToolBar {background-color: #3B3E4A; border-width: 0px; border-radius: 0px; border-style: none;}') self.closeButton = QtGui.QPushButton("") self.closeButton.setStyleSheet('QPushButton {border: none;}') icon = QtGui.QIcon(os.path.join(gIconPath + "close.png")) self.closeButton.setIcon(icon) self.closeButton.clicked.connect(self.close) self.toolBar.addWidget(self.closeButton) layout.addWidget(self.toolBar) pixmap = QtGui.QPixmap(os.path.join(gIconPath + "logo-64px.png")) lbl = QtGui.QLabel("") lbl.setPixmap(pixmap) lbl.setAlignment(Qt.AlignCenter) layout.addWidget(lbl) font = QtGui.QFont() font.setPointSize(20) self.topLabel = QtGui.QLabel("Sign In") self.topLabel.setFont(font) self.topLabel.setAlignment(Qt.AlignCenter) layout.addWidget(self.topLabel) self.statusLabel = QtGui.QLabel("") self.statusLabel.setAlignment(Qt.AlignCenter) layout.addWidget(self.statusLabel) self.stackView = QtGui.QStackedWidget(self) # Login Screen View self.loginView = QtGui.QWidget() self.loginViewLayout = QtGui.QVBoxLayout(self) self.loginViewLayout.setAlignment(Qt.AlignCenter) self.emailLineEdit = QtGui.QLineEdit() self.emailLineEdit.setPlaceholderText("E-mail") self.emailLineEdit.setFont(font) self.emailLineEdit.setAlignment(Qt.AlignCenter) self.emailLineEdit.setFixedWidth(370) self.emailLineEdit.setFixedHeight(60) if self.username: self.emailLineEdit.setText(self.username) # Validator for checking email address is valid namerx = QRegExp("\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b") namerx.setCaseSensitivity(Qt.CaseInsensitive); namerx.setPatternSyntax(QRegExp.RegExp); self.nameval = QtGui.QRegExpValidator(namerx, self) self.emailLineEdit.setValidator(self.nameval) self.loginViewLayout.addWidget(self.emailLineEdit) self.passwordLineEdit = QtGui.QLineEdit() self.passwordLineEdit.setStyleSheet('') self.passwordLineEdit.setPlaceholderText("Password") self.passwordLineEdit.setFont(font) self.passwordLineEdit.setAlignment(Qt.AlignCenter) self.passwordLineEdit.setFixedWidth(370) self.passwordLineEdit.setFixedHeight(60) self.passwordLineEdit.setEchoMode(QtGui.QLineEdit.Password) self.loginViewLayout.addWidget(self.passwordLineEdit) self.submitButton = QtGui.QPushButton("LET'S GO") self.submitButton.setFlat(True) self.submitButton.setFont(font) self.submitButton.clicked.connect(self._submitButtonPressed) self.submitButton.setStyleSheet('QPushButton {width: 370px; height: 60px; border-width: 0px; border-radius: 4px; border-style: solid; background-color: #83DEBD; color: white;}') self.loginViewLayout.addWidget(self.submitButton) self.loginView.setLayout(self.loginViewLayout) self.stackView.addWidget(self.loginView) ### View to handle uploading of Clips via drag-drop into a dropzone self.uploadDropzoneView = QtGui.QWidget() self.uploadDropzoneView.setAcceptDrops(True) # Not hooked up. self.uploadDropzoneLayout = QtGui.QVBoxLayout(self) self.uploadDropzoneLayout.setAlignment(Qt.AlignCenter) pixmap = QtGui.QPixmap(os.path.join(gIconPath + "uploadDropzone-64px.png")) uploadIcon = QtGui.QLabel("") uploadIcon.setPixmap(pixmap) uploadIcon.setAlignment(Qt.AlignCenter) self.uploadDropzoneLayout.addWidget(uploadIcon) self.uploadDropzoneLabel1 = QtGui.QLabel("Upload your files") self.uploadDropzoneLabel1.setAlignment(Qt.AlignCenter) self.uploadDropzoneLabel1.setFont(font) self.uploadDropzoneLabel2 = QtGui.QLabel("Drag 'n Drop your files or Clips/Sequences here.") self.uploadDropzoneLabel1.setAlignment(Qt.AlignCenter) self.uploadDropzoneLayout.addWidget(self.uploadDropzoneLabel1) font.setPointSize(16) self.uploadDropzoneLabel2.setFont(font) self.uploadDropzoneLayout.addWidget(self.uploadDropzoneLabel2) self.uploadDropzoneView.setLayout(self.uploadDropzoneLayout) self.stackView.addWidget(self.uploadDropzoneView) ### View to handle uploading of Clips and Timelines View self.uploadView = QtGui.QWidget() self.uploadView.setStyleSheet('QPushButton {width: 100px; height: 100px; border-width: 0px; border-radius: 50px; border-style: solid; background-color: #9974BA; color: white;}') self.uploadViewLayout = QtGui.QVBoxLayout(self) self.uploadViewLayout.setAlignment(Qt.AlignCenter) self.uploadTopButtonWidget = QtGui.QWidget() self.uploadTopButtonLayout = QtGui.QHBoxLayout(self) self.uploadTopButtonLayout.setAlignment(Qt.AlignCenter) self.uploadTimelineOptionButton = QtGui.QPushButton("Timeline") self.uploadClipOptionButton = QtGui.QPushButton("Clips") self.uploadTimelineOptionButton.setCheckable(True) self.uploadTimelineOptionButton.setChecked(False) self.uploadTimelineOptionButton.setFont(font) self.uploadClipOptionButton.setCheckable(True) self.uploadClipOptionButton.setChecked(False) self.uploadClipOptionButton.setFont(font) self.uploadTopButtonLayout.addWidget(self.uploadTimelineOptionButton) self.uploadTopButtonLayout.addWidget(self.uploadClipOptionButton) self.uploadTopButtonWidget.setLayout(self.uploadTopButtonLayout) # This will control whether annotations are uploaded into Frame.io for the item self.exportAnnotationsCheckbox = QtGui.QCheckBox("Export Tags+Annotations Text comments") self.uploadBottomButtonWidget = QtGui.QWidget() self.uploadBottomButtonLayout = QtGui.QHBoxLayout(self) self.uploadBottomButtonLayout.setAlignment(Qt.AlignCenter) self.uploadCancelButton = QtGui.QPushButton("Cancel") self.uploadCancelButton.setStyleSheet('QPushButton {width: 170px; height: 70px; border-width: 0px; border-radius: 4px; border-style: solid; background-color: #767C8E; color: white;}') self.uploadCancelButton.clicked.connect(self.showDropzoneUploadView) self.uploadTaskButton = QtGui.QPushButton("Upload") self.uploadTaskButton.setStyleSheet('QPushButton {width: 170px; height: 70px; border-width: 0px; border-radius: 4px; border-style: solid; color: white;}') self.uploadTaskButton.clicked.connect(self._uploadButtonPushed) font.setPointSize(20) self.uploadCancelButton.setFont(font) self.uploadTaskButton.setFont(font) self.uploadBottomButtonLayout.addWidget(self.uploadCancelButton) self.uploadBottomButtonLayout.addWidget(self.uploadTaskButton) self.uploadBottomButtonWidget.setLayout(self.uploadBottomButtonLayout) self.projectDropdown = QtGui.QComboBox() self.projectDropdown.setFont(font) self.projectDropdown.setEditable(True) self.projectDropdown.lineEdit().setAlignment(Qt.AlignCenter) self.projectDropdown.setEditable(False) self.projectDropdown.setStyleSheet('QComboBox {width: 350px; height: 50px; border-width: 0px; border-radius: 4px; border-style: solid; background-color: #4F535F; color: white;}') # We don't really need these FCP X style buttons because this acts upon a Selection #self.uploadViewLayout.addWidget(self.uploadTopButtonWidget) ### Enable when annotation uploads are supported #self.uploadViewLayout.addWidget(self.exportAnnotationsCheckbox) self.uploadViewLayout.addWidget(self.projectDropdown) self.uploadViewLayout.addWidget(self.uploadBottomButtonWidget) self.uploadView.setLayout(self.uploadViewLayout) self.stackView.addWidget(self.uploadView) sizeGrip = QtGui.QSizeGrip(self) sizeGrip.setStyleSheet("QSizeGrip { height:12px; }") layout.addWidget(self.stackView) layout.addWidget(sizeGrip, 0, Qt.AlignBottom | Qt.AlignRight); self.setMinimumSize(160, 160) self.setLayout(layout) self.emailLineEdit.setFocus()
def handleOddsHtmlPage(self, htmlPage, source=BETEXPLORER_SOURCE): print "handleOddsHtmlPage source = %d" % source epochDate = self._gridList[self._index][1] date = QDateTime() date.setMSecsSinceEpoch(int(epochDate) * 1000) deprecated = QDateTime.currentDateTime() > date.addDays(+1) strHtml = str(htmlPage) if source == BETEXPLORER_SOURCE: oddsRx = QRegExp( "<a href=.*data-odd-max=\"(\\d*\.\\d*)\".*data-odd-max=\"(\\d*\.\\d*)\".*data-odd-max=\"(\\d*\.\\d*)\".*>") elif source == ZULUBET_SOURCE: oddsRx = QRegExp( "<td\\s*class=\"aver_odds_full\"\\s*align=\"center\">(\\d*\.\\d*)</td><td\\s*class=\"aver_odds_full\"\\s*align=\"center\">(\\d*\.\\d*)</td><td\\s*class=\"aver_odds_full\"\\s*align=\"center\">(\\d*\.\\d*)</td>") for match in self._grid.matches(): if not match.cotesDisponibles(): if source == BETEXPLORER_SOURCE and not deprecated: team1Rx = QRegExp( "><span>(\\w*[\\'\\.-]?\\s*)*(%s)(\\w*[\\'\\.-]?\\s*)*</span>\\s*-\\s*<span>\\s*((\\w*[\\'\\.-]?\\s*)*)</span><" % match.team1()) team1Rx.setCaseSensitivity(QtCore.Qt.CaseInsensitive) team2Rx = QRegExp( "><span>\\s*(\\w*[\\'\\.-]?\\s*)*</span>\\s*-\\s*<span>(\\w*[\\'\\.-]?\\s*)*(%s)(\\w*[\\'\\.-]?\\s*)*</span><" % match.team2()) team2Rx.setCaseSensitivity(QtCore.Qt.CaseInsensitive) elif source == ZULUBET_SOURCE: team1Rx = QRegExp( #"<img\\s*src=\"http://www\.zulubet\.com/flags/flag-\\w*\.png\"\\s*class=\"flags\\s*flag-\\w*\"\\s*title=\"(\\w*\\'?\\s*-?)*,(\\w*\\'?\\s*-?)*\"\\s*width=\"\\d*\"\\s*height=\"\\d*\">\\s*(%s)\\s*-\\s*(\\w*\\'?\\s*-?)*<\img>" % match.team1()) "width=\"\\d*\"\\s*height=\"\\d*\">\\s*(%s)\\s*-\\s*(\\w*[\\'\\.-]?\\s*)*</td>" % match.team1()) team1Rx.setCaseSensitivity(QtCore.Qt.CaseInsensitive) team2Rx = QRegExp( "width=\"\\d*\"\\s*height=\"\\d*\">(\\w*[\\'\\.-]?\\s*)*-\\s*(%s)\\s*</td>" % match.team2()) team2Rx.setCaseSensitivity(QtCore.Qt.CaseInsensitive) else: team1Rx = QRegExp("---deprecated---") team2Rx = QRegExp("---deprecated---") # team2Rx = QRegExp(match.team2()) teamXRx = team1Rx posi = teamXRx.indexIn(strHtml) posi2 = team2Rx.indexIn(strHtml) #if posi < 0: #print "-1-%s- not found" % match.team1() #teamXRx = team2Rx #posi = teamXRx.indexIn(strHtml) #if (posi >= 0) and (posi2 >= 0): if (posi >= 0) and (posi2 == posi): print "-%s- found" % ''.join((match.team1(), " vs " + match.team2())) else: # try in an other way print "-%s- not found, try another way" % ''.join((match.team1(), " vs " + match.team2())) # split team names team1list = match.team1().split(" ") team2list = match.team2().split(" ") # find the longest maxLen = 0 miniTeam1 = "" for elt1 in team1list: if len(elt1) > maxLen: maxLen = len(elt1) miniTeam1 = filter(onlyascii, elt1) maxLen = 0 miniTeam2 = "" for elt2 in team2list: if len(elt2) > maxLen: maxLen = len(elt2) miniTeam2 = filter(onlyascii, elt2) print "Try with {0} vs {1}".format(miniTeam1, miniTeam2) if source == BETEXPLORER_SOURCE and not deprecated: teamRx = QRegExp( "><span>\\s*(\\w*\\'?\\s*-?)*{0}(\\w*\\'?\\s*-?)*</span>\\s*-\\s*<span>(\\w*\\'?\\s*-?)*{1}(\\w*\\'?\\s*-?)*</span><".format( miniTeam1, miniTeam2)) elif source == ZULUBET_SOURCE: #teamRx = QRegExp( #"<img\\s*src=\"http://www\.zulubet\.com/flags/flag-\\w*\.png\"\\s*class=\"flags\\s*flag-\\w*\"\\s*title=\"(\\w*\\'?\\s*-?)*,(\\w*\\'?\\s*-?)*\"\\s*width=\"\\d*\"\\s*height=\"\\d*\">(\\w*\\'?\\s*-?)*{0}(\\w*\\'?\\s*-?)*-(\\w*\\'?\\s*-?)*{1}(\\w*\\'?\\s*-?)*<\img>".format( #miniTeam1, miniTeam2)) teamRx = QRegExp("\">(\\w*\\'?\\s*-?)*{0}(\\w*\\'?\\s*-?)*-(\\w*\\'?\\s*-?)*{1}(\\w*\\'?\\s*-?)*</td>".format(miniTeam1, miniTeam2)) else: teamRx = QRegExp("---deprecated---") print "---GRID DEPRECATED---" teamRx.setCaseSensitivity(QtCore.Qt.CaseInsensitive) posi = teamRx.indexIn(strHtml) if posi >= 0: print "found : {0} vs {1}".format(miniTeam1, miniTeam2) else: print "still not found :'(" # print "Odds handling KO %s not found" % str(match) if posi >= 0: print "posi = %d" % posi posi = oddsRx.indexIn(strHtml, posi) oddStr1 = oddsRx.cap(1) oddStr2 = oddsRx.cap(2) oddStr3 = oddsRx.cap(3) print "read odds1 = %s" % oddStr1 try: match.setCotes(float(oddsRx.cap(1)), float(oddsRx.cap(2)), float(oddsRx.cap(3))) team1 = filter(onlyascii, match.team1()) team2 = filter(onlyascii, match.team2()) print "Odds handling OK : %s" % team1 + " vs " + team2 print "Odds handling OK : " match.setCotesDisponibles(True) except: team1 = filter(onlyascii, match.team1()) team2 = filter(onlyascii, match.team2()) print "Odds handling OK : cant read odds for %s" % team1 + " vs " + team2 return