2

Is there a way to control screen brightness through Python? For example, I'm using Tkinter right now, and I'm wondering if there is a way I can program a button in tkinter to increase the brightness of the screen (and make another button that decreases the brightness of the screen)?

EDIT: I'm using a Windows computer, it's on Windows 10, but I also need it to work on Windows 7 too.

Quantum Pizza
  • 41
  • 1
  • 4

2 Answers2

4

I used the WMI library and it really worked fine. Here is the code, but this is for Windows. I think it is OS specific so if it doesn't work for you, you should look for a better solution.

import wmi
    
brightness = 40 # percentage [0-100] For changing thee screen 
c = wmi.WMI(namespace='wmi')
methods = c.WmiMonitorBrightnessMethods()[0]    
methods.WmiSetBrightness(brightness, 0)
5Ke
  • 1,209
  • 11
  • 28
LucSuper
  • 83
  • 5
0

In tkinter you will not be able to adjust screen brightness. You might be able to make a macro and have your python program access it. Also with desktop monitors brightness is set by the monitor so depending on your model you will probably not be able to make any change at all. Good luck :)

Here is a link on using macros. Check it out and maybe find a way to control screen.

Daniel
  • 547
  • 5
  • 25