I am having a hard time figuring out how I can include several QWidgets (created in individual scripts) into the QT Designer ui file generated from a QGIS plugin builder. These are custom widgets I would like to include in the ui file because , however, I realize I have to use the ui file from Qt designer to make it connect with the map canvas in qgis. When I generate the widgets over the ui file, one gui overlaps the other.
How do I get the QWidgets into my script instead of on top of my script to where they will be included in the ui file?
I have looked at many tutorials and I can't seem to find any with this problem.
The dialog.py file is included below where it shows how all the widgets are incorporated with the ui file:
from PyQt4 import QtGui, uic from PyQt4.QtGui import * from PyQt4.QtCore import * import numpy import re import sys from ui_eggcode import Ui_BoxCodeDialogBase #Individual QWidgets to import import ConcSpin, ConcSpin_Ct, ProxyWidget, PoshLabel, StageSpin, FormSpin import IceBox, BoxCodeWidget, PresetsWidget, BoxDiagram FORM_CLASS, _ = uic.loadUiType(os.path.join(os.path.dirname(__file__), 'egg_code_dialog_base.ui')) class BoxCodeDialogDialog(QtGui.QDialog, FORM_CLASS): def __init__(self, parent = none): """Constructor.""" #super(BoxCodeDialogDialog, self).__init__(parent) # The following line is just the default for a dialog box, # comes in from QGIS plugin designer. Do not use. # QtGui.QDialog.__init__(self) self.eggvals = IceBox.IceBox() eggdiagram = BoxDiagram.BoxDiagram(self.eggvals) tabWidget = QTabWidget() tabWidget.setMinimumSize(QSize(370.0, 332.0)) presetWidget = PresetsWidget.PresetsWidget(self.eggvals,eggdiagram,parent=tabWidget) tabWidget.addTab(presetWidget, "&Presets") eggWidget = BoxCodeWidget.BoxCodeWidget(self.eggvals,eggdiagram,parent=tabWidget) tabWidget.addTab(eggWidget, "&Box Code") buttonBox = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel) self.connect(buttonBox, SIGNAL("accepted()"), self, SLOT("accept()")) self.connect(buttonBox, SIGNAL("rejected()"), self, SLOT("reject()")) self.setWindowTitle("Set Number Format (Modal)") #The following activates the ui file in QT Designer # Sets dialog layout correctly layout =QVBoxLayout() layout.setSizeConstraint(QLayout.SetFixedSize) layout.addWidget(eggdiagram) layout.addWidget(tabWidget) layout.addWidget(buttonBox) #The following activates the ui file in QT Designer self.setLayout(layout) self.setWindowTitle("Box Code") # Set up the user interface from Designer. # After setupUI you can access any designer object by doing # self., and you can use autoconnect slots - see # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html # #widgets-and-dialogs-with-auto-connect # Don't use the following, use Ui_BoxCodeDialogBase()from the original self.setupUi(self) self.ui = Ui_BoxCodeDialogBase() # Sets dialog layout correctly #attribute for storing position of the dialog self.userPos = None
أكثر...
How do I get the QWidgets into my script instead of on top of my script to where they will be included in the ui file?
I have looked at many tutorials and I can't seem to find any with this problem.
The dialog.py file is included below where it shows how all the widgets are incorporated with the ui file:
from PyQt4 import QtGui, uic from PyQt4.QtGui import * from PyQt4.QtCore import * import numpy import re import sys from ui_eggcode import Ui_BoxCodeDialogBase #Individual QWidgets to import import ConcSpin, ConcSpin_Ct, ProxyWidget, PoshLabel, StageSpin, FormSpin import IceBox, BoxCodeWidget, PresetsWidget, BoxDiagram FORM_CLASS, _ = uic.loadUiType(os.path.join(os.path.dirname(__file__), 'egg_code_dialog_base.ui')) class BoxCodeDialogDialog(QtGui.QDialog, FORM_CLASS): def __init__(self, parent = none): """Constructor.""" #super(BoxCodeDialogDialog, self).__init__(parent) # The following line is just the default for a dialog box, # comes in from QGIS plugin designer. Do not use. # QtGui.QDialog.__init__(self) self.eggvals = IceBox.IceBox() eggdiagram = BoxDiagram.BoxDiagram(self.eggvals) tabWidget = QTabWidget() tabWidget.setMinimumSize(QSize(370.0, 332.0)) presetWidget = PresetsWidget.PresetsWidget(self.eggvals,eggdiagram,parent=tabWidget) tabWidget.addTab(presetWidget, "&Presets") eggWidget = BoxCodeWidget.BoxCodeWidget(self.eggvals,eggdiagram,parent=tabWidget) tabWidget.addTab(eggWidget, "&Box Code") buttonBox = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel) self.connect(buttonBox, SIGNAL("accepted()"), self, SLOT("accept()")) self.connect(buttonBox, SIGNAL("rejected()"), self, SLOT("reject()")) self.setWindowTitle("Set Number Format (Modal)") #The following activates the ui file in QT Designer # Sets dialog layout correctly layout =QVBoxLayout() layout.setSizeConstraint(QLayout.SetFixedSize) layout.addWidget(eggdiagram) layout.addWidget(tabWidget) layout.addWidget(buttonBox) #The following activates the ui file in QT Designer self.setLayout(layout) self.setWindowTitle("Box Code") # Set up the user interface from Designer. # After setupUI you can access any designer object by doing # self., and you can use autoconnect slots - see # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html # #widgets-and-dialogs-with-auto-connect # Don't use the following, use Ui_BoxCodeDialogBase()from the original self.setupUi(self) self.ui = Ui_BoxCodeDialogBase() # Sets dialog layout correctly #attribute for storing position of the dialog self.userPos = None
أكثر...