예제 #1
0
 def __init__(self, max_w=240):
     super().__init__()
     # ImageSelector.image_url = ""
     self.the_line = QHBoxLayout()
     self.the_line.setContentsMargins(0, 0, 0, 0)
     self.the_line.setSpacing(0)
     self.text = ClickableLineEdit()
     self.text.setFixedHeight(33)
     self.setMaximumWidth(max_w)
     self.text.setText("Choose Database")
     self.text.setReadOnly(True)
     self.text.clicked.connect(self.do_select_image)
     self.text.setAlignment(Qt.AlignRight)
     self.text.setStyleSheet(
         "border-top-right-radius: 10px; border-bottom-right-radius: 10px; padding: 7px;"
     )
     self.button = QPushButton()
     pixmap = QIcon("resources/assets/images/upload-blue.png")
     self.button.setIcon(pixmap)
     self.button.setIconSize(QSize(33, 33))
     self.button.setCursor(QCursor(Qt.PointingHandCursor))
     self.button.setStyleSheet(
         "border-top-left-radius: 10px; border-bottom-left-radius: 10px; background-color : #fff;"
     )
     self.the_line.addWidget(self.text)
     self.the_line.addWidget(self.button)
     self.button.clicked.connect(self.do_select_image)
     self.setLayout(self.the_line)
예제 #2
0
 def __init__(self, txt, max_w=240):
     super().__init__()
     # ImageSelector.image_url = ""
     self.the_line = QHBoxLayout()
     self.the_line.setContentsMargins(0, 0, 0, 0)
     self.the_line.setSpacing(0)
     self.text = ClickableLineEdit()
     self.text.setFixedHeight(33)
     self.setMaximumWidth(max_w)
     self.text.setText(txt)
     self.text.setReadOnly(True)
     self.text.clicked.connect(self.emit_clicked)
     self.text.setStyleSheet(
         "border-top-left-radius: 10px; border-bottom-left-radius: 10px; padding: 7px;"
     )
     self.img_select_btn = QPushButton()
     self.img_select_btn.setAutoDefault(False)
     pixmap = QIcon("resources/assets/images/import.png")
     self.img_select_btn.setIcon(pixmap)
     self.img_select_btn.setIconSize(QSize(33, 33))
     self.img_select_btn.setCursor(QCursor(Qt.PointingHandCursor))
     self.text.setCursor(QCursor(Qt.PointingHandCursor))
     self.img_select_btn.setStyleSheet(
         "border-top-right-radius: 10px; border-bottom-right-radius: 10px; background-color : #fff;"
     )
     self.the_line.addWidget(self.text)
     self.the_line.addWidget(self.img_select_btn)
     self.img_select_btn.clicked.connect(self.emit_clicked)
     self.setLayout(self.the_line)
예제 #3
0
 def __init__(self,
              is_read_only=False,
              icon="resources/assets/images/search.png",
              place_holder=None):
     super().__init__()
     self.the_line = QHBoxLayout()
     self.the_line.setSpacing(0)
     self.text_input = ClickableLineEdit()
     self.text_input.setFixedHeight(33)
     self.text_input.textChanged[str].connect(self.update_value)
     self.text_input.returnPressed.connect(self.event_emittor)
     if is_read_only:
         self.text_input.setReadOnly(True)
         self.text_input.clicked.connect(self.event_emittor)
     if place_holder:
         self.text_input.setPlaceholderText(place_holder)
     #self.text_input.setAlignment(Qt.AlignRight)
     self.text_input.setStyleSheet(
         "border-top-left-radius: 10px; border-bottom-left-radius: 10px; padding: 7px;"
     )
     self.button = QPushButton()
     pixmap = QIcon(icon)
     self.button.setIcon(pixmap)
     self.button.setIconSize(QSize(33, 33))
     self.button.setCursor(QCursor(Qt.PointingHandCursor))
     self.button.setStyleSheet(
         "border-top-right-radius: 10px; border-bottom-right-radius: 10px; background-color : #fff;"
     )
     self.the_line.addWidget(self.text_input)
     self.the_line.addWidget(self.button)
     self.button.clicked.connect(self.event_emittor)
     self.setLayout(self.the_line)
