Comments (6)
Thanks @davep! that did the trick, I had played around with that parameter but in an inconsistent way and with too small I size I believe. Yet again a super quick response describing an easy-to-implement solution to an issue, thanks!!
from textual.
Glad to hear that solved it for you. :-)
from textual.
We found the following entry in the FAQ which you may find helpful:
Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.
This is an automated reply, generated by FAQtory
from textual.
I would imagine that the issue is what the exception says:
Target offset is outside of currently-visible screen region.
The click is happening outside of the screen; that that happens when adding/removing margin
is, I would imagine, coincidental, and just happens to be bumping where the click would happen outside of the screen. Consider this extreme example:
from asyncio import run
from textual.app import App, ComposeResult
from textual.widget import Widget
class PilotMarginApp(App[None]):
CSS = """
#click-me {
margin: 200;
width: 20;
height: 10;
border: solid red;
background: green;
}
"""
def compose(self) -> ComposeResult:
yield Widget(id="click-me")
async def test_app():
async with PilotMarginApp().run_test() as pilot:
await pilot.click("#click-me")
if __name__ == "__main__":
run(test_app())
This throws the same exception. Remove the margin
from this, or drop to something like 1
, and it runs fine.
You probably want to make your "terminal" big enough to handle the display you're attempting to test. For example, I can make my code above work by making the "terminal" 400x400 (note the size
parameter for run_test
):
from asyncio import run
from textual.app import App, ComposeResult
from textual.widget import Widget
class PilotMarginApp(App[None]):
CSS = """
#click-me {
margin: 200;
width: 20;
height: 10;
border: solid red;
background: green;
}
"""
def compose(self) -> ComposeResult:
yield Widget(id="click-me")
async def test_app():
async with PilotMarginApp().run_test(size=(400, 400)) as pilot:
await pilot.click("#click-me")
if __name__ == "__main__":
run(test_app())
Long story short: your test seems to be trying to do something the user can't do; click on a widget that isn't visible to click.
from textual.
Don't forget to star the repository!
Follow @textualizeio for Textual updates.
from textual.
@JoeZiminski you can do pilot.app.save_screenshot()
and have a look at the resulting SVG file, to see if the thing you are clicking is really on-screen at that moment.
from textual.
Related Issues (20)
- Clicking `Select` doesn't properly collapse overlay HOT 5
- Could not find a version that satisfies the requirement textual (from versions: ) HOT 1
- Add the ability to customise scrollbar bar segments HOT 7
- Can i do chart using sparkline? HOT 1
- Auto width results in zero-width when applied to `OptionList` HOT 2
- Footer in ModalScreen lists ignored App keybindings HOT 4
- `action_back` leads to empty screen when not using `_default` Screen HOT 2
- Content height of markdown does not take border/padding into account HOT 8
- Broken links in grid reference HOT 1
- DataTable not moving cursor into view when move_cursor invoked before scrollbar is visible in other screen HOT 1
- Running `App.run_test()` multiple times in separate `with` statements crashes. HOT 3
- Cover screen events in guide
- OptionList sizing issue
- Prevent mounting on unmounted widgets HOT 1
- Broken bindings after 0.61.0 HOT 3
- Header icon broken since 0.61.0 HOT 4
- Action lookup failing HOT 3
- Footer issue on 0.63.0 HOT 1
- Action lookup problems on 0.63.1 HOT 1
- Footer bindings invisible on app launch HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from textual.