Getting a custom frame as a qt-designer plugin - python

I'm trying to get this custom frame be usable as a widget in qt-designer. I'm following this example in pyqt5 documentation. I've implemented subclasses of QPyDesignerContainerExtension, CollapsibleBoxExtensionFactory and QPyDesignerCustomWidgetPlugin. The only difference is that the example involves pages, and mine is just a custom frame. It is the only example demonstrating a container plugin, and therefore, using the class QPyDesignerContainerExtension.
All function of the widget work when used in python, it appears in qt-designer, but I'm unable to drop a widget in it. Except if I force getCurrentIndex to be 0 instead of -1 when the frame is empty. But this obviously create a segmentation fault error in qt designer as it tries to access a non existing widget.
After a bit of reverse ingeneering on how qt designer interact with multipagewidgetplugin, I have the impression that the QPyDesignerContainerExtension is more for multipage containers that for basic frames.
Is QPyDesignerContainerExtension supposed to work with basic containers, as a frame ? Or should I be looking for a bug in my code...
Thanks for any help
edit:
To refocus the question on the primary problem, here is a simple version of the widget I want to use in qt-designer
The widget:
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot
from PyQt5.QtWidgets import QWidget, QScrollArea, QSizePolicy, QVBoxLayout, QLabel
class CustomFrame(QWidget):
def __init__(self, parent=None, title='title'):
super().__init__(parent)
layout = QVBoxLayout(self)
self.setLayout(layout)
self.title = QLabel(text=title)
layout.addWidget(self.title)
self.content_area = QScrollArea()
# self.content_area.setMinimumHeight(0)
# self.content_area.setMaximumHeight(0)
self.content_area.setSizePolicy(
QSizePolicy.Expanding, QSizePolicy.Fixed
)
layout.addWidget(self.content_area)
self.content_layout = QVBoxLayout(self.content_area)
self.content_area.setLayout(self.content_layout)
def _update_animation(self):
# need to be called each time a widget is added
pass
def getTitle(self):
return self.toggle_button.text()
#pyqtSlot(str)
def setTitle(self, value):
self.toggle_button.setText(value)
def resetTitle(self):
self.toggle_button.setText("Title")
titleString = pyqtProperty(str, getTitle, setTitle, resetTitle)
A plugin:
from PyQt5.QtDesigner import QPyDesignerCustomWidgetPlugin
class MultiPageWidgetPlugin(QPyDesignerCustomWidgetPlugin):
def __init__(self, parent=None):
super(MultiPageWidgetPlugin, self).__init__(parent)
self.initialized = False
def initialize(self, formEditor):
if self.initialized:
return
self.initialized = True
def isInitialized(self):
return self.initialized
def createWidget(self, parent):
widget = CustomFrame(parent)
return widget
def name(self):
return "CustomFrame"
def group(self):
return "PyQt Examples"
def icon(self):
return QIcon()
def toolTip(self):
return ""
def whatsThis(self):
return ""
def isContainer(self):
return True
def domXml(self):
return ('<widget class="CustomFrame" name="customframe">'
' <widget class="QWidget" name="page" />'
'</widget>')
def includeFile(self):
return "customframe"
The goal is, in qt-designer, that a widget dropped to the CustomFrame is added to content_area. By setting isContainer() to true, the widget accept dropped widgets, but they are added the widget itself, not to content_area. So unless there is a way to change this behaviour, It seems to be requiered to use a QPyDesignerContainerExtension with a single page...

Related

QtCore.signal not doing anything

