pyloid 0.20.1.dev2__py3-none-any.whl → 0.20.2__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
pyloid/monitor.py CHANGED
@@ -1,921 +1,921 @@
1
- from PySide6.QtGui import QScreen
2
- from typing import Optional, Callable, Any
3
-
4
- class Monitor():
5
- def __init__(self, index: int, screen: QScreen):
6
- """
7
- Constructor for the Monitor class.
8
-
9
- Parameters
10
- ----------
11
- index : int
12
- Index of the monitor.
13
- screen : QScreen
14
- QScreen object of the monitor.
15
- """
16
- super().__init__()
17
- self.index = index
18
- self.screen = screen
19
-
20
- def capture(self, save_path: str, x: Optional[int] = None, y: Optional[int] = None, width: Optional[int] = None, height: Optional[int] = None):
21
- """
22
- Captures the entire desktop screen.
23
-
24
- Parameters
25
- ----------
26
- save_path : str
27
- Path to save the captured image. If not specified, it will be saved in the current directory.
28
- x : int, optional
29
- x-coordinate of the area to capture. Default is None.
30
- y : int, optional
31
- y-coordinate of the area to capture. Default is None.
32
- width : int, optional
33
- Width of the area to capture. Default is None.
34
- height : int, optional
35
- Height of the area to capture. Default is None.
36
-
37
- Returns
38
- -------
39
- str or None
40
- Returns the path of the saved image. Returns None if an error occurs.
41
-
42
- Examples
43
- --------
44
- ```python
45
- app = Pyloid("Pyloid-App")
46
-
47
- monitor = app.get_primary_monitor()
48
- save_path = monitor.capture("screenshot.png")
49
- print(f"Screenshot saved at: {save_path}")
50
- ```
51
- """
52
- try:
53
- screenshot = self.screen.grabWindow(0, x, y, width, height)
54
- screenshot.save(save_path)
55
- return save_path
56
-
57
- except Exception as e:
58
- print(f"Error occurred while capturing the desktop: {e}")
59
- return None
60
-
61
- def info(self) -> dict[str, Any]:
62
- """
63
- Returns information about the monitor.
64
-
65
- Returns
66
- -------
67
- dict[str, Any]
68
- A dictionary containing monitor information.
69
-
70
- Examples
71
- --------
72
- ```python
73
- app = Pyloid("Pyloid-App")
74
-
75
- monitor = app.get_primary_monitor()
76
- info = monitor.info()
77
- print("Monitor Info:", info)
78
- ```
79
-
80
- Output Example
81
- --------------
82
- ```
83
- {
84
- "index": 0,
85
- "name": "Primary Monitor",
86
- "manufacturer": "Dell",
87
- "model": "U2718Q",
88
- "serial_number": "SN123456789",
89
- "x": 0,
90
- "y": 0,
91
- "width": 2560,
92
- "height": 1440,
93
- "is_primary": True,
94
- "geometry": {
95
- "x": 0,
96
- "y": 0,
97
- "width": 2560,
98
- "height": 1440,
99
- },
100
- "size": {
101
- "width": 2560,
102
- "height": 1440,
103
- },
104
- "available_geometry": {
105
- "x": 0,
106
- "y": 0,
107
- "width": 2560,
108
- "height": 1400,
109
- },
110
- "available_size": {
111
- "width": 2560,
112
- "height": 1400,
113
- },
114
- "virtual_geometry":{
115
- "x": 0,
116
- "y": 0,
117
- "width": 5120,
118
- "height": 1440,
119
- },
120
- "virtual_size": {
121
- "width": 5120,
122
- "height": 1440,
123
- },
124
- "available_virtual_geometry": {
125
- "x": 0,
126
- "y": 0,
127
- "width": 5120,
128
- "height": 1400,
129
- },
130
- "available_virtual_size": {
131
- "width": 5120,
132
- "height": 1400,
133
- },
134
- "physical_size": {
135
- "width": 600,
136
- "height": 340,
137
- },
138
- "depth": 24,
139
- "device_pixel_ratio": 1.0,
140
- "logical_dots_per_inch": 96.0,
141
- "logical_dots_per_inch_x": 96.0,
142
- "logical_dots_per_inch_y": 96.0,
143
- "orientation": "Landscape",
144
- "physical_dots_per_inch": 109.0,
145
- "physical_dots_per_inch_x": 109.0,
146
- "physical_dots_per_inch_y": 109.0,
147
- "refresh_rate": 60.0,
148
- }
149
- ```
150
- """
151
- monitor = self.screen
152
-
153
- monitor_data = {
154
- "index": self.index,
155
- "name": monitor.name(),
156
- "manufacturer": monitor.manufacturer(),
157
- "model": monitor.model(),
158
- "serial_number": monitor.serialNumber(),
159
- "x": monitor.geometry().x(),
160
- "y": monitor.geometry().y(),
161
- "width": monitor.size().width(),
162
- "height": monitor.size().height(),
163
- "is_primary": self.is_primary(),
164
- "geometry": {
165
- "x": monitor.geometry().x(),
166
- "y": monitor.geometry().y(),
167
- "width": monitor.geometry().width(),
168
- "height": monitor.geometry().height(),
169
- },
170
- "size": {
171
- "width": monitor.size().width(),
172
- "height": monitor.size().height(),
173
- },
174
- "available_geometry": {
175
- "x": monitor.availableGeometry().x(),
176
- "y": monitor.availableGeometry().y(),
177
- "width": monitor.availableGeometry().width(),
178
- "height": monitor.availableGeometry().height(),
179
- },
180
- "available_size": {
181
- "width": monitor.availableSize().width(),
182
- "height": monitor.availableSize().height(),
183
- },
184
- "virtual_geometry":{
185
- "x": monitor.virtualGeometry().x(),
186
- "y": monitor.virtualGeometry().y(),
187
- "width": monitor.virtualGeometry().width(),
188
- "height": monitor.virtualGeometry().height(),
189
- },
190
- "virtual_size": {
191
- "width": monitor.virtualSize().width(),
192
- "height": monitor.virtualSize().height(),
193
- },
194
- "available_virtual_geometry": {
195
- "x": monitor.availableVirtualGeometry().x(),
196
- "y": monitor.availableVirtualGeometry().y(),
197
- "width": monitor.availableVirtualGeometry().width(),
198
- "height": monitor.availableVirtualGeometry().height(),
199
- },
200
- "available_virtual_size": {
201
- "width": monitor.availableVirtualSize().width(),
202
- "height": monitor.availableVirtualSize().height(),
203
- },
204
- "physical_size": {
205
- "width": monitor.physicalSize().width(),
206
- "height": monitor.physicalSize().height(),
207
- },
208
- "depth": monitor.depth(),
209
- "device_pixel_ratio": monitor.devicePixelRatio(),
210
- "logical_dots_per_inch": monitor.logicalDotsPerInch(),
211
- "logical_dots_per_inch_x": monitor.logicalDotsPerInchX(),
212
- "logical_dots_per_inch_y": monitor.logicalDotsPerInchY(),
213
- "orientation": monitor.orientation().name,
214
- "physical_dots_per_inch": monitor.physicalDotsPerInch(),
215
- "physical_dots_per_inch_x": monitor.physicalDotsPerInchX(),
216
- "physical_dots_per_inch_y": monitor.physicalDotsPerInchY(),
217
- "refresh_rate": monitor.refreshRate(),
218
- }
219
-
220
- return monitor_data
221
-
222
- def is_primary(self) -> bool:
223
- """
224
- Checks if the monitor is the primary monitor.
225
-
226
- Returns
227
- -------
228
- bool
229
- Returns True if the monitor is the primary monitor, otherwise False.
230
-
231
- Examples
232
- --------
233
- ```python
234
- app = Pyloid("Pyloid-App")
235
-
236
- monitor = app.get_all_monitors()[1]
237
- is_primary = monitor.is_primary()
238
- print(f"Is primary monitor: {is_primary}") # False
239
- ```
240
- """
241
- return self.index == 0
242
-
243
- def size(self) -> dict[str, int]:
244
- """
245
- Returns the size of the monitor.
246
-
247
- Returns
248
- -------
249
- dict[str, int]
250
- A dictionary containing the width and height of the monitor.
251
-
252
- Examples
253
- --------
254
- ```python
255
- app = Pyloid("Pyloid-App")
256
-
257
- monitor = app.get_primary_monitor()
258
- size = monitor.size()
259
- print("Monitor Size:", size)
260
- ```
261
- """
262
- monitor = self.screen
263
- return {
264
- "width": monitor.size().width(),
265
- "height": monitor.size().height(),
266
- },
267
-
268
- def geometry(self) -> dict[str, int]:
269
- """
270
- Returns the geometry of the monitor.
271
-
272
- Returns
273
- -------
274
- dict[str, int]
275
- A dictionary containing the x and y coordinates, width, and height of the monitor.
276
-
277
- Examples
278
- --------
279
- ```python
280
- app = Pyloid("Pyloid-App")
281
-
282
- monitor = app.get_primary_monitor()
283
- geometry = monitor.geometry()
284
- print("Monitor Geometry:", geometry)
285
- ```
286
- """
287
- monitor = self.screen
288
- return {
289
- "x": monitor.geometry().x(),
290
- "y": monitor.geometry().y(),
291
- "width": monitor.geometry().width(),
292
- "height": monitor.geometry().height(),
293
- }
294
-
295
- def available_geometry(self) -> dict[str, int]:
296
- """
297
- Returns the available geometry of the monitor.
298
-
299
- The available geometry refers to the portion of the monitor's geometry that is not occupied by system UI elements such as taskbars or docks.
300
-
301
- Returns
302
- -------
303
- dict[str, int]
304
- A dictionary containing the x and y coordinates, width, and height of the available geometry.
305
-
306
- Examples
307
- --------
308
- ```python
309
- app = Pyloid("Pyloid-App")
310
-
311
- monitor = app.get_primary_monitor()
312
- available_geometry = monitor.available_geometry()
313
- print("Available Geometry:", available_geometry)
314
- ```
315
- """
316
- monitor = self.screen
317
- return {
318
- "x": monitor.availableGeometry().x(),
319
- "y": monitor.availableGeometry().y(),
320
- "width": monitor.availableGeometry().width(),
321
- "height": monitor.availableGeometry().height(),
322
- }
323
-
324
- def available_size(self) -> dict[str, int]:
325
- """
326
- Returns the available size of the monitor.
327
-
328
- The available size refers to the portion of the monitor's size that is not occupied by system UI elements such as taskbars or docks.
329
-
330
- Returns
331
- -------
332
- dict[str, int]
333
- A dictionary containing the width and height of the available size.
334
-
335
- Examples
336
- --------
337
- ```python
338
- app = Pyloid("Pyloid-App")
339
-
340
- monitor = app.get_primary_monitor()
341
- available_size = monitor.available_size()
342
- print("Available Size:", available_size)
343
- ```
344
- """
345
- monitor = self.screen
346
- return {
347
- "width": monitor.availableSize().width(),
348
- "height": monitor.availableSize().height(),
349
- }
350
-
351
- def virtual_geometry(self) -> dict[str, int]:
352
- """
353
- Returns the virtual geometry of the monitor.
354
-
355
- The virtual geometry refers to the combined geometry of all monitors in a multi-monitor setup.
356
-
357
- Returns
358
- -------
359
- dict[str, int]
360
- A dictionary containing the x and y coordinates, width, and height of the virtual geometry.
361
-
362
- Examples
363
- --------
364
- ```python
365
- app = Pyloid("Pyloid-App")
366
-
367
- monitor = app.get_primary_monitor()
368
- virtual_geometry = monitor.virtual_geometry()
369
- print("Virtual Geometry:", virtual_geometry)
370
- ```
371
- """
372
- monitor = self.screen
373
- return {
374
- "x": monitor.virtualGeometry().x(),
375
- "y": monitor.virtualGeometry().y(),
376
- "width": monitor.virtualGeometry().width(),
377
- "height": monitor.virtualGeometry().height(),
378
- }
379
-
380
- def virtual_size(self) -> dict[str, int]:
381
- """
382
- Returns the virtual size of the monitor.
383
-
384
- The virtual size refers to the combined size of all monitors in a multi-monitor setup.
385
-
386
- Returns
387
- -------
388
- dict[str, int]
389
- A dictionary containing the width and height of the virtual size.
390
-
391
- Examples
392
- --------
393
- ```python
394
- app = Pyloid("Pyloid-App")
395
-
396
- monitor = app.get_primary_monitor()
397
- virtual_size = monitor.virtual_size()
398
- print("Virtual Size:", virtual_size)
399
- ```
400
- """
401
- monitor = self.screen
402
- return {
403
- "width": monitor.virtualSize().width(),
404
- "height": monitor.virtualSize().height(),
405
- }
406
-
407
- def available_virtual_geometry(self) -> dict[str, int]:
408
- """
409
- Returns the available virtual geometry of the monitor.
410
-
411
- The available virtual geometry refers to the portion of the virtual geometry that is not occupied by system UI elements such as taskbars or docks.
412
-
413
- Returns
414
- -------
415
- dict[str, int]
416
- A dictionary containing the x and y coordinates, width, and height of the available virtual geometry.
417
-
418
- Examples
419
- --------
420
- ```python
421
- app = Pyloid("Pyloid-App")
422
-
423
- monitor = app.get_primary_monitor()
424
- available_virtual_geometry = monitor.available_virtual_geometry()
425
- print("Available Virtual Geometry:", available_virtual_geometry)
426
- ```
427
- """
428
- monitor = self.screen
429
- return {
430
- "x": monitor.availableVirtualGeometry().x(),
431
- "y": monitor.availableVirtualGeometry().y(),
432
- "width": monitor.availableVirtualGeometry().width(),
433
- "height": monitor.availableVirtualGeometry().height(),
434
- }
435
-
436
- def available_virtual_size(self) -> dict[str, int]:
437
- """
438
- Returns the available virtual size of the monitor.
439
-
440
- The available virtual size refers to the portion of the virtual size that is not occupied by system UI elements such as taskbars or docks.
441
-
442
- Returns
443
- -------
444
- dict[str, int]
445
- A dictionary containing the width and height of the available virtual size.
446
-
447
- Examples
448
- --------
449
- ```python
450
- app = Pyloid("Pyloid-App")
451
-
452
- monitor = app.get_primary_monitor()
453
- available_virtual_size = monitor.available_virtual_size()
454
- print("Available Virtual Size:", available_virtual_size)
455
- ```
456
- """
457
- monitor = self.screen
458
- return {
459
- "width": monitor.availableVirtualSize().width(),
460
- "height": monitor.availableVirtualSize().height(),
461
- }
462
-
463
- def physical_size(self) -> dict[str, float]:
464
- """
465
- Returns the physical size of the monitor.
466
-
467
- The physical size refers to the actual physical dimensions of the monitor.
468
-
469
- Returns
470
- -------
471
- dict[str, float]
472
- A dictionary containing the width and height of the physical size.
473
-
474
- Examples
475
- --------
476
- ```python
477
- app = Pyloid("Pyloid-App")
478
-
479
- monitor = app.get_primary_monitor()
480
- physical_size = monitor.physical_size()
481
- print("Physical Size:", physical_size)
482
- ```
483
- """
484
- monitor = self.screen
485
- return {
486
- "width": monitor.physicalSize().width(),
487
- "height": monitor.physicalSize().height(),
488
- }
489
-
490
- def depth(self) -> int:
491
- """
492
- Returns the depth of the monitor.
493
-
494
- The depth refers to the color depth of the monitor, which is the number of bits used to represent the color of a single pixel.
495
-
496
- Returns
497
- -------
498
- int
499
- The color depth of the monitor.
500
-
501
- Examples
502
- --------
503
- ```python
504
- app = Pyloid("Pyloid-App")
505
-
506
- monitor = app.get_primary_monitor()
507
- depth = monitor.depth()
508
- print("Color Depth:", depth)
509
- ```
510
- """
511
- monitor = self.screen
512
- return monitor.depth()
513
-
514
- def device_pixel_ratio(self) -> float:
515
- """
516
- Returns the device pixel ratio of the monitor.
517
-
518
- The device pixel ratio is the ratio between physical pixels and device-independent pixels (DIPs).
519
-
520
- Returns
521
- -------
522
- float
523
- The device pixel ratio of the monitor.
524
-
525
- Examples
526
- --------
527
- ```python
528
- app = Pyloid("Pyloid-App")
529
-
530
- monitor = app.get_primary_monitor()
531
- device_pixel_ratio = monitor.device_pixel_ratio()
532
- print("Device Pixel Ratio:", device_pixel_ratio)
533
- ```
534
- """
535
- monitor = self.screen
536
- return monitor.devicePixelRatio()
537
-
538
- def logical_dots_per_inch(self) -> float:
539
- """
540
- Returns the logical dots per inch (DPI) of the monitor.
541
-
542
- The logical DPI is the number of device-independent pixels (DIPs) per inch.
543
-
544
- Returns
545
- -------
546
- float
547
- The logical DPI of the monitor.
548
-
549
- Examples
550
- --------
551
- ```python
552
- app = Pyloid("Pyloid-App")
553
-
554
- monitor = app.get_primary_monitor()
555
- logical_dpi = monitor.logical_dots_per_inch()
556
- print("Logical DPI:", logical_dpi)
557
- ```
558
- """
559
- monitor = self.screen
560
- return monitor.logicalDotsPerInch()
561
-
562
- def logical_dots_per_inch_x(self) -> float:
563
- """
564
- Returns the logical dots per inch (DPI) along the X axis of the monitor.
565
-
566
- The logical DPI along the X axis is the number of device-independent pixels (DIPs) per inch along the horizontal axis.
567
-
568
- Returns
569
- -------
570
- float
571
- The logical DPI along the X axis of the monitor.
572
-
573
- Examples
574
- --------
575
- ```python
576
- app = Pyloid("Pyloid-App")
577
-
578
- monitor = app.get_primary_monitor()
579
- logical_dpi_x = monitor.logical_dots_per_inch_x()
580
- print("Logical DPI X:", logical_dpi_x)
581
- ```
582
- """
583
- monitor = self.screen
584
- return monitor.logicalDotsPerInchX()
585
-
586
- def logical_dots_per_inch_y(self) -> float:
587
- """
588
- Returns the logical dots per inch (DPI) along the Y axis of the monitor.
589
-
590
- The logical DPI along the Y axis is the number of device-independent pixels (DIPs) per inch along the vertical axis.
591
-
592
- Returns
593
- -------
594
- float
595
- The logical DPI along the Y axis of the monitor.
596
-
597
- Examples
598
- --------
599
- ```python
600
- app = Pyloid("Pyloid-App")
601
-
602
- monitor = app.get_primary_monitor()
603
- logical_dpi_y = monitor.logical_dots_per_inch_y()
604
- print("Logical DPI Y:", logical_dpi_y)
605
- ```
606
- """
607
- monitor = self.screen
608
- return monitor.logicalDotsPerInchY()
609
-
610
- def orientation(self) -> str:
611
- """
612
- Returns the orientation of the monitor.
613
-
614
- The orientation refers to the current orientation of the monitor, such as landscape or portrait.
615
-
616
- Returns
617
- -------
618
- str
619
- The orientation of the monitor.
620
-
621
- Examples
622
- --------
623
- ```python
624
- app = Pyloid("Pyloid-App")
625
-
626
- monitor = app.get_primary_monitor()
627
- orientation = monitor.orientation()
628
- print("Orientation:", orientation)
629
- ```
630
- """
631
- monitor = self.screen
632
- return monitor.orientation().name
633
-
634
- def physical_dots_per_inch(self) -> float:
635
- """
636
- Returns the physical dots per inch (DPI) of the monitor.
637
-
638
- The physical DPI is the number of physical pixels per inch.
639
-
640
- Returns
641
- -------
642
- float
643
- The physical DPI of the monitor.
644
-
645
- Examples
646
- --------
647
- ```python
648
- app = Pyloid("Pyloid-App")
649
-
650
- monitor = app.get_primary_monitor()
651
- physical_dpi = monitor.physical_dots_per_inch()
652
- print("Physical DPI:", physical_dpi)
653
- ```
654
- """
655
- monitor = self.screen
656
- return monitor.physicalDotsPerInch()
657
-
658
- def physical_dots_per_inch_x(self) -> float:
659
- """
660
- Returns the physical dots per inch (DPI) along the X axis of the monitor.
661
-
662
- The physical DPI along the X axis is the number of physical pixels per inch along the horizontal axis.
663
-
664
- Returns
665
- -------
666
- float
667
- The physical DPI along the X axis of the monitor.
668
-
669
- Examples
670
- --------
671
- ```python
672
- app = Pyloid("Pyloid-App")
673
-
674
- monitor = app.get_primary_monitor()
675
- physical_dpi_x = monitor.physical_dots_per_inch_x()
676
- print("Physical DPI X:", physical_dpi_x)
677
- ```
678
- """
679
- monitor = self.screen
680
- return monitor.physicalDotsPerInchX()
681
-
682
- def physical_dots_per_inch_y(self) -> float:
683
- """
684
- Returns the physical dots per inch (DPI) along the Y axis of the monitor.
685
-
686
- The physical DPI along the Y axis is the number of physical pixels per inch along the vertical axis.
687
-
688
- Returns
689
- -------
690
- float
691
- The physical DPI along the Y axis of the monitor.
692
-
693
- Examples
694
- --------
695
- ```python
696
- app = Pyloid("Pyloid-App")
697
-
698
- monitor = app.get_primary_monitor()
699
- physical_dpi_y = monitor.physical_dots_per_inch_y()
700
- print("Physical DPI Y:", physical_dpi_y)
701
- ```
702
- """
703
- monitor = self.screen
704
- return monitor.physicalDotsPerInchY()
705
-
706
- def refresh_rate(self) -> float:
707
- """
708
- Returns the refresh rate of the monitor.
709
-
710
- The refresh rate is the number of times the monitor updates with new information per second, measured in Hertz (Hz).
711
-
712
- Returns
713
- -------
714
- float
715
- The refresh rate of the monitor.
716
-
717
- Examples
718
- --------
719
- ```python
720
- app = Pyloid("Pyloid-App")
721
-
722
- monitor = app.get_primary_monitor()
723
- refresh_rate = monitor.refresh_rate()
724
- print("Refresh Rate:", refresh_rate)
725
- ```
726
- """
727
- monitor = self.screen
728
- return monitor.refreshRate()
729
-
730
- def manufacturer(self) -> str:
731
- """
732
- Returns the manufacturer of the monitor.
733
-
734
- The manufacturer refers to the company that produced the monitor.
735
-
736
- Returns
737
- -------
738
- str
739
- The manufacturer of the monitor.
740
-
741
- Examples
742
- --------
743
- ```python
744
- app = Pyloid("Pyloid-App")
745
-
746
- monitor = app.get_primary_monitor()
747
- manufacturer = monitor.manufacturer()
748
- print("Manufacturer:", manufacturer)
749
- ```
750
- """
751
- monitor = self.screen
752
- return monitor.manufacturer()
753
-
754
- def model(self) -> str:
755
- """
756
- Returns the model of the monitor.
757
-
758
- The model refers to the specific model name or number assigned by the manufacturer.
759
-
760
- Returns
761
- -------
762
- str
763
- The model of the monitor.
764
-
765
- Examples
766
- --------
767
- ```python
768
- app = Pyloid("Pyloid-App")
769
-
770
- monitor = app.get_primary_monitor()
771
- model = monitor.model()
772
- print("Model:", model)
773
- ```
774
- """
775
- monitor = self.screen
776
- return monitor.model()
777
-
778
- def name(self) -> str:
779
- """
780
- Returns the name of the monitor.
781
-
782
- The name refers to the user-friendly name assigned to the monitor.
783
-
784
- Returns
785
- -------
786
- str
787
- The name of the monitor.
788
-
789
- Examples
790
- --------
791
- ```python
792
- app = Pyloid("Pyloid-App")
793
-
794
- monitor = app.get_primary_monitor()
795
- name = monitor.name()
796
- print("Name:", name)
797
- ```
798
- """
799
- monitor = self.screen
800
- return monitor.name()
801
-
802
- def serial_number(self) -> str:
803
- """
804
- Returns the serial number of the monitor.
805
-
806
- The serial number is a unique identifier assigned to the monitor by the manufacturer.
807
-
808
- Returns
809
- -------
810
- str
811
- The serial number of the monitor.
812
-
813
- Examples
814
- --------
815
- ```python
816
- app = Pyloid("Pyloid-App")
817
-
818
- monitor = app.get_primary_monitor()
819
- serial_number = monitor.serial_number()
820
- print("Serial Number:", serial_number)
821
- ```
822
- """
823
- monitor = self.screen
824
- return monitor.serialNumber()
825
-
826
- def geometry_changed(self, callback: Callable):
827
- """
828
- Registers a callback for the event that occurs when the geometry of the monitor changes.
829
-
830
- Parameters
831
- ----------
832
- callback : Callable
833
- The function to be called when the geometry changes.
834
-
835
- Examples
836
- --------
837
- ```python
838
- app = Pyloid("Pyloid-App")
839
-
840
- def on_geometry_changed():
841
- print("Geometry changed!")
842
-
843
- monitor = app.get_primary_monitor()
844
- monitor.geometry_changed(on_geometry_changed)
845
- ```
846
- """
847
- monitor = self.screen
848
- monitor.geometryChanged.connect(callback)
849
-
850
- def orientation_changed(self, callback: Callable):
851
- """
852
- Registers a callback for the event that occurs when the orientation of the monitor changes.
853
-
854
- Parameters
855
- ----------
856
- callback : Callable
857
- The function to be called when the orientation changes.
858
-
859
- Examples
860
- --------
861
- ```python
862
- app = Pyloid("Pyloid-App")
863
-
864
- def on_orientation_changed():
865
- print("Orientation changed!")
866
-
867
- monitor = app.get_primary_monitor()
868
- monitor.orientation_changed(on_orientation_changed)
869
- ```
870
- """
871
- monitor = self.screen
872
- monitor.orientationChanged.connect(callback)
873
-
874
- def refresh_rate_changed(self, callback: Callable):
875
- """
876
- Registers a callback for the event that occurs when the refresh rate of the monitor changes.
877
-
878
- Parameters
879
- ----------
880
- callback : Callable
881
- The function to be called when the refresh rate changes.
882
-
883
- Examples
884
- --------
885
- ```python
886
- app = Pyloid("Pyloid-App")
887
-
888
- def on_refresh_rate_changed():
889
- print("Refresh rate changed!")
890
-
891
- monitor = app.get_primary_monitor()
892
- monitor.refresh_rate_changed(on_refresh_rate_changed)
893
- ```
894
- """
895
- monitor = self.screen
896
- monitor.refreshRateChanged.connect(callback)
897
-
898
- def virtual_geometry_changed(self, callback: Callable):
899
- """
900
- Registers a callback for the event that occurs when the virtual geometry of the monitor changes.
901
-
902
- Parameters
903
- ----------
904
- callback : Callable
905
- The function to be called when the virtual geometry changes.
906
-
907
- Examples
908
- --------
909
- ```python
910
- app = Pyloid("Pyloid-App")
911
-
912
- def on_virtual_geometry_changed():
913
- print("Virtual geometry changed!")
914
-
915
- monitor = app.get_primary_monitor()
916
- monitor.virtual_geometry_changed(on_virtual_geometry_changed)
917
- ```
918
- """
919
- monitor = self.screen
920
- monitor.virtualGeometryChanged.connect(callback)
921
-
1
+ from PySide6.QtGui import QScreen
2
+ from typing import Optional, Callable, Any
3
+
4
+ class Monitor():
5
+ def __init__(self, index: int, screen: QScreen):
6
+ """
7
+ Constructor for the Monitor class.
8
+
9
+ Parameters
10
+ ----------
11
+ index : int
12
+ Index of the monitor.
13
+ screen : QScreen
14
+ QScreen object of the monitor.
15
+ """
16
+ super().__init__()
17
+ self.index = index
18
+ self.screen = screen
19
+
20
+ def capture(self, save_path: str, x: Optional[int] = None, y: Optional[int] = None, width: Optional[int] = None, height: Optional[int] = None):
21
+ """
22
+ Captures the entire desktop screen.
23
+
24
+ Parameters
25
+ ----------
26
+ save_path : str
27
+ Path to save the captured image. If not specified, it will be saved in the current directory.
28
+ x : int, optional
29
+ x-coordinate of the area to capture. Default is None.
30
+ y : int, optional
31
+ y-coordinate of the area to capture. Default is None.
32
+ width : int, optional
33
+ Width of the area to capture. Default is None.
34
+ height : int, optional
35
+ Height of the area to capture. Default is None.
36
+
37
+ Returns
38
+ -------
39
+ str or None
40
+ Returns the path of the saved image. Returns None if an error occurs.
41
+
42
+ Examples
43
+ --------
44
+ ```python
45
+ app = Pyloid("Pyloid-App")
46
+
47
+ monitor = app.get_primary_monitor()
48
+ save_path = monitor.capture("screenshot.png")
49
+ print(f"Screenshot saved at: {save_path}")
50
+ ```
51
+ """
52
+ try:
53
+ screenshot = self.screen.grabWindow(0, x, y, width, height)
54
+ screenshot.save(save_path)
55
+ return save_path
56
+
57
+ except Exception as e:
58
+ print(f"Error occurred while capturing the desktop: {e}")
59
+ return None
60
+
61
+ def info(self) -> dict[str, Any]:
62
+ """
63
+ Returns information about the monitor.
64
+
65
+ Returns
66
+ -------
67
+ dict[str, Any]
68
+ A dictionary containing monitor information.
69
+
70
+ Examples
71
+ --------
72
+ ```python
73
+ app = Pyloid("Pyloid-App")
74
+
75
+ monitor = app.get_primary_monitor()
76
+ info = monitor.info()
77
+ print("Monitor Info:", info)
78
+ ```
79
+
80
+ Output Example
81
+ --------------
82
+ ```
83
+ {
84
+ "index": 0,
85
+ "name": "Primary Monitor",
86
+ "manufacturer": "Dell",
87
+ "model": "U2718Q",
88
+ "serial_number": "SN123456789",
89
+ "x": 0,
90
+ "y": 0,
91
+ "width": 2560,
92
+ "height": 1440,
93
+ "is_primary": True,
94
+ "geometry": {
95
+ "x": 0,
96
+ "y": 0,
97
+ "width": 2560,
98
+ "height": 1440,
99
+ },
100
+ "size": {
101
+ "width": 2560,
102
+ "height": 1440,
103
+ },
104
+ "available_geometry": {
105
+ "x": 0,
106
+ "y": 0,
107
+ "width": 2560,
108
+ "height": 1400,
109
+ },
110
+ "available_size": {
111
+ "width": 2560,
112
+ "height": 1400,
113
+ },
114
+ "virtual_geometry":{
115
+ "x": 0,
116
+ "y": 0,
117
+ "width": 5120,
118
+ "height": 1440,
119
+ },
120
+ "virtual_size": {
121
+ "width": 5120,
122
+ "height": 1440,
123
+ },
124
+ "available_virtual_geometry": {
125
+ "x": 0,
126
+ "y": 0,
127
+ "width": 5120,
128
+ "height": 1400,
129
+ },
130
+ "available_virtual_size": {
131
+ "width": 5120,
132
+ "height": 1400,
133
+ },
134
+ "physical_size": {
135
+ "width": 600,
136
+ "height": 340,
137
+ },
138
+ "depth": 24,
139
+ "device_pixel_ratio": 1.0,
140
+ "logical_dots_per_inch": 96.0,
141
+ "logical_dots_per_inch_x": 96.0,
142
+ "logical_dots_per_inch_y": 96.0,
143
+ "orientation": "Landscape",
144
+ "physical_dots_per_inch": 109.0,
145
+ "physical_dots_per_inch_x": 109.0,
146
+ "physical_dots_per_inch_y": 109.0,
147
+ "refresh_rate": 60.0,
148
+ }
149
+ ```
150
+ """
151
+ monitor = self.screen
152
+
153
+ monitor_data = {
154
+ "index": self.index,
155
+ "name": monitor.name(),
156
+ "manufacturer": monitor.manufacturer(),
157
+ "model": monitor.model(),
158
+ "serial_number": monitor.serialNumber(),
159
+ "x": monitor.geometry().x(),
160
+ "y": monitor.geometry().y(),
161
+ "width": monitor.size().width(),
162
+ "height": monitor.size().height(),
163
+ "is_primary": self.is_primary(),
164
+ "geometry": {
165
+ "x": monitor.geometry().x(),
166
+ "y": monitor.geometry().y(),
167
+ "width": monitor.geometry().width(),
168
+ "height": monitor.geometry().height(),
169
+ },
170
+ "size": {
171
+ "width": monitor.size().width(),
172
+ "height": monitor.size().height(),
173
+ },
174
+ "available_geometry": {
175
+ "x": monitor.availableGeometry().x(),
176
+ "y": monitor.availableGeometry().y(),
177
+ "width": monitor.availableGeometry().width(),
178
+ "height": monitor.availableGeometry().height(),
179
+ },
180
+ "available_size": {
181
+ "width": monitor.availableSize().width(),
182
+ "height": monitor.availableSize().height(),
183
+ },
184
+ "virtual_geometry":{
185
+ "x": monitor.virtualGeometry().x(),
186
+ "y": monitor.virtualGeometry().y(),
187
+ "width": monitor.virtualGeometry().width(),
188
+ "height": monitor.virtualGeometry().height(),
189
+ },
190
+ "virtual_size": {
191
+ "width": monitor.virtualSize().width(),
192
+ "height": monitor.virtualSize().height(),
193
+ },
194
+ "available_virtual_geometry": {
195
+ "x": monitor.availableVirtualGeometry().x(),
196
+ "y": monitor.availableVirtualGeometry().y(),
197
+ "width": monitor.availableVirtualGeometry().width(),
198
+ "height": monitor.availableVirtualGeometry().height(),
199
+ },
200
+ "available_virtual_size": {
201
+ "width": monitor.availableVirtualSize().width(),
202
+ "height": monitor.availableVirtualSize().height(),
203
+ },
204
+ "physical_size": {
205
+ "width": monitor.physicalSize().width(),
206
+ "height": monitor.physicalSize().height(),
207
+ },
208
+ "depth": monitor.depth(),
209
+ "device_pixel_ratio": monitor.devicePixelRatio(),
210
+ "logical_dots_per_inch": monitor.logicalDotsPerInch(),
211
+ "logical_dots_per_inch_x": monitor.logicalDotsPerInchX(),
212
+ "logical_dots_per_inch_y": monitor.logicalDotsPerInchY(),
213
+ "orientation": monitor.orientation().name,
214
+ "physical_dots_per_inch": monitor.physicalDotsPerInch(),
215
+ "physical_dots_per_inch_x": monitor.physicalDotsPerInchX(),
216
+ "physical_dots_per_inch_y": monitor.physicalDotsPerInchY(),
217
+ "refresh_rate": monitor.refreshRate(),
218
+ }
219
+
220
+ return monitor_data
221
+
222
+ def is_primary(self) -> bool:
223
+ """
224
+ Checks if the monitor is the primary monitor.
225
+
226
+ Returns
227
+ -------
228
+ bool
229
+ Returns True if the monitor is the primary monitor, otherwise False.
230
+
231
+ Examples
232
+ --------
233
+ ```python
234
+ app = Pyloid("Pyloid-App")
235
+
236
+ monitor = app.get_all_monitors()[1]
237
+ is_primary = monitor.is_primary()
238
+ print(f"Is primary monitor: {is_primary}") # False
239
+ ```
240
+ """
241
+ return self.index == 0
242
+
243
+ def size(self) -> dict[str, int]:
244
+ """
245
+ Returns the size of the monitor.
246
+
247
+ Returns
248
+ -------
249
+ dict[str, int]
250
+ A dictionary containing the width and height of the monitor.
251
+
252
+ Examples
253
+ --------
254
+ ```python
255
+ app = Pyloid("Pyloid-App")
256
+
257
+ monitor = app.get_primary_monitor()
258
+ size = monitor.size()
259
+ print("Monitor Size:", size)
260
+ ```
261
+ """
262
+ monitor = self.screen
263
+ return {
264
+ "width": monitor.size().width(),
265
+ "height": monitor.size().height(),
266
+ },
267
+
268
+ def geometry(self) -> dict[str, int]:
269
+ """
270
+ Returns the geometry of the monitor.
271
+
272
+ Returns
273
+ -------
274
+ dict[str, int]
275
+ A dictionary containing the x and y coordinates, width, and height of the monitor.
276
+
277
+ Examples
278
+ --------
279
+ ```python
280
+ app = Pyloid("Pyloid-App")
281
+
282
+ monitor = app.get_primary_monitor()
283
+ geometry = monitor.geometry()
284
+ print("Monitor Geometry:", geometry)
285
+ ```
286
+ """
287
+ monitor = self.screen
288
+ return {
289
+ "x": monitor.geometry().x(),
290
+ "y": monitor.geometry().y(),
291
+ "width": monitor.geometry().width(),
292
+ "height": monitor.geometry().height(),
293
+ }
294
+
295
+ def available_geometry(self) -> dict[str, int]:
296
+ """
297
+ Returns the available geometry of the monitor.
298
+
299
+ The available geometry refers to the portion of the monitor's geometry that is not occupied by system UI elements such as taskbars or docks.
300
+
301
+ Returns
302
+ -------
303
+ dict[str, int]
304
+ A dictionary containing the x and y coordinates, width, and height of the available geometry.
305
+
306
+ Examples
307
+ --------
308
+ ```python
309
+ app = Pyloid("Pyloid-App")
310
+
311
+ monitor = app.get_primary_monitor()
312
+ available_geometry = monitor.available_geometry()
313
+ print("Available Geometry:", available_geometry)
314
+ ```
315
+ """
316
+ monitor = self.screen
317
+ return {
318
+ "x": monitor.availableGeometry().x(),
319
+ "y": monitor.availableGeometry().y(),
320
+ "width": monitor.availableGeometry().width(),
321
+ "height": monitor.availableGeometry().height(),
322
+ }
323
+
324
+ def available_size(self) -> dict[str, int]:
325
+ """
326
+ Returns the available size of the monitor.
327
+
328
+ The available size refers to the portion of the monitor's size that is not occupied by system UI elements such as taskbars or docks.
329
+
330
+ Returns
331
+ -------
332
+ dict[str, int]
333
+ A dictionary containing the width and height of the available size.
334
+
335
+ Examples
336
+ --------
337
+ ```python
338
+ app = Pyloid("Pyloid-App")
339
+
340
+ monitor = app.get_primary_monitor()
341
+ available_size = monitor.available_size()
342
+ print("Available Size:", available_size)
343
+ ```
344
+ """
345
+ monitor = self.screen
346
+ return {
347
+ "width": monitor.availableSize().width(),
348
+ "height": monitor.availableSize().height(),
349
+ }
350
+
351
+ def virtual_geometry(self) -> dict[str, int]:
352
+ """
353
+ Returns the virtual geometry of the monitor.
354
+
355
+ The virtual geometry refers to the combined geometry of all monitors in a multi-monitor setup.
356
+
357
+ Returns
358
+ -------
359
+ dict[str, int]
360
+ A dictionary containing the x and y coordinates, width, and height of the virtual geometry.
361
+
362
+ Examples
363
+ --------
364
+ ```python
365
+ app = Pyloid("Pyloid-App")
366
+
367
+ monitor = app.get_primary_monitor()
368
+ virtual_geometry = monitor.virtual_geometry()
369
+ print("Virtual Geometry:", virtual_geometry)
370
+ ```
371
+ """
372
+ monitor = self.screen
373
+ return {
374
+ "x": monitor.virtualGeometry().x(),
375
+ "y": monitor.virtualGeometry().y(),
376
+ "width": monitor.virtualGeometry().width(),
377
+ "height": monitor.virtualGeometry().height(),
378
+ }
379
+
380
+ def virtual_size(self) -> dict[str, int]:
381
+ """
382
+ Returns the virtual size of the monitor.
383
+
384
+ The virtual size refers to the combined size of all monitors in a multi-monitor setup.
385
+
386
+ Returns
387
+ -------
388
+ dict[str, int]
389
+ A dictionary containing the width and height of the virtual size.
390
+
391
+ Examples
392
+ --------
393
+ ```python
394
+ app = Pyloid("Pyloid-App")
395
+
396
+ monitor = app.get_primary_monitor()
397
+ virtual_size = monitor.virtual_size()
398
+ print("Virtual Size:", virtual_size)
399
+ ```
400
+ """
401
+ monitor = self.screen
402
+ return {
403
+ "width": monitor.virtualSize().width(),
404
+ "height": monitor.virtualSize().height(),
405
+ }
406
+
407
+ def available_virtual_geometry(self) -> dict[str, int]:
408
+ """
409
+ Returns the available virtual geometry of the monitor.
410
+
411
+ The available virtual geometry refers to the portion of the virtual geometry that is not occupied by system UI elements such as taskbars or docks.
412
+
413
+ Returns
414
+ -------
415
+ dict[str, int]
416
+ A dictionary containing the x and y coordinates, width, and height of the available virtual geometry.
417
+
418
+ Examples
419
+ --------
420
+ ```python
421
+ app = Pyloid("Pyloid-App")
422
+
423
+ monitor = app.get_primary_monitor()
424
+ available_virtual_geometry = monitor.available_virtual_geometry()
425
+ print("Available Virtual Geometry:", available_virtual_geometry)
426
+ ```
427
+ """
428
+ monitor = self.screen
429
+ return {
430
+ "x": monitor.availableVirtualGeometry().x(),
431
+ "y": monitor.availableVirtualGeometry().y(),
432
+ "width": monitor.availableVirtualGeometry().width(),
433
+ "height": monitor.availableVirtualGeometry().height(),
434
+ }
435
+
436
+ def available_virtual_size(self) -> dict[str, int]:
437
+ """
438
+ Returns the available virtual size of the monitor.
439
+
440
+ The available virtual size refers to the portion of the virtual size that is not occupied by system UI elements such as taskbars or docks.
441
+
442
+ Returns
443
+ -------
444
+ dict[str, int]
445
+ A dictionary containing the width and height of the available virtual size.
446
+
447
+ Examples
448
+ --------
449
+ ```python
450
+ app = Pyloid("Pyloid-App")
451
+
452
+ monitor = app.get_primary_monitor()
453
+ available_virtual_size = monitor.available_virtual_size()
454
+ print("Available Virtual Size:", available_virtual_size)
455
+ ```
456
+ """
457
+ monitor = self.screen
458
+ return {
459
+ "width": monitor.availableVirtualSize().width(),
460
+ "height": monitor.availableVirtualSize().height(),
461
+ }
462
+
463
+ def physical_size(self) -> dict[str, float]:
464
+ """
465
+ Returns the physical size of the monitor.
466
+
467
+ The physical size refers to the actual physical dimensions of the monitor.
468
+
469
+ Returns
470
+ -------
471
+ dict[str, float]
472
+ A dictionary containing the width and height of the physical size.
473
+
474
+ Examples
475
+ --------
476
+ ```python
477
+ app = Pyloid("Pyloid-App")
478
+
479
+ monitor = app.get_primary_monitor()
480
+ physical_size = monitor.physical_size()
481
+ print("Physical Size:", physical_size)
482
+ ```
483
+ """
484
+ monitor = self.screen
485
+ return {
486
+ "width": monitor.physicalSize().width(),
487
+ "height": monitor.physicalSize().height(),
488
+ }
489
+
490
+ def depth(self) -> int:
491
+ """
492
+ Returns the depth of the monitor.
493
+
494
+ The depth refers to the color depth of the monitor, which is the number of bits used to represent the color of a single pixel.
495
+
496
+ Returns
497
+ -------
498
+ int
499
+ The color depth of the monitor.
500
+
501
+ Examples
502
+ --------
503
+ ```python
504
+ app = Pyloid("Pyloid-App")
505
+
506
+ monitor = app.get_primary_monitor()
507
+ depth = monitor.depth()
508
+ print("Color Depth:", depth)
509
+ ```
510
+ """
511
+ monitor = self.screen
512
+ return monitor.depth()
513
+
514
+ def device_pixel_ratio(self) -> float:
515
+ """
516
+ Returns the device pixel ratio of the monitor.
517
+
518
+ The device pixel ratio is the ratio between physical pixels and device-independent pixels (DIPs).
519
+
520
+ Returns
521
+ -------
522
+ float
523
+ The device pixel ratio of the monitor.
524
+
525
+ Examples
526
+ --------
527
+ ```python
528
+ app = Pyloid("Pyloid-App")
529
+
530
+ monitor = app.get_primary_monitor()
531
+ device_pixel_ratio = monitor.device_pixel_ratio()
532
+ print("Device Pixel Ratio:", device_pixel_ratio)
533
+ ```
534
+ """
535
+ monitor = self.screen
536
+ return monitor.devicePixelRatio()
537
+
538
+ def logical_dots_per_inch(self) -> float:
539
+ """
540
+ Returns the logical dots per inch (DPI) of the monitor.
541
+
542
+ The logical DPI is the number of device-independent pixels (DIPs) per inch.
543
+
544
+ Returns
545
+ -------
546
+ float
547
+ The logical DPI of the monitor.
548
+
549
+ Examples
550
+ --------
551
+ ```python
552
+ app = Pyloid("Pyloid-App")
553
+
554
+ monitor = app.get_primary_monitor()
555
+ logical_dpi = monitor.logical_dots_per_inch()
556
+ print("Logical DPI:", logical_dpi)
557
+ ```
558
+ """
559
+ monitor = self.screen
560
+ return monitor.logicalDotsPerInch()
561
+
562
+ def logical_dots_per_inch_x(self) -> float:
563
+ """
564
+ Returns the logical dots per inch (DPI) along the X axis of the monitor.
565
+
566
+ The logical DPI along the X axis is the number of device-independent pixels (DIPs) per inch along the horizontal axis.
567
+
568
+ Returns
569
+ -------
570
+ float
571
+ The logical DPI along the X axis of the monitor.
572
+
573
+ Examples
574
+ --------
575
+ ```python
576
+ app = Pyloid("Pyloid-App")
577
+
578
+ monitor = app.get_primary_monitor()
579
+ logical_dpi_x = monitor.logical_dots_per_inch_x()
580
+ print("Logical DPI X:", logical_dpi_x)
581
+ ```
582
+ """
583
+ monitor = self.screen
584
+ return monitor.logicalDotsPerInchX()
585
+
586
+ def logical_dots_per_inch_y(self) -> float:
587
+ """
588
+ Returns the logical dots per inch (DPI) along the Y axis of the monitor.
589
+
590
+ The logical DPI along the Y axis is the number of device-independent pixels (DIPs) per inch along the vertical axis.
591
+
592
+ Returns
593
+ -------
594
+ float
595
+ The logical DPI along the Y axis of the monitor.
596
+
597
+ Examples
598
+ --------
599
+ ```python
600
+ app = Pyloid("Pyloid-App")
601
+
602
+ monitor = app.get_primary_monitor()
603
+ logical_dpi_y = monitor.logical_dots_per_inch_y()
604
+ print("Logical DPI Y:", logical_dpi_y)
605
+ ```
606
+ """
607
+ monitor = self.screen
608
+ return monitor.logicalDotsPerInchY()
609
+
610
+ def orientation(self) -> str:
611
+ """
612
+ Returns the orientation of the monitor.
613
+
614
+ The orientation refers to the current orientation of the monitor, such as landscape or portrait.
615
+
616
+ Returns
617
+ -------
618
+ str
619
+ The orientation of the monitor.
620
+
621
+ Examples
622
+ --------
623
+ ```python
624
+ app = Pyloid("Pyloid-App")
625
+
626
+ monitor = app.get_primary_monitor()
627
+ orientation = monitor.orientation()
628
+ print("Orientation:", orientation)
629
+ ```
630
+ """
631
+ monitor = self.screen
632
+ return monitor.orientation().name
633
+
634
+ def physical_dots_per_inch(self) -> float:
635
+ """
636
+ Returns the physical dots per inch (DPI) of the monitor.
637
+
638
+ The physical DPI is the number of physical pixels per inch.
639
+
640
+ Returns
641
+ -------
642
+ float
643
+ The physical DPI of the monitor.
644
+
645
+ Examples
646
+ --------
647
+ ```python
648
+ app = Pyloid("Pyloid-App")
649
+
650
+ monitor = app.get_primary_monitor()
651
+ physical_dpi = monitor.physical_dots_per_inch()
652
+ print("Physical DPI:", physical_dpi)
653
+ ```
654
+ """
655
+ monitor = self.screen
656
+ return monitor.physicalDotsPerInch()
657
+
658
+ def physical_dots_per_inch_x(self) -> float:
659
+ """
660
+ Returns the physical dots per inch (DPI) along the X axis of the monitor.
661
+
662
+ The physical DPI along the X axis is the number of physical pixels per inch along the horizontal axis.
663
+
664
+ Returns
665
+ -------
666
+ float
667
+ The physical DPI along the X axis of the monitor.
668
+
669
+ Examples
670
+ --------
671
+ ```python
672
+ app = Pyloid("Pyloid-App")
673
+
674
+ monitor = app.get_primary_monitor()
675
+ physical_dpi_x = monitor.physical_dots_per_inch_x()
676
+ print("Physical DPI X:", physical_dpi_x)
677
+ ```
678
+ """
679
+ monitor = self.screen
680
+ return monitor.physicalDotsPerInchX()
681
+
682
+ def physical_dots_per_inch_y(self) -> float:
683
+ """
684
+ Returns the physical dots per inch (DPI) along the Y axis of the monitor.
685
+
686
+ The physical DPI along the Y axis is the number of physical pixels per inch along the vertical axis.
687
+
688
+ Returns
689
+ -------
690
+ float
691
+ The physical DPI along the Y axis of the monitor.
692
+
693
+ Examples
694
+ --------
695
+ ```python
696
+ app = Pyloid("Pyloid-App")
697
+
698
+ monitor = app.get_primary_monitor()
699
+ physical_dpi_y = monitor.physical_dots_per_inch_y()
700
+ print("Physical DPI Y:", physical_dpi_y)
701
+ ```
702
+ """
703
+ monitor = self.screen
704
+ return monitor.physicalDotsPerInchY()
705
+
706
+ def refresh_rate(self) -> float:
707
+ """
708
+ Returns the refresh rate of the monitor.
709
+
710
+ The refresh rate is the number of times the monitor updates with new information per second, measured in Hertz (Hz).
711
+
712
+ Returns
713
+ -------
714
+ float
715
+ The refresh rate of the monitor.
716
+
717
+ Examples
718
+ --------
719
+ ```python
720
+ app = Pyloid("Pyloid-App")
721
+
722
+ monitor = app.get_primary_monitor()
723
+ refresh_rate = monitor.refresh_rate()
724
+ print("Refresh Rate:", refresh_rate)
725
+ ```
726
+ """
727
+ monitor = self.screen
728
+ return monitor.refreshRate()
729
+
730
+ def manufacturer(self) -> str:
731
+ """
732
+ Returns the manufacturer of the monitor.
733
+
734
+ The manufacturer refers to the company that produced the monitor.
735
+
736
+ Returns
737
+ -------
738
+ str
739
+ The manufacturer of the monitor.
740
+
741
+ Examples
742
+ --------
743
+ ```python
744
+ app = Pyloid("Pyloid-App")
745
+
746
+ monitor = app.get_primary_monitor()
747
+ manufacturer = monitor.manufacturer()
748
+ print("Manufacturer:", manufacturer)
749
+ ```
750
+ """
751
+ monitor = self.screen
752
+ return monitor.manufacturer()
753
+
754
+ def model(self) -> str:
755
+ """
756
+ Returns the model of the monitor.
757
+
758
+ The model refers to the specific model name or number assigned by the manufacturer.
759
+
760
+ Returns
761
+ -------
762
+ str
763
+ The model of the monitor.
764
+
765
+ Examples
766
+ --------
767
+ ```python
768
+ app = Pyloid("Pyloid-App")
769
+
770
+ monitor = app.get_primary_monitor()
771
+ model = monitor.model()
772
+ print("Model:", model)
773
+ ```
774
+ """
775
+ monitor = self.screen
776
+ return monitor.model()
777
+
778
+ def name(self) -> str:
779
+ """
780
+ Returns the name of the monitor.
781
+
782
+ The name refers to the user-friendly name assigned to the monitor.
783
+
784
+ Returns
785
+ -------
786
+ str
787
+ The name of the monitor.
788
+
789
+ Examples
790
+ --------
791
+ ```python
792
+ app = Pyloid("Pyloid-App")
793
+
794
+ monitor = app.get_primary_monitor()
795
+ name = monitor.name()
796
+ print("Name:", name)
797
+ ```
798
+ """
799
+ monitor = self.screen
800
+ return monitor.name()
801
+
802
+ def serial_number(self) -> str:
803
+ """
804
+ Returns the serial number of the monitor.
805
+
806
+ The serial number is a unique identifier assigned to the monitor by the manufacturer.
807
+
808
+ Returns
809
+ -------
810
+ str
811
+ The serial number of the monitor.
812
+
813
+ Examples
814
+ --------
815
+ ```python
816
+ app = Pyloid("Pyloid-App")
817
+
818
+ monitor = app.get_primary_monitor()
819
+ serial_number = monitor.serial_number()
820
+ print("Serial Number:", serial_number)
821
+ ```
822
+ """
823
+ monitor = self.screen
824
+ return monitor.serialNumber()
825
+
826
+ def geometry_changed(self, callback: Callable):
827
+ """
828
+ Registers a callback for the event that occurs when the geometry of the monitor changes.
829
+
830
+ Parameters
831
+ ----------
832
+ callback : Callable
833
+ The function to be called when the geometry changes.
834
+
835
+ Examples
836
+ --------
837
+ ```python
838
+ app = Pyloid("Pyloid-App")
839
+
840
+ def on_geometry_changed():
841
+ print("Geometry changed!")
842
+
843
+ monitor = app.get_primary_monitor()
844
+ monitor.geometry_changed(on_geometry_changed)
845
+ ```
846
+ """
847
+ monitor = self.screen
848
+ monitor.geometryChanged.connect(callback)
849
+
850
+ def orientation_changed(self, callback: Callable):
851
+ """
852
+ Registers a callback for the event that occurs when the orientation of the monitor changes.
853
+
854
+ Parameters
855
+ ----------
856
+ callback : Callable
857
+ The function to be called when the orientation changes.
858
+
859
+ Examples
860
+ --------
861
+ ```python
862
+ app = Pyloid("Pyloid-App")
863
+
864
+ def on_orientation_changed():
865
+ print("Orientation changed!")
866
+
867
+ monitor = app.get_primary_monitor()
868
+ monitor.orientation_changed(on_orientation_changed)
869
+ ```
870
+ """
871
+ monitor = self.screen
872
+ monitor.orientationChanged.connect(callback)
873
+
874
+ def refresh_rate_changed(self, callback: Callable):
875
+ """
876
+ Registers a callback for the event that occurs when the refresh rate of the monitor changes.
877
+
878
+ Parameters
879
+ ----------
880
+ callback : Callable
881
+ The function to be called when the refresh rate changes.
882
+
883
+ Examples
884
+ --------
885
+ ```python
886
+ app = Pyloid("Pyloid-App")
887
+
888
+ def on_refresh_rate_changed():
889
+ print("Refresh rate changed!")
890
+
891
+ monitor = app.get_primary_monitor()
892
+ monitor.refresh_rate_changed(on_refresh_rate_changed)
893
+ ```
894
+ """
895
+ monitor = self.screen
896
+ monitor.refreshRateChanged.connect(callback)
897
+
898
+ def virtual_geometry_changed(self, callback: Callable):
899
+ """
900
+ Registers a callback for the event that occurs when the virtual geometry of the monitor changes.
901
+
902
+ Parameters
903
+ ----------
904
+ callback : Callable
905
+ The function to be called when the virtual geometry changes.
906
+
907
+ Examples
908
+ --------
909
+ ```python
910
+ app = Pyloid("Pyloid-App")
911
+
912
+ def on_virtual_geometry_changed():
913
+ print("Virtual geometry changed!")
914
+
915
+ monitor = app.get_primary_monitor()
916
+ monitor.virtual_geometry_changed(on_virtual_geometry_changed)
917
+ ```
918
+ """
919
+ monitor = self.screen
920
+ monitor.virtualGeometryChanged.connect(callback)
921
+