Window margin variable supported but tricky, margin default changed to (0,0), fix in DrawCircle, styles change for ComboBox, frame color now defaults to light gray (gainsboro),
This commit is contained in:
parent
a013ad6f14
commit
de4c48fea2
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
from PySimpleGUI import Column
|
from PySimpleGUI import Column
|
||||||
|
|
||||||
version = __version__ = "0.35.0.17 Unreleased\nMassive update of docstrings (thanks nngogol), default for slider tick interval set automatically now, margins added to Window but not yet hooked up, VSeparator added (spelling error), added Radio.reset_group and removed clearing all when one of them is cleared (recent change), added default key for one_line_progress_meter, auto-add keys to tables & trees, InputText element gets new disabled-readonly foreground and background color settings and also a readonly parameter, InputText gets border_width parameter, fixed up some docstrings, popup gets new image and any_key_closes parms, input type popups also get image parameter, error checks for trying to manipulate a window prior to finalize, added a dummy Element.expand method, added theme_add_new, added Window.set_title, updated to the latest themes from tktiner port, big styles update (thanks nngogol!), more Styles work, changed popup text layout to match tkinter port, fixed vertical alignment in row, added margin to some elements, renamed styles related variables"
|
version = __version__ = "0.35.0.18 Unreleased\nMassive update of docstrings (thanks nngogol), default for slider tick interval set automatically now, margins added to Window but not yet hooked up, VSeparator added (spelling error), added Radio.reset_group and removed clearing all when one of them is cleared (recent change), added default key for one_line_progress_meter, auto-add keys to tables & trees, InputText element gets new disabled-readonly foreground and background color settings and also a readonly parameter, InputText gets border_width parameter, fixed up some docstrings, popup gets new image and any_key_closes parms, input type popups also get image parameter, error checks for trying to manipulate a window prior to finalize, added a dummy Element.expand method, added theme_add_new, added Window.set_title, updated to the latest themes from tktiner port, big styles update (thanks nngogol!), more Styles work, changed popup text layout to match tkinter port, fixed vertical alignment in row, added margin to some elements, renamed styles related variables, window margin support but be careful"
|
||||||
|
|
||||||
__version__ = version.split()[0] # For PEP 396 and PEP 345
|
__version__ = version.split()[0] # For PEP 396 and PEP 345
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ def TimerStop():
|
||||||
DEFAULT_WINDOW_ICON = DEFAULT_BASE64_ICON
|
DEFAULT_WINDOW_ICON = DEFAULT_BASE64_ICON
|
||||||
DEFAULT_ELEMENT_SIZE = (250, 22) # In PIXELS
|
DEFAULT_ELEMENT_SIZE = (250, 22) # In PIXELS
|
||||||
DEFAULT_BUTTON_ELEMENT_SIZE = (80, 25 ) # In PIXELS
|
DEFAULT_BUTTON_ELEMENT_SIZE = (80, 25 ) # In PIXELS
|
||||||
DEFAULT_MARGINS = (10, 5) # Margins for each LEFT/RIGHT margin is first term
|
DEFAULT_MARGINS = (0,0) # For Qt, use a Column element with padding to get same effect as tkinter port
|
||||||
DEFAULT_ELEMENT_PADDING = (4, 2) # Padding between elements (row, col) in pixels
|
DEFAULT_ELEMENT_PADDING = (4, 2) # Padding between elements (row, col) in pixels
|
||||||
# DEFAULT_ELEMENT_PADDING = (0, 0) # Padding between elements (row, col) in pixels
|
# DEFAULT_ELEMENT_PADDING = (0, 0) # Padding between elements (row, col) in pixels
|
||||||
DEFAULT_PIXELS_TO_CHARS_SCALING = (10,35) # 1 character represents x by y pixels
|
DEFAULT_PIXELS_TO_CHARS_SCALING = (10,35) # 1 character represents x by y pixels
|
||||||
|
@ -130,6 +130,7 @@ OFFICIAL_PYSIMPLEGUI_BUTTON_COLOR = ('white', BLUES[0]) # Colors should never b
|
||||||
|
|
||||||
|
|
||||||
CURRENT_LOOK_AND_FEEL = 'DarkBlue3'
|
CURRENT_LOOK_AND_FEEL = 'DarkBlue3'
|
||||||
|
# CURRENT_LOOK_AND_FEEL = 'Dark Red'
|
||||||
|
|
||||||
DEFAULT_ERROR_BUTTON_COLOR = ("#FFFFFF", "#FF0000")
|
DEFAULT_ERROR_BUTTON_COLOR = ("#FFFFFF", "#FF0000")
|
||||||
DEFAULT_BACKGROUND_COLOR = None
|
DEFAULT_BACKGROUND_COLOR = None
|
||||||
|
@ -2393,8 +2394,8 @@ class Graph(Element):
|
||||||
pen = QPen(qcolor)
|
pen = QPen(qcolor)
|
||||||
qcolor = QColor(fill_color)
|
qcolor = QColor(fill_color)
|
||||||
brush = QBrush(qcolor)
|
brush = QBrush(qcolor)
|
||||||
circle_id = self.QT_QGraphicsScene.addEllipse(self.x+converted_point[0], self.y+converted_point[1],
|
circle_id = self.QT_QGraphicsScene.addEllipse(self.x + converted_point[0] - radius, self.y + converted_point[1] - radius,
|
||||||
radius, radius, pen=pen, brush=brush)
|
radius * 2, radius * 2, pen=pen, brush=brush)
|
||||||
return circle_id # type: QGraphicsEllipseItem
|
return circle_id # type: QGraphicsEllipseItem
|
||||||
|
|
||||||
def RelocateFigure(self, id, x, y):
|
def RelocateFigure(self, id, x, y):
|
||||||
|
@ -2606,7 +2607,7 @@ class Frame(Element):
|
||||||
self.BorderWidth = border_width
|
self.BorderWidth = border_width
|
||||||
self.BackgroundColor = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
|
self.BackgroundColor = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
|
||||||
self.ElementJustification = element_justification
|
self.ElementJustification = element_justification
|
||||||
self.FrameColor = frame_color if frame_color is not None else theme_text_color()
|
self.FrameColor = frame_color
|
||||||
self.Widget = self.QT_QGroupBox = None # type: QGroupBox
|
self.Widget = self.QT_QGroupBox = None # type: QGroupBox
|
||||||
self.Layout(layout)
|
self.Layout(layout)
|
||||||
|
|
||||||
|
@ -4116,6 +4117,7 @@ class Window:
|
||||||
self.metadata = metadata
|
self.metadata = metadata
|
||||||
self.ElementJustification = element_justification
|
self.ElementJustification = element_justification
|
||||||
self.AllKeysDict = {}
|
self.AllKeysDict = {}
|
||||||
|
self.margins = margins
|
||||||
|
|
||||||
if layout is not None:
|
if layout is not None:
|
||||||
self.Layout(layout)
|
self.Layout(layout)
|
||||||
|
@ -6258,6 +6260,10 @@ def PackFormIntoFrame(container_elem, containing_frame, toplevel_win):
|
||||||
element = element # type: Combo
|
element = element # type: Combo
|
||||||
element.Widget = element.QT_ComboBox = QComboBox()
|
element.Widget = element.QT_ComboBox = QComboBox()
|
||||||
|
|
||||||
|
items_as_strings = [str(v) for v in element.Values]
|
||||||
|
# element.QT_ComboBox.addItems(element.Values)
|
||||||
|
element.QT_ComboBox.addItems(items_as_strings)
|
||||||
|
|
||||||
# === style ===
|
# === style ===
|
||||||
style = QtStyle('QComboBox')
|
style = QtStyle('QComboBox')
|
||||||
style['font'] = create_style_from_font(font)
|
style['font'] = create_style_from_font(font)
|
||||||
|
@ -6265,25 +6271,22 @@ def PackFormIntoFrame(container_elem, containing_frame, toplevel_win):
|
||||||
style['background_color'] = (element.BackgroundColor, COLOR_SYSTEM_DEFAULT)
|
style['background_color'] = (element.BackgroundColor, COLOR_SYSTEM_DEFAULT)
|
||||||
style['border'] = '{}px solid gray '.format(border_depth)
|
style['border'] = '{}px solid gray '.format(border_depth)
|
||||||
style['margin'] = full_element_pad
|
style['margin'] = full_element_pad
|
||||||
# style2 = Style('QListView')
|
|
||||||
# style2['color'] = (element.TextColor, COLOR_SYSTEM_DEFAULT)
|
|
||||||
# style2['background_color'] = (element.BackgroundColor, COLOR_SYSTEM_DEFAULT)
|
|
||||||
|
|
||||||
element.QT_ComboBox.setStyleSheet(style.build_css_string())# content+style2.content)
|
style2 = QtStyle('QListView')
|
||||||
element.qt_styles = (style,)
|
style2['color'] = (element.TextColor, COLOR_SYSTEM_DEFAULT)
|
||||||
|
style2['background_color'] = (element.BackgroundColor, COLOR_SYSTEM_DEFAULT)
|
||||||
|
|
||||||
|
element.QT_ComboBox.setStyleSheet(str(style)+str(style2))
|
||||||
|
element.qt_styles = (style, style2)
|
||||||
# === style === end
|
# === style === end
|
||||||
|
|
||||||
if not auto_size_text:
|
if element_size[0] is not None:
|
||||||
if element_size[0] is not None:
|
element.QT_ComboBox.setFixedWidth(element_size[0])
|
||||||
element.QT_ComboBox.setFixedWidth(element_size[0])
|
if element_size[1] is not None:
|
||||||
if element_size[1] is not None:
|
element.QT_ComboBox.setFixedHeight(element_size[1])
|
||||||
element.QT_ComboBox.setFixedHeight(element_size[1])
|
|
||||||
|
|
||||||
if element.Disabled:
|
if element.Disabled:
|
||||||
element.QT_ComboBox.setDisabled(True)
|
element.QT_ComboBox.setDisabled(True)
|
||||||
items_as_strings = [str(v) for v in element.Values]
|
|
||||||
# element.QT_ComboBox.addItems(element.Values)
|
|
||||||
element.QT_ComboBox.addItems(items_as_strings)
|
|
||||||
|
|
||||||
element.QT_ComboBox.setMaxVisibleItems(element.VisibleItems)
|
element.QT_ComboBox.setMaxVisibleItems(element.VisibleItems)
|
||||||
if element.DefaultValue is not None:
|
if element.DefaultValue is not None:
|
||||||
|
@ -6799,6 +6802,7 @@ def PackFormIntoFrame(container_elem, containing_frame, toplevel_win):
|
||||||
qt_row_layout.addWidget(element.QT_QPushButton, alignment=Qt.AlignVCenter)
|
qt_row_layout.addWidget(element.QT_QPushButton, alignment=Qt.AlignVCenter)
|
||||||
# ------------------------- Frame placement element ------------------------- #
|
# ------------------------- Frame placement element ------------------------- #
|
||||||
elif element_type == ELEM_TYPE_FRAME:
|
elif element_type == ELEM_TYPE_FRAME:
|
||||||
|
element = element # type: Frame
|
||||||
element.Widget = column_widget = QGroupBox()
|
element.Widget = column_widget = QGroupBox()
|
||||||
element.QT_QGroupBox = column_widget
|
element.QT_QGroupBox = column_widget
|
||||||
|
|
||||||
|
@ -6809,7 +6813,11 @@ def PackFormIntoFrame(container_elem, containing_frame, toplevel_win):
|
||||||
if element.BackgroundColor is not None: style['background-color'] = element.BackgroundColor
|
if element.BackgroundColor is not None: style['background-color'] = element.BackgroundColor
|
||||||
# style['origin'] = 'margin'
|
# style['origin'] = 'margin'
|
||||||
style['font'] = create_style_from_font(font)
|
style['font'] = create_style_from_font(font)
|
||||||
style['border'] = '{}px solid {} '.format(border_depth, element.FrameColor)
|
if element.FrameColor is not None:
|
||||||
|
style['border'] = '{}px solid {} '.format(border_depth, element.FrameColor)
|
||||||
|
else:
|
||||||
|
style['border'] = '{}px solid {} '.format(border_depth, 'gainsboro') # default to a light gray
|
||||||
|
|
||||||
|
|
||||||
# style['padding'] = (10,10,10,10)
|
# style['padding'] = (10,10,10,10)
|
||||||
# style['margin'] = full_element_pad
|
# style['margin'] = full_element_pad
|
||||||
|
@ -7269,8 +7277,8 @@ def stop_timer(timer):
|
||||||
def StartupTK(window):
|
def StartupTK(window):
|
||||||
"""
|
"""
|
||||||
Does the building of the window with all the widgets
|
Does the building of the window with all the widgets
|
||||||
:param my_flex_form: you window object
|
:param window: you window object
|
||||||
:type my_flex_form: (Window)
|
:type window: (Window)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
global using_pyqt5
|
global using_pyqt5
|
||||||
|
@ -7330,12 +7338,26 @@ def StartupTK(window):
|
||||||
# window.QTWindow.setWindowFlags(Qt.WindowStaysOnTopHint)
|
# window.QTWindow.setWindowFlags(Qt.WindowStaysOnTopHint)
|
||||||
|
|
||||||
|
|
||||||
# style = 'QMainWindow {'
|
style = QtStyle('QMainWindow')
|
||||||
# style = window.QT_QMainWindow.styleSheet()
|
|
||||||
if window.BackgroundColor is not None and window.BackgroundColor != COLOR_SYSTEM_DEFAULT:
|
if window.BackgroundColor is not None and window.BackgroundColor != COLOR_SYSTEM_DEFAULT:
|
||||||
style = 'background-color: %s;' % window.BackgroundColor
|
style['background-color'] = window.BackgroundColor
|
||||||
# style += '}'
|
window.QT_QMainWindow.setStyleSheet(str(style))
|
||||||
window.QT_QMainWindow.setStyleSheet(style)
|
|
||||||
|
if window.margins != (None, None):
|
||||||
|
margin_left = margin_right = margin_top = margin_bottom = 0
|
||||||
|
if isinstance(window.margins[0], tuple):
|
||||||
|
margin_left = window.margins[0][0]
|
||||||
|
margin_right = window.margins[0][1]
|
||||||
|
elif isinstance(window.margins[0], int):
|
||||||
|
margin_left = window.margins[0]
|
||||||
|
margin_right = window.margins[0]
|
||||||
|
if isinstance(window.margins[1], tuple):
|
||||||
|
margin_top = window.margins[1][0]
|
||||||
|
margin_bottom = window.margins[1][1]
|
||||||
|
elif isinstance(window.margins[1], int):
|
||||||
|
margin_top = window.margins[1]
|
||||||
|
margin_bottom = window.margins[1]
|
||||||
|
window.QT_QMainWindow.setContentsMargins(margin_left, margin_top, margin_right, margin_bottom)
|
||||||
|
|
||||||
if window.BackgroundImage is not None:
|
if window.BackgroundImage is not None:
|
||||||
qlabel = QLabel(window.QTWindow)
|
qlabel = QLabel(window.QTWindow)
|
||||||
|
@ -9749,7 +9771,7 @@ def main():
|
||||||
key='_LISTBOX_', font='Courier 12', text_color='red',)],
|
key='_LISTBOX_', font='Courier 12', text_color='red',)],
|
||||||
[Combo([1,2,3], size=(200, 35), tooltip='Combo', visible_items=2, key='_COMBO_')],
|
[Combo([1,2,3], size=(200, 35), tooltip='Combo', visible_items=2, key='_COMBO_')],
|
||||||
[Spin([1, 2, 3], size=(40, 30), tooltip='Spinner', key='_SPIN1_')],
|
[Spin([1, 2, 3], size=(40, 30), tooltip='Spinner', key='_SPIN1_')],
|
||||||
[Spin(['Combo item 1', 'Combo item 2', 'Combo item 3'], size=(240, 30), tooltip='Spinner', key='_SPIN2_')],
|
[Spin(['Spin item 1', 'Spin item 2', 'Spin item 3'], size=(240, 30), tooltip='Spinner', key='_SPIN2_')],
|
||||||
]
|
]
|
||||||
|
|
||||||
frame3 = [
|
frame3 = [
|
||||||
|
@ -9790,8 +9812,8 @@ def main():
|
||||||
[Text('VERSION {}'.format(ver), size=(85,1), text_color='yellow', font='ANY 18')],
|
[Text('VERSION {}'.format(ver), size=(85,1), text_color='yellow', font='ANY 18')],
|
||||||
|
|
||||||
# [Image(data_base64=logo, tooltip='Image', click_submits=True, key='_IMAGE_'),
|
# [Image(data_base64=logo, tooltip='Image', click_submits=True, key='_IMAGE_'),
|
||||||
[Frame('Input Text Group', frame1, title_color='yellow', tooltip='Text Group', font='Courier 20', pad=(0,0)), Stretch()],
|
[Frame('Input Text Group', frame1, title_color='yellow', tooltip='Text Group', frame_color='yellow', pad=(0,0)), Stretch()],
|
||||||
[Frame('Multiple Choice Group', frame2, title_color=theme_text_color()),
|
[Frame('Multiple Choice Group', frame2, title_color=theme_text_color(), frame_color='yellow'),
|
||||||
# Column([[Frame('Binary Choice Group', frame3, frame_color='white', title_color='white')]], pad=(0,0)),
|
# Column([[Frame('Binary Choice Group', frame3, frame_color='white', title_color='white')]], pad=(0,0)),
|
||||||
Frame('Binary Choice Group', frame3, frame_color='white', title_color='white'),
|
Frame('Binary Choice Group', frame3, frame_color='white', title_color='white'),
|
||||||
Frame('Variable Choice Group', frame4, title_color='blue'), Stretch()],
|
Frame('Variable Choice Group', frame4, title_color='blue'), Stretch()],
|
||||||
|
@ -9807,9 +9829,10 @@ def main():
|
||||||
|
|
||||||
window = Window('Window Title', layout,
|
window = Window('Window Title', layout,
|
||||||
font=('Helvetica', 13),
|
font=('Helvetica', 13),
|
||||||
default_button_element_size=(100, 30),
|
# default_button_element_size=(100, 30),
|
||||||
auto_size_buttons=False,
|
# auto_size_buttons=False,
|
||||||
default_element_size=(200, 22),
|
default_element_size=(200, 22),
|
||||||
|
margins = (40,40),
|
||||||
# border_depth=1,
|
# border_depth=1,
|
||||||
)
|
)
|
||||||
# graph_elem.DrawCircle((200, 200), 50, 'blue')
|
# graph_elem.DrawCircle((200, 200), 50, 'blue')
|
||||||
|
|
Loading…
Reference in New Issue