I am a beginner with PyQt5 and I am having trouble to use QtCore.signal
I'd like to send a signal when I press my buttons and switch the current widget displayed.
I don't have any errors when I run my code but when I press the buttons nothing happen and I guess it is because I am doing something wrong with the QtCore.Signal
Here is my code :
from PySide2 import QtCore, QtWidgets
from ui_Page_accueil import Ui_MainWindow
from ui_NouvelleVerif import Ui_Dialog as Ui_NouvelleVerif
from ui_NouvelleVerifEssieux import Ui_Dialog as Ui_NouvelleVerifEssieux
import sys
class MainWindowUi(Ui_MainWindow):
to_NouvelleVerif = QtCore.Signal()
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
self.setupUi(self)
#self.pushButton.clicked.connect(self.pushbutton_handler1)
self.pushButton_2.clicked.connect(self.pushbutton_handler2)
#def pushbutton_handler1(self):
# self.to_MainWindow.emit()
def pushbutton_handler2(self):
self.to_NouvelleVerif.emit()
class NouvelleVerifUi(QtWidgets.QWidget, Ui_NouvelleVerif):
to_MainWindow = QtCore.Signal()
to_NouvelleVerifEssieux = QtCore.Signal()
def __init__(self):
QtWidgets.QWidget.__init__(self)
self.setupUi(self)
self.pushButton.clicked.connect(self.pushbutton_handler1)
#self.pushButton_2.clicked.connect(self.pushbutton_handler2)
self.pushButton_3.clicked.connect(self.pushbutton_handler3)
def pushbutton_handler1(self):
self.to_MainWindow.emit()
#def pushbutton_handler2(self):
# self.switch_window.emit()
def pushbutton_handler3(self):
self.to_NouvelleVerifEssieux.emit()
class NouvelleVerifEssieuxUi(QtWidgets.QWidget, Ui_NouvelleVerifEssieux):
to_NouvelleVerif = QtCore.Signal()
def __init__(self):
QtWidgets.QWidget.__init__(self)
self.setupUi(self)
self.pushButton.clicked.connect(self.pushbutton_handler1)
def pushbutton_handler1(self):
self.to_NouvelleVerif.emit()
class Controller :
app = QtWidgets.QApplication(sys.argv)
widget = QtWidgets.QStackedWidget()
MainWindow = MainWindowUi()
NouvelleVerif = NouvelleVerifUi()
NouvelleVerifEssieux = NouvelleVerifEssieuxUi()
def __init__(self):
self.widget.addWidget(self.MainWindow) # create an instance of the first page class and add it to stackedwidget
self.widget.addWidget(self.NouvelleVerif) # adding second page
self.widget.addWidget(self.NouvelleVerifEssieux)
self.widget.setCurrentWidget(self.MainWindow) # setting the page that you want to load when application starts up. you can also use setCurrentIndex(int)
def show_MainWindow(self):
self.NouvelleVerif = NouvelleVerifUi()
self.NouvelleVerif.to_MainWindow.connect(self.show_MainWindow)
self.widget.setCurrentWidget(self.MainWindow)
def show_NouvelleVerif(self):
self.MainWindow = MainWindowUi()
self.NouvelleVerifEssieux = NouvelleVerifEssieuxUi()
self.MainWindow.to_NouvelleVerif.connect(self.show_NouvelleVerif)
self.NouvelleVerifEssieux.to_NouvelleVerif.connect(self.show_NouvelleVerif)
self.widget.setCurrentWidget(self.NouvelleVerif)
def show_NouvelleVerifEssieux(self):
self.NouvelleVerif = NouvelleVerifUi()
self.NouvelleVerif.to_NouvelleVerifEssieux.connect(self.show_NouvelleVerifEssieux)
self.widget.setCurrentWidget(self.NouvelleVerifEssieux)
def main():
controller = Controller()
controller.widget.show()
sys.exit(controller.app.exec_())
if __name__ == '__main__':
main()
#musicamante I don't know why I though the QtCore.Signal could be call even if he was in a function which has not been called. I did what you said and I realise I made another mistake with the widgets.
In the controller class they are create and add to the QStackedWidget in the __init__, but I was creating new ones and trying to set them as CurrentWidget without adding them to the QStackedWidget.
#alexpdev I wanted to navigate through my three differents with pushButton UI this way :
Start with MainWindowUI
MainWindowUI pushButton_2.clicked --> set the current widget display to NouvelleVerifUI
NouvelleVerifUI pushButton_1.clicked --> set the current widget display back to MainWindowUI
NouvelleVerifUI pushButton_3.clicked --> set the current widget display to NouvelleVerifEssieuxUI
NouvelleVerifEssieuxUI pushButton_1.clicked --> set the current widget display back to NouvelleVerifUI
Now everything work I did what you said #musicamante and I also use the UI created at first.
class Controller :
app = QtWidgets.QApplication(sys.argv)
widget = QtWidgets.QStackedWidget()
MainWindow = MainWindowUi()
NouvelleVerif = NouvelleVerifUi()
NouvelleVerifEssieux = NouvelleVerifEssieuxUi()
def __init__(self):
self.widget.addWidget(self.MainWindow) # create an instance of the first page class and add it to stackedwidget
self.widget.addWidget(self.NouvelleVerif) # adding second page
self.widget.addWidget(self.NouvelleVerifEssieux)
self.widget.setCurrentWidget(self.MainWindow) # setting the page that you want to load when application starts up. you can also use setCurrentIndex(int)
self.NouvelleVerif.to_MainWindow.connect(self.show_MainWindow)
self.MainWindow.to_NouvelleVerif.connect(self.show_NouvelleVerif)
self.NouvelleVerifEssieux.to_NouvelleVerif.connect(self.show_NouvelleVerif)
self.NouvelleVerif.to_NouvelleVerifEssieux.connect(self.show_NouvelleVerifEssieux)
def show_MainWindow(self):
self.widget.setCurrentWidget(self.MainWindow)
def show_NouvelleVerif(self):
self.widget.setCurrentWidget(self.NouvelleVerif)
def show_NouvelleVerifEssieux(self):
self.widget.setCurrentWidget(self.NouvelleVerifEssieux)
Thank you all for your time

