Added location parameter so that launchers can place these widgets at any location on multiple screens

This commit is contained in:
PySimpleGUI 2020-07-28 04:11:25 -04:00
parent 8fc47b964a
commit d2102c8b17
6 changed files with 147 additions and 46 deletions

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python
import PySimpleGUI as sg
import psutil
import sys
"""
Desktop "Rainmeter" style widget - Drive usage
@ -34,7 +35,7 @@ def update_window(window):
pass
def main():
def main(location):
sg.theme(THEME)
# ---------------- Create Layout ----------------
@ -58,7 +59,7 @@ def main():
layout += [[sg.Text('Refresh', font='Any 8', key='-REFRESH-', enable_events=True), sg.Text('', enable_events=True, key='Exit Text')]]
# ---------------- Create Window ----------------
window = sg.Window('Drive Status Widget', layout, keep_on_top=True, grab_anywhere=True, no_titlebar=True, alpha_channel=ALPHA, use_default_focus=False,
window = sg.Window('Drive Status Widget', layout, location=location, keep_on_top=True, grab_anywhere=True, no_titlebar=True, alpha_channel=ALPHA, use_default_focus=False,
finalize=True)
update_window(window) # sets the progress bars
@ -71,5 +72,11 @@ def main():
update_window(window)
if __name__ == "__main__":
main()
if __name__ == '__main__':
if len(sys.argv) > 1:
location = sys.argv[1].split(',')
location = (int(location[0]), int(location[1]))
else:
location = (None, None)
main(location)