예제 #4
0
class IconTextBox(QWidget):
    text_value = ""
    iconClicked = pyqtSignal()

    def __init__(self,
                 is_read_only=False,
                 icon="resources/assets/images/search.png",
                 place_holder=None):
        super().__init__()
        self.the_line = QHBoxLayout()
        self.the_line.setSpacing(0)
        self.text_input = ClickableLineEdit()
        self.text_input.setFixedHeight(33)
        self.text_input.textChanged[str].connect(self.update_value)
        self.text_input.returnPressed.connect(self.event_emittor)
        if is_read_only:
            self.text_input.setReadOnly(True)
            self.text_input.clicked.connect(self.event_emittor)
        if place_holder:
            self.text_input.setPlaceholderText(place_holder)
        #self.text_input.setAlignment(Qt.AlignRight)
        self.text_input.setStyleSheet(
            "border-top-left-radius: 10px; border-bottom-left-radius: 10px; padding: 7px;"
        )
        self.button = QPushButton()
        pixmap = QIcon(icon)
        self.button.setIcon(pixmap)
        self.button.setIconSize(QSize(33, 33))
        self.button.setCursor(QCursor(Qt.PointingHandCursor))
        self.button.setStyleSheet(
            "border-top-right-radius: 10px; border-bottom-right-radius: 10px; background-color : #fff;"
        )
        self.the_line.addWidget(self.text_input)
        self.the_line.addWidget(self.button)
        self.button.clicked.connect(self.event_emittor)
        self.setLayout(self.the_line)

    def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            pass
        else:
            super().mousePressEvent(event)

    def setMaximumWidth(self, p_int):
        self.setFixedWidth(p_int)

    def setText(self, txt):
        self.text_input.setText(txt)
        IconTextBoxAR.text_value = txt

    @staticmethod
    def text():
        return IconTextBoxAR.text_value

    def update_value(self, txt):
        IconTextBoxAR.text_value = txt

    def event_emittor(self):
        self.iconClicked.emit()
예제 #5
0
class DatabaseSelector(QWidget):
    db_url = ""

    def __init__(self, max_w=240):
        super().__init__()
        # DatabaseSelector.db_url = ""
        self.the_line = QHBoxLayout()
        self.the_line.setContentsMargins(0, 0, 0, 0)
        self.the_line.setSpacing(0)
        self.text = ClickableLineEdit()
        self.text.setFixedHeight(33)
        self.setMaximumWidth(max_w)
        self.text.setText("Choose Database")
        self.text.setReadOnly(True)
        self.text.clicked.connect(self.do_select_image)
        self.text.setStyleSheet(
            "border-top-left-radius: 10px; border-bottom-left-radius: 10px; padding: 7px;"
        )
        self.img_select_btn = QPushButton()
        self.img_select_btn.setAutoDefault(False)
        pixmap = QIcon("resources/assets/images/file.png")
        self.img_select_btn.setIcon(pixmap)
        self.img_select_btn.setIconSize(QSize(33, 33))
        self.img_select_btn.setCursor(QCursor(Qt.PointingHandCursor))
        self.img_select_btn.setStyleSheet(
            "border-top-right-radius: 10px; border-bottom-right-radius: 10px; background-color : #fff;"
        )
        self.the_line.addWidget(self.text)
        self.the_line.addWidget(self.img_select_btn)
        self.img_select_btn.clicked.connect(self.do_select_image)
        self.setLayout(self.the_line)

    def do_select_image(self):
        options = QFileDialog.Options()
        # options |= QFileDialog.DontUseNativeDialog
        db_path, _ = QFileDialog.getOpenFileName(None,
                                                 "Choose Database",
                                                 "",
                                                 "Database Files (*.db)",
                                                 options=options)
        if db_path:
            DatabaseSelector.db_url = db_path
            self.text.setText(db_path)

    def setMaximumWidth(self, p_int):
        self.setFixedWidth(p_int)

    def setText(self, txt):
        self.text.setText(txt)

    @staticmethod
    def value():
        return DatabaseSelector.db_url