Update information on QWizardPage based on information from other pages when IndependentPages option is used

I want to build a QWizard that takes information in some initial pages, then summarizes this info on the final page. The user should be able to navigate back and update values on initial pages, without losing information. Thus I am using the QWizard.IndependentPages option. This prevents Qt from running the cleanupPage() which clears previously input data. However, an issue is that initializePage() is also only called the first time the page is visited.
I cannot seem to find a clean method to allow the information on the final page to always be updated with whatever has been input on previous pages.
I have attached a small piece of code, with 3 pages, to illustrate the functionality as-is. When navigating to the second page, inputting data, then reviewing this data on page 3. When going back to page 2, the previous data is still shown (as required), when navigating to page 1 and then to page 2, still the initial data is shown (as required). Then the data op page 2 is changed and the user moves to page 3, the old data is still shown. This is because not the constructor or the initializePage() function is called, and nothing triggers an update of this label.
from os import terminal_size
import sys
import csv
from PyQt5 import QtCore
from PyQt5.QtCore import QDir
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QFrame, QWizard, QWizardPage, QVBoxLayout, QLabel, QFormLayout, QRadioButton, QLineEdit, QComboBox, \
QGroupBox, QApplication, QCheckBox, QHBoxLayout, QScrollArea, QWidget
wizard_page_index = {
"IntroPage": 0,
"EvalPage": 1,
"RegisterPage": 2
}
TEST = ""
class LicenseWizard(QWizard):
def __init__(self):
super().__init__()
self.setPage(wizard_page_index["IntroPage"], IntroPage())
self.setPage(wizard_page_index["EvalPage"], EvalPage())
self.setPage(wizard_page_index["RegisterPage"], RegisterPage())
self.setStartId(wizard_page_index["IntroPage"])
self.setWindowTitle("Test Wizard")
self.setOption(QWizard.IndependentPages)
class IntroPage(QWizardPage):
def __init__(self):
super().__init__()
self.setTitle("Intro Page")
data_source_layout = QFormLayout()
eval_btn = QRadioButton("evaluate")
self.registerField("evaluate_btn", eval_btn)
data_source_layout.addWidget(eval_btn)
register_btn = QRadioButton("register")
self.registerField("register_btn", register_btn)
data_source_layout.addWidget(register_btn)
register_btn.setChecked(True)
layout = QVBoxLayout()
layout.addWidget(eval_btn)
layout.addWidget(register_btn)
self.setLayout(layout)
def nextId(self) -> int:
if self.field("evaluate_btn"):
return wizard_page_index["EvalPage"]
else:
return wizard_page_index["RegisterPage"]
class EvalPage(QWizardPage):
def __init__(self):
super().__init__()
self.setTitle("EvalPage")
layout = QFormLayout()
model_name = QLineEdit(TEST)
layout.addRow("Model Name:", model_name)
self.registerField("model_name*", model_name)
self.setLayout(layout)
def nextId(self) -> int:
return wizard_page_index["RegisterPage"]
class RegisterPage(QWizardPage):
def __init__(self):
super().__init__()
self.setTitle("RegisterPage")
self.label2 = QLabel()
self.label2.setFrameStyle(QFrame.Panel)
self.label2.setText(self.field("model_name"))
layout = QFormLayout()
layout.addRow("name:", self.label2)
self.setLayout(layout)
def initializePage(self) -> None:
self.label2.setText(self.field("model_name"))
def nextId(self) -> int:
# self.label2.setText(self.field("model_name"))
return wizard_page_index["EvalPage"]
if __name__ == "__main__":
application = QApplication(sys.argv)
wizard = LicenseWizard()
wizard.show()
return_code = application.exec_()
input('Press ENTER to exit')
sys.exit(return_code)
One possible solution is to not use QWizard::IndependentPages and override the QWizard::cleanupPage() method:
class LicenseWizard(QWizard):
def __init__(self):
super().__init__()
self.setPage(wizard_page_index["IntroPage"], IntroPage())
self.setPage(wizard_page_index["EvalPage"], EvalPage())
self.setPage(wizard_page_index["RegisterPage"], RegisterPage())
self.setStartId(wizard_page_index["IntroPage"])
self.setWindowTitle("Test Wizard")
# self.setOption(QWizard.IndependentPages)
def cleanupPage(self, _id):
pass

