Is there a way to make a background using the graph function and drawrectangle. I want to have all of my buttons overlay the graph and have the rectangles just act as a background to make the gui look nice. Here is my current code:
"""
-- Engineer: Taylor Fettig
-- Group: Hardware Sorting and Dispense
-- Create Date: 03/20/2024
-- Design Name: admin_screen.py
"""
# admin_screen.py
import PySimpleGUI as sg
from state import State
class ADMIN_SCREEN:
def __init__(self):
layout = [
[sg.Sizer(350, 0), sg.Text('Enter Quantity to Edit Count', size=(25, 1), font=('Helvetica', 18), justification='center')],
[sg.Button('Screw: M3 x 16', size=(12, 4), key='-SCREW16-'), sg.Sizer(371, 0), sg.Input(size=(10, 1), justification='center', key='input')],
[sg.Button('Screw: M3 x 30', size=(12, 4), key='-SCREW30-'), sg.Sizer(290, 0),sg.Button('1', size=(8, 4)),sg.Button('2', size=(8, 4)), sg.Button('3', size=(8, 4))],
[sg.Button('Screw: M3 x 50', size=(12, 4), key='-SCREW50-'), sg.Sizer(100, 0), sg.Button('+', size=(8, 4)), sg.Sizer(107, 0),sg.Button('4', size=(8, 4)), sg.Button('5', size=(8, 4)), sg.Button('6', size=(8, 4))],
[sg.Button('Nut: M3', size=(12, 4), key='-NUT-'), sg.Sizer(100, 0), sg.Button('-', size=(8, 4)), sg.Sizer(107, 0),sg.Button('7', size=(8, 4)), sg.Button('8', size=(8, 4)), sg.Button('9', size=(8, 4))],
[sg.Button('Locknut: M3', size=(12, 4), key='-LOCKNUT-'), sg.Sizer(290, 0),sg.Button('Submit', size=(8, 4)), sg.Button('0', size=(8, 4)), sg.Button('Clear', size=(8, 4))],
[sg.Button('Washer: M3', size=(12, 4), key='-WASHER-'), sg.Sizer(372, 0),sg.Button('Exit', size=(8, 4))],
[sg.Sizer(413, 0),sg.Text(size=(15, 1), font=('Helvetica', 18), text_color='white', key='out', justification='center')],
[sg.Graph(canvas_size=(1024, 600), graph_bottom_left=(0, 0), graph_top_right=(1024, 600),
background_color='#0032A0', key='GRAPH')]
]
# Create the window
self.window = sg.Window('', layout, background_color='#0032A0', size=(1024, 600))
# Finalize the window
self.window.finalize()
# Loop forever reading the window's values, updating the Input field
keys_entered = ''
while True:
event, values = self.window.read() # read the window
if event == sg.WIN_CLOSED: # if the X button clicked, just exit
break
if event == 'Clear': # clear keys if clear button
keys_entered = ''
elif event in '1234567890':
keys_entered = values['input'] # get what's been entered so far
keys_entered += event # add the new digit
elif event == 'Submit':
keys_entered = values['input']
self.window['out'].update(keys_entered) # output the final string
elif event == 'Exit':
return State.HOME_SCREEN
self.window['input'].update(keys_entered) # change the window to reflect current key string
I tried adding a rectangle 100 pixels in from the window in each direction. when i put this at the bottom of the layout it seems to push the rectangle down. how do i get it as a background