Merge pull request #1107 from PySimpleGUI/Dev-latest

Dev latest
This commit is contained in:
MikeTheWatchGuy 2019-01-23 22:08:40 -05:00 committed by GitHub
commit 3de25852c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 110 additions and 28 deletions

View File

@ -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()

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
@ -1059,8 +1058,8 @@ 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
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)
@ -3110,10 +3109,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=False, 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 +3136,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)
#
@ -3897,8 +3904,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:
@ -3926,7 +3936,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
@ -3992,7 +4003,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
@ -6456,20 +6466,21 @@ 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('Here is your sample input window....')],
[Text('Source Folder',justification='right'), InputText('Source', focus=True),
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))],
[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'), 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)
window = Window('Demo window..', font='Arial 18').Layout(layout)
while True:
event, values = window.Read()
print(event, values)
if event is None:
if event in (None, 'Exit'):
break
window.Close()

View File

@ -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.

View File

@ -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
* [GraDesk](https://github.com/sidbmw/ICS
<!--stackedit_data:
eyJoaXN0b3J5IjpbMTE2NjQwNTUyLDI2NjM2NDQxNyw0NDk0Mz
MyNDMsLTExNDg0OTA2MjNdfQ==
eyJoaXN0b3J5IjpbLTI5Njc4MzU1LC03NzQwNzQyMzAsMjY2Mz
Y0NDE3LDQ0OTQzMzI0MywtMTE0ODQ5MDYyM119
-->