commit
6521111ad0
|
@ -103,15 +103,10 @@ def AllWidgetsWithContext():
|
||||||
"""
|
"""
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
# Green & tan color scheme
|
# Green & tan color scheme
|
||||||
sg.SetOptions(background_color='#9FB8AD',
|
sg.ChangeLookAndFeel('GreenTan')
|
||||||
text_element_background_color='#9FB8AD',
|
|
||||||
element_background_color='#9FB8AD',
|
|
||||||
input_elements_background_color='#F7F3EC',
|
# sg.ChangeLookAndFeel('GreenTan')
|
||||||
button_color=('white', '#475841'),
|
|
||||||
border_width=0,
|
|
||||||
slider_border_width=0,
|
|
||||||
progress_meter_border_depth=0,
|
|
||||||
scrollbar_color='#F7F3EC')
|
|
||||||
|
|
||||||
with sg.FlexForm('Everything bagel', default_element_size=(40, 1)) as form:
|
with sg.FlexForm('Everything bagel', default_element_size=(40, 1)) as form:
|
||||||
layout = [
|
layout = [
|
||||||
|
@ -143,15 +138,7 @@ def AllWidgetsNoContext():
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
|
|
||||||
# Green & tan color scheme
|
# Green & tan color scheme
|
||||||
sg.SetOptions(background_color='#9FB8AD',
|
sg.ChangeLookAndFeel('GreenTan')
|
||||||
text_element_background_color='#9FB8AD',
|
|
||||||
element_background_color='#9FB8AD',
|
|
||||||
input_elements_background_color='#F7F3EC',
|
|
||||||
button_color=('white', '#475841'),
|
|
||||||
border_width=0,
|
|
||||||
slider_border_width=0,
|
|
||||||
progress_meter_border_depth=0,
|
|
||||||
scrollbar_color='#F7F3EC')
|
|
||||||
|
|
||||||
form = sg.FlexForm('Everything bagel', default_element_size=(40, 1))
|
form = sg.FlexForm('Everything bagel', default_element_size=(40, 1))
|
||||||
layout = [
|
layout = [
|
||||||
|
@ -791,7 +778,7 @@ while True:
|
||||||
form.FindElement('multi').Update(inspect.getsource(func))
|
form.FindElement('multi').Update(inspect.getsource(func))
|
||||||
button, values = form.Read()
|
button, values = form.Read()
|
||||||
elif button is 'Run':
|
elif button is 'Run':
|
||||||
sg.ChangeLookAndFeel('SystemDefault')
|
# sg.ChangeLookAndFeel('SystemDefault')
|
||||||
func()
|
func()
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -770,7 +770,7 @@ class Output(Element):
|
||||||
# Button Class #
|
# Button Class #
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
class Button(Element):
|
class Button(Element):
|
||||||
def __init__(self, button_type=BUTTON_TYPE_CLOSES_WIN, target=(None, None), button_text='', file_types=(("ALL Files", "*.*"),), image_filename=None, image_size=(None, None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False, pad=None, key=None):
|
def __init__(self, button_type=BUTTON_TYPE_CLOSES_WIN, target=(None, None), button_text='', file_types=(("ALL Files", "*.*"),), image_filename=None, image_size=(None, None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, default_value = None, font=None, bind_return_key=False, focus=False, pad=None, key=None):
|
||||||
'''
|
'''
|
||||||
Button Element - Specifies all types of buttons
|
Button Element - Specifies all types of buttons
|
||||||
:param button_type:
|
:param button_type:
|
||||||
|
@ -802,6 +802,7 @@ class Button(Element):
|
||||||
self.BindReturnKey = bind_return_key
|
self.BindReturnKey = bind_return_key
|
||||||
self.Focus = focus
|
self.Focus = focus
|
||||||
self.TKCal = None
|
self.TKCal = None
|
||||||
|
self.DefaultValue = None
|
||||||
super().__init__(ELEM_TYPE_BUTTON, scale=scale, size=size, font=font, pad=pad, key=key)
|
super().__init__(ELEM_TYPE_BUTTON, scale=scale, size=size, font=font, pad=pad, key=key)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -892,7 +893,7 @@ class Button(Element):
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def Update(self, new_text=None, button_color=(None, None)):
|
def Update(self, value=None, new_text=None, button_color=(None, None)):
|
||||||
try:
|
try:
|
||||||
if new_text is not None:
|
if new_text is not None:
|
||||||
self.TKButton.configure(text=new_text)
|
self.TKButton.configure(text=new_text)
|
||||||
|
@ -900,6 +901,7 @@ class Button(Element):
|
||||||
self.TKButton.config(foreground=button_color[0], background=button_color[1])
|
self.TKButton.config(foreground=button_color[0], background=button_color[1])
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
|
self.DefaultValue = value
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
try:
|
try:
|
||||||
|
@ -1193,6 +1195,9 @@ class Column(Element):
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
|
|
||||||
class TKCalendar(ttk.Frame):
|
class TKCalendar(ttk.Frame):
|
||||||
|
"""
|
||||||
|
This code was shamelessly lifted from moshekaplan's repository - moshekaplan/tkinter_components
|
||||||
|
"""
|
||||||
# XXX ToDo: cget and configure
|
# XXX ToDo: cget and configure
|
||||||
|
|
||||||
datetime = calendar.datetime.datetime
|
datetime = calendar.datetime.datetime
|
||||||
|
@ -1393,37 +1398,6 @@ class TKCalendar(ttk.Frame):
|
||||||
year, month = self._date.year, self._date.month
|
year, month = self._date.year, self._date.month
|
||||||
return self.datetime(year, month, int(self._selection[0]))
|
return self.datetime(year, month, int(self._selection[0]))
|
||||||
|
|
||||||
class Calendar(Element):
|
|
||||||
def __init__(self, scale=(None, None), size=(None, None), pad=None, key=None):
|
|
||||||
'''
|
|
||||||
Image Element
|
|
||||||
:param filename:
|
|
||||||
:param scale: Adds multiplier to size (w,h)
|
|
||||||
:param size: Size of field in characters
|
|
||||||
'''
|
|
||||||
self.tkCalendar = None
|
|
||||||
|
|
||||||
|
|
||||||
if data is None and filename is None:
|
|
||||||
print('* Warning... no image specified in Image Element! *')
|
|
||||||
super().__init__(ELEM_TYPE_IMAGE, scale=scale, size=size, pad=pad, key=key)
|
|
||||||
return
|
|
||||||
|
|
||||||
def Update(self, filename=None, data=None):
|
|
||||||
if filename is not None:
|
|
||||||
image = tk.PhotoImage(file=filename)
|
|
||||||
elif data is not None:
|
|
||||||
if type(data) is bytes:
|
|
||||||
image = tk.PhotoImage(data=data)
|
|
||||||
else:
|
|
||||||
image = data
|
|
||||||
else: return
|
|
||||||
width, height = image.width(), image.height()
|
|
||||||
self.tktext_label.configure(image=image, width=width, height=height)
|
|
||||||
self.tktext_label.image = image
|
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
super().__del__()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1984,7 +1958,14 @@ def BuildResultsForSubform(form, initialize_only, top_level_form):
|
||||||
value = None
|
value = None
|
||||||
|
|
||||||
# if an input type element, update the results
|
# if an input type element, update the results
|
||||||
if (element.Type == ELEM_TYPE_BUTTON and element.BType == BUTTON_TYPE_CALENDAR_CHOOSER) or element.Type != ELEM_TYPE_TEXT and element.Type != ELEM_TYPE_IMAGE and element.Type != ELEM_TYPE_OUTPUT and element.Type != ELEM_TYPE_PROGRESS_BAR and element.Type!= ELEM_TYPE_COLUMN:
|
if element.Type != ELEM_TYPE_BUTTON and element.Type != ELEM_TYPE_TEXT and element.Type != ELEM_TYPE_IMAGE and\
|
||||||
|
element.Type != ELEM_TYPE_OUTPUT and element.Type != ELEM_TYPE_PROGRESS_BAR and \
|
||||||
|
element.Type!= ELEM_TYPE_COLUMN:
|
||||||
|
AddToReturnList(form, value)
|
||||||
|
AddToReturnDictionary(top_level_form, element, value)
|
||||||
|
elif (element.Type == ELEM_TYPE_BUTTON and element.BType == BUTTON_TYPE_CALENDAR_CHOOSER) or \
|
||||||
|
(element.Type == ELEM_TYPE_BUTTON and element.Target == (None,None) and \
|
||||||
|
(element.BType in (BUTTON_TYPE_SAVEAS_FILE, BUTTON_TYPE_BROWSE_FILE, BUTTON_TYPE_BROWSE_FILES, BUTTON_TYPE_BROWSE_FOLDER))):
|
||||||
AddToReturnList(form, value)
|
AddToReturnList(form, value)
|
||||||
AddToReturnDictionary(top_level_form, element, value)
|
AddToReturnDictionary(top_level_form, element, value)
|
||||||
|
|
||||||
|
@ -2037,7 +2018,8 @@ def FillSubformWithValues(form, values_dict):
|
||||||
element.Update(value)
|
element.Update(value)
|
||||||
elif element.Type == ELEM_TYPE_INPUT_SPIN:
|
elif element.Type == ELEM_TYPE_INPUT_SPIN:
|
||||||
element.Update(value)
|
element.Update(value)
|
||||||
|
elif element.Type == ELEM_TYPE_BUTTON:
|
||||||
|
element.Update(value)
|
||||||
|
|
||||||
def _FindElementFromKeyInSubForm(form, key):
|
def _FindElementFromKeyInSubForm(form, key):
|
||||||
for row_num, row in enumerate(form.Rows):
|
for row_num, row in enumerate(form.Rows):
|
||||||
|
|
|
@ -1987,7 +1987,8 @@ GNU Lesser General Public License (LGPL 3) +
|
||||||
* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence
|
* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence
|
||||||
* [Fredrik Lundh](https://wiki.python.org/moin/FredrikLundh) for his work on `tkinter`
|
* [Fredrik Lundh](https://wiki.python.org/moin/FredrikLundh) for his work on `tkinter`
|
||||||
* [Ruud van der Ham](https://forum.pythonistacafe.com/u/Ruud) for all the help he's provided as a Python-mentor. Quite a few tricky bits of logic was supplied by Ruud. The dual-purpose return values scheme is Ruud's for example
|
* [Ruud van der Ham](https://forum.pythonistacafe.com/u/Ruud) for all the help he's provided as a Python-mentor. Quite a few tricky bits of logic was supplied by Ruud. The dual-purpose return values scheme is Ruud's for example
|
||||||
* Numerous users who provided feature suggestions! Many of the cool features were suggested by others. If you were one of them and are willing to take more credit, I'll list you here if you give me permission. Most are too modest.
|
* **Numerous** users who provided feature suggestions! Many of the cool features were suggested by others. If you were one of them and are willing to take more credit, I'll list you here if you give me permission. Most are too modest
|
||||||
|
* [moshekaplan](https://github.com/moshekaplan)/**[tkinter_components](https://github.com/moshekaplan/tkinter_components)** wrote the code for the Calendar Chooser Element. It was lifted straight from GitHub
|
||||||
|
|
||||||
|
|
||||||
## How Do I
|
## How Do I
|
||||||
|
|
|
@ -1987,7 +1987,8 @@ GNU Lesser General Public License (LGPL 3) +
|
||||||
* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence
|
* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence
|
||||||
* [Fredrik Lundh](https://wiki.python.org/moin/FredrikLundh) for his work on `tkinter`
|
* [Fredrik Lundh](https://wiki.python.org/moin/FredrikLundh) for his work on `tkinter`
|
||||||
* [Ruud van der Ham](https://forum.pythonistacafe.com/u/Ruud) for all the help he's provided as a Python-mentor. Quite a few tricky bits of logic was supplied by Ruud. The dual-purpose return values scheme is Ruud's for example
|
* [Ruud van der Ham](https://forum.pythonistacafe.com/u/Ruud) for all the help he's provided as a Python-mentor. Quite a few tricky bits of logic was supplied by Ruud. The dual-purpose return values scheme is Ruud's for example
|
||||||
* Numerous users who provided feature suggestions! Many of the cool features were suggested by others. If you were one of them and are willing to take more credit, I'll list you here if you give me permission. Most are too modest.
|
* **Numerous** users who provided feature suggestions! Many of the cool features were suggested by others. If you were one of them and are willing to take more credit, I'll list you here if you give me permission. Most are too modest
|
||||||
|
* [moshekaplan](https://github.com/moshekaplan)/**[tkinter_components](https://github.com/moshekaplan/tkinter_components)** wrote the code for the Calendar Chooser Element. It was lifted straight from GitHub
|
||||||
|
|
||||||
|
|
||||||
## How Do I
|
## How Do I
|
||||||
|
|
Loading…
Reference in New Issue