How to get a Custom QCompleter to work with a custom item delegate?

I have a custom qcompleter (to match any part of the string) and a custom QStyledItemDelegate (to show different formatting on the drop down options returned by the qcompleter) applied to a QLineEdit, and they both work individually however the QStyledItemDelegate doesn't work when I apply them both.
import sys
from PySide2.QtWidgets import QApplication, QMainWindow, QLineEdit, QCompleter, QStyledItemDelegate
from PySide2.QtCore import Qt, QSortFilterProxyModel, QStringListModel
from PySide2.QtGui import QColor, QPalette
Qcompleter Item delegate:
class CompleterItemDelegate(QStyledItemDelegate):
def initStyleOption(self, option, index):
super(CompleterItemDelegate, self).initStyleOption(option, index)
option.backgroundBrush = QColor("red")
option.palette.setBrush(QPalette.Text, QColor("blue"))
option.displayAlignment = Qt.AlignCenter
Custom QCompleter:
class CustomQCompleter(QCompleter):
def __init__(self, parent=None):
super(CustomQCompleter, self).__init__(parent)
self.local_completion_prefix = ""
self.source_model = None
def setModel(self, model):
self.source_model = model
super(CustomQCompleter, self).setModel(self.source_model)
def updateModel(self):
local_completion_prefix = self.local_completion_prefix
class InnerProxyModel(QSortFilterProxyModel):
def filterAcceptsRow(self, sourceRow, sourceParent):
index0 = self.sourceModel().index(sourceRow, 0, sourceParent)
searchStr = local_completion_prefix.lower()
searchStr_list = searchStr.split()
modelStr = self.sourceModel().data(index0,Qt.DisplayRole).lower()
for string in searchStr_list:
if not string in modelStr:
return False
return True
proxy_model = InnerProxyModel()
proxy_model.setSourceModel(self.source_model)
super(CustomQCompleter, self).setModel(proxy_model)
def splitPath(self, path):
self.local_completion_prefix = str(path)
self.updateModel()
return ""
Main:
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
model = QStringListModel()
model.setStringList(['Tom', 'Tommy Stevens', 'Steven'])
# ITEM DELEGATE ONLY - WORKS
# completer = QCompleter()
# completer.setModel(model)
# delegate = CompleterDelegate()
# completer.popup().setItemDelegate(delegate)
# QCOMPLETER DELEGATE ONLY - WORKS
# completer = CustomQCompleter(self)
# completer.setModel(model)
# ITEM DELEGATE AND QCOMPLETER DELEGATE - ITEM DELEGATE DOESNT WORK
completer = CustomQCompleter(self)
completer.setModel(model)
delegate = CompleterItemDelegate()
completer.popup().setItemDelegate(delegate)
self.lineEdit = QLineEdit()
self.lineEdit.setCompleter(completer)
self.setCentralWidget(self.lineEdit)
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
p = MainWindow()
p.show()
sys.exit(app.exec_())
Is there a way to make this code work?
Is there a better way to achieve both choosing the completion rules for the qcompleter and formatting the popup results?
Setting the delegate on the popup won't work if the model is set afterwards, since setModel() also calls setPopup(), which in turn sets a new item delegate.
So, you either:
ensure that you set the delegate after setting the model on the completer;
subclass the completer and override setModel(), by calling the base implementation and then restore the delegate, or complete() by restoring the delegate before the base implementation call; note that this won't work in your case because you called the base implementation in updateModel() which will clearly ignore the override;
Moving
delegate = CompleterItemDelegate()
self.popup().setItemDelegate(delegate)
into the CustomQCompleter updateModel function solves the problem as pointed out by musicamante.

