Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Document and window #1222

Answered by Archmonger
stephanosn asked this question in Question
Discussion options

I have created a css grid where users can enter the number of rows and columns. I want to be able, when the width of the window is smaller than the height, to swap the number of rows and columns around. I can’t seem to find a way to access the window element, so I’ve created a custom event handler that sends the window.innerHeight and width under detail. I receive the event but the detail information doesn’t seem to be there. Any help would be appreciated

You must be logged in to vote

If you need direct access to the client-side DOM, I would recommend switching to reactpy-django and use pyscript_component.

Then, you'd be able to query the DOM within a use_effect hook with pyscipt's JS module.

import js
@use_effect
async def peroidic_polling():
 while True:
 if js.window.innerWidth < 1200:
 ...
 await asyncio.sleep(0.5)

I am working on migrating pyscript components to core, but a few other things are currently taking priority.

Replies: 1 comment

Comment options

If you need direct access to the client-side DOM, I would recommend switching to reactpy-django and use pyscript_component.

Then, you'd be able to query the DOM within a use_effect hook with pyscipt's JS module.

import js
@use_effect
async def peroidic_polling():
 while True:
 if js.window.innerWidth < 1200:
 ...
 await asyncio.sleep(0.5)

I am working on migrating pyscript components to core, but a few other things are currently taking priority.

You must be logged in to vote
0 replies
Answer selected by Archmonger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /