More element padding... works better with Window padding values now, Issue watcher app update

This commit is contained in:
MikeTheWatchGuy 2018-11-25 10:07:17 -05:00
parent a2e44da1c9
commit 522cfa0aaf
2 changed files with 28 additions and 23 deletions

View File

@ -33,16 +33,16 @@ def get_num_issues():
def gui():
sg.ChangeLookAndFeel('Topanga')
sg.SetOptions(border_width=0, margins=(0, 0), element_padding=(0, 0))
sg.SetOptions(border_width=0)
layout = [
[sg.T('GitHub Issues Watcher' + 48 * ' '),
[sg.T('GitHub Issues Watcher' + 5 * ' ', click_submits=True, key='GitHub'),
sg.Button('', size=(25,25),
image_data=red_x,
key='_quit_',button_color=(sg.LOOK_AND_FEEL_TABLE['Topanga']['TEXT'],sg.LOOK_AND_FEEL_TABLE['Topanga']['BACKGROUND']),
tooltip='Closes window')],
[sg.T('', key='_status_', size=(12, 1))],
[sg.T('', key='_numissues_', size=(20, 1))],
[sg.T('', key='_numissues_', size=(18, 1))],
]
window = sg.Window('Issue watcher',
@ -50,7 +50,8 @@ def gui():
grab_anywhere=True,
keep_on_top=True,
alpha_channel=.8, # dim the lights a little
location=(2121,310), # locate in upper right corner of screen
location=(2360,310), # locate in upper right corner of screen
element_padding=(0,0)
).Layout(layout).Finalize()
window.Refresh()
@ -58,10 +59,17 @@ def gui():
issues_elem = window.FindElement('_numissues_')
initial_issue_count, initial_first_issue = get_num_issues()
# The Event Loop runs every 1000ms
i = 0
# The Event Loop runs every 5000ms
poll_frequncy = 5000
seconds = 0
while True:
if i % 60 == 0: # Every 60 seconds read GitHub
# read with a 5 second timeout
event, values = window.Read(timeout=poll_frequncy)
# print(event, values)
if event in ('_quit_', None):
break
if seconds % 60 == 0 or event.startswith('GitHub'): # Every 60 seconds read GitHub
status_elem.Update('Reading...')
window.Refresh()
issues, first_issue = get_num_issues()
@ -69,20 +77,16 @@ def gui():
window.Refresh()
# if something changed, then make a popup
if issues != initial_issue_count or first_issue != initial_first_issue:
sg.PopupNoWait('Issues changed on GitHub', background_color='red')
sg.PopupNoWait('Issues changed on GitHub ', 'First issue # is {}'.format(first_issue), background_color='red', keep_on_top=True)
initial_issue_count = issues
initial_first_issue = first_issue
status_elem.Update('')
else:
status_elem.Update('.' if i%2 else '') # blink a '.' every 2 seconds so know still running
# read with a 1 second timeout
event, values = window.Read(timeout=1000)
if event in ('_quit_', None):
break
i += 1
status_elem.Update('.' if seconds%2 else '') # blink a '.' every 2 seconds so know still running
seconds += poll_frequncy/1000
red_x = b"R0lGODlhEAAQAPeQAIsAAI0AAI4AAI8AAJIAAJUAAJQCApkAAJoAAJ4AAJkJCaAAAKYAAKcAAKcCAKcDA6cGAKgAAKsAAKsCAKwAAK0AAK8AAK4CAK8DAqUJAKULAKwLALAAALEAALIAALMAALMDALQAALUAALYAALcEALoAALsAALsCALwAAL8AALkJAL4NAL8NAKoTAKwbAbEQALMVAL0QAL0RAKsREaodHbkQELMsALg2ALk3ALs+ALE2FbgpKbA1Nbc1Nb44N8AAAMIWAMsvAMUgDMcxAKVABb9NBbVJErFYEq1iMrtoMr5kP8BKAMFLAMxKANBBANFCANJFANFEB9JKAMFcANFZANZcANpfAMJUEMZVEc5hAM5pAMluBdRsANR8AM9YOrdERMpIQs1UVMR5WNt8X8VgYMdlZcxtYtx4YNF/btp9eraNf9qXXNCCZsyLeNSLd8SSecySf82kd9qqc9uBgdyBgd+EhN6JgtSIiNuJieGHhOGLg+GKhOKamty1ste4sNO+ueenp+inp+HHrebGrefKuOPTzejWzera1O7b1vLb2/bl4vTu7fbw7ffx7vnz8f///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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yqICFBVyKgJJkFaQW4Hna4THQ4X/gUiD2+QXEwjNZsASJvTgWgMqoY95WWw7raAJdjheeTEeniCTqgZu2IxswnSmGI3gEZjMiQpAMocTC2nJcm4hU9gRjp9E+6Ajb07wKFpHqRVOzKqedFUhOX4HyRnEwSjMQCB8/4IqnxU2DYiaGnsIe7n2UlK61MWe0dbW18Ijdfk/wuy7IXeEEvEvmM+kcRM4XYYSkohW62ChtIS/NKbWGwO8z9+Anp9TNSsQU2wEtVdEZy5o7Gfi7Z5ewj/vxbkPs51kYhVP4zAw3I3IN+ohSVFcfZeEs67Gid/c03E1uEv5QpTFzvZK5EAAAAASUVORK5CYII='
gui()

View File

@ -314,7 +314,8 @@ class Element():
self.Size = size
self.Type = elem_type
self.AutoSizeText = auto_size_text
self.Pad = DEFAULT_ELEMENT_PADDING if pad is None else pad
# self.Pad = DEFAULT_ELEMENT_PADDING if pad is None else pad
self.Pad = pad
if font is not None and type(font) is not str:
self.Font = font
elif font is not None:
@ -4118,15 +4119,15 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win):
else:
auto_size_text = False # if user has specified a size then it shouldn't autosize
full_element_pad = [0,0,0,0] # Top, Right, Bottom, Left
if type(element.Pad[0]) != tuple: # left and right
full_element_pad[1] = full_element_pad[3] = element.Pad[0]
elementpad = element.Pad if element.Pad is not None else toplevel_win.ElementPadding
if type(elementpad[0]) != tuple: # left and right
full_element_pad[1] = full_element_pad[3] = elementpad[0]
else:
full_element_pad[3], full_element_pad[1] = element.Pad[0]
if type(element.Pad[1]) != tuple: # top and bottom
full_element_pad[0] = full_element_pad[2] = element.Pad[1]
full_element_pad[3], full_element_pad[1] = elementpad[0]
if type(elementpad[1]) != tuple: # top and bottom
full_element_pad[0] = full_element_pad[2] = elementpad[1]
else:
full_element_pad[0], full_element_pad[2] = element.Pad[1]
element_pad = full_element_pad
full_element_pad[0], full_element_pad[2] = elementpad[1]
border_depth = toplevel_win.BorderDepth if toplevel_win.BorderDepth is not None else DEFAULT_BORDER_WIDTH
try: