python - How can I show a PyQt modal dialog and get data out of its controls once its closed? -


for built-in dialog qinputdialog, i've read can this:

text, ok = qtgui.qinputdialog.gettext(self, 'input dialog', 'enter name:') 

how can emulate behavior using dialog design myself in qt designer? instance, do:

my_date, my_time, ok = mycustomdatetimedialog.get_date_time(self) 

here simple class can use prompt date:

class datedialog(qdialog):     def __init__(self, parent = none):         super(datedialog, self).__init__(parent)          layout = qvboxlayout(self)          # nice widget editing date         self.datetime = qdatetimeedit(self)         self.datetime.setcalendarpopup(true)         self.datetime.setdatetime(qdatetime.currentdatetime())         layout.addwidget(self.datetime)          # ok , cancel buttons         buttons = qdialogbuttonbox(             qdialogbuttonbox.ok | qdialogbuttonbox.cancel,             qt.horizontal, self)         buttons.accepted.connect(self.accept)         buttons.rejected.connect(self.reject)         layout.addwidget(buttons)      # current date , time dialog     def datetime(self):         return self.datetime.datetime()      # static method create dialog , return (date, time, accepted)     @staticmethod     def getdatetime(parent = none):         dialog = datedialog(parent)         result = dialog.exec_()         date = dialog.datetime()         return (date.date(), date.time(), result == qdialog.accepted) 

and use it:

date, time, ok = datedialog.getdatetime() 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -