Reputation: 700
How to make only one Text element not transparent?
As transparent app I use sg.Window option alpha_channel=0.1, but one text element I need to make better visible. It is possible with Pysimplegui? Maybe somehow with canvas or second Window?
App to test with:
import PySimpleGUI as sg
import time
layout = [[sg.Text('', key='text'), sg.Button('Btn')]]
window = sg.Window('Sample window', layout,
keep_on_top=True,
auto_size_buttons=False,
grab_anywhere=True,
no_titlebar=False,
return_keyboard_events=False,
alpha_channel=0.65,
use_default_focus=False,
finalize=True
)
while True:
event, values = window.read(timeout=1000)
window['text'].update('need better visability here ' + str(round(time.time()))) # this element should be not transparent
if event == 'Btn':
print('test')
elif event in (sg.WIN_CLOSED, 'Exit'):
break
Upvotes: 1
Views: 336
Reputation: 13061
Maybe you can use multi-window for it
import PySimpleGUI as sg
import time
def popup(location):
message = 'need better visability here ' + str(round(time.time()))
layout = [[sg.Text(message,size=50, enable_events=True, key='TIME')]]
window = sg.Window('Message', layout, no_titlebar=True, modal=True, location=location)
while True:
event, values = window.read(timeout=100)
if event == sg.TIMEOUT_EVENT:
window['TIME'].update('need better visability here ' + str(round(time.time())))
else:
break
window.close()
message = 'need better visability here ' + str(round(time.time()))
layout = [
[sg.Text(message, size=50, key='TIME')],
[sg.Button('Start', expand_x=True), sg.Button('Exit')],
]
window = sg.Window('Sample window', layout, no_titlebar=True, finalize=True, grab_anywhere=True,)
while True:
event, values = window.read(timeout=1000)
if event in (sg.WIN_CLOSED, 'Exit'):
break
elif event == 'Start':
window.set_alpha(0.1)
location = window.current_location(more_accurate=True)
popup(location)
window.set_alpha(1.0)
elif event == sg.TIMEOUT_EVENT:
window['TIME'].update('need better visability here ' + str(round(time.time())))
window.close()
Upvotes: 1