예제 #6
0
class ImageSelector(QWidget):
    image_url = ""

    def __init__(self, max_w=240):
        super().__init__()
        # ImageSelector.image_url = ""
        self.the_line = QHBoxLayout()
        self.the_line.setContentsMargins(0, 0, 0, 0)
        self.the_line.setSpacing(0)
        self.text = ClickableLineEdit()
        self.text.setFixedHeight(33)
        self.setMaximumWidth(max_w)
        self.text.setText("Choose Database")
        self.text.setReadOnly(True)
        self.text.clicked.connect(self.do_select_image)
        self.text.setAlignment(Qt.AlignRight)
        self.text.setStyleSheet(
            "border-top-right-radius: 10px; border-bottom-right-radius: 10px; padding: 7px;"
        )
        self.button = QPushButton()
        pixmap = QIcon("resources/assets/images/upload-blue.png")
        self.button.setIcon(pixmap)
        self.button.setIconSize(QSize(33, 33))
        self.button.setCursor(QCursor(Qt.PointingHandCursor))
        self.button.setStyleSheet(
            "border-top-left-radius: 10px; border-bottom-left-radius: 10px; background-color : #fff;"
        )
        self.the_line.addWidget(self.text)
        self.the_line.addWidget(self.button)
        self.button.clicked.connect(self.do_select_image)
        self.setLayout(self.the_line)

    def do_select_image(self):
        options = QFileDialog.Options()
        # options |= QFileDialog.DontUseNativeDialog
        img_path, _ = QFileDialog.getOpenFileName(None,
                                                  "اختر الصورة",
                                                  "",
                                                  "Image Files (*.jpg *.png)",
                                                  options=options)
        if img_path:
            ImageSelector.image_url = img_path
            self.text.setText(img_path)

    def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            pass
        else:
            super().mousePressEvent(event)

    def setMaximumWidth(self, p_int):
        self.setFixedWidth(p_int)

    def setText(self, txt):
        self.text.setText(txt)

    @staticmethod
    def value():
        return ImageSelector.image_url
예제 #7
0
class PathSelector(QWidget):
    selected_path = ""

    def __init__(self, max_w=240, start_path=''):
        super().__init__()
        self.start_path = start_path
        self.the_line = QHBoxLayout()
        PathSelector.selected_path = start_path
        self.the_line.setContentsMargins(0, 0, 0, 0)
        self.the_line.setSpacing(0)
        self.text = ClickableLineEdit()
        self.text.setFixedHeight(33)
        self.setMaximumWidth(max_w)
        self.text.setText("           "+start_path)
        self.text.setReadOnly(True)
        self.text.clicked.connect(self.do_select_path)
        self.text.setAlignment(Qt.AlignRight)
        self.text.setStyleSheet("border-top-right-radius: 10px; border-bottom-right-radius: 10px; padding: 7px;")
        self.button = QPushButton()
        pixmap = QIcon("resources/assets/images/upload-blue.png")
        self.button.setIcon(pixmap)
        self.button.setIconSize(QSize(33, 33))
        self.button.setCursor(QCursor(Qt.PointingHandCursor))
        self.button.setStyleSheet("border-top-left-radius: 10px; border-bottom-left-radius: 10px; background-color : #fff;")
        self.the_line.addWidget(self.text)
        self.the_line.addWidget(self.button)
        self.button.clicked.connect(self.do_select_path)
        self.setLayout(self.the_line)

    def do_select_path(self):
        options = QFileDialog.Options()
        the_path = str(QFileDialog.getExistingDirectory(None, "اختر مسار الحفظ", self.start_path, options=options))
        if the_path:
            PathSelector.selected_path = the_path
            self.text.setText(the_path)

    def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            pass
        else:
            super().mousePressEvent(event)

    def setMaximumWidth(self, p_int):
        self.setFixedWidth(p_int)

    def setText(self, txt):
        self.text.setText(txt)

    @staticmethod
    def value():
        return PathSelector.selected_path