Disable element, Release 0.2.0

This commit is contained in:
MikeTheWatchGuy 2019-01-23 16:59:54 -05:00
parent 538e469723
commit 698849d9b4
2 changed files with 63 additions and 8 deletions

View file

@ -494,8 +494,7 @@ class Element():
class InputText(Element):
def __init__(self, default_text='', size=(None, None), disabled=False, password_char='',
justification=None, background_color=None, text_color=None, font=None, tooltip=None,
change_submits=False,
do_not_clear=False, key=None, focus=False, pad=None):
change_submits=False, do_not_clear=False, key=None, focus=False, pad=None):
'''
Input a line of text Element
:param default_text: Default value to display
@ -1061,6 +1060,7 @@ class Text(Element):
pixelsize = size[0]*10, size[1]*20
self.WxStaticText:wx.StaticText = None # wx.StaticText(form.MasterPanel, -1, element.DisplayText)
self.BorderWidth = border_width if border_width is not None else DEFAULT_BORDER_WIDTH
self.Disabled = False
super().__init__(ELEM_TYPE_TEXT, pixelsize, auto_size_text, background_color=bg, font=font if font else DEFAULT_FONT,
text_color=self.TextColor, pad=pad, key=key, tooltip=tooltip, size_px=size_px, visible=visible)
@ -3897,8 +3897,11 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
widget.style['color'] = element.TextColor
widget.style['font-size'] = '{}px'.format(font_info[1])
size = convert_tkinter_size_to_Wx(element_size)
# if not auto_size_text:
widget.style['height'] = '{}px'.format(size[1])
widget.style['width'] = '{}px'.format(size[0])
if element.Disabled:
widget.set_enabled(False)
#
# widget.SetMinSize(element_size)
# if element.Disabled:
@ -3992,7 +3995,6 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
element.Widget.style['text-align'] = 'center'
elif element.Justification.startswith('r'):
element.Widget.style['text-align'] = 'right'
tk_row_frame.append(element.Widget)
# auto_size_text = element.AutoSizeText
@ -6458,18 +6460,18 @@ def PopupGetText(message, default_text='', password_char='', size=(None, None),
def main():
SetOptions(background_color='blue', text_element_background_color='blue', text_color='white')
layout = [[Text('You are running the PySimpleGUI.py file itself', background_color='blue', font='Courier 20')],
[Text('You should be importing it rather than running it', size=(50, 2))],
[Text('You should be importing it rather than running it', size=(60, 1))],
[Text('Here is your sample input window....')],
[Text('Source Folder',justification='right'), InputText('Source', focus=True),
[Text('Source Folder',justification='right', size=(40,1)), InputText('Source', focus=True, disabled=True),
FolderBrowse()],
[Text('Destination Folder', justification='right'), InputText('Dest'), FolderBrowse()],
[Ok(), Cancel()]]
[Text('Destination Folder', justification='right', size=(40,1)), InputText('Dest'), FolderBrowse()],
[Ok(), Cancel(disabled=True), Exit()]]
window = Window('Demo window..', background_color='blue', font='Courier 18').Layout(layout)
while True:
event, values = window.Read()
print(event, values)
if event is None:
if event in (None, 'Exit'):
break
window.Close()