QGraphicesItem emit a signal upon hoverEnterEvent

What is the best method/practice for emitting a signal upon entering either a QGraphicsWidget or a QGraphicsItem ?
In my MWE I would like to trigger a call to MainWindow.update, from Square.hoverEnterEvent, whenever the user mouse(s) over an item in a QGraphicsScene. The trouble is that QGraphicsItem/Widget is not really designed to emit signals. Instead these classes are setup to handle events passed down to them from QGraphicsScene. QGraphicsScene handles the case that the user has selected an item but does not appear to handle mouse entry events, At least there is no mechanism for entryEvent to percolate up to the parent widget/window.
import sys
from PyQt5.QtWidgets import QWidget, QApplication, qApp, QMainWindow, QGraphicsScene, QGraphicsView, QStatusBar, QGraphicsWidget, QStyle
from PyQt5.QtCore import Qt, QSizeF
class Square(QGraphicsWidget) :
"""
doc string
"""
def __init__(self,*args, name = None, **kvps) :
super().__init__(*args, **kvps)
self.radius = 5
self.name = name
self.setAcceptHoverEvents(True)
def sizeHint(self, hint, size):
size = super().sizeHint(hint, size)
print(size)
return QSizeF(50,50)
def paint(self, painter, options, widget):
self.initStyleOption(options)
ink = options.palette.highLight() if options.state == QStyle.State_Selected else options.palette.button()
painter.setBrush(ink) # ink
painter.drawRoundedRect(self.rect(), self.radius, self.radius)
def hoverEnterEvent(self, event) :
print("Enter Event")
super().hoverEnterEvent(event)
class MainWindow(QMainWindow):
def __init__(self, *args, **kvps) :
super().__init__(*args, **kvps)
# Status bar
self.stat = QStatusBar(self)
self.setStatusBar(self.stat)
self.stat.showMessage("Started")
# Widget(s)
self.data = QGraphicsScene(self)
self.view = QGraphicsView(self.data, self)
item = self.data.addItem(Square())
self.view.ensureVisible(self.data.sceneRect())
self.setCentralWidget(self.view)
# Visibility
self.showMaximized()
def update(self, widget) :
self.stat.showMessage(str(widget.name))
if __name__ == "__main__" :
# Application
app = QApplication(sys.argv)
# Scene Tests
main = MainWindow()
main.show()
# Loop
sys.exit(app.exec_())
The docs state that QGraphicsItem is not designed to emit signals, instead it is meant to respond to the events sent to it by QGraphicsScene. In contrast it seems that QGraphicsWidget is designed to do so but I'm not entirely sure where the entry point ought to be. Personally I feel QGraphicsScene should really be emitting these signals, from what I understand of the design, but am not sure where the entry point ought to be in this case either.
Currently I see the following possible solutions, with #3 being the preferred method. I was wondering if anyone else had a better strategy :
Create a QGraphicsScene subclass, let's call it Scene, to each QGraphicsItem/QGraphicsWidget and call a custom trigger/signal upon the Scene from each widget. Here I would have to subclass any item I intend on including within the scene.
Set Mainwindow up as the event filter for each item in the scene or upon the scene itself and calling MainWindow.update.
Set Mainwindow.data to be a subclass of QGraphicsScene, let's call it Scene, and let it filter it's own events emitting a hoverEntry signal. hoverEntry is then connected to MainWindow.update as necessary.
As Murphy's Law would have it Ekhumoro already provides an answer.
It seems one should subclass QGraphicsScene and add the necessary signal. this is then triggered from the QGraphicsItem/Widget. This requires that all items within a scene be sub-classed to ensure that they call the corresponding emit function but it seems must do this do this anyhow when working with the graphics scene stuff.
I'll not mark this as answered for a bit in case some one has a better suggestion.
import sys
from PyQt5.QtWidgets import QWidget, QApplication, qApp, QMainWindow, QGraphicsScene, QGraphicsView, QStatusBar, QGraphicsWidget, QStyle, QGraphicsItem
from PyQt5.QtCore import Qt, QSizeF, pyqtSignal
class Square(QGraphicsWidget) :
"""
doc string
"""
def __init__(self,*args, name = None, **kvps) :
super().__init__(*args, **kvps)
self.radius = 5
self.name = name
self.setAcceptHoverEvents(True)
self.setFlag(self.ItemIsSelectable)
self.setFlag(self.ItemIsFocusable)
def sizeHint(self, hint, size):
size = super().sizeHint(hint, size)
print(size)
return QSizeF(50,50)
def paint(self, painter, options, widget):
self.initStyleOption(options)
ink = options.palette.highLight() if options.state == QStyle.State_Selected else options.palette.button()
painter.setBrush(ink) # ink
painter.drawRoundedRect(self.rect(), self.radius, self.radius)
def hoverEnterEvent(self, event) :
super().hoverEnterEvent(event)
self.scene().entered.emit(self)
self.update()
class GraphicsScene(QGraphicsScene) :
entered = pyqtSignal([QGraphicsItem],[QGraphicsWidget])
class MainWindow(QMainWindow):
def __init__(self, *args, **kvps) :
super().__init__(*args, **kvps)
# Status bar
self.stat = QStatusBar(self)
self.setStatusBar(self.stat)
self.stat.showMessage("Started")
# Widget(s)
self.data = GraphicsScene(self)
self.data.entered.connect(self.itemInfo)
self.data.focusItemChanged.connect(self.update)
self.view = QGraphicsView(self.data, self)
item = Square(name = "A")
item.setPos( 50,0)
self.data.addItem(item)
item = Square(name = "B")
item.setPos(-50,0)
self.data.addItem(item)
self.view.ensureVisible(self.data.sceneRect())
self.setCentralWidget(self.view)
# Visibility
self.showMaximized()
def itemInfo(self, item):
print("Here it is -> ", item)
if __name__ == "__main__" :
# Application
app = QApplication(sys.argv)
# Scene Tests
main = MainWindow()
main.show()
# Loop
sys.exit(app.exec_())
The magic lines of interest are then the QGrahicsScene subclass.
class GraphicsScene(QGraphicsScene) :
entered = pyqtSignal([QGraphicsItem],[QGraphicsWidget])
The QGraphicsWidget.hoverEnterEvent triggers the entered signal. (This is where I got stuck)
def hoverEnterEvent(self, event) :
...
self.scene().entered.emit(self)
...
And the switcheroo from self.data = QGraphicsScene(...) to self.data = GraphicsScene in the MainWindow's init function.

