Skip to content

Commit d77f660

Browse files
committed
Frame support (but no label yet). Display Remi version in the main() teest harness
1 parent e469e67 commit d77f660

1 file changed

Lines changed: 60 additions & 13 deletions

File tree

PySimpleGUIWeb/PySimpleGUIWeb.py

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#usr/bin/python3
22

3-
version = __version__ = "0.38.0 Released 06-May-2020"
3+
version = __version__ = "0.38.0.1 Unreleased\n Addition of Frame (but without a label)"
44

55
port = 'PySimpleGUIWeb'
66

@@ -19,6 +19,8 @@
1919
import mimetypes
2020
from random import randint
2121
import time
22+
import pkg_resources
23+
2224

2325
# from typing import List, Any, Union, Tuple, Dict # For doing types in comments. perhaps not required
2426

@@ -1908,6 +1910,22 @@ def _DragCallback(self, emitter, x, y):
19081910
# ---------------------------------------------------------------------- #
19091911
# Frame #
19101912
# ---------------------------------------------------------------------- #
1913+
1914+
# First the REMI implementation of a frame
1915+
1916+
class CLASSframe( remi.gui.VBox ):
1917+
def __init__(self, title, *args, **kwargs):
1918+
super( CLASSframe, self ).__init__(*args, **kwargs)
1919+
self.style.update({"overflow":"visible","border-width":"1px","border-style":"solid","border-color":"#7d7d7d"})
1920+
self.frame_label = remi.gui.Label('frame label')
1921+
self.frame_label.style.update({"position":"relative","overflow":"auto","background-color":"#ffffff","border-width":"1px","border-style":"solid","top":"-7px","width":"0px","height":"0px","left":"10px"})
1922+
self.append(self.frame_label,'frame_label')
1923+
self.set_title(title)
1924+
1925+
def set_title(self, title):
1926+
self.frame_label.set_text(title)
1927+
1928+
19111929
class Frame(Element):
19121930
def __init__(self, title, layout, title_color=None, background_color=None, title_location=None,
19131931
relief=DEFAULT_FRAME_RELIEF, element_justification='left', size=(None, None), font=None, pad=None, border_width=None, key=None,
@@ -1943,6 +1961,8 @@ def __init__(self, title, layout, title_color=None, background_color=None, title
19431961
self.BackgroundColor = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
19441962
self.Justification = 'left'
19451963
self.ElementJustification = element_justification
1964+
self.Widget = None # type: CLASSframe
1965+
19461966

19471967

19481968
self.Layout(layout)
@@ -4146,6 +4166,9 @@ def AddMenuItem(top_menu, sub_menu_info, element, is_sub_menu=False, skip=False)
41464166
# ===================================== REMI CODE STARTS HERE ================================================ #
41474167
# ------------------------------------------------------------------------------------------------------------ #
41484168

4169+
4170+
4171+
41494172
def PackFormIntoFrame(form, containing_frame, toplevel_form):
41504173
def CharWidthInPixels():
41514174
return tkinter.font.Font().measure('A') # single character width
@@ -4208,9 +4231,12 @@ def do_font_and_color(widget):
42084231
if form.ElementJustification.startswith('c'):
42094232
tk_row_frame.style['margin-left'] = 'auto'
42104233
tk_row_frame.style['margin-right'] = 'auto'
4234+
# tk_row_frame.style['justify-content'] = 'center'
42114235
elif form.ElementJustification.startswith('r'):
4236+
# tk_row_frame.style['justify-content'] = 'flex-end'
42124237
tk_row_frame.style['margin-left'] = 'auto'
4213-
else:
4238+
else: # everything else is left justified
4239+
# tk_row_frame.style['justify-content'] = 'flex-flexstart'
42144240
tk_row_frame.style['margin-right'] = 'auto'
42154241

42164242
if form.BackgroundColor not in(None, COLOR_SYSTEM_DEFAULT):
@@ -4757,20 +4783,28 @@ def do_font_and_color(widget):
47574783

47584784
# ------------------------- Frame element ------------------------- #
47594785
elif element_type == ELEM_TYPE_FRAME:
4760-
element = element # type: Frame
4761-
element.Widget = column_widget = remi.gui.VBox()
4762-
if element.Justification.startswith('c'):
4763-
# print('CENTERING')
4764-
column_widget.style['align-items'] = 'center'
4765-
column_widget.style['justify-content'] = 'center'
4766-
else:
4767-
column_widget.style['justify-content'] = 'flex-start'
4768-
column_widget.style['align-items'] = 'baseline'
4786+
element = element # type: Frame
4787+
# element.Widget = column_widget = remi.gui.VBox()
4788+
element.Widget = column_widget = CLASSframe(element.Title)
47694789
if element.BackgroundColor not in (None, COLOR_SYSTEM_DEFAULT):
47704790
column_widget.style['background-color'] = element.BackgroundColor
47714791
PackFormIntoFrame(element, column_widget, toplevel_form)
47724792
tk_row_frame.append(element.Widget)
47734793

4794+
#
4795+
# element = element # type: Frame
4796+
# element.Widget = column_widget = remi.gui.VBox()
4797+
# if element.Justification.startswith('c'):
4798+
# column_widget.style['align-items'] = 'center'
4799+
# column_widget.style['justify-content'] = 'center'
4800+
# else:
4801+
# column_widget.style['justify-content'] = 'flex-start'
4802+
# column_widget.style['align-items'] = 'baseline'
4803+
# if element.BackgroundColor not in (None, COLOR_SYSTEM_DEFAULT):
4804+
# column_widget.style['background-color'] = element.BackgroundColor
4805+
# PackFormIntoFrame(element, column_widget, toplevel_form)
4806+
# tk_row_frame.append(element.Widget)
4807+
47744808
# labeled_frame = tk.LabelFrame(tk_row_frame, text=element.Title, relief=element.Relief)
47754809
# PackFormIntoFrame(element, labeled_frame, toplevel_form)
47764810
# labeled_frame.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1])
@@ -7916,6 +7950,15 @@ def main():
79167950
# FolderBrowse()],
79177951
# [Text('Destination Folder', justification='right', size=(40,1)), InputText('Dest'), FolderBrowse()],
79187952
# [Ok(), Cancel(disabled=True), Exit(tooltip='Exit button'), Button('Hidden Button', visible=False)]]
7953+
try:
7954+
ver = version[:version.index('\n')]
7955+
except:
7956+
ver = version
7957+
7958+
7959+
def VerLine(version, description, size=(30,1)):
7960+
return [Column([[T(description, font='Courier 18', text_color='yellow')], [T(version, font='Courier 18', size=size)]])]
7961+
79197962

79207963
menu_def = [['&File', ['&Open', '&Save', 'E&xit', 'Properties']],
79217964
['&Edit', ['Paste', ['Special', 'Normal', ], '!Undo'], ],
@@ -7933,12 +7976,16 @@ def main():
79337976
layout = [
79347977
[Menu(menu_def, key='_MENU_', text_color='yellow', background_color='#475841', font='Courier 14')],
79357978
# [T('123435', size=(1,8))],
7936-
[Text('PySimpleGUIWeb Welcomes You...', tooltip='text', font=('Comic sans ms', 20),size=(40,1), text_color='red', enable_events=False, key='_PySimpleGUIWeb_')],
7979+
[Text('PySimpleGUIWeb Welcomes You...', tooltip='text', font=('Comic sans ms', 20),size=(40,1), text_color='yellow', enable_events=False, key='_PySimpleGUIWeb_')],
79377980
# [OptionMenu([])],
79387981
[T('System platform = %s'%sys.platform)],
79397982
[Image(data=DEFAULT_BASE64_ICON, enable_events=False)],
79407983
# [Image(filename=r'C:\Python\PycharmProjects\GooeyGUI\logo500.png', key='-IMAGE-')],
7941-
[Text('VERSION {}'.format(version), text_color='red', font='Courier 24')],
7984+
VerLine(ver, 'PySimpleGUI Version'),
7985+
VerLine(os.path.dirname(os.path.abspath(__file__)), 'PySimpleGUI Location'),
7986+
VerLine(sys.version, 'Python Version', size=(60,2)),
7987+
VerLine(pkg_resources.get_distribution("remi").version, 'Remi Version'),
7988+
# [Text('VERSION {}'.format(version), text_color='red', font='Courier 24')],
79427989
[T('Current Time '), Text('Text', key='_TEXT_', font='Arial 18', text_color='black', size=(30,1)), Column(col1, background_color='red')],
79437990
[T('Up Time'), Text('Text', key='_TEXT_UPTIME_', font='Arial 18', text_color='black', size=(30,1))],
79447991
[Input('Single Line Input', do_not_clear=True, enable_events=False, size=(30, 1), text_color='red', key='_IN_')],

0 commit comments

Comments
 (0)