From 698849d9b4348eb823a0a9306c8adb0d5b3c48da Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 23 Jan 2019 16:59:54 -0500 Subject: [PATCH 1/6] Disable element, Release 0.2.0 --- PySimpleGUIWeb/Demo Programs/Web_Timer.py | 53 +++++++++++++++++++++++ PySimpleGUIWeb/PySimpleGUIWeb.py | 18 ++++---- 2 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 PySimpleGUIWeb/Demo Programs/Web_Timer.py diff --git a/PySimpleGUIWeb/Demo Programs/Web_Timer.py b/PySimpleGUIWeb/Demo Programs/Web_Timer.py new file mode 100644 index 00000000..ff342585 --- /dev/null +++ b/PySimpleGUIWeb/Demo Programs/Web_Timer.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python +import PySimpleGUIWeb as sg +import time + +# ---------------- Create Form ---------------- +layout = [ + [sg.Text('', background_color='black')], + [sg.Text('test', size=(20, 1), font=('Helvetica', 30), justification='center', text_color='white', key='text', background_color='black')], + [sg.Text('', background_color='black')], + [sg.Button('Pause', key='button', button_color=('white', '#001480')), + sg.Button('Reset', button_color=('white', '#007339'), key='Reset'), + sg.Exit(button_color=('white', '#8B1A1A'), key='Exit')] + ] + +window = sg.Window('Running Timer', background_color='black', font='Helvetica 18').Layout(layout) + +# ---------------- main loop ---------------- +current_time = 0 +paused = False +start_time = int(round(time.time() * 100)) +while (True): + # --------- Read and update window -------- + if not paused: + event, values = window.Read(timeout=0) + current_time = int(round(time.time() * 100)) - start_time + else: + event, values = window.Read() + if event == 'button': + event = window.FindElement(event).GetText() + # --------- Do Button Operations -------- + if event is None or event == 'Exit': # ALWAYS give a way out of program + break + if event is 'Reset': + start_time = int(round(time.time() * 100)) + current_time = 0 + paused_time = start_time + elif event == 'Pause': + paused = True + paused_time = int(round(time.time() * 100)) + element = window.FindElement('button') + element.Update(text='Run') + elif event == 'Run': + paused = False + start_time = start_time + int(round(time.time() * 100)) - paused_time + element = window.FindElement('button') + element.Update(text='Pause') + + # --------- Display timer in window -------- + window.FindElement('text').Update('{:02d}:{:02d}.{:02d}'.format((current_time // 100) // 60, + (current_time // 100) % 60, + current_time % 100)) +# --------- After loop -------- +window.Close() diff --git a/PySimpleGUIWeb/PySimpleGUIWeb.py b/PySimpleGUIWeb/PySimpleGUIWeb.py index 6ee0df3c..4ba23cd6 100644 --- a/PySimpleGUIWeb/PySimpleGUIWeb.py +++ b/PySimpleGUIWeb/PySimpleGUIWeb.py @@ -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() From 94c48183f00bbb8077073fbf45ae876ecf444da3 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 23 Jan 2019 18:49:05 -0500 Subject: [PATCH 2/6] background color fix. Crashed if you didn't specify a color. Quick spin of release 0.2.1 --- PySimpleGUIWeb/PySimpleGUIWeb.py | 29 +++++++++++++++++++---------- PySimpleGUIWeb/readme.md | 32 +++++++++++++++++++++++++------- 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/PySimpleGUIWeb/PySimpleGUIWeb.py b/PySimpleGUIWeb/PySimpleGUIWeb.py index 4ba23cd6..6a525bcd 100644 --- a/PySimpleGUIWeb/PySimpleGUIWeb.py +++ b/PySimpleGUIWeb/PySimpleGUIWeb.py @@ -3110,10 +3110,17 @@ class Window: def remi_thread(self): - logging.getLogger('remi').setLevel(level=logging.CRITICAL) logging.getLogger('remi').disabled = True - logging.disable(logging.CRITICAL) - remi.start(self.MyApp, title=self.Title ,debug=False, address='0.0.0.0', port=0, start_browser=True, userdata=(self,)) # standalone=True) + logging.getLogger('remi.server.ws').disabled = True + logging.getLogger('remi.server').disabled = True + logging.getLogger('remi.request').disabled = True + # use this code to start the application instead of the **start** call + s = remi.Server(self.MyApp, start=True, title=self.Title, address='0.0.0.0', port=8081, start_browser=True, userdata=(self,), multiple_instance=True, update_interval=.001) + + # logging.getLogger('remi').setLevel(level=logging.CRITICAL) + # logging.getLogger('remi').disabled = True + # logging.disable(logging.CRITICAL) + # remi.start(self.MyApp, title=self.Title ,debug=False, address='0.0.0.0', port=0, start_browser=True, userdata=(self,)) # standalone=True) self.MessageQueue.put(None) class MyApp(remi.App): @@ -3130,7 +3137,8 @@ class Window: wid = remi.gui.VBox() wid.style['justify-content'] = 'flex-start' wid.style['align-items'] = 'baseline' - wid.style['background-color'] = self.window.BackgroundColor + if self.window.BackgroundColor not in (None, COLOR_SYSTEM_DEFAULT): + wid.style['background-color'] = self.window.BackgroundColor PackFormIntoFrame(self.window, wid, self.window) # @@ -3929,7 +3937,8 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): tk_row_frame = remi.gui.HBox() # TODO Get horizontal ROW widget to put others into tk_row_frame.style['justify-content'] = 'flex-start' tk_row_frame.style['align-items'] = 'baseline' - tk_row_frame.style['background-color'] = toplevel_form.BackgroundColor + if toplevel_form.BackgroundColor not in(None, COLOR_SYSTEM_DEFAULT): + tk_row_frame.style['background-color'] = toplevel_form.BackgroundColor for col_num, element in enumerate(flex_row): element.ParentForm = toplevel_form # save the button's parent form object @@ -6458,16 +6467,16 @@ 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')], + # SetOptions(background_color='blue', text_element_background_color='blue', text_color='white') + layout = [[Text('You are running the PySimpleGUI.py file itself', font='Courier 20')], [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', size=(40,1)), InputText('Source', focus=True, disabled=True), + [Text('Here is your sample window....')], + [Text('Source Folder', justification='right', size=(40,1)), InputText('Source', focus=True, disabled=True), FolderBrowse()], [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) + window = Window('Demo window..', font='Courier 18').Layout(layout) while True: event, values = window.Read() print(event, values) diff --git a/PySimpleGUIWeb/readme.md b/PySimpleGUIWeb/readme.md index 5c436726..13d39eda 100644 --- a/PySimpleGUIWeb/readme.md +++ b/PySimpleGUIWeb/readme.md @@ -8,7 +8,7 @@ ![Python Version](https://img.shields.io/badge/Python-3.x-yellow.svg) -![Python Version](https://img.shields.io/badge/PySimpleGUIWeb_Version-0.1.0-orange.svg?longCache=true&style=for-the-badge) +![Python Version](https://img.shields.io/badge/PySimpleGUIWeb_Version-0.2.0-orange.svg?longCache=true&style=for-the-badge) @@ -28,7 +28,7 @@ PySimpleGUIWeb enables you to run your PySimpleGUI programs in your web browser. At the moment (22-Jan-2019) the port has barely begun but it's far enough along to see that it's going to work. The Text, Input Text and Button elements are "functional". You can run simple PySimpleGUI programs and they actually WORK correctly. -## Engineering Pre-Release Version 0.1.0 +## Engineering Pre-Release Version 0.2.0 [Announcements of Latest Developments](https://github.com/MikeTheWatchGuy/PySimpleGUI/issues/142) @@ -69,15 +69,15 @@ PySimpleGUIWeb runs only on Python 3. Legacy Python is not supported. ## What Works -Text Element -Input Text Element -Button Element +* Text Element +* Input Text Element +* Button Element + -Things like colors, fonts, etc, are not yet completed. This is SO early in the process, but it's exciting to see at the same time. # Release Notes: -### 0.1.0 - 22-Jan-2019 +## 0.1.0 PySimpleGUIWeb 22-Jan-2019 * Initial release * Text Element @@ -86,6 +86,24 @@ Things like colors, fonts, etc, are not yet completed. This is SO early in the * Window class +## 0.2.0 PySimpleGUIWeb 23-Jan-2019 + +Day 2 of development brings fonts, sizes, and colors... + +* For all elements (Text, Input Text, Button): + * Font family + * Font size + * Text Color + * Background Color + * Disable + * Size +* Button Color +* Read timeouts (zero, non-zero, None/pend) +* Window close +* Window background color + + + # Design # Author Mike B. From a71f6b2acc8009edaf4d563612d4626a11cd1aca Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 23 Jan 2019 19:56:57 -0500 Subject: [PATCH 3/6] Release 0.2.2 --- PySimpleGUIWeb/PySimpleGUIWeb.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PySimpleGUIWeb/PySimpleGUIWeb.py b/PySimpleGUIWeb/PySimpleGUIWeb.py index 6a525bcd..51f2bb33 100644 --- a/PySimpleGUIWeb/PySimpleGUIWeb.py +++ b/PySimpleGUIWeb/PySimpleGUIWeb.py @@ -1058,7 +1058,6 @@ class Text(Element): pixelsize = size if size[1] is not None and size[1] < 10: 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 @@ -3115,7 +3114,7 @@ class Window: logging.getLogger('remi.server').disabled = True logging.getLogger('remi.request').disabled = True # use this code to start the application instead of the **start** call - s = remi.Server(self.MyApp, start=True, title=self.Title, address='0.0.0.0', port=8081, start_browser=True, userdata=(self,), multiple_instance=True, update_interval=.001) + s = remi.Server(self.MyApp, start=True, title=self.Title, address='0.0.0.0', port=8081, start_browser=True, userdata=(self,), multiple_instance=False, update_interval=.001) # logging.getLogger('remi').setLevel(level=logging.CRITICAL) # logging.getLogger('remi').disabled = True @@ -6467,6 +6466,7 @@ def PopupGetText(message, default_text='', password_char='', size=(None, None), def main(): + ChangeLookAndFeel('GreenTan' ) # SetOptions(background_color='blue', text_element_background_color='blue', text_color='white') layout = [[Text('You are running the PySimpleGUI.py file itself', font='Courier 20')], [Text('You should be importing it rather than running it', size=(60, 1))], @@ -6476,7 +6476,7 @@ def main(): [Text('Destination Folder', justification='right', size=(40,1)), InputText('Dest'), FolderBrowse()], [Ok(), Cancel(disabled=True), Exit()]] - window = Window('Demo window..', font='Courier 18').Layout(layout) + window = Window('Demo window..', font='Arial 18').Layout(layout) while True: event, values = window.Read() print(event, values) From 90a98fdc8f5f0513d319367515f17bf27cb52f4f Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy <13696193+MikeTheWatchGuy@users.noreply.github.com> Date: Wed, 23 Jan 2019 21:59:33 -0500 Subject: [PATCH 4/6] readme.md updated from https://stackedit.io/ --- readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 458f8928..21e866e6 100644 --- a/readme.md +++ b/readme.md @@ -4991,8 +4991,8 @@ GNU Lesser General Public License (LGPL 3) + * [venim](https://github.com/venim) code to doing Alt-Selections in menus, updating Combobox using index, request to disable windows (a really good idea), checkbox and tab submits on change, returning keys for elements that have change_submits set, ... * [rtrrtr](https://github.com/rtrrtr) Helped get the 2.7 and 3.x code unified (big damned deal) * Tony Crewe (anthony.crewe@gmail.com) Generously provided his classroom materials that he has written to teach a GUI course. If you're an educator and want to trade materials with Tony, he would like to hear from you. -* [spectre6000](https://github.com/spectre +https://github.com/sidbmw/ICS4U \ No newline at end of file From c603f77235fb786cfcaba016afcc69e080622bf9 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy <13696193+MikeTheWatchGuy@users.noreply.github.com> Date: Wed, 23 Jan 2019 22:01:09 -0500 Subject: [PATCH 5/6] readme.md updated from https://stackedit.io/ --- readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 21e866e6..89cd0c2a 100644 --- a/readme.md +++ b/readme.md @@ -4991,8 +4991,8 @@ GNU Lesser General Public License (LGPL 3) + * [venim](https://github.com/venim) code to doing Alt-Selections in menus, updating Combobox using index, request to disable windows (a really good idea), checkbox and tab submits on change, returning keys for elements that have change_submits set, ... * [rtrrtr](https://github.com/rtrrtr) Helped get the 2.7 and 3.x code unified (big damned deal) * Tony Crewe (anthony.crewe@gmail.com) Generously provided his classroom materials that he has written to teach a GUI course. If you're an educator and want to trade materials with Tony, he would like to hear from you. -https://github.com/sidbmw/ICS4U +* * [GraDesk](https://github.com/sidbmw/IC \ No newline at end of file From 714a5f88c77f13f05855772577cf1da133f82a89 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy <13696193+MikeTheWatchGuy@users.noreply.github.com> Date: Wed, 23 Jan 2019 22:06:12 -0500 Subject: [PATCH 6/6] readme.md updated from https://stackedit.io/ --- readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 89cd0c2a..c4c51b92 100644 --- a/readme.md +++ b/readme.md @@ -4991,8 +4991,8 @@ GNU Lesser General Public License (LGPL 3) + * [venim](https://github.com/venim) code to doing Alt-Selections in menus, updating Combobox using index, request to disable windows (a really good idea), checkbox and tab submits on change, returning keys for elements that have change_submits set, ... * [rtrrtr](https://github.com/rtrrtr) Helped get the 2.7 and 3.x code unified (big damned deal) * Tony Crewe (anthony.crewe@gmail.com) Generously provided his classroom materials that he has written to teach a GUI course. If you're an educator and want to trade materials with Tony, he would like to hear from you. -* * [GraDesk](https://github.com/sidbmw/IC +* [GraDesk](https://github.com/sidbmw/ICS \ No newline at end of file