Pyqt Pass Variable to QDialog Class

I have developed a QGIS plugin using Pyqt. I now have a need within this plugin to have a QDialog popup have its fields populated with data from our database.
My problem is how to pass a variable (in this case it might be a table and row reference) into a class and have it used by the static method.
If I print a passed in variable from within the class it will return the variable in addition to None?? If I take the same variable and try and populate a qplaintextedit it won't work because its complaining of being type 'None'.
Here is some test code I'm trying out just to get the concept down...
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import pdb
class mydi(QDialog):
def __init__(self, pass_var, parent=None):
super(mydi, self).__init__(parent)
layout = QVBoxLayout(self)
self.pass_var = pass_var
print pass_var
self.txt_comments = QPlainTextEdit(self)
self.txt_comments.appendPlainText(pass_var)
layout.addWidget(self.txt_comments)
self.buttons = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
Qt.Horizontal, self)
layout.addWidget(self.buttons)
self.buttons.accepted.connect(self.accept)
self.buttons.rejected.connect(self.reject)
def something(self):
return self.somevar
def comments(self):
return self.txt_comments.toPlainText()
#staticmethod
def getData(parent=None):
dialog = mydi(None)
dialog.exec_()
return (dialog.comments())
def main():
app = QApplication([])
pass_in_var = "test"
dia = mydi(pass_in_var)
data = dia.getData()
print data

Categories