From c765f1f6f754fe8d6a6fd3321c5dd474c9ebf2e8 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 21 Aug 2018 19:10:26 -0400 Subject: [PATCH] Manually moving from Dev Latest on PC --- Demo_Keyboard.py | 17 +++++++---------- Demo_Keyboard_Realtime.py | 15 ++++++--------- Demo_PDF_Viewer.py | 4 +++- PySimpleGUI.py | 16 ---------------- 4 files changed, 16 insertions(+), 36 deletions(-) diff --git a/Demo_Keyboard.py b/Demo_Keyboard.py index 85f63b8a..88c5fc5d 100644 --- a/Demo_Keyboard.py +++ b/Demo_Keyboard.py @@ -1,26 +1,23 @@ -import sys import PySimpleGUI as sg # Recipe for getting keys, one at a time as they are released # If want to use the space bar, then be sure and disable the "default focus" -with sg.FlexForm('Realtime Keyboard Test', return_keyboard_events=True, use_default_focus=False) as form: - text_elem = sg.Text('', size=(12,1)) - layout = [[sg.Text('Press a key')], +with sg.FlexForm("Keyboard Test", return_keyboard_events=True, use_default_focus=False) as form: + text_elem = sg.Text("", size=(18,1)) + layout = [[sg.Text("Press a key or scroll mouse")], [text_elem], - [sg.SimpleButton('OK')]] + [sg.SimpleButton("OK")]] form.Layout(layout) # ---===--- Loop taking in user input --- # while True: - button, value = form.Read() + button, value = form.ReadNonBlocking() - if button == 'OK': - print(button, 'exiting') + if button == "OK" or (button is None and value is None): + print(button, "exiting") break if button is not None: text_elem.Update(button) - else: - break diff --git a/Demo_Keyboard_Realtime.py b/Demo_Keyboard_Realtime.py index bb1d145e..25812024 100644 --- a/Demo_Keyboard_Realtime.py +++ b/Demo_Keyboard_Realtime.py @@ -1,19 +1,16 @@ import PySimpleGUI as sg -# Recipe for getting a continuous stream of keys when using a non-blocking form -# If want to use the space bar, then be sure and disable the "default focus" - -with sg.FlexForm('Realtime Keyboard Test', return_keyboard_events=True, use_default_focus=False) as form: - layout = [[sg.Text('Hold down a key')], - [sg.SimpleButton('OK')]] +with sg.FlexForm("Realtime Keyboard Test", return_keyboard_events=True, use_default_focus=False) as form: + layout = [[sg.Text("Hold down a key")], + [sg.SimpleButton("OK")]] form.Layout(layout) - # ---===--- Loop taking in user input --- # + while True: button, value = form.ReadNonBlocking() - if button == 'OK': - print(button, value, 'exiting') + if button == "OK": + print(button, value, "exiting") break if button is not None: print(button) diff --git a/Demo_PDF_Viewer.py b/Demo_PDF_Viewer.py index ecd60c9c..6fd5fb42 100644 --- a/Demo_PDF_Viewer.py +++ b/Demo_PDF_Viewer.py @@ -37,6 +37,8 @@ import fitz import PySimpleGUI as sg from binascii import hexlify +sg.ChangeLookAndFeel('GreenTan') + if len(sys.argv) == 1: rc, fname = sg.GetFileBox('PDF Browser', 'PDF file to open', file_types=(("PDF Files", "*.pdf"),)) if rc is False: @@ -126,7 +128,7 @@ while True: if button is None: continue - if button in ("Escape:27"): # this spares me a 'Quit' button! + if button in ("Escape:27",): # this spares me a 'Quit' button! break # print("hex(button)", hexlify(button.encode())) if button[0] == chr(13): # surprise: this is 'Enter'! diff --git a/PySimpleGUI.py b/PySimpleGUI.py index ffdec2b7..8cbed783 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -867,10 +867,6 @@ class FlexForm: ''' Display a user defined for and return the filled in data ''' -<<<<<<< HEAD -======= - ->>>>>>> 531b32ab66746c9f4b6acd2ea8b6d113cb235827 def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, return_keyboard_events=False, use_default_focus=True, text_justification=None): self.AutoSizeText = auto_size_text if auto_size_text is not None else DEFAULT_AUTOSIZE_TEXT self.AutoSizeButtons = auto_size_buttons if auto_size_buttons is not None else DEFAULT_AUTOSIZE_BUTTONS @@ -1038,10 +1034,6 @@ class FlexForm: return BuildResults(self, False, self) def KeyboardCallback(self, event ): -<<<<<<< HEAD -======= - ->>>>>>> 531b32ab66746c9f4b6acd2ea8b6d113cb235827 self.LastButtonClicked = None self.FormRemainedOpen = True if event.char != '': @@ -1060,10 +1052,6 @@ class FlexForm: BuildResults(self, False, self) self.TKroot.quit() -<<<<<<< HEAD -======= - ->>>>>>> 531b32ab66746c9f4b6acd2ea8b6d113cb235827 def _Close(self): try: @@ -1826,10 +1814,6 @@ def StartupTK(my_flex_form): # root.bind('', MyFlexForm.DestroyedCallback()) ConvertFlexToTK(my_flex_form) my_flex_form.SetIcon(my_flex_form.WindowIcon) -<<<<<<< HEAD -======= - ->>>>>>> 531b32ab66746c9f4b6acd2ea8b6d113cb235827 if my_flex_form.ReturnKeyboardEvents and not my_flex_form.NonBlocking: root.bind("", my_flex_form.KeyboardCallback) root.bind("", my_flex_form.MouseWheelCallback)