Merge pull request #3765 from PySimpleGUI/Dev-latest
Added code and comments to show all 3 ways to create a custom titlebar
This commit is contained in:
		
						commit
						24ebbcca10
					
				
					 1 changed files with 16 additions and 11 deletions
				
			
		|  | @ -2,15 +2,18 @@ import PySimpleGUI as sg | ||||||
| 
 | 
 | ||||||
| """ | """ | ||||||
|     The Custom Titlebar Demo |     The Custom Titlebar Demo | ||||||
|     Two ways of getting a custom titlebar: |     3 ways of getting a custom titlebar: | ||||||
|     1. set_options - will create a titlebar that every window will have based on theme |     1. set_options - will create a titlebar that every window will have based on theme | ||||||
|     2. Titlebar element - Adds custom titlebar to your window |     2. Titlebar element - Adds custom titlebar to your window | ||||||
|  |     3. use_custom_titlebar parameter - Add to your Window object | ||||||
| """ | """ | ||||||
| 
 | 
 | ||||||
| sg.set_options(use_custom_titlebar=True) | # sg.set_options(use_custom_titlebar=True) | ||||||
|  | # sg.set_options(titlebar_background_color='red', titlebar_text_color='white', titlebar_font='courier 12', ) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| def main(): | def main(): | ||||||
| 
 |  | ||||||
|     layout = [ |     layout = [ | ||||||
|         # [sg.Titlebar('My Custom Titlebar', background_color='light blue', text_color='red', k='-T-')], |         # [sg.Titlebar('My Custom Titlebar', background_color='light blue', text_color='red', k='-T-')], | ||||||
|         [sg.Text('My Window')], |         [sg.Text('My Window')], | ||||||
|  | @ -20,10 +23,11 @@ def main(): | ||||||
|         [sg.Button('Clear'), sg.Button('Popup'), sg.Button('Exit')]] |         [sg.Button('Clear'), sg.Button('Popup'), sg.Button('Exit')]] | ||||||
| 
 | 
 | ||||||
|     # Use the same title so that when the window minimizes, the title will be the same as the custom titlebar title |     # Use the same title so that when the window minimizes, the title will be the same as the custom titlebar title | ||||||
|     window = sg.Window('My Custom Titlebar', layout) |     # window = sg.Window('My Custom Titlebar', layout) | ||||||
|  |     window = sg.Window('My Custom Titlebar', layout, use_custom_titlebar=True) | ||||||
| 
 | 
 | ||||||
|     while True: |     while True: | ||||||
|         event, values = window() |         event, values = window.read() | ||||||
|         print(event, values) |         print(event, values) | ||||||
|         if event in (sg.WIN_CLOSED, 'Exit'): |         if event in (sg.WIN_CLOSED, 'Exit'): | ||||||
|             break |             break | ||||||
|  | @ -34,4 +38,5 @@ def main(): | ||||||
| 
 | 
 | ||||||
|     window.close() |     window.close() | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| main() | main() | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue