Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the best way to get just one parameter? #89

Open
rtek1000 opened this issue Feb 21, 2025 · 0 comments
Open

What is the best way to get just one parameter? #89

rtek1000 opened this issue Feb 21, 2025 · 0 comments

Comments

@rtek1000
Copy link

rtek1000 commented Feb 21, 2025

Hello,

Does the library return a dictionary, or do I need to convert it?

print(get_screen(True).get('width')) # the primary screen
print(get_screen(False).get('width')) # the secondary screen

# screeninfo.get_monitors() sample:
# [Monitor(x=0, y=0, width=1920, height=1080, width_mm=309, height_mm=174, name='\\\\.\\DISPLAY1', is_primary=True), Monitor(x=1920, y=0, width=1366, height=768, width_mm=256, height_mm=144, name='\\\\.\\DISPLAY2', is_primary=False)]    
def get_screen(is_primary=True):
    for m1 in screeninfo.get_monitors():
        dict1 = m1.__dict__
        # print(dict1)
        if is_primary == True and dict1.get('is_primary') == True:
            return dict1
        elif is_primary == False and dict1.get('is_primary') == False:
            return dict1
    dict0 = dict({'width': 0, 'height': 0})
    return dict0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant