2
from spyderlib.qt.QtGui import (QApplication, QMainWindow, QWidget, QLabel,
3
QLineEdit, QHBoxLayout, QDockWidget, QFont)
4
from spyderlib.qt.QtCore import Qt
6
from spyderlib.widgets.internalshell import InternalShell
9
class MyWidget(QWidget):
11
QWidget.__init__(self)
12
label = QLabel("Imagine an extraordinary complex widget right here...")
13
self.edit = QLineEdit("Text")
14
layout = QHBoxLayout()
15
layout.addWidget(label)
16
layout.addWidget(self.edit)
17
self.setLayout(layout)
20
"""Return sample edit text"""
21
return self.edit.text()
23
def set_text(self, text):
24
"""Set sample edit text"""
25
self.edit.setText(text)
28
class MyWindow(QMainWindow):
30
QMainWindow.__init__(self)
32
# Set this very simple widget as central widget
34
self.setCentralWidget(widget)
36
# Create the console widget
37
font = QFont("Courier new")
39
ns = {'win': self, 'widget': widget}
40
msg = "Try for example: widget.set_text('foobar') or win.close()"
41
# Note: by default, the internal shell is multithreaded which is safer
42
# but not compatible with graphical user interface creation.
43
# For example, if you need to plot data with Matplotlib, you will need
44
# to pass the option: multithreaded=False
45
self.console = cons = InternalShell(self, namespace=ns, message=msg)
47
# Setup the console widget
49
cons.set_codecompletion_auto(True)
50
cons.set_calltips(True)
51
cons.setup_calltips(size=600, font=font)
52
cons.setup_completion(size=(300, 180), font=font)
53
console_dock = QDockWidget("Console", self)
54
console_dock.setWidget(cons)
56
# Add the console widget to window as a dockwidget
57
self.addDockWidget(Qt.BottomDockWidgetArea, console_dock)
61
def closeEvent(self, event):
62
self.console.exit_interpreter()
66
app = QApplication([])
71
if __name__ == "__main__":
2
from spyderlib.qt.QtGui import (QApplication, QMainWindow, QWidget, QLabel,
3
QLineEdit, QHBoxLayout, QDockWidget, QFont)
4
from spyderlib.qt.QtCore import Qt
6
from spyderlib.widgets.internalshell import InternalShell
9
class MyWidget(QWidget):
11
QWidget.__init__(self)
12
label = QLabel("Imagine an extraordinary complex widget right here...")
13
self.edit = QLineEdit("Text")
14
layout = QHBoxLayout()
15
layout.addWidget(label)
16
layout.addWidget(self.edit)
17
self.setLayout(layout)
20
"""Return sample edit text"""
21
return self.edit.text()
23
def set_text(self, text):
24
"""Set sample edit text"""
25
self.edit.setText(text)
28
class MyWindow(QMainWindow):
30
QMainWindow.__init__(self)
32
# Set this very simple widget as central widget
34
self.setCentralWidget(widget)
36
# Create the console widget
37
font = QFont("Courier new")
39
ns = {'win': self, 'widget': widget}
40
msg = "Try for example: widget.set_text('foobar') or win.close()"
41
# Note: by default, the internal shell is multithreaded which is safer
42
# but not compatible with graphical user interface creation.
43
# For example, if you need to plot data with Matplotlib, you will need
44
# to pass the option: multithreaded=False
45
self.console = cons = InternalShell(self, namespace=ns, message=msg)
47
# Setup the console widget
49
cons.set_codecompletion_auto(True)
50
cons.set_calltips(True)
51
cons.setup_calltips(size=600, font=font)
52
cons.setup_completion(size=(300, 180), font=font)
53
console_dock = QDockWidget("Console", self)
54
console_dock.setWidget(cons)
56
# Add the console widget to window as a dockwidget
57
self.addDockWidget(Qt.BottomDockWidgetArea, console_dock)
61
def closeEvent(self, event):
62
self.console.exit_interpreter()
66
app = QApplication([])
71
if __name__ == "__main__":
b'\\ No newline at end of file'