-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c54245c
commit 51087ff
Showing
8 changed files
with
493 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="function", autouse=True) | ||
def qapp(qapp_args, qapp_cls, pytestconfig, qtbot): | ||
# workaround for https://bugreports.qt.io/browse/PYSIDE-2575 | ||
import asyncio | ||
|
||
from PySide6 import QtCore | ||
from PySide6.QtAsyncio import QAsyncioEventLoopPolicy | ||
from PySide6.QtWidgets import QMainWindow | ||
from pytestqt.qt_compat import qt_api | ||
|
||
app = qt_api.QtWidgets.QApplication.instance() | ||
if app is None: | ||
assert False | ||
app = qapp_cls(qapp_args) | ||
name = pytestconfig.getini("qt_qapp_name") | ||
app.setApplicationName(name) | ||
else: | ||
# Check that there are not left-over widgets from other tests | ||
assert len(app.topLevelWidgets()) == 0 | ||
|
||
policy = asyncio.get_event_loop_policy() | ||
if not isinstance(policy, QAsyncioEventLoopPolicy): | ||
asyncio.set_event_loop_policy(QAsyncioEventLoopPolicy()) | ||
|
||
yield app | ||
|
||
for widget in app.topLevelWidgets(): | ||
if isinstance(widget, QMainWindow): | ||
widget.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) | ||
widget.close() | ||
widget.deleteLater() | ||
|
||
# Process events to make sure that widgets will be cleaned up | ||
app.processEvents() | ||
|
||
qtbot.waitUntil(lambda: len(app.topLevelWidgets()) == 0, timeout=500) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<window> | ||
<widget> | ||
<qsplitter> | ||
|
||
<component | ||
v-for="view in ['qlistview', 'qtableview', 'qtreeview']" | ||
:is="view" | ||
> | ||
<qstandarditemmodel :column_count="2"> | ||
<qstandarditem | ||
v-for="content in items_content()" | ||
|
||
:text="content['text']" | ||
:model_index="content['model_index']" | ||
/> | ||
|
||
<!-- v-bind="content" --> | ||
</qstandarditemmodel> | ||
</component> | ||
|
||
<!-- <qlistview> | ||
<qstandarditemmodel :column_count="2"> | ||
<qstandarditem | ||
v-for="content in items_content()" | ||
v-bind="content" | ||
/> | ||
</qstandarditemmodel> | ||
</qlistview> | ||
<qtableview> | ||
<qstandarditemmodel :column_count="2"> | ||
<qstandarditem | ||
v-for="content in items_content()" | ||
v-bind="content" | ||
/> | ||
</qstandarditemmodel> | ||
</qtableview> | ||
<qtreeview> | ||
<qstandarditemmodel :column_count="2"> | ||
<qstandarditem | ||
v-for="content in items_content()" | ||
v-bind="content" | ||
/> | ||
</qstandarditemmodel> | ||
</qtreeview> --> | ||
</qsplitter> | ||
<widget :layout="{'type': 'box', 'direction': 'LeftToRight'}" :maximum-height="50"> | ||
<button text="Add" @clicked="add_item" object-name="add" /> | ||
<button text="Remove" @clicked="remove_item" object-name="remove" /> | ||
</widget> | ||
</widget> | ||
</window> | ||
|
||
<script> | ||
import collagraph as cg | ||
from observ import to_raw | ||
|
||
class ListsExample(cg.Component): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.state["values"] = to_raw(self.props["items"]) | ||
|
||
def items_content(self): | ||
return [ | ||
{"text": text, "model_index": (row, column)} | ||
for row, (item, _) in enumerate(self.state["values"]) | ||
for column, text in enumerate(item) | ||
] | ||
|
||
def add_item(self): | ||
self.state["values"].append([["NEW", "ITEM"], False]) | ||
|
||
def remove_item(self): | ||
if len(self.state["values"]): | ||
self.state["values"].pop(0) | ||
</script> |
Oops, something went wrong.