PyQt4 | PyQt4 module for Maya on Windows and Mac | Animation library

 by   zclongpop123 Python Version: Current License: No License

kandi X-RAY | PyQt4 Summary

kandi X-RAY | PyQt4 Summary

PyQt4 is a Python library typically used in User Interface, Animation applications. PyQt4 has no bugs, it has no vulnerabilities, it has build file available and it has low support. You can download it from GitHub.

PyQt4 for Maya 2012 - 2016 =.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              PyQt4 has a low active ecosystem.
              It has 16 star(s) with 8 fork(s). There are 2 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              PyQt4 has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of PyQt4 is current.

            kandi-Quality Quality

              PyQt4 has 0 bugs and 0 code smells.

            kandi-Security Security

              PyQt4 has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              PyQt4 code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              PyQt4 does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              PyQt4 releases are not available. You will need to build from source code and install.
              Build file is available. You can build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              PyQt4 saves you 9381 person hours of effort in developing the same functionality from scratch.
              It has 19162 lines of code, 2161 functions and 348 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed PyQt4 and discovered the below as its top functions. This is intended to give you an instant insight into PyQt4 implemented functionality, and help decide if they suit your requirements.
            • Create a widget from an element .
            • Compile a .ui file .
            • Create a QObject .
            • Compiles the given UIFile to a Python code file .
            • Return an icon from the given iconset .
            • Load a QtGui type from a file .
            • Return the position of the layout .
            • Set the icon .
            • Invoke the driver .
            • Write the given function to the proxy .
            Get all kandi verified functions for this library.

            PyQt4 Key Features

            No Key Features are available at this moment for PyQt4.

            PyQt4 Examples and Code Snippets

            No Code Snippets are available at this moment for PyQt4.

            Community Discussions

            QUESTION

            want to filter rows on the basis of comboBoxes and search bar also I want to make checkboxes multiselect with select deselect all and search in pyQt5
            Asked 2021-May-19 at 08:44

            Here, I have one tableView, Upload Button ,two ComboBoxes which will be filled automatically when user upload a csv file also there is a search bar (QLineEdit_2) , I want to filter rows on the basis of two checkBoxes and search bar (QLineEdit_2), also I want to make comboBoxes multiselect with select all and deselect all with Search functionality altogether.

            ...

            ANSWER

            Answered 2021-May-19 at 08:44
            import pandas as pd
            from PyQt5 import QtCore, QtGui, QtWidgets
            from PyQt5.QtWidgets import QFileDialog
            from PyQt5.QtCore import Qt
            import sys
            
            ########################################### PandasModel to display it on tableView #####################
            
            class PandasModel(QtCore.QAbstractTableModel):
                def __init__(self, df=pd.DataFrame(), parent=None):
                    QtCore.QAbstractTableModel.__init__(self, parent=parent)
                    self._df = df.copy()
            
                def toDataFrame(self):
                    return self._df.copy()
            
                def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole):
                    if role != QtCore.Qt.DisplayRole:
                        return QtCore.QVariant()
            
                    if orientation == QtCore.Qt.Horizontal:
                        try:
                            return self._df.columns.tolist()[section]
                        except (IndexError, ):
                            return QtCore.QVariant()
                    elif orientation == QtCore.Qt.Vertical:
                        try:
                            # return self.df.index.tolist()
                            return self._df.index.tolist()[section]
                        except (IndexError, ):
                            return QtCore.QVariant()
            
                def data(self, index, role=QtCore.Qt.DisplayRole):
                    if role != QtCore.Qt.DisplayRole:
                        return QtCore.QVariant()
            
                    if not index.isValid():
                        return QtCore.QVariant()
            
                    return QtCore.QVariant(str(self._df.iloc[index.row(), index.column()]))
            
                def setData(self, index, value, role):
                    row = self._df.index[index.row()]
                    col = self._df.columns[index.column()]
                    if hasattr(value, 'toPyObject'):
                        # PyQt4 gets a QVariant
                        value = value.toPyObject()
                    else:
                        # PySide gets an unicode
                        dtype = self._df[col].dtype
                        if dtype != object:
                            value = None if value == '' else dtype.type(value)
                    self._df.set_value(row, col, value)
                    return True
            
                def rowCount(self, parent=QtCore.QModelIndex()):
                    return len(self._df.index)
            
                def columnCount(self, parent=QtCore.QModelIndex()):
                    return len(self._df.columns)
            
                def sort(self, column, order):
                    colname = self._df.columns.tolist()[column]
                    self.layoutAboutToBeChanged.emit()
                    self._df.sort_values(colname, ascending=order ==
                                         QtCore.Qt.AscendingOrder, inplace=True)
                    self._df.reset_index(inplace=True, drop=True)
                    self.layoutChanged.emit()
            
            
            ################################################ Main UI ###############################################
            
            class Ui_Dialog(object):
                def setupUi(self, Dialog):
                    Dialog.setObjectName("Dialog")
                    Dialog.resize(1678, 977)
                    self.verticalLayoutWidget = QtWidgets.QWidget(Dialog)
                    self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 230, 201, 40))
                    self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
                    self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
                    self.verticalLayout.setContentsMargins(0, 0, 0, 0)
                    self.verticalLayout.setObjectName("verticalLayout")
                    
                    # Upload Button Signal
                    self.pushButton = QtWidgets.QPushButton(self.verticalLayoutWidget)
                    self.pushButton.clicked.connect(self.upload)
                    font = QtGui.QFont()
                    font.setFamily("Waree")
                    font.setPointSize(12)
                    font.setBold(True)
                    font.setWeight(75)
                    self.pushButton.setFont(font)
                    self.pushButton.setObjectName("pushButton")
                    self.verticalLayout.addWidget(self.pushButton)
                    self.verticalLayoutWidget_2 = QtWidgets.QWidget(Dialog)
                    self.verticalLayoutWidget_2.setGeometry(QtCore.QRect(220, 20, 1441, 40))
                    self.verticalLayoutWidget_2.setObjectName("verticalLayoutWidget_2")
                    self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_2)
                    self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
                    self.verticalLayout_2.setObjectName("verticalLayout_2")
                    self.lineEdit = QtWidgets.QLineEdit(self.verticalLayoutWidget_2)
                    font = QtGui.QFont()
                    font.setFamily("Waree")
                    font.setPointSize(12)
                    font.setBold(True)
                    font.setWeight(75)
                    self.lineEdit.setFont(font)
                    self.lineEdit.setObjectName("lineEdit")
                    self.verticalLayout_2.addWidget(self.lineEdit)
                    self.verticalLayoutWidget_3 = QtWidgets.QWidget(Dialog)
                    self.verticalLayoutWidget_3.setGeometry(QtCore.QRect(220, 60, 1441, 40))
                    self.verticalLayoutWidget_3.setObjectName("verticalLayoutWidget_3")
                    self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_3)
                    self.verticalLayout_3.setContentsMargins(0, 0, 0, 0)
                    self.verticalLayout_3.setObjectName("verticalLayout_3")
                    self.lineEdit_2 = QtWidgets.QLineEdit(self.verticalLayoutWidget_3)
                    font = QtGui.QFont()
                    font.setFamily("Waree")
                    font.setPointSize(12)
                    font.setBold(True)
                    font.setWeight(75)
                    self.lineEdit_2.setFont(font)
                    self.lineEdit_2.setObjectName("lineEdit_2")
                    self.verticalLayout_3.addWidget(self.lineEdit_2)
                    self.gridLayoutWidget = QtWidgets.QWidget(Dialog)
                    self.gridLayoutWidget.setGeometry(QtCore.QRect(220, 100, 1441, 861))
                    self.gridLayoutWidget.setObjectName("gridLayoutWidget")
                    self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
                    self.gridLayout.setContentsMargins(0, 0, 0, 0)
                    self.gridLayout.setObjectName("gridLayout")
                    self.tableView = QtWidgets.QTableView(self.gridLayoutWidget)
                    font = QtGui.QFont()
                    font.setFamily("MS Shell Dlg 2")
                    font.setPointSize(10)
                    font.setBold(True)
                    font.setWeight(75)
                    self.tableView.setFont(font)
                    self.tableView.setObjectName("tableView")
                    self.gridLayout.addWidget(self.tableView, 0, 0, 1, 1)
                    self.verticalLayoutWidget_4 = QtWidgets.QWidget(Dialog)
                    self.verticalLayoutWidget_4.setGeometry(QtCore.QRect(10, 270, 201, 40))
                    self.verticalLayoutWidget_4.setObjectName("verticalLayoutWidget_4")
                    self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_4)
                    self.verticalLayout_4.setContentsMargins(0, 0, 0, 0)
                    self.verticalLayout_4.setObjectName("verticalLayout_4")
                    
                    # Validate Button Signal
                    self.pushButton_2 = QtWidgets.QPushButton(self.verticalLayoutWidget_4)
                    self.pushButton_2.clicked.connect(self.validate)
                    font = QtGui.QFont()
                    font.setFamily("Waree")
                    font.setPointSize(12)
                    font.setBold(True)
                    font.setWeight(75)
                    self.pushButton_2.setFont(font)
                    self.pushButton_2.setObjectName("pushButton_2")
                    self.verticalLayout_4.addWidget(self.pushButton_2)
                    self.verticalLayoutWidget_5 = QtWidgets.QWidget(Dialog)
                    self.verticalLayoutWidget_5.setGeometry(QtCore.QRect(10, 710, 201, 41))
                    self.verticalLayoutWidget_5.setObjectName("verticalLayoutWidget_5")
                    self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_5)
                    self.verticalLayout_5.setContentsMargins(0, 0, 0, 0)
                    self.verticalLayout_5.setObjectName("verticalLayout_5")
                    
                    # Export Button Signal
                    self.pushButton_3 = QtWidgets.QPushButton(self.verticalLayoutWidget_5)
                    self.pushButton_3.clicked.connect(self.exportCSV)
                    font = QtGui.QFont()
                    font.setFamily("Waree")
                    font.setPointSize(12)
                    font.setBold(True)
                    font.setWeight(75)
                    self.pushButton_3.setFont(font)
                    self.pushButton_3.setObjectName("pushButton_3")
                    self.verticalLayout_5.addWidget(self.pushButton_3)
                    self.verticalLayoutWidget_6 = QtWidgets.QWidget(Dialog)
                    self.verticalLayoutWidget_6.setGeometry(QtCore.QRect(10, 770, 201, 41))
                    self.verticalLayoutWidget_6.setObjectName("verticalLayoutWidget_6")
                    self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_6)
                    self.verticalLayout_6.setContentsMargins(0, 0, 0, 0)
                    self.verticalLayout_6.setObjectName("verticalLayout_6")
                    
                    # Reset Button Signal
                    self.pushButton_4 = QtWidgets.QPushButton(self.verticalLayoutWidget_6)
                    font = QtGui.QFont()
                    font.setFamily("Waree")
                    font.setPointSize(12)
                    font.setBold(True)
                    font.setWeight(75)
                    self.pushButton_4.setFont(font)
                    self.pushButton_4.setObjectName("pushButton_4")
                    self.verticalLayout_6.addWidget(self.pushButton_4)
                    self.gridLayoutWidget_4 = QtWidgets.QWidget(Dialog)
                    self.gridLayoutWidget_4.setGeometry(QtCore.QRect(60, 20, 117, 144))
                    self.gridLayoutWidget_4.setObjectName("gridLayoutWidget_4")
                    self.gridLayout_2 = QtWidgets.QGridLayout(self.gridLayoutWidget_4)
                    self.gridLayout_2.setContentsMargins(0, 0, 0, 0)
                    self.gridLayout_2.setObjectName("gridLayout_2")
                    self.label_3 = QtWidgets.QLabel(self.gridLayoutWidget_4)
                    self.label_3.setText("")
                    self.label_3.setPixmap(QtGui.QPixmap("../../../../Pictures/74067_web (2).jpg"))
                    self.label_3.setObjectName("label_3")
                    self.gridLayout_2.addWidget(self.label_3, 0, 0, 1, 1)
                    
                    # Select State Signal
                    self.pushButton_5 = QtWidgets.QPushButton(Dialog)
                    self.pushButton_5.clicked.connect(self.onSelectState)
                    self.pushButton_5.setGeometry(QtCore.QRect(10, 330, 201, 33))
                    font = QtGui.QFont()
                    font.setFamily("Waree")
                    font.setPointSize(12)
                    font.setBold(True)
                    font.setWeight(75)
                    self.pushButton_5.setFont(font)
                    self.pushButton_5.setObjectName("pushButton_5")
                    
                    # Select District Signal
                    self.pushButton_6 = QtWidgets.QPushButton(Dialog)
                    self.pushButton_6.clicked.connect(self.onSelectDistrict)
                    self.pushButton_6.setGeometry(QtCore.QRect(10, 380, 201, 33))
                    font = QtGui.QFont()
                    font.setFamily("Waree")
                    font.setPointSize(12)
                    font.setBold(True)
                    font.setWeight(75)
                    self.pushButton_6.setFont(font)
                    self.pushButton_6.setObjectName("pushButton_6")
                    
                    # Select Facility Type Signal
                    self.pushButton_7 = QtWidgets.QPushButton(Dialog)
                    self.pushButton_7.clicked.connect(self.onSelectFacilitytype)
                    self.pushButton_7.setGeometry(QtCore.QRect(0, 430, 211, 33))
                    font = QtGui.QFont()
                    font.setFamily("Waree")
                    font.setPointSize(12)
                    font.setBold(True)
                    font.setWeight(75)
                    self.pushButton_7.setFont(font)
                    self.pushButton_7.setObjectName("pushButton_7")
                    
                    # Select Facility Name Signal
                    self.pushButton_8 = QtWidgets.QPushButton(Dialog)
                    self.pushButton_8.clicked.connect(self.onSelectFacilityName)
                    self.pushButton_8.setGeometry(QtCore.QRect(0, 480, 211, 33))
                    font = QtGui.QFont()
                    font.setFamily("Waree")
                    font.setPointSize(12)
                    font.setBold(True)
                    font.setWeight(75)
                    self.pushButton_8.setFont(font)
                    self.pushButton_8.setObjectName("pushButton_8")
                    
                    #Select Month Signal
                    self.pushButton_9 = QtWidgets.QPushButton(Dialog)
                    self.pushButton_9.setGeometry(QtCore.QRect(0, 530, 211, 33))
                    font = QtGui.QFont()
                    font.setFamily("Waree")
                    font.setPointSize(12)
                    font.setBold(True)
                    font.setWeight(75)
                    self.pushButton_9.setFont(font)
                    self.pushButton_9.setObjectName("pushButton_9")
                    
                    #Select Year Signal
                    self.pushButton_10 = QtWidgets.QPushButton(Dialog)
                    self.pushButton_10.setGeometry(QtCore.QRect(0, 580, 211, 33))
                    font = QtGui.QFont()
                    font.setFamily("Waree")
                    font.setPointSize(12)
                    font.setBold(True)
                    font.setWeight(75)
                    self.pushButton_10.setFont(font)
                    self.pushButton_10.setObjectName("pushButton_10")
            
                    self.retranslateUi(Dialog)
                    QtCore.QMetaObject.connectSlotsByName(Dialog)
            
                def retranslateUi(self, Dialog):
                    _translate = QtCore.QCoreApplication.translate
                    Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
                    self.pushButton.setText(_translate("Dialog", "Upload"))
                    self.lineEdit_2.setPlaceholderText(_translate("Dialog", "Search..."))
                    self.pushButton_2.setText(_translate("Dialog", "Validate"))
                    self.pushButton_3.setText(_translate("Dialog", "Export"))
                    self.pushButton_4.setText(_translate("Dialog", "Reset"))
                    self.pushButton_5.setText(_translate("Dialog", "Select State"))
                    self.pushButton_6.setText(_translate("Dialog", "Select District"))
                    self.pushButton_7.setText(_translate("Dialog", "Select Facility Type"))
                    self.pushButton_8.setText(_translate("Dialog", "Select Facility Name"))
                    self.pushButton_9.setText(_translate("Dialog", "Select Month"))
                    self.pushButton_10.setText(_translate("Dialog", "Select Year"))
            
                # To upload file
                def upload(self):
                    global df_, df_OrgHeaders
                    products = {'Date': [2,3,1,5,3,9],
                                'Month': ['April', 'May', 'April', 'June', 'May', 'July'],        
                                'Year': [2020, 2021, 2019, 2020, 2020, 2020],
                                'State': ['BR', 'JH', 'HR', 'JH', 'BR', 'PB'],
                                'Blank': ['nan','nan','nan','nan','nan','nan'],
                                'District' : ['BS', 'GW', 'AM', 'RN', 'PB', 'GR'],
                                'Facility Type': ['HSC', 'DH', 'HSC', 'CHC', 'HSC', 'DH'],
                                'Facility Name': ['PP CAC', 'SC Bkr', 'SC Bara', 'SC Bkr', 'PP CAC', 'PP CAC'],
                                '4.3': [1, 0, 2, 2, 9, 8],
                                '2.1.1.a': [0, 1, 1, 2, 3, 4],
                                '2.1.1.b': [1, 2, 0, 0, 0, 0],
                                '2.2': [1,2, 3, 4, 0, 0],
                                }
                    df_ = pd.DataFrame(products, columns= ['Date', 'Month', 'Year', 'State', 'Blank', 'District', 'Facility Type', 'Facility Name', '4.3', '2.1.1.a', '2.1.1.b', '2.2'])
            
                    self.tableView.setModel(PandasModel(df_))
            
                    # grab the first row for the header
                    new_header = df_.iloc[1]
            
                    # set the header row as the df header
                    df_.columns = new_header
            
                    #df_.dropna(how='all', axis=1)
                    df_.columns = ['col_' + str(index)
                                   for index in range(1, len(df_.columns)+1)]
                    df_OrgHeaders = df_.iloc[[0, 1]]
                    #df_.drop(df_.index[[0, 1]], inplace=True)
                    #df_.dropna(subset=['col_4'], how='all', inplace=True)
                    return df_
            
                def loadFile(self, df_):
                    self.pushButton.setDisabled(False)
                    return df_
            
                # to validate modified checks
                def validate(self):
                    global df, list_set
                    # df = self.loadFile()
                    df = self.loadFile(df_)
            
                    print("Entering Validate")
            
                    # 4.3 <= 2.1.1.a + 2.1.1.b + 2.2
                    def res1(df):
                        count = 0
                        if float(df['col_9']) > float(df['col_10']) + float(df['col_11']) + float(df['col_12']):
                            count = count+1
                            return 'Inconsistent'
                        elif pd.isnull(df['col_9']) and pd.isnull(df['col_10']) and pd.isnull(df['col_11']) and pd.isnull(df['col_12']):
                            return 'Blank'
                        elif pd.isnull(df['col_9']) or pd.isnull(df['col_10']) or pd.isnull(df['col_11']) or pd.isnull(df['col_12']):
                            return 'Blank Error'
                        else:
                            return 'Consistent'
                    
                    df['4.3 <= 2.1.1.a + 2.1.1.b + 2.2'] = df.apply(res1, axis=1)
                    
                    df = pd.concat([df_, df['4.3 <= 2.1.1.a + 2.1.1.b + 2.2']], axis=1)
            
                    df.astype(str)
                    # Select State #
                    # convert the set to the list
                    list_set = df_['col_4'].tolist()
                    unique_list = set(list_set)
                    return df
            
                ################################################################################
                # Select State
            
                # Select State Functionality
                def onSelectState(self, index):
                    self.keywords = dict([(i, []) for i in range(df.shape[0])])
                    print(self.keywords)
                    self.menu = QtWidgets.QMenu(Dialog)
                    self.menu.setStyleSheet('QMenu { menu-scrollable: true; width: 400 }')
                    font = self.menu.font()
                    font.setPointSize(9)
                    font.setBold(True)
                    font.setWeight(75)
                    self.menu.setFont(font) 
                    
                    index = 4
                    self.col = index
            
                    data_unique = []
            
                    self.checkBoxs = []
                    
                    # Selectall added into Dropdown
                    checkBox = QtWidgets.QCheckBox("Select all", self.menu)
            
                    # All the checkboxes are enabled to check
                    checkableAction = QtWidgets.QWidgetAction(self.menu)
                    checkableAction.setDefaultWidget(checkBox)
                    self.menu.addAction(checkableAction)
                    checkBox.setChecked(True)
                    checkBox.stateChanged.connect(self.slotSelect)
            
                    # list storing state data
                    item = list_set
                    
                    # looping to fill checkboxes, initially all checkboxes will be checked
                    for i in range(len(df)):
                        if item[i] not in data_unique:
                            data_unique.append(item[i])
                            checkBox = QtWidgets.QCheckBox(item[i], self.menu)
                            checkBox.setChecked(True)
                            checkableAction = QtWidgets.QWidgetAction(self.menu)
                            checkableAction.setDefaultWidget(checkBox)
                            self.menu.addAction(checkableAction)
                            self.checkBoxs.append(checkBox)
            
                    # Ok, cancel button
                    btn = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
                                                 QtCore.Qt.Horizontal, self.menu)
            
                    # ok selected                             
                    btn.accepted.connect(self.menuClose)
                    # rejected , nothing selected
                    btn.rejected.connect(self.menu.close)
            
                    checkableAction = QtWidgets.QWidgetAction(self.menu)
                    checkableAction.setDefaultWidget(btn)
                    self.menu.addAction(checkableAction)
                    self.pushButton_5.setMenu(self.menu)
            
                # method to check -> uncheck and vice versa
                def slotSelect(self, state):
                    for checkbox in self.checkBoxs:
                        checkbox.setChecked(QtCore.Qt.Checked == state)
            
                # after ok selected 
                def menuClose(self):
                    self.keywords[self.col] = []
                    for element in self.checkBoxs:
                        if element.isChecked():
                            self.keywords[self.col].append(element.text())
                    self.filterdata()
                    self.menu.close()
            
                # Filter data columnwise
                def filterdata(self):
                    global final_df
                    #keywords = dict([(i, []) for i in range(self.filterall.columnCount())])
                    columnsShow = dict([(i, True) for i in range(df.shape[0])])
            
                    # for i in range(df.shape[0]): 
                    j=0 
                    for j in range(df.shape[0]):
                        item = list_set
                        
                        print(self.keywords[self.col])
                        #if self.keywords[self.col]:
                        if item[j] not in self.keywords[self.col]:
                            columnsShow[j] = False     
            
                    # for key, value in columnsShow.items():
                    final_lst = [i for i in columnsShow.values()] 
                    print(final_lst, 'this is final list of Select State')
                    final_df = df[final_lst]
                    print(final_df)
                    self.tableView.setModel(PandasModel(final_df))
                    return final_df
            
                
                ################################################################################
                # Select District
            
                    # Select District Functionality
                def onSelectDistrict(self, index):
                    self.keywords = dict([(i, []) for i in range(final_df.shape[0])])
                    print(self.keywords)
                    self.menu = QtWidgets.QMenu(Dialog)
                    self.menu.setStyleSheet('QMenu { menu-scrollable: true; width: 400 }')
                    font = self.menu.font()
                    font.setPointSize(9)
                    font.setBold(True)
                    font.setWeight(75)
                    self.menu.setFont(font) 
                    
                    index = 6
                    self.col = index
            
                    data_unique = []
            
                    self.checkBoxs = []
                    
                    # Selectall added into Dropdown
                    checkBox = QtWidgets.QCheckBox("Select all", self.menu)
            
                    # All the checkboxes are enabled to check
                    checkableAction = QtWidgets.QWidgetAction(self.menu)
                    checkableAction.setDefaultWidget(checkBox)
                    self.menu.addAction(checkableAction)
                    checkBox.setChecked(True)
                    checkBox.stateChanged.connect(self.slotSelectDistrict)
            
                    # list storing state data
                    list_set = final_df['col_6'].to_list()
            
                    item = list_set
                    
                    # looping to fill checkboxes, initially all checkboxes will be checked
                    for i in range(len(item)):
                        if item[i] not in data_unique:
                            data_unique.append(item[i])
                            checkBox = QtWidgets.QCheckBox(item[i], self.menu)
                            checkBox.setChecked(True)
                            checkableAction = QtWidgets.QWidgetAction(self.menu)
                            checkableAction.setDefaultWidget(checkBox)
                            self.menu.addAction(checkableAction)
                            self.checkBoxs.append(checkBox)
            
                    # Ok, cancel button
                    btn = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
                                                 QtCore.Qt.Horizontal, self.menu)
            
                    # ok selected                             
                    btn.accepted.connect(self.menuCloseDistrict)
                    # rejected , nothing selected
                    btn.rejected.connect(self.menu.close)
            
                    checkableAction = QtWidgets.QWidgetAction(self.menu)
                    checkableAction.setDefaultWidget(btn)
                    self.menu.addAction(checkableAction)
                    self.pushButton_6.setMenu(self.menu)
            
                # method to check -> uncheck and vice versa
                def slotSelectDistrict(self, state):
                    for checkbox in self.checkBoxs:
                        checkbox.setChecked(QtCore.Qt.Checked == state)
            
                # after ok selected 
                def menuCloseDistrict(self):
                    self.keywords[self.col] = []
                    for element in self.checkBoxs:
                        if element.isChecked():
                            self.keywords[self.col].append(element.text())
                    print(self.keywords[self.col])
                    self.filterdataDistrict()
                    self.menu.close()
            
                # Filter data columnwise
                def filterdataDistrict(self):
                    global final_df_District
                    #keywords = dict([(i, []) for i in range(self.filterall.columnCount())])
                    columnsShow = dict([(i, True) for i in range(final_df['col_6'].shape[0])])
                    print(columnsShow)
            
                    j=0 
                    for j in range(final_df['col_6'].shape[0]):
                        item = final_df['col_6'].to_list()
                        
                        #if self.keywords[self.col]:
                        if item[j] not in self.keywords[self.col]:
                            columnsShow[j] = False     
            
                    # for key, value in columnsShow.items():
                    final_lst = [i for i in columnsShow.values()] 
                    print(final_lst, 'this is final list of Select District')
                    final_df_District = final_df[final_lst]
                    print(final_df_District)
                    self.tableView.setModel(PandasModel(final_df_District))
                    return final_df_District
            
            
                
            ################################# Main Function ##################################
            
            if __name__ == "__main__":
                import sys
                app = QtWidgets.QApplication(sys.argv)
                Dialog = QtWidgets.QDialog()
                ui = Ui_Dialog()
                ui.setupUi(Dialog)
                Dialog.show()
                sys.exit(app.exec_())
            

            Source https://stackoverflow.com/questions/67224959

            QUESTION

            Convert from PyQt5 to PyQt4
            Asked 2021-Apr-18 at 12:35

            Hey brothers and sisters, I just wondered if anyone could help me convert this program to PyQt4. I did my best however I couldn't ;,). It is a basic program for displaying Real Time text on the UI.

            Here is the program:

            ...

            ANSWER

            Answered 2021-Apr-18 at 12:35

            I am not an expert in PyQt however I use it to develop a telemetry for Cars, Robots, Small Aircraft. Thanks to eyllanesc its solved now and working well. The problem was that PyQt4 uses QtGui instead of QtWidgets in PyQt5

            Here is the sample code:

            Source https://stackoverflow.com/questions/67144422

            QUESTION

            cx_Freeze executable runs multiple tasks when using multiprocessing and freeze_support
            Asked 2021-Apr-07 at 18:31

            I build an executable with cx_Freeze. I always read that I need to include multiprocessing.freeze_support to avoid multiple tasks of the executable running in the task manager. But if I use multiprocessing and freeze_support I still get two tasks running in the task manager.

            Here is my example GUI named test_wibu.py:

            ...

            ANSWER

            Answered 2021-Apr-07 at 12:07

            According to this excellent answer, the reason for the multiprocessing.freeze_support() call is

            lack of fork() on Windows (which is not entirely true). Because of this, on Windows the fork is simulated by creating a new process in which code, which on Linux is being run in child process, is being run.

            and thus not to avoid multiple tasks of the executable running in the task manager as stated in your premise.

            Therefore, the behavior you observe in the task manager is probably normal and can't be avoided.

            Source https://stackoverflow.com/questions/66890197

            QUESTION

            display two color font on QToolButton
            Asked 2021-Mar-30 at 23:40

            I want a button that shows a text with two colors. I've tried the following:

            ...

            ANSWER

            Answered 2021-Mar-30 at 23:30

            The QPainter methods are not executed immediately since for efficiency reasons what these methods do is accumulate instructions. And that's what happens in your case since the QPainter is still active and has the property of the QPixmap, that's why you get that error, so in this case the solution is to invoke the end() method:

            Source https://stackoverflow.com/questions/66879531

            QUESTION

            PyQt4 - QLineEdit() and QCheckbox()
            Asked 2021-Feb-26 at 18:01

            I am building a GUI for obtaining user inputs and then using them in some complex step later. I have a group of checkboxes from which the user has to choose at least one and also provide an 'alias' name for it in the QLineEdit right below the checkbox (default name is taken otherwise).

            Currently, I have to first enter the alias name and then check the checkbox to register the entered name in the line edit to get the value entered by the user and connected checkbox name. This order is not normal. Is there a way to get the Editline data and the connected checkbox name when 'Continue' is clicked?

            Here is my code:

            ...

            ANSWER

            Answered 2021-Feb-26 at 18:01

            The simplest solution is to create a method that analyzes the information and that returns a dictionary of the selected elements:

            Source https://stackoverflow.com/questions/66390433

            QUESTION

            Not able to install PyQt4 on a macOS Catalina
            Asked 2021-Feb-24 at 07:30

            I am not able to install PyQt4 on a macOS Catalina. I have tried the following:

            ...

            ANSWER

            Answered 2021-Feb-23 at 22:52

            apt-get is a package manager for certain Linux distros.

            PyQT4 is no longer supported, try installing PyQT5 with this command: pip install PyQt5.

            Source https://stackoverflow.com/questions/66339717

            QUESTION

            Padding issue while drawing points over QGraphicsScene
            Asked 2021-Feb-11 at 14:37

            I have a PyQt application where I have drawn points using QPainter over a QGraphicsScene and made a drag n drop sort of a thing.

            Now, there is one issue which I'm facing and that is I'm unable to drag those points at the extreme corner and edges of QGraphicsScene. It always seems as if some amount of padding or space is left.

            How do I get round this problem?

            Code:

            ...

            ANSWER

            Answered 2021-Feb-10 at 18:21

            The simplest solution would be to add lay.setContentsMargins(0, 0, 0, 0) for the layout of the graphics view:

            Source https://stackoverflow.com/questions/66142210

            QUESTION

            Prevent QPainter point from going outside the window scope
            Asked 2021-Feb-10 at 17:28

            I have a PyQt application in which I have to implement a drap n drop functionality of points made via QPainter. My problem is that I'm even able to drag those points outside the window scope e.g. I can drag the point to the title bar or taskbar and leave it there and once left there, I can no longer drag them back to my Mainwindow.

            Please provide a solution so that I can never ever drag them there.

            Code:

            ...

            ANSWER

            Answered 2021-Feb-10 at 17:14

            This has nothing to do with the painting (which obviously cannot go "outside"), but to the way you're getting the coordinates.

            Just ensure that the point is within the margins of the widget:

            Source https://stackoverflow.com/questions/66141118

            QUESTION

            QtableView crashes as soon two validators with QStyledItemDelegate are set
            Asked 2021-Feb-07 at 18:21

            Based on the answer for this Question I went one step further and created two individual validators based on QStyledItemDelegate one for Integers one for Doubles.

            Each one of the validators ist working perfectly if it is the only one set. As soon I try to set both validators (each in its individual column) the whole application is crashing.

            ...

            ANSWER

            Answered 2021-Feb-07 at 18:21

            It seems that the problem is caused because the view does not take ownership of the delegates and then they are removed from memory as they are local variables causing a Segmentation fault. The solution is to extend its life cycle by making the class attributes:

            Source https://stackoverflow.com/questions/66091468

            QUESTION

            can not connect to Xserver while running python file using pyQT4 via ubuntu service
            Asked 2021-Jan-26 at 13:37

            I am trying to execute python file which uses PyQT4

            I am running below service file

            ...

            ANSWER

            Answered 2021-Jan-05 at 09:57

            Commonly a service dont have the same environment than a normal user who is able to login/start the X environment. Therefore i guess DISPLAY is not set. Try this in your service file but make sure it will start after X is already running...

            Source https://stackoverflow.com/questions/65574289

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install PyQt4

            You can download it from GitHub.
            You can use PyQt4 like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/zclongpop123/PyQt4.git

          • CLI

            gh repo clone zclongpop123/PyQt4

          • sshUrl

            git@github.com:zclongpop123/PyQt4.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link