pyzo_test.py, given below, illustrates how easy it is to create floatable
windows in qt. It also use the cool "fusion" Qt style, whose best feature
are the visible splitter handles. You can run pyzo_test.py using Python,
or from Leo using this @button node:
# Run pyzo_test.py externally.
g.execute_shell_commands(r'&python "c:\test\pyzo_test.py"')
Here is pyzo_test.py:
try:
g
print('must be run externally')
assert False
except NameError:
pass
import sys
import leo.core.leoGlobals as g
from leo.core.leoQt import QtWidgets, QtCore
lt_area = QtCore.Qt.LeftDockWidgetArea
rt_area = QtCore.Qt.RightDockWidgetArea
g.cls()
print("pyzo_test.py")
def make_widget(name):
'''Make a new docwidget in the MainWindow mw.'''
w = QtWidgets.QDockWidget(mw)
w.setFeatures(w.DockWidgetMovable | w.DockWidgetFloatable | w.
DockWidgetClosable)
w.setWindowTitle(name)
return w
def set_style():
'''Use the fusion style.'''
nativePalette = app.palette()
style = app.setStyle('Fusion') # 'Cleanlooks'
if style:
app.setPalette(nativePalette)
app = QtWidgets.QApplication([])
set_style() # The gutter is a bit small.
mw = QtWidgets.QMainWindow()
mw.setStyleSheet("background: #657b83")
widgets = [
(lt_area, make_widget('shell')),
(rt_area, make_widget('test')),
(rt_area, make_widget('log')),
]
for area, w in widgets:
mw.addDockWidget(area, w)
mw.show()
app.exec_()
g.trace('done')
sys.exit()
*Discussion*
The demo above shows that it is easy to get exactly pyzo's look and feel.
Adapting Leo's existing code to support this has little to do with pyzo.
How much of pyzo's actual code will Leo eventually use? My present plan is
to* access pyzo's tool windows via imports only.* The intention is to *use
pyzo's actual (unchanged) code to create and manage pyzo's best features*,
all of which are tools, represented as QDockWidgets.
This could be called *stealing via imports*. Imo, it's much the best
policy. Surprisingly little "shimming" was be needed to prototype the pyzo
file browser in Leo. Perhaps only a bit more shimming will be needed to
access pyzo's other tools, including the "Shells", "Logger", "Interactive
Help", "Web Browser", and "Workspace" widgets.
Some new code will be needed to adapt pyzo to Leo. For example, pyzo's
MainWindow.saveWindowState saves the entire configuration of the main
window--it will automatically reloaded the next time pyzo starts. Leo will
use something similar, but the code must be adapted to Leo.
*Summary*
Short, easy prototypes have already demonstrated that:
- Leo can have pyzo's look and feel.
- Leo can use, *via imports only*, pyzo's tools windows.
A note about acknowledgements: Stealing via imports might be a gray area
in copyright. After all, we don't require programs to have copyright
notices when they import sys! However, I plan to gratefully and fully
acknowledge pyzo in all shims, and in Leo's main docs.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.