commit
b00011a213
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
version = __version__ = "4.11.0.5 Unreleased - ability to set disabled colors for buttons (tk + ttk), popup no more closebutton use, browse cancel fix for linux, highlight thickness=0"
|
||||
version = __version__ = "4.12.0 Released 14-Dec-2019"
|
||||
|
||||
port = 'PySimpleGUI'
|
||||
|
||||
|
@ -11188,7 +11188,7 @@ def Popup(*args, title=None, button_color=None, background_color=None, text_colo
|
|||
button, values = window.Read(timeout=0)
|
||||
else:
|
||||
button, values = window.Read()
|
||||
window.close()
|
||||
window.close(); del window
|
||||
|
||||
return button
|
||||
|
||||
|
@ -11263,7 +11263,7 @@ def PopupScrolled(*args, title=None, button_color=None, background_color=None, t
|
|||
button, values = window.Read(timeout=0)
|
||||
else:
|
||||
button, values = window.Read()
|
||||
window.close()
|
||||
window.close(); del window
|
||||
return button
|
||||
|
||||
|
||||
|
@ -11708,7 +11708,7 @@ def PopupGetFolder(message, title=None, default_path='', no_window=False, size=(
|
|||
location=location)
|
||||
|
||||
button, values = window.Read()
|
||||
window.Close()
|
||||
window.close(); del window
|
||||
if button != 'Ok':
|
||||
return None
|
||||
else:
|
||||
|
@ -11806,7 +11806,7 @@ def PopupGetFile(message, title=None, default_path='', default_extension='', sav
|
|||
no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location)
|
||||
|
||||
button, values = window.Read()
|
||||
window.Close()
|
||||
window.close(); del window
|
||||
if button != 'Ok':
|
||||
return None
|
||||
else:
|
||||
|
@ -11849,7 +11849,7 @@ def PopupGetText(message, title=None, default_text='', password_char='', size=(N
|
|||
location=location)
|
||||
|
||||
button, values = window.Read()
|
||||
window.Close()
|
||||
window.close(); del window
|
||||
if button != 'Ok':
|
||||
return None
|
||||
else:
|
||||
|
@ -11905,7 +11905,7 @@ def PopupAnimated(image_source, message=None, background_color=None, text_color=
|
|||
window = Window.animated_popup_dict[image_source]
|
||||
window.Element('_IMAGE_').UpdateAnimation(image_source, time_between_frames=time_between_frames)
|
||||
|
||||
window.read(timeout=10) # call refresh instead of Read to save significant CPU time
|
||||
window.refresh() # call refresh instead of Read to save significant CPU time
|
||||
|
||||
|
||||
#####################################################################################################
|
||||
|
|
|
@ -0,0 +1,229 @@
|
|||
import PySimpleGUI as sg
|
||||
import random
|
||||
|
||||
'''
|
||||
Source code of MineSweeper Game
|
||||
'''
|
||||
|
||||
blank = b'iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAA5SURBVEhL7c0xAQAgDMTABynVU7MohAUN6ZJbMmbV6ZsB+xfnGOMY4xjjGOMY4xjjGOMY4xgzNE4euGMCWklhg+IAAAAASUVORK5CYII='
|
||||
bomb = b'iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAHLklEQVR4nMWVTYydVRnHf+fjfd+59/bOnbnMTL2WthRaa2qlAhEwgpSSWIiKCXFWuHCBuHOhiQs3DcRENy5cmKiRkBgXkEESNEY0VKtGUm2RBGIsWFPDjJ3OR++d+/l+nXMeF3NbB+wAmhCf5Gzek/f5nf85z/N/FO9hnP0+0d6dTCSaBIuq/5HL6jECgHovgCJoFqgPKuw2iqZx9AtFgWNtR5O2uhdn/5fEJ06c0KdOndIAc3NzsrCwEARAUAsLqO7PmbR19sWWwwhHMKSxcEESVgY9zgCr71ax4s23E7ZuagWb5LHis1TdGreHiIfE8zHTZYcIb/gaP9Ga0ysD/vZ2ihX33GNOHD0aHnv88YCIbLKF+c9/dd8rr7z4mSiK7I5686XTp577rcjxZPWZS7flo436+oV8ojYzOqDj0UfNuj+oz8lEaElT1zkbDOcnYWkbxfMG9YxHrsqYiuN4riiK6PinHm52up1nB/2NGWVi6tOzPHSw89KN4dULH2iGP/c3imKiKe+7br8+PLUr3Vspyuv1miRMyWKo8HSAk4NFzrwVrEAAJcDszF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9sHjup0BVqZnW2iZjzC5r7RZg4dTuUtBp87hQRECG1j9X/e21Ow/HltVTfuMGGSYOiQAaRVHXNDDI521UyrinBhv0VjqTWw3I8uXkmLiptOi3jQ0oWBcxEe+SmgHMoMUsmmGRwuU/I2xGcKGIqJhBRWuK22ZL08a4UEQM3CSf/Jw8WfoS/yea1uL3Y5f9mcncVaFs68qVZUy8Qv47cEF3E/fui6KJxKOa2QLOBFZALl8mq8LjyEWLAfb/Hxa3teX7BPndqCwF6G2bPXDJh8B4EVEdEqRuUtssaKY8BpFbQN1sAWcEj+etMojo1Br8r1XS1Zwk5upNYMWkzcyCjKpOG7cT8eNMA/kZ+BJmr4ioqvwF0Vn06LBZVccAAAAASUVORK5CYII='
|
||||
|
||||
font = 'Courier 16 bold'
|
||||
width = 25
|
||||
height = 14
|
||||
all = 80
|
||||
new_start = True
|
||||
size = (30,30)
|
||||
# 0: 0, 1: hidden card, 2: bomb card, 3: flag card, 4: shown card
|
||||
im = ['', blank, bomb,flag, '']
|
||||
color = [('grey', 'grey'), ('black', 'green'),
|
||||
('black', 'green'), ('black', 'green'), ('black', 'grey')]
|
||||
|
||||
def binding_all(): # Bind right button of mouse to cell object
|
||||
|
||||
for x in range(width):
|
||||
for y in range(height):
|
||||
window[b[x][y].key].bind(
|
||||
'<Button-3>', '+RIGHT')
|
||||
|
||||
# Setting for top buttons
|
||||
def button1(text, key=None, disabled=False, button_color=('white', 'green')):
|
||||
|
||||
return sg.Button(text, pad=(10, 10), font=font, focus=False, key=key,
|
||||
disabled=disabled, button_color=button_color)
|
||||
|
||||
def button2(x, y): # define cell as instance of button and
|
||||
|
||||
b[x][y] = button(x,y) # bulid Button
|
||||
return b[x][y].button
|
||||
|
||||
def check_blank(x, y): # Check if cell near 0-bomb cel
|
||||
|
||||
if b[x][y].num==0: return False
|
||||
for i in [-1, 0, 1]:
|
||||
for j in [-1, 0, 1]:
|
||||
if i==0 and j==0: continue
|
||||
if ((0<=x+i<width) and (0<=y+j<height) and
|
||||
(b[x+i][y+j].num==0)): return True
|
||||
return False
|
||||
|
||||
def check_num(): # check number of bombs, flags and hides
|
||||
|
||||
bomb_count = flag_count = hide_count = 0
|
||||
for x in range(width):
|
||||
for y in range(height):
|
||||
if b[x][y].state == 1:
|
||||
hide_count += 1
|
||||
elif b[x][y].state == 2:
|
||||
bomb_count += 1
|
||||
elif b[x][y].state == 3:
|
||||
flag_count += 1
|
||||
return bomb_count, flag_count, hide_count
|
||||
|
||||
# Count number of bombs about cell
|
||||
def count_bomb(x, y):
|
||||
|
||||
global bomb
|
||||
if bomb[x][y]==10: return 10
|
||||
count = 0
|
||||
for i in [-1, 0, 1]:
|
||||
for j in [-1, 0, 1]:
|
||||
if i==0 and j==0: continue
|
||||
if ((0<=x+i<width) and (0<=y+j<height) and
|
||||
(bomb[x+i][y+j]==10)):
|
||||
count += 1
|
||||
return count
|
||||
|
||||
# set position for all boms
|
||||
def deal():
|
||||
|
||||
global bomb
|
||||
bomb_list = random.sample(range(width*height), all)
|
||||
bomb = [[0 for y in range(height)] for x in range(width)]
|
||||
|
||||
for x in range(width):
|
||||
for y in range(height):
|
||||
if x*height+y in bomb_list: bomb[x][y]=10
|
||||
|
||||
for x in range(width):
|
||||
for y in range(height):
|
||||
bomb[x][y] = count_bomb(x, y)
|
||||
|
||||
return
|
||||
|
||||
def new_card(): # refresh all cells to hidden card
|
||||
|
||||
for x in range(width):
|
||||
for y in range(height):
|
||||
b[x][y].state = 1
|
||||
b[x][y].num = bomb[x][y]
|
||||
b[x][y].color = color[1]
|
||||
b[x][y].update(1)
|
||||
|
||||
def show_blank(): # Show all cell not around by any bomb
|
||||
|
||||
for x in range(width):
|
||||
for y in range(height):
|
||||
if b[x][y].num == 0:
|
||||
b[x][y].update(0)
|
||||
elif check_blank(x, y):
|
||||
b[x][y].update(4)
|
||||
|
||||
# Class for each button object
|
||||
class button():
|
||||
|
||||
def __init__(self, x, y):
|
||||
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.state = 1
|
||||
self.color = color[self.state]
|
||||
self.disabled = False
|
||||
self.key = (x,y) # keys can be ANYTHING, not just strings
|
||||
self.num = bomb[x][y]
|
||||
self.button = sg.Button(' ',
|
||||
auto_size_button=False,
|
||||
border_width=2,
|
||||
button_color=self.color,
|
||||
disabled=self.disabled,
|
||||
focus=False,
|
||||
font=font,
|
||||
image_size=size,
|
||||
# image_filename=im[self.state],
|
||||
image_data=im[self.state],
|
||||
key=self.key,
|
||||
pad=(1,1))
|
||||
|
||||
def right_click(self): # Right_click handler
|
||||
|
||||
if self.state == 1:
|
||||
self.update(3)
|
||||
elif self.state == 3:
|
||||
self.update(1)
|
||||
|
||||
def update(self, state): # update state of cell
|
||||
|
||||
self.state = state
|
||||
if state == 0:
|
||||
self.disabled = True
|
||||
text = ' '
|
||||
elif state in [1,2,3]:
|
||||
self.disabled = False
|
||||
text = ' '
|
||||
elif state == 4:
|
||||
self.disabled = True
|
||||
text = str(self.num)
|
||||
self.color = color[self.state]
|
||||
window[self.key].Widget['disabledforeground'] = 'white'
|
||||
self.button.Update(text=text, disabled=self.disabled,
|
||||
# image_filename=im[self.state],
|
||||
image_data=im[self.state],
|
||||
image_size=size,
|
||||
button_color=self.color)
|
||||
|
||||
# set theme for window
|
||||
sg.change_look_and_feel('DarkGreen')
|
||||
|
||||
deal() # Initial position of bombs
|
||||
b = [[0 for j in range(height)] for i in range(width)]
|
||||
|
||||
layout = [[button1('New Game', key='-New Game-'), # Layout of window
|
||||
button1('Game Over', key='-Game Over-'),
|
||||
button1('Target:'+str(all), key='-Target-'),
|
||||
button1('Bomb:0', key='-Count-Bomb-'),
|
||||
button1('Flag:0', key='-Count-Flag-')]]+[
|
||||
[button2(x, y) for x in range(width)] for y in range(height)]
|
||||
|
||||
window = sg.Window('MineSweeper', layout=layout, finalize=True) # Create window
|
||||
binding_all() # Binding right button event handler of all cells
|
||||
show_blank() # Show all cells near no-bomb cell
|
||||
|
||||
new_start = True # Flag for new game
|
||||
message = False # Flag for game over message sent
|
||||
|
||||
while True:
|
||||
|
||||
if new_start: # Actions for new game
|
||||
|
||||
deal()
|
||||
new_card()
|
||||
show_blank()
|
||||
message = False
|
||||
new_start = False
|
||||
pass
|
||||
|
||||
event, values = window.read() # read window event
|
||||
|
||||
if event==None or event=='-Game Over-': # Window close / Game over
|
||||
break
|
||||
|
||||
elif event == '-New Game-': # New Game, set the flag
|
||||
new_start = True
|
||||
|
||||
elif isinstance(event, tuple): # buttons have tuple for event
|
||||
right_click = False
|
||||
if isinstance(event[0], tuple): # if the tuple has a tuple, then it's a right click event
|
||||
x,y = event[0]
|
||||
right_click = True
|
||||
else:
|
||||
x, y = event
|
||||
if not right_click:
|
||||
if b[x][y].state == 1:
|
||||
if b[x][y].num == 10:
|
||||
b[x][y].update(2)
|
||||
else:
|
||||
b[x][y].update(4)
|
||||
else:
|
||||
b[x][y].right_click()
|
||||
# Update number onf bombs, flags
|
||||
bomb_num, flag_num, hide_num = check_num()
|
||||
window['-Count-Bomb-'].Update(text='Bomb:'+str(bomb_num))
|
||||
window['-Count-Flag-'].Update(text='Flag:'+str(flag_num))
|
||||
|
||||
# Check if game over
|
||||
if hide_num==0 and (bomb_num+flag_num==all) and (not message):
|
||||
message = True
|
||||
sg.popup('Game Over', title='Note')
|
||||
|
||||
window.close()
|
|
@ -14,7 +14,7 @@
|
|||
![Awesome Meter](https://img.shields.io/badge/Awesome_meter-100-yellow.svg)
|
||||
![Python Version](https://img.shields.io/badge/Python-2.7_3.x-yellow.svg)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_3.x_Version-4.11.0-red.svg?longCache=true&style=for-the-badge)
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_3.x_Version-4.12.0-red.svg?longCache=true&style=for-the-badge)
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_2.7_Version-2.4.1-blue.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIQt_Version-0.30.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
|
@ -5424,6 +5424,7 @@ Button(button_text="",
|
|||
size=(None, None),
|
||||
auto_size_button=None,
|
||||
button_color=None,
|
||||
disabled_button_color=None,
|
||||
use_ttk_buttons=None,
|
||||
font=None,
|
||||
bind_return_key=False,
|
||||
|
@ -5455,6 +5456,7 @@ Parameter Descriptions:
|
|||
|size|Tuple[int, int] (width, height) of the button in characters wide, rows high|
|
||||
|auto_size_button|(bool) if True the button size is sized to fit the text|
|
||||
|button_color|Tuple[str, str] (text color, background color) of button. Easy to remember which is which if you say "ON" between colors. "red" on "green".|
|
||||
|disabled_button_color|Tuple[str, str] colors to use when button is disabled (text, background). Use None for a color if don't want to change. Only ttk buttons support both text and background colors. tk buttons only support changing text color|
|
||||
|use_ttk_buttons|(bool) True = use ttk buttons. False = do not use ttk buttons. None (Default) = use ttk buttons only if on a Mac and not with button images|
|
||||
|font|Union[str, Tuple[str, int]] specifies the font family, size, etc|
|
||||
|bind_return_key|(bool) If True the return key will cause this button to be pressed|
|
||||
|
@ -5523,6 +5525,7 @@ Update(text=None,
|
|||
image_filename=None,
|
||||
visible=None,
|
||||
image_subsample=None,
|
||||
disabled_button_color=(None, None),
|
||||
image_size=None)
|
||||
```
|
||||
|
||||
|
@ -5535,6 +5538,7 @@ Parameter Descriptions:
|
|||
|disabled|(bool) disable or enable state of the element|
|
||||
|image_data|Union[bytes, str] Raw or Base64 representation of the image to put on button. Choose either filename or data|
|
||||
|image_filename|(str) image filename if there is a button image. GIFs and PNGs only.|
|
||||
|disabled_button_color|Tuple[str, str] colors to use when button is disabled (text, background). Use None for a color if don't want to change. Only ttk buttons support both text and background colors. tk buttons only support changing text color|
|
||||
|visible|(bool) control visibility of element|
|
||||
|image_subsample|(int) amount to reduce the size of the image. Divides the size by this number. 2=1/2, 3=1/3, 4=1/4, etc|
|
||||
|image_size|Tuple[int, int] Size of the image in pixels (width, height)|
|
||||
|
@ -5687,6 +5691,7 @@ update(text=None,
|
|||
image_filename=None,
|
||||
visible=None,
|
||||
image_subsample=None,
|
||||
disabled_button_color=(None, None),
|
||||
image_size=None)
|
||||
```
|
||||
|
||||
|
@ -5699,6 +5704,7 @@ Parameter Descriptions:
|
|||
|disabled|(bool) disable or enable state of the element|
|
||||
|image_data|Union[bytes, str] Raw or Base64 representation of the image to put on button. Choose either filename or data|
|
||||
|image_filename|(str) image filename if there is a button image. GIFs and PNGs only.|
|
||||
|disabled_button_color|Tuple[str, str] colors to use when button is disabled (text, background). Use None for a color if don't want to change. Only ttk buttons support both text and background colors. tk buttons only support changing text color|
|
||||
|visible|(bool) control visibility of element|
|
||||
|image_subsample|(int) amount to reduce the size of the image. Divides the size by this number. 2=1/2, 3=1/3, 4=1/4, etc|
|
||||
|image_size|Tuple[int, int] Size of the image in pixels (width, height)|
|
||||
|
@ -14307,6 +14313,8 @@ call and then have that same source run on plain PySimpleGUI.
|
|||
|---|---|
|
||||
| **return** | |
|
||||
|
||||
## Function Reference
|
||||
|
||||
```
|
||||
CButton(button_text,
|
||||
image_filename=None,
|
||||
|
@ -15021,6 +15029,39 @@ Parameter Descriptions:
|
|||
|||
|
||||
| **return** | (Button) |
|
||||
|
||||
```
|
||||
Open(button_text="Open",
|
||||
size=(None, None),
|
||||
auto_size_button=None,
|
||||
button_color=None,
|
||||
disabled=False,
|
||||
bind_return_key=True,
|
||||
tooltip=None,
|
||||
font=None,
|
||||
focus=False,
|
||||
pad=None,
|
||||
key=None,
|
||||
metadata=None)
|
||||
```
|
||||
|
||||
Parameter Descriptions:
|
||||
|
||||
|Name|Meaning|
|
||||
|---|---|
|
||||
|button_text|text in the button (Default value = 'Open')|
|
||||
|size|(w,h) w=characters-wide, h=rows-high|
|
||||
|auto_size_button|True if button size is determined by button text|
|
||||
|button_color|button color (foreground, background)|
|
||||
|disabled|set disable state for element (Default = False)|
|
||||
|bind_return_key|(Default = True)|
|
||||
|tooltip|(str) text, that will appear when mouse hovers over the element|
|
||||
|font|specifies the font family, size, etc|
|
||||
|focus|if focus should be set to this|
|
||||
|pad|Amount of padding to put around element|
|
||||
|key|Used with window.FindElement and with return values to uniquely identify this element|
|
||||
|
||||
## OneLineProgressMeter
|
||||
|
||||
```
|
||||
OneLineProgressMeter(title,
|
||||
current_value,
|
||||
|
@ -15061,36 +15102,7 @@ Parameter Descriptions:
|
|||
|---|---|
|
||||
|key|Used with window.FindElement and with return values to uniquely identify this element|
|
||||
|
||||
```
|
||||
Open(button_text="Open",
|
||||
size=(None, None),
|
||||
auto_size_button=None,
|
||||
button_color=None,
|
||||
disabled=False,
|
||||
bind_return_key=True,
|
||||
tooltip=None,
|
||||
font=None,
|
||||
focus=False,
|
||||
pad=None,
|
||||
key=None,
|
||||
metadata=None)
|
||||
```
|
||||
|
||||
Parameter Descriptions:
|
||||
|
||||
|Name|Meaning|
|
||||
|---|---|
|
||||
|button_text|text in the button (Default value = 'Open')|
|
||||
|size|(w,h) w=characters-wide, h=rows-high|
|
||||
|auto_size_button|True if button size is determined by button text|
|
||||
|button_color|button color (foreground, background)|
|
||||
|disabled|set disable state for element (Default = False)|
|
||||
|bind_return_key|(Default = True)|
|
||||
|tooltip|(str) text, that will appear when mouse hovers over the element|
|
||||
|font|specifies the font family, size, etc|
|
||||
|focus|if focus should be set to this|
|
||||
|pad|Amount of padding to put around element|
|
||||
|key|Used with window.FindElement and with return values to uniquely identify this element|
|
||||
## Popup Functions
|
||||
|
||||
Popup - Display a popup Window with as many parms as you wish to include. This is the GUI equivalent of the
|
||||
"print" statement. It's also great for "pausing" your program's flow until the user can read some error messages.
|
||||
|
@ -16453,6 +16465,8 @@ Parameter Descriptions:
|
|||
|||
|
||||
| **return** | (Button) |
|
||||
|
||||
## PEP8 Function Bindings
|
||||
|
||||
Change the "color scheme" of all future PySimpleGUI Windows.
|
||||
The scheme are string names that specify a group of colors. Background colors, text colors, button colors.
|
||||
There are 13 different color settings that are changed at one time using a single call to ChangeLookAndFeel
|
||||
|
@ -16634,6 +16648,8 @@ Parameter Descriptions:
|
|||
|---|---|
|
||||
|key|Used with window.FindElement and with return values to uniquely identify this element|
|
||||
|
||||
## Popups
|
||||
|
||||
Popup - Display a popup Window with as many parms as you wish to include. This is the GUI equivalent of the
|
||||
"print" statement. It's also great for "pausing" your program's flow until the user can read some error messages.
|
||||
|
||||
|
@ -18981,7 +18997,24 @@ The Element & Window bindings release
|
|||
* Window.bind - New method for Windows, just like Elements
|
||||
* Enables tkinter bindings to be added to Windows
|
||||
* Will get an event returned from window.read() if the tkinter event happens
|
||||
* TabGround fonts - can now set the font and font size for Tab text
|
||||
* TabGroup fonts - can now set the font and font size for Tab text
|
||||
|
||||
## 4.12.0 PySimpleGUI 14-Dec-2019
|
||||
|
||||
Finally no more outlines around TK Elements on Linux
|
||||
|
||||
* Fixed a long-term problem of the mysterious white border around (almost) all TK Elements on Linux
|
||||
* Ability to set the disabled button colors
|
||||
* New Button and Button.update parameter - disabled_button_color
|
||||
* Specified as (Text Color, Background Color) just like button colors
|
||||
* For Normal / TK Buttons - can set button text color only
|
||||
* For TTK Buttons - can set both a disabled button and text color
|
||||
* Either parameter can be None to use current setting
|
||||
* Removed use of CloseButton from Popups (still have a bug in the CloseButton code but not in popups now)
|
||||
* Combobox - removed requirement of setting disabled if want to set to readonly using update method
|
||||
* Fix for cancelling out of file/folder browse on Linux caused target to be cleared instead of just cancelling
|
||||
* Removed try block around setting button colors - if user sets a bad color, well don't do that
|
||||
* Now deleting windows after closing them for popup
|
||||
|
||||
### Upcoming
|
||||
|
||||
|
|
97
readme.md
97
readme.md
|
@ -14,7 +14,7 @@
|
|||
![Awesome Meter](https://img.shields.io/badge/Awesome_meter-100-yellow.svg)
|
||||
![Python Version](https://img.shields.io/badge/Python-2.7_3.x-yellow.svg)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_3.x_Version-4.11.0-red.svg?longCache=true&style=for-the-badge)
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_3.x_Version-4.12.0-red.svg?longCache=true&style=for-the-badge)
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_2.7_Version-2.4.1-blue.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIQt_Version-0.30.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
|
@ -5424,6 +5424,7 @@ Button(button_text="",
|
|||
size=(None, None),
|
||||
auto_size_button=None,
|
||||
button_color=None,
|
||||
disabled_button_color=None,
|
||||
use_ttk_buttons=None,
|
||||
font=None,
|
||||
bind_return_key=False,
|
||||
|
@ -5455,6 +5456,7 @@ Parameter Descriptions:
|
|||
|size|Tuple[int, int] (width, height) of the button in characters wide, rows high|
|
||||
|auto_size_button|(bool) if True the button size is sized to fit the text|
|
||||
|button_color|Tuple[str, str] (text color, background color) of button. Easy to remember which is which if you say "ON" between colors. "red" on "green".|
|
||||
|disabled_button_color|Tuple[str, str] colors to use when button is disabled (text, background). Use None for a color if don't want to change. Only ttk buttons support both text and background colors. tk buttons only support changing text color|
|
||||
|use_ttk_buttons|(bool) True = use ttk buttons. False = do not use ttk buttons. None (Default) = use ttk buttons only if on a Mac and not with button images|
|
||||
|font|Union[str, Tuple[str, int]] specifies the font family, size, etc|
|
||||
|bind_return_key|(bool) If True the return key will cause this button to be pressed|
|
||||
|
@ -5523,6 +5525,7 @@ Update(text=None,
|
|||
image_filename=None,
|
||||
visible=None,
|
||||
image_subsample=None,
|
||||
disabled_button_color=(None, None),
|
||||
image_size=None)
|
||||
```
|
||||
|
||||
|
@ -5535,6 +5538,7 @@ Parameter Descriptions:
|
|||
|disabled|(bool) disable or enable state of the element|
|
||||
|image_data|Union[bytes, str] Raw or Base64 representation of the image to put on button. Choose either filename or data|
|
||||
|image_filename|(str) image filename if there is a button image. GIFs and PNGs only.|
|
||||
|disabled_button_color|Tuple[str, str] colors to use when button is disabled (text, background). Use None for a color if don't want to change. Only ttk buttons support both text and background colors. tk buttons only support changing text color|
|
||||
|visible|(bool) control visibility of element|
|
||||
|image_subsample|(int) amount to reduce the size of the image. Divides the size by this number. 2=1/2, 3=1/3, 4=1/4, etc|
|
||||
|image_size|Tuple[int, int] Size of the image in pixels (width, height)|
|
||||
|
@ -5687,6 +5691,7 @@ update(text=None,
|
|||
image_filename=None,
|
||||
visible=None,
|
||||
image_subsample=None,
|
||||
disabled_button_color=(None, None),
|
||||
image_size=None)
|
||||
```
|
||||
|
||||
|
@ -5699,6 +5704,7 @@ Parameter Descriptions:
|
|||
|disabled|(bool) disable or enable state of the element|
|
||||
|image_data|Union[bytes, str] Raw or Base64 representation of the image to put on button. Choose either filename or data|
|
||||
|image_filename|(str) image filename if there is a button image. GIFs and PNGs only.|
|
||||
|disabled_button_color|Tuple[str, str] colors to use when button is disabled (text, background). Use None for a color if don't want to change. Only ttk buttons support both text and background colors. tk buttons only support changing text color|
|
||||
|visible|(bool) control visibility of element|
|
||||
|image_subsample|(int) amount to reduce the size of the image. Divides the size by this number. 2=1/2, 3=1/3, 4=1/4, etc|
|
||||
|image_size|Tuple[int, int] Size of the image in pixels (width, height)|
|
||||
|
@ -14307,6 +14313,8 @@ call and then have that same source run on plain PySimpleGUI.
|
|||
|---|---|
|
||||
| **return** | |
|
||||
|
||||
## Function Reference
|
||||
|
||||
```
|
||||
CButton(button_text,
|
||||
image_filename=None,
|
||||
|
@ -15021,6 +15029,39 @@ Parameter Descriptions:
|
|||
|||
|
||||
| **return** | (Button) |
|
||||
|
||||
```
|
||||
Open(button_text="Open",
|
||||
size=(None, None),
|
||||
auto_size_button=None,
|
||||
button_color=None,
|
||||
disabled=False,
|
||||
bind_return_key=True,
|
||||
tooltip=None,
|
||||
font=None,
|
||||
focus=False,
|
||||
pad=None,
|
||||
key=None,
|
||||
metadata=None)
|
||||
```
|
||||
|
||||
Parameter Descriptions:
|
||||
|
||||
|Name|Meaning|
|
||||
|---|---|
|
||||
|button_text|text in the button (Default value = 'Open')|
|
||||
|size|(w,h) w=characters-wide, h=rows-high|
|
||||
|auto_size_button|True if button size is determined by button text|
|
||||
|button_color|button color (foreground, background)|
|
||||
|disabled|set disable state for element (Default = False)|
|
||||
|bind_return_key|(Default = True)|
|
||||
|tooltip|(str) text, that will appear when mouse hovers over the element|
|
||||
|font|specifies the font family, size, etc|
|
||||
|focus|if focus should be set to this|
|
||||
|pad|Amount of padding to put around element|
|
||||
|key|Used with window.FindElement and with return values to uniquely identify this element|
|
||||
|
||||
## OneLineProgressMeter
|
||||
|
||||
```
|
||||
OneLineProgressMeter(title,
|
||||
current_value,
|
||||
|
@ -15061,36 +15102,7 @@ Parameter Descriptions:
|
|||
|---|---|
|
||||
|key|Used with window.FindElement and with return values to uniquely identify this element|
|
||||
|
||||
```
|
||||
Open(button_text="Open",
|
||||
size=(None, None),
|
||||
auto_size_button=None,
|
||||
button_color=None,
|
||||
disabled=False,
|
||||
bind_return_key=True,
|
||||
tooltip=None,
|
||||
font=None,
|
||||
focus=False,
|
||||
pad=None,
|
||||
key=None,
|
||||
metadata=None)
|
||||
```
|
||||
|
||||
Parameter Descriptions:
|
||||
|
||||
|Name|Meaning|
|
||||
|---|---|
|
||||
|button_text|text in the button (Default value = 'Open')|
|
||||
|size|(w,h) w=characters-wide, h=rows-high|
|
||||
|auto_size_button|True if button size is determined by button text|
|
||||
|button_color|button color (foreground, background)|
|
||||
|disabled|set disable state for element (Default = False)|
|
||||
|bind_return_key|(Default = True)|
|
||||
|tooltip|(str) text, that will appear when mouse hovers over the element|
|
||||
|font|specifies the font family, size, etc|
|
||||
|focus|if focus should be set to this|
|
||||
|pad|Amount of padding to put around element|
|
||||
|key|Used with window.FindElement and with return values to uniquely identify this element|
|
||||
## Popup Functions
|
||||
|
||||
Popup - Display a popup Window with as many parms as you wish to include. This is the GUI equivalent of the
|
||||
"print" statement. It's also great for "pausing" your program's flow until the user can read some error messages.
|
||||
|
@ -16453,6 +16465,8 @@ Parameter Descriptions:
|
|||
|||
|
||||
| **return** | (Button) |
|
||||
|
||||
## PEP8 Function Bindings
|
||||
|
||||
Change the "color scheme" of all future PySimpleGUI Windows.
|
||||
The scheme are string names that specify a group of colors. Background colors, text colors, button colors.
|
||||
There are 13 different color settings that are changed at one time using a single call to ChangeLookAndFeel
|
||||
|
@ -16634,6 +16648,8 @@ Parameter Descriptions:
|
|||
|---|---|
|
||||
|key|Used with window.FindElement and with return values to uniquely identify this element|
|
||||
|
||||
## Popups
|
||||
|
||||
Popup - Display a popup Window with as many parms as you wish to include. This is the GUI equivalent of the
|
||||
"print" statement. It's also great for "pausing" your program's flow until the user can read some error messages.
|
||||
|
||||
|
@ -18981,7 +18997,24 @@ The Element & Window bindings release
|
|||
* Window.bind - New method for Windows, just like Elements
|
||||
* Enables tkinter bindings to be added to Windows
|
||||
* Will get an event returned from window.read() if the tkinter event happens
|
||||
* TabGround fonts - can now set the font and font size for Tab text
|
||||
* TabGroup fonts - can now set the font and font size for Tab text
|
||||
|
||||
## 4.12.0 PySimpleGUI 14-Dec-2019
|
||||
|
||||
Finally no more outlines around TK Elements on Linux
|
||||
|
||||
* Fixed a long-term problem of the mysterious white border around (almost) all TK Elements on Linux
|
||||
* Ability to set the disabled button colors
|
||||
* New Button and Button.update parameter - disabled_button_color
|
||||
* Specified as (Text Color, Background Color) just like button colors
|
||||
* For Normal / TK Buttons - can set button text color only
|
||||
* For TTK Buttons - can set both a disabled button and text color
|
||||
* Either parameter can be None to use current setting
|
||||
* Removed use of CloseButton from Popups (still have a bug in the CloseButton code but not in popups now)
|
||||
* Combobox - removed requirement of setting disabled if want to set to readonly using update method
|
||||
* Fix for cancelling out of file/folder browse on Linux caused target to be cleared instead of just cancelling
|
||||
* Removed try block around setting button colors - if user sets a bad color, well don't do that
|
||||
* Now deleting windows after closing them for popup
|
||||
|
||||
### Upcoming
|
||||
|
||||
|
|
Loading…
Reference in New Issue