<small id='vfCYu'></small><noframes id='vfCYu'>

    <bdo id='vfCYu'></bdo><ul id='vfCYu'></ul>
<legend id='vfCYu'><style id='vfCYu'><dir id='vfCYu'><q id='vfCYu'></q></dir></style></legend>
    1. <tfoot id='vfCYu'></tfoot>
    2. <i id='vfCYu'><tr id='vfCYu'><dt id='vfCYu'><q id='vfCYu'><span id='vfCYu'><b id='vfCYu'><form id='vfCYu'><ins id='vfCYu'></ins><ul id='vfCYu'></ul><sub id='vfCYu'></sub></form><legend id='vfCYu'></legend><bdo id='vfCYu'><pre id='vfCYu'><center id='vfCYu'></center></pre></bdo></b><th id='vfCYu'></th></span></q></dt></tr></i><div id='vfCYu'><tfoot id='vfCYu'></tfoot><dl id='vfCYu'><fieldset id='vfCYu'></fieldset></dl></div>
      1. 如何显示 PyQt 模式对话框并在关闭后从其控件中

        时间:2023-10-08

          <tbody id='DJAww'></tbody>

                <i id='DJAww'><tr id='DJAww'><dt id='DJAww'><q id='DJAww'><span id='DJAww'><b id='DJAww'><form id='DJAww'><ins id='DJAww'></ins><ul id='DJAww'></ul><sub id='DJAww'></sub></form><legend id='DJAww'></legend><bdo id='DJAww'><pre id='DJAww'><center id='DJAww'></center></pre></bdo></b><th id='DJAww'></th></span></q></dt></tr></i><div id='DJAww'><tfoot id='DJAww'></tfoot><dl id='DJAww'><fieldset id='DJAww'></fieldset></dl></div>

                <small id='DJAww'></small><noframes id='DJAww'>

                <legend id='DJAww'><style id='DJAww'><dir id='DJAww'><q id='DJAww'></q></dir></style></legend>

              • <tfoot id='DJAww'></tfoot>
                  <bdo id='DJAww'></bdo><ul id='DJAww'></ul>
                • 本文介绍了如何显示 PyQt 模式对话框并在关闭后从其控件中获取数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  对于像 QInputDialog 这样的内置对话框,我读到我可以这样做:

                  For a built-in dialog like QInputDialog, I've read that I can do this:

                  text, ok = QtGui.QInputDialog.getText(self, 'Input Dialog', 'Enter your name:')
                  

                  如何使用我在 Qt Designer 中自己设计的对话框来模拟这种行为?例如,我想做:

                  How can I emulate this behavior using a dialog that I design myself in Qt Designer? For instance, I would like to do:

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

                  推荐答案

                  这是一个简单的类,你可以用它来提示日期:

                  Here is simple class you can use to prompt for date:

                  class DateDialog(QDialog):
                      def __init__(self, parent = None):
                          super(DateDialog, self).__init__(parent)
                  
                          layout = QVBoxLayout(self)
                  
                          # nice widget for editing the date
                          self.datetime = QDateTimeEdit(self)
                          self.datetime.setCalendarPopup(True)
                          self.datetime.setDateTime(QDateTime.currentDateTime())
                          layout.addWidget(self.datetime)
                  
                          # OK and Cancel buttons
                          buttons = QDialogButtonBox(
                              QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
                              Qt.Horizontal, self)
                          buttons.accepted.connect(self.accept)
                          buttons.rejected.connect(self.reject)
                          layout.addWidget(buttons)
                  
                      # get current date and time from the dialog
                      def dateTime(self):
                          return self.datetime.dateTime()
                  
                      # static method to create the dialog and 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)
                  

                  并使用它:

                  date, time, ok = DateDialog.getDateTime()
                  

                  这篇关于如何显示 PyQt 模式对话框并在关闭后从其控件中获取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何使用 asksaveasfile 将文本从 Text-widget Tkinter 保 下一篇:如何将对话框窗口中的选定文件添加到字典中?

                  相关文章

                  最新文章

                      <i id='Vyy9f'><tr id='Vyy9f'><dt id='Vyy9f'><q id='Vyy9f'><span id='Vyy9f'><b id='Vyy9f'><form id='Vyy9f'><ins id='Vyy9f'></ins><ul id='Vyy9f'></ul><sub id='Vyy9f'></sub></form><legend id='Vyy9f'></legend><bdo id='Vyy9f'><pre id='Vyy9f'><center id='Vyy9f'></center></pre></bdo></b><th id='Vyy9f'></th></span></q></dt></tr></i><div id='Vyy9f'><tfoot id='Vyy9f'></tfoot><dl id='Vyy9f'><fieldset id='Vyy9f'></fieldset></dl></div>
                      <legend id='Vyy9f'><style id='Vyy9f'><dir id='Vyy9f'><q id='Vyy9f'></q></dir></style></legend>
                      <tfoot id='Vyy9f'></tfoot>

                        <bdo id='Vyy9f'></bdo><ul id='Vyy9f'></ul>

                      <small id='Vyy9f'></small><noframes id='Vyy9f'>