Help with Qt Designer classes and Python



  • I cant seem to understand one thing that is causing me trouble with my music player project.
    For the sake of example lets say i have 4 classes.

    1. Main class (for managing lifecycle and other stuff)
      2.Qt Designer generated class with one method for view setup
      3 and 4 are different subWindows (settings for the music player)
      As far as i understand i have to put main to make the class standalone runnable, but in my case it doesnt make the class CALLABLE.
      I need to be able to call the main program window(2) from the main class(1) and from the main window(2) to be able to call the other 2 setting windows(3 and 4). I cant make it right. Can you please show me some dummy examples of how to manage that?
      Here are my classes so far:
      1:
    from gui import Ui_Main_Window
    import sys
    
    
    def check_db():
        dbManager.check_if_present()
    
    
    def populateList():
        songs_from_db = []
        songs_from_db = dbManager.get_all()
        return songs_from_db
    
    
    class Main(QtGui.QMainWindow, Ui_Main_Window):
        def __init__(self):
            QtGui.QMainWindow.__init__(self)
            self.ui = Ui_Main_Window()
            self.ui.setupUi(self)
    
    
    if __name__ == "__main__":
        app = QtGui.QApplication(sys.argv)
        window = Main()
        window.show()
        check_db()
        sys.exit(app.exec_())
    

    2:

    import sys
    from PyQt4 import QtCore, QtGui
    from library_settings import LibSettings
    
    try:
        _from_utf8 = QtCore.QString.fromUtf8
    except AttributeError:
        def _from_utf8(s):
            return s
    
    try:
        _encoding = QtGui.QApplication.UnicodeUTF8
    
    
        def _translate(context, text, disambig):
            return QtGui.QApplication.translate(context, text, disambig, _encoding)
    except AttributeError:
        def _translate(context, text, disambig):
            return QtGui.QApplication.translate(context, text, disambig)
    
    
    class Ui_Main_Window:
        def setupUi(self, MainWindow):
            MainWindow.setObjectName(_from_utf8("MainWindow"))
            MainWindow.resize(1229, 818)
            MainWindow.setToolButtonStyle(QtCore.Qt.ToolButtonFollowStyle)
            MainWindow.setTabShape(QtGui.QTabWidget.Rounded)
            self.centralwidget = QtGui.QWidget(MainWindow)
            self.centralwidget.setObjectName(_from_utf8("centralwidget"))
            self.gridLayout = QtGui.QGridLayout(self.centralwidget)
            self.gridLayout.setObjectName(_from_utf8("gridLayout"))
            self.verticalLayout = QtGui.QVBoxLayout()
            self.verticalLayout.setObjectName(_from_utf8("verticalLayout"))
            self.horizontalLayout_3 = QtGui.QHBoxLayout()
            self.horizontalLayout_3.setObjectName(_from_utf8("horizontalLayout_3"))
            self.verticalLayout_2 = QtGui.QVBoxLayout()
            self.verticalLayout_2.setObjectName(_from_utf8("verticalLayout_2"))
            self.label = QtGui.QLabel(self.centralwidget)
            self.label.setMinimumSize(QtCore.QSize(0, 50))
            self.label.setMaximumSize(QtCore.QSize(16777215, 80))
            self.label.setAlignment(QtCore.Qt.AlignCenter)
            self.label.setObjectName(_from_utf8("label"))
            self.verticalLayout_2.addWidget(self.label)
            self.horizontalSlider_3 = QtGui.QSlider(self.centralwidget)
            sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
            sizePolicy.setHorizontalStretch(0)
            sizePolicy.setVerticalStretch(0)
            sizePolicy.setHeightForWidth(self.horizontalSlider_3.sizePolicy().hasHeightForWidth())
            self.horizontalSlider_3.setSizePolicy(sizePolicy)
            self.horizontalSlider_3.setMinimumSize(QtCore.QSize(300, 60))
            self.horizontalSlider_3.setMaximumSize(QtCore.QSize(300, 16777215))
            self.horizontalSlider_3.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
            self.horizontalSlider_3.setAutoFillBackground(False)
            self.horizontalSlider_3.setOrientation(QtCore.Qt.Horizontal)
            self.horizontalSlider_3.setInvertedAppearance(False)
            self.horizontalSlider_3.setTickPosition(QtGui.QSlider.TicksAbove)
            self.horizontalSlider_3.setObjectName(_from_utf8("horizontalSlider_3"))
            self.verticalLayout_2.addWidget(self.horizontalSlider_3)
            self.horizontalLayout_4 = QtGui.QHBoxLayout()
            self.horizontalLayout_4.setSizeConstraint(QtGui.QLayout.SetMinimumSize)
            self.horizontalLayout_4.setContentsMargins(-1, 8, -1, -1)
            self.horizontalLayout_4.setSpacing(3)
            self.horizontalLayout_4.setObjectName(_from_utf8("horizontalLayout_4"))
            self.pushButton_2 = QtGui.QPushButton(self.centralwidget)
            sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed)
            sizePolicy.setHorizontalStretch(0)
            sizePolicy.setVerticalStretch(0)
            sizePolicy.setHeightForWidth(self.pushButton_2.sizePolicy().hasHeightForWidth())
            self.pushButton_2.setSizePolicy(sizePolicy)
            self.pushButton_2.setMaximumSize(QtCore.QSize(40, 25))
            self.pushButton_2.setFocusPolicy(QtCore.Qt.NoFocus)
            self.pushButton_2.setText(_from_utf8(""))
            icon = QtGui.QIcon()
            icon.addPixmap(
                QtGui.QPixmap(_from_utf8("artwork/prev.png")),
                QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.pushButton_2.setIcon(icon)
            self.pushButton_2.setIconSize(QtCore.QSize(40, 25))
            self.pushButton_2.setObjectName(_from_utf8("pushButton_2"))
            self.horizontalLayout_4.addWidget(self.pushButton_2)
            self.pushButton = QtGui.QPushButton(self.centralwidget)
            sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed)
            sizePolicy.setHorizontalStretch(0)
            sizePolicy.setVerticalStretch(0)
            sizePolicy.setHeightForWidth(self.pushButton.sizePolicy().hasHeightForWidth())
            self.pushButton.setSizePolicy(sizePolicy)
            self.pushButton.setMaximumSize(QtCore.QSize(40, 25))
            self.pushButton.setFocusPolicy(QtCore.Qt.NoFocus)
            self.pushButton.setText(_from_utf8(""))
            icon1 = QtGui.QIcon()
            icon1.addPixmap(
                QtGui.QPixmap(_from_utf8("artwork/play.png")),
                QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.pushButton.setIcon(icon1)
            self.pushButton.setIconSize(QtCore.QSize(40, 25))
            self.pushButton.setObjectName(_from_utf8("pushButton"))
            self.horizontalLayout_4.addWidget(self.pushButton)
            self.pushButton_3 = QtGui.QPushButton(self.centralwidget)
            sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed)
            sizePolicy.setHorizontalStretch(0)
            sizePolicy.setVerticalStretch(0)
            sizePolicy.setHeightForWidth(self.pushButton_3.sizePolicy().hasHeightForWidth())
            self.pushButton_3.setSizePolicy(sizePolicy)
            self.pushButton_3.setMaximumSize(QtCore.QSize(40, 25))
            self.pushButton_3.setFocusPolicy(QtCore.Qt.NoFocus)
            self.pushButton_3.setText(_from_utf8(""))
            icon2 = QtGui.QIcon()
            icon2.addPixmap(
                QtGui.QPixmap(_from_utf8("artwork/pause.png")),
                QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.pushButton_3.setIcon(icon2)
            self.pushButton_3.setIconSize(QtCore.QSize(40, 25))
            self.pushButton_3.setObjectName(_from_utf8("pushButton_3"))
            self.horizontalLayout_4.addWidget(self.pushButton_3)
            self.pushButton_4 = QtGui.QPushButton(self.centralwidget)
            sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed)
            sizePolicy.setHorizontalStretch(0)
            sizePolicy.setVerticalStretch(0)
            sizePolicy.setHeightForWidth(self.pushButton_4.sizePolicy().hasHeightForWidth())
            self.pushButton_4.setSizePolicy(sizePolicy)
            self.pushButton_4.setMaximumSize(QtCore.QSize(40, 25))
            self.pushButton_4.setFocusPolicy(QtCore.Qt.NoFocus)
            self.pushButton_4.setText(_from_utf8(""))
            icon3 = QtGui.QIcon()
            icon3.addPixmap(
                QtGui.QPixmap(_from_utf8("artwork/stop.png")),
                QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.pushButton_4.setIcon(icon3)
            self.pushButton_4.setIconSize(QtCore.QSize(40, 25))
            self.pushButton_4.setObjectName(_from_utf8("pushButton_4"))
            self.horizontalLayout_4.addWidget(self.pushButton_4)
            self.pushButton_5 = QtGui.QPushButton(self.centralwidget)
            sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed)
            sizePolicy.setHorizontalStretch(0)
            sizePolicy.setVerticalStretch(0)
            sizePolicy.setHeightForWidth(self.pushButton_5.sizePolicy().hasHeightForWidth())
            self.pushButton_5.setSizePolicy(sizePolicy)
            self.pushButton_5.setMaximumSize(QtCore.QSize(40, 25))
            self.pushButton_5.setFocusPolicy(QtCore.Qt.NoFocus)
            self.pushButton_5.setText(_from_utf8(""))
            icon4 = QtGui.QIcon()
            icon4.addPixmap(
                QtGui.QPixmap(_from_utf8("artwork/next.png")),
                QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.pushButton_5.setIcon(icon4)
            self.pushButton_5.setIconSize(QtCore.QSize(40, 25))
            self.pushButton_5.setObjectName(_from_utf8("pushButton_5"))
            self.horizontalLayout_4.addWidget(self.pushButton_5)
            self.verticalLayout_2.addLayout(self.horizontalLayout_4)
            self.horizontalLayout_3.addLayout(self.verticalLayout_2)
            self.verticalLayout_3 = QtGui.QVBoxLayout()
            self.verticalLayout_3.setObjectName(_from_utf8("verticalLayout_3"))
            self.horizontalLayout_5 = QtGui.QHBoxLayout()
            self.horizontalLayout_5.setObjectName(_from_utf8("horizontalLayout_5"))
            self.label_2 = QtGui.QLabel(self.centralwidget)
            self.label_2.setMinimumSize(QtCore.QSize(0, 180))
            self.label_2.setMaximumSize(QtCore.QSize(16777215, 200))
            font = QtGui.QFont()
            font.setPointSize(50)
            font.setBold(True)
            font.setItalic(True)
            font.setWeight(75)
            self.label_2.setFont(font)
            self.label_2.setScaledContents(False)
            self.label_2.setAlignment(QtCore.Qt.AlignCenter)
            self.label_2.setWordWrap(True)
            self.label_2.setIndent(1)
            self.label_2.setObjectName(_from_utf8("label_2"))
            self.horizontalLayout_5.addWidget(self.label_2)
            self.label_3 = QtGui.QLabel(self.centralwidget)
            self.label_3.setMinimumSize(QtCore.QSize(180, 180))
            self.label_3.setMaximumSize(QtCore.QSize(180, 180))
            self.label_3.setAutoFillBackground(True)
            self.label_3.setFrameShape(QtGui.QFrame.StyledPanel)
            self.label_3.setText(_from_utf8(""))
            self.label_3.setScaledContents(True)
            self.label_3.setAlignment(QtCore.Qt.AlignCenter)
            self.label_3.setObjectName(_from_utf8("label_3"))
            self.horizontalLayout_5.addWidget(self.label_3)
            self.verticalLayout_3.addLayout(self.horizontalLayout_5)
            self.horizontalSlider = QtGui.QSlider(self.centralwidget)
            self.horizontalSlider.setOrientation(QtCore.Qt.Horizontal)
            self.horizontalSlider.setObjectName(_from_utf8("horizontalSlider"))
            self.verticalLayout_3.addWidget(self.horizontalSlider)
            self.horizontalLayout_3.addLayout(self.verticalLayout_3)
            self.verticalLayout.addLayout(self.horizontalLayout_3)
            self.horizontalLayout_2 = QtGui.QHBoxLayout()
            self.horizontalLayout_2.setObjectName(_from_utf8("horizontalLayout_2"))
            self.listView = QtGui.QListView(self.centralwidget)
            self.listView.setMaximumSize(QtCore.QSize(300, 16777215))
            self.listView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
            self.listView.setVerticalScrollMode(QtGui.QAbstractItemView.ScrollPerPixel)
            self.listView.setHorizontalScrollMode(QtGui.QAbstractItemView.ScrollPerPixel)
            self.listView.setObjectName(_from_utf8("listView"))
            self.horizontalLayout_2.addWidget(self.listView)
            self.tabWidget = QtGui.QTabWidget(self.centralwidget)
            self.tabWidget.setObjectName(_from_utf8("tabWidget"))
            self.tab = QtGui.QWidget()
            self.tab.setObjectName(_from_utf8("tab"))
            self.gridLayout_2 = QtGui.QGridLayout(self.tab)
            self.gridLayout_2.setObjectName(_from_utf8("gridLayout_2"))
            self.listWidget = QtGui.QListWidget(self.tab)
            self.listWidget.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
            self.listWidget.setFrameShape(QtGui.QFrame.NoFrame)
            self.listWidget.setFrameShadow(QtGui.QFrame.Plain)
            self.listWidget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
            self.listWidget.setDragEnabled(True)
            self.listWidget.setDragDropOverwriteMode(True)
            self.listWidget.setDragDropMode(QtGui.QAbstractItemView.InternalMove)
            self.listWidget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
            self.listWidget.setIconSize(QtCore.QSize(100, 100))
            self.listWidget.setTextElideMode(QtCore.Qt.ElideMiddle)
            self.listWidget.setVerticalScrollMode(QtGui.QAbstractItemView.ScrollPerPixel)
            self.listWidget.setHorizontalScrollMode(QtGui.QAbstractItemView.ScrollPerPixel)
            self.listWidget.setMovement(QtGui.QListView.Static)
            self.listWidget.setResizeMode(QtGui.QListView.Adjust)
            self.listWidget.setLayoutMode(QtGui.QListView.Batched)
            self.listWidget.setViewMode(QtGui.QListView.IconMode)
            self.listWidget.setUniformItemSizes(True)
            self.listWidget.setObjectName(_from_utf8("listWidget"))
            self.gridLayout_2.addWidget(self.listWidget, 0, 0, 1, 1)
            self.tabWidget.addTab(self.tab, _from_utf8(""))
            self.tab_2 = QtGui.QWidget()
            self.tab_2.setObjectName(_from_utf8("tab_2"))
            self.gridLayout_3 = QtGui.QGridLayout(self.tab_2)
            self.gridLayout_3.setObjectName(_from_utf8("gridLayout_3"))
            self.listWidget_2 = QtGui.QListWidget(self.tab_2)
            self.listWidget_2.setFrameShape(QtGui.QFrame.NoFrame)
            self.listWidget_2.setFrameShadow(QtGui.QFrame.Plain)
            self.listWidget_2.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
            self.listWidget_2.setDragEnabled(True)
            self.listWidget_2.setDragDropMode(QtGui.QAbstractItemView.NoDragDrop)
            self.listWidget_2.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
            self.listWidget_2.setIconSize(QtCore.QSize(100, 100))
            self.listWidget_2.setVerticalScrollMode(QtGui.QAbstractItemView.ScrollPerPixel)
            self.listWidget_2.setHorizontalScrollMode(QtGui.QAbstractItemView.ScrollPerPixel)
            self.listWidget_2.setMovement(QtGui.QListView.Static)
            self.listWidget_2.setResizeMode(QtGui.QListView.Adjust)
            self.listWidget_2.setViewMode(QtGui.QListView.IconMode)
            self.listWidget_2.setObjectName(_from_utf8("listWidget_2"))
            self.gridLayout_3.addWidget(self.listWidget_2, 0, 0, 1, 1)
            self.tabWidget.addTab(self.tab_2, _from_utf8(""))
            self.horizontalLayout_2.addWidget(self.tabWidget)
            self.verticalLayout.addLayout(self.horizontalLayout_2)
            self.horizontalLayout = QtGui.QHBoxLayout()
            self.horizontalLayout.setObjectName(_from_utf8("horizontalLayout"))
            spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
            self.horizontalLayout.addItem(spacerItem)
            self.horizontalSlider_2 = QtGui.QSlider(self.centralwidget)
            self.horizontalSlider_2.setOrientation(QtCore.Qt.Horizontal)
            self.horizontalSlider_2.setObjectName(_from_utf8("horizontalSlider_2"))
            self.horizontalLayout.addWidget(self.horizontalSlider_2)
            self.verticalLayout.addLayout(self.horizontalLayout)
            self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)
            MainWindow.setCentralWidget(self.centralwidget)
            self.menubar = QtGui.QMenuBar(MainWindow)
            self.menubar.setGeometry(QtCore.QRect(0, 0, 1229, 19))
            self.menubar.setObjectName(_from_utf8("menubar"))
            self.menuFile = QtGui.QMenu(self.menubar)
            self.menuFile.setObjectName(_from_utf8("menuFile"))
            self.menuSettings = QtGui.QMenu(self.menubar)
            self.menuSettings.setObjectName(_from_utf8("menuSettings"))
            self.menuPlayback_Device = QtGui.QMenu(self.menuSettings)
            self.menuPlayback_Device.setObjectName(_from_utf8("menuPlayback_Device"))
            self.menuMusic = QtGui.QMenu(self.menubar)
            self.menuMusic.setObjectName(_from_utf8("menuMusic"))
            MainWindow.setMenuBar(self.menubar)
            self.statusbar = QtGui.QStatusBar(MainWindow)
            self.statusbar.setObjectName(_from_utf8("statusbar"))
            MainWindow.setStatusBar(self.statusbar)
            self.actionOpen = QtGui.QAction(MainWindow)
            self.actionOpen.setObjectName(_from_utf8("actionOpen"))
            self.actionOpen_Dir = QtGui.QAction(MainWindow)
            self.actionOpen_Dir.setObjectName(_from_utf8("actionOpen_Dir"))
            self.actionMute = QtGui.QAction(MainWindow)
            self.actionMute.setObjectName(_from_utf8("actionMute"))
            self.actionMinimize = QtGui.QAction(MainWindow)
            self.actionMinimize.setObjectName(_from_utf8("actionMinimize"))
            self.actionQuit = QtGui.QAction(MainWindow)
            self.actionQuit.setObjectName(_from_utf8("actionQuit"))
            self.actionAll_Settings = QtGui.QAction(MainWindow)
            self.actionAll_Settings.setObjectName(_from_utf8("actionAll_Settings"))
            self.actionEqualizer = QtGui.QAction(MainWindow)
            self.actionEqualizer.setObjectName(_from_utf8("actionEqualizer"))
            self.actionALSA = QtGui.QAction(MainWindow)
            self.actionALSA.setObjectName(_from_utf8("actionALSA"))
            self.actionPulseAudio = QtGui.QAction(MainWindow)
            self.actionPulseAudio.setObjectName(_from_utf8("actionPulseAudio"))
            self.actionSelect_Folders = QtGui.QAction(MainWindow)
            # self.actionSelect_Folders.triggered.connect(create_new_window)
            self.actionSelect_Folders.setObjectName(_from_utf8("actionSelect_Folders"))
            self.actionSync_settings = QtGui.QAction(MainWindow)
            self.actionSync_settings.setObjectName(_from_utf8("actionSync_settings"))
            self.actionRebuild_Library = QtGui.QAction(MainWindow)
            self.actionRebuild_Library.setObjectName(_from_utf8("actionRebuild_Library"))
            self.actionClear_Library = QtGui.QAction(MainWindow)
            self.actionClear_Library.setObjectName(_from_utf8("actionClear_Library"))
            self.menuFile.addAction(self.actionOpen)
            self.menuFile.addAction(self.actionOpen_Dir)
            self.menuFile.addSeparator()
            self.menuFile.addAction(self.actionMute)
            self.menuFile.addAction(self.actionMinimize)
            self.menuFile.addSeparator()
            self.menuFile.addAction(self.actionQuit)
            self.menuPlayback_Device.addAction(self.actionALSA)
            self.menuPlayback_Device.addAction(self.actionPulseAudio)
            self.menuSettings.addAction(self.actionAll_Settings)
            self.menuSettings.addAction(self.menuPlayback_Device.menuAction())
            self.menuSettings.addAction(self.actionEqualizer)
            self.menuMusic.addAction(self.actionSelect_Folders)
            self.menuMusic.addAction(self.actionSync_settings)
            self.menuMusic.addAction(self.actionRebuild_Library)
            self.menuMusic.addAction(self.actionClear_Library)
            self.menubar.addAction(self.menuFile.menuAction())
            self.menubar.addAction(self.menuSettings.menuAction())
            self.menubar.addAction(self.menuMusic.menuAction())
    
            self.retranslateUi(MainWindow)
            self.tabWidget.setCurrentIndex(0)
            QtCore.QObject.connect(self.horizontalSlider_2, QtCore.SIGNAL(_from_utf8("valueChanged(int)")),
                                   self.listWidget.doItemsLayout)
            QtCore.QObject.connect(self.horizontalSlider_3, QtCore.SIGNAL(_from_utf8("valueChanged(int)")),
                                   self.label.setNum)
            QtCore.QMetaObject.connectSlotsByName(MainWindow)
    
        def retranslateUi(self, MainWindow):
            MainWindow.setWindowTitle(_translate("MainWindow", "Siren 0.1(Alpha)", None))
            self.label.setText(_translate("MainWindow", "Volume indicator", None))
            self.label_2.setText(_translate("MainWindow", "PlayBackInfo", None))
            __sortingEnabled = self.listWidget.isSortingEnabled()
            self.listWidget.setSortingEnabled(False)
            self.listWidget.setSortingEnabled(__sortingEnabled)
            self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("MainWindow", "Tab 1", None))
            self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("MainWindow", "Tab 2", None))
            self.menuFile.setTitle(_translate("MainWindow", "File", None))
            self.menuSettings.setTitle(_translate("MainWindow", "Settings", None))
            self.menuPlayback_Device.setTitle(_translate("MainWindow", "Playback Device", None))
            self.menuMusic.setTitle(_translate("MainWindow", "Music", None))
            self.actionOpen.setText(_translate("MainWindow", "Open", None))
            self.actionOpen_Dir.setText(_translate("MainWindow", "Open Dir...", None))
            self.actionMute.setText(_translate("MainWindow", "Mute", None))
            self.actionMinimize.setText(_translate("MainWindow", "Minimize", None))
            self.actionQuit.setText(_translate("MainWindow", "Quit", None))
            self.actionAll_Settings.setText(_translate("MainWindow", "All Settings", None))
            self.actionEqualizer.setText(_translate("MainWindow", "Equalizer", None))
            self.actionALSA.setText(_translate("MainWindow", "ALSA", None))
            self.actionPulseAudio.setText(_translate("MainWindow", "PulseAudio", None))
            self.actionSelect_Folders.setText(_translate("MainWindow", "Select Folders", None))
            self.actionSync_settings.setText(_translate("MainWindow", "Sync settings", None))
            self.actionRebuild_Library.setText(_translate("MainWindow", "Rebuild Library", None))
            self.actionClear_Library.setText(_translate("MainWindow", "Clear Library", None))
    

    3:

    from PyQt4 import QtCore, QtGui
    import sys
    
    try:
        _fromUtf8 = QtCore.QString.fromUtf8
    except AttributeError:
        def _fromUtf8(s):
            return s
    
    try:
        _encoding = QtGui.QApplication.UnicodeUTF8
    
    
        def _translate(context, text, disambig):
            return QtGui.QApplication.translate(context, text, disambig, _encoding)
    except AttributeError:
        def _translate(context, text, disambig):
            return QtGui.QApplication.translate(context, text, disambig)
    
    
    class LibSettings(QtGui.QMainWindow):
        def setupUi(self, MainWindow):
            MainWindow.setObjectName(_fromUtf8("MainWindow"))
            MainWindow.resize(537, 325)
            self.centralwidget = QtGui.QWidget(MainWindow)
            self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
            self.gridLayout_2 = QtGui.QGridLayout(self.centralwidget)
            self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
            self.listView = QtGui.QListView(self.centralwidget)
            self.listView.setFrameShape(QtGui.QFrame.NoFrame)
            self.listView.setFrameShadow(QtGui.QFrame.Plain)
            self.listView.setObjectName(_fromUtf8("listView"))
            self.gridLayout_2.addWidget(self.listView, 2, 0, 1, 1)
            self.lineEdit = QtGui.QLineEdit(self.centralwidget)
            self.lineEdit.setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor))
            self.lineEdit.setAutoFillBackground(True)
            self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
            self.gridLayout_2.addWidget(self.lineEdit, 0, 0, 1, 1)
            self.verticalLayout = QtGui.QVBoxLayout()
            self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
            self.pushButton_4 = QtGui.QPushButton(self.centralwidget)
            self.pushButton_4.setFocusPolicy(QtCore.Qt.NoFocus)
            icon = QtGui.QIcon()
            icon.addPixmap(QtGui.QPixmap(_fromUtf8("PycharmProjects/SirenPlayer v0.1/artwork/plus.png")),
                           QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.pushButton_4.setIcon(icon)
            self.pushButton_4.setObjectName(_fromUtf8("pushButton_4"))
            self.verticalLayout.addWidget(self.pushButton_4)
            self.pushButton_3 = QtGui.QPushButton(self.centralwidget)
            self.pushButton_3.setFocusPolicy(QtCore.Qt.NoFocus)
            icon1 = QtGui.QIcon()
            icon1.addPixmap(QtGui.QPixmap(_fromUtf8("PycharmProjects/SirenPlayer v0.1/artwork/minus.png")),
                            QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.pushButton_3.setIcon(icon1)
            self.pushButton_3.setObjectName(_fromUtf8("pushButton_3"))
            self.verticalLayout.addWidget(self.pushButton_3)
            self.verticalLayout_2 = QtGui.QVBoxLayout()
            self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
            spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
            self.verticalLayout_2.addItem(spacerItem)
            self.pushButton_5 = QtGui.QPushButton(self.centralwidget)
            self.pushButton_5.setFocusPolicy(QtCore.Qt.NoFocus)
            icon2 = QtGui.QIcon()
            icon2.addPixmap(QtGui.QPixmap(_fromUtf8("PycharmProjects/SirenPlayer v0.1/artwork/cancel.png")),
                            QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.pushButton_5.setIcon(icon2)
            self.pushButton_5.setObjectName(_fromUtf8("pushButton_5"))
            self.verticalLayout_2.addWidget(self.pushButton_5)
            spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
            self.verticalLayout_2.addItem(spacerItem1)
            self.pushButton_6 = QtGui.QPushButton(self.centralwidget)
            self.pushButton_6.setFocusPolicy(QtCore.Qt.NoFocus)
            icon3 = QtGui.QIcon()
            icon3.addPixmap(QtGui.QPixmap(_fromUtf8("PycharmProjects/SirenPlayer v0.1/artwork/ok.png")), QtGui.QIcon.Normal,
                            QtGui.QIcon.Off)
            self.pushButton_6.setIcon(icon3)
            self.pushButton_6.setObjectName(_fromUtf8("pushButton_6"))
            self.verticalLayout_2.addWidget(self.pushButton_6)
            self.verticalLayout.addLayout(self.verticalLayout_2)
            self.gridLayout_2.addLayout(self.verticalLayout, 0, 1, 3, 1)
            self.horizontalLayout = QtGui.QHBoxLayout()
            self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
            self.pushButton_2 = QtGui.QPushButton(self.centralwidget)
            sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
            sizePolicy.setHorizontalStretch(0)
            sizePolicy.setVerticalStretch(0)
            sizePolicy.setHeightForWidth(self.pushButton_2.sizePolicy().hasHeightForWidth())
            self.pushButton_2.setSizePolicy(sizePolicy)
            self.pushButton_2.setMinimumSize(QtCore.QSize(35, 35))
            self.pushButton_2.setMaximumSize(QtCore.QSize(35, 35))
            self.pushButton_2.setFocusPolicy(QtCore.Qt.NoFocus)
            self.pushButton_2.setText(_fromUtf8(""))
            self.pushButton_2.setIcon(icon)
            self.pushButton_2.setIconSize(QtCore.QSize(35, 35))
            self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
            self.horizontalLayout.addWidget(self.pushButton_2)
            self.pushButton = QtGui.QPushButton(self.centralwidget)
            sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
            sizePolicy.setHorizontalStretch(0)
            sizePolicy.setVerticalStretch(0)
            sizePolicy.setHeightForWidth(self.pushButton.sizePolicy().hasHeightForWidth())
            self.pushButton.setSizePolicy(sizePolicy)
            self.pushButton.setMinimumSize(QtCore.QSize(35, 35))
            self.pushButton.setMaximumSize(QtCore.QSize(35, 35))
            self.pushButton.setFocusPolicy(QtCore.Qt.NoFocus)
            self.pushButton.setText(_fromUtf8(""))
            self.pushButton.setIcon(icon1)
            self.pushButton.setIconSize(QtCore.QSize(35, 35))
            self.pushButton.setObjectName(_fromUtf8("pushButton"))
            self.horizontalLayout.addWidget(self.pushButton)
            spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
            self.horizontalLayout.addItem(spacerItem2)
            self.gridLayout_2.addLayout(self.horizontalLayout, 1, 0, 1, 1)
            MainWindow.setCentralWidget(self.centralwidget)
            self.menubar = QtGui.QMenuBar(MainWindow)
            self.menubar.setGeometry(QtCore.QRect(0, 0, 537, 19))
            self.menubar.setObjectName(_fromUtf8("menubar"))
            MainWindow.setMenuBar(self.menubar)
            self.statusbar = QtGui.QStatusBar(MainWindow)
            self.statusbar.setObjectName(_fromUtf8("statusbar"))
            MainWindow.setStatusBar(self.statusbar)
    
            self.retranslateUi(MainWindow)
            QtCore.QMetaObject.connectSlotsByName(MainWindow)
    
        def retranslateUi(self, MainWindow):
            MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
            self.pushButton_4.setText(_translate("MainWindow", "Browse", None))
            self.pushButton_3.setText(_translate("MainWindow", "Clear selected", None))
            self.pushButton_5.setText(_translate("MainWindow", "Cancel", None))
            self.pushButton_6.setText(_translate("MainWindow", "Apply", None))
    
        def __init__(self, QWidget_parent=None, Qt_WindowFlags_flags=0):
            QtGui.QMainWindow.__init__(self)
            self.ui = LibSettings()
            self.ui.setupUi(self)
    
    if __name__ == '__main__':  # if we're running file directly and not importing it
        app = QtGui.QApplication(sys.argv)  # A new instance of QApplication
        form = LibSettings()  # We set the form to be our ExampleApp (design)
        form.show()  # Show the form
        sys.exit(app.exec_())
    

    4 is not made yet but i need to call it from a function in 2 also (main app window)
    Please any (simply explained ) ideas will be great. I am ok with java but i cant seem to understand this python specifics.
    Is it possible to call 2 from 1 with one line(or two?) and 3 from 2 the same way without preparing 100 lines of code in the previous class?
    I am really stuck at this. Dont want to do it in crap Java Graphical editors like swing or similar. Any help will do...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.