Ejemplo n.º 1
0
def fedit(data, title="", comment="", icon=None, parent=None, apply=None):
    """
    Create form dialog and return result
    (if Cancel button is pressed, return None)
    
    data: datalist, datagroup
    title: string
    comment: string
    icon: QIcon instance
    parent: parent QWidget
    apply: apply callback (function)
    
    datalist: list/tuple of (field_name, field_value)
    datagroup: list/tuple of (datalist *or* datagroup, title, comment)
    
    -> one field for each member of a datalist
    -> one tab for each member of a top-level datagroup
    -> one page (of a multipage widget, each page can be selected with a combo
       box) for each member of a datagroup inside a datagroup
       
    Supported types for field_value:
      - int, float, str, unicode, bool
      - colors: in Qt-compatible text form, i.e. in hex format or name (red,...)
                (automatically detected from a string)
      - list/tuple:
          * the first element will be the selected index (or value)
          * the other elements can be couples (key, value) or only values
    """
    # Create a QApplication instance if no instance currently exists
    # (e.g. if the module is used directly from the interpreter)
    test_travis = os.environ.get('TEST_TRAVIS_WIDGETS', None)
    if test_travis is not None:
        from spyderlib.utils.qthelpers import qapplication
        _app = qapplication(test_time=1)
    elif QApplication.startingUp():
        _app = QApplication([])

    dialog = FormDialog(data, title, comment, icon, parent, apply)
    if dialog.exec_():
        return dialog.get()
Ejemplo n.º 2
0
def test():
    """ """
    app = QApplication([])
    win = TestWindow()
    win.show()
    app.exec_()
Ejemplo n.º 3
0
                # silently ignored here.
                eintr = errno.WSAEINTR if os.name == 'nt' else errno.EINTR
                if e.args[0] == eintr:
                    continue
                raise
            if not self._initialized:
                server_port = read_packet(conn)
                if isinstance(server_port, int):
                    self._initialized = True
                    self.initialized.emit(server_port)
            else:
                self.request_handled.emit(read_packet(conn))


if __name__ == '__main__':
    app = QApplication(sys.argv)
    plugin = PluginClient('jedi')

    def handle_return(value):
        print(value)
        if value['method'] == 'foo':
            app.quit()
        else:
            plugin.send(dict(method='foo'))

    def handle_errored():
        print('errored')
        sys.exit(1)

    def start():
        print('start')