def disable(db, win):
    res = sg.popup_yes_no('Are you sure you want to disabled edit mode?')
    return True if res == 'Yes' else False


# Define our layout. We will use the ss.record convenience function to create the controls
layout = [
    ss.record('Restaurant.name'),
    ss.record('Restaurant.location'),
    ss.record('Restaurant.fkType',
              sg.Combo,
              size=(30, 10),
              auto_size_text=False)
]
sub_layout = [
    ss.selector('selector1', 'Item', size=(35, 10)) + [
        sg.Col([
            ss.record('Item.name'),
            ss.record(
                'Item.fkMenu', sg.Combo, size=(30, 10), auto_size_text=False),
            ss.record('Item.price'),
            ss.record('Item.description', sg.MLine, (30, 7))
        ])
    ],
    ss.actions('act_item',
               'Item',
               edit_protect=False,
               navigation=False,
               save=False,
               search=False)
]
Esempio n. 2
0
INSERT INTO Mood VALUES (1,"Happy");
INSERT INTO Mood VALUES (2,"Sad");
INSERT INTO Mood VALUES (3,"Angry");
INSERT INTO Mood VALUES (4,"Emotional");
INSERT INTO Mood VALUES (5,"Content");
INSERT INTO Mood VALUES (6,"Curious");
"""

# -------------------------
# CREATE PYSIMPLEGUI LAYOUT
# -------------------------
# Define the columns for the table selector
headings=['id','Date:              ','Mood:      ','Title:                                 '] # The width of the headings defines column width!
visible=[0,1,1,1] # Hide the id column
layout=[
    ss.selector('sel_journal','Journal',sg.Table,num_rows=10,headings=headings,visible_column_map=visible),
    ss.actions('act_journal','Journal', edit_protect=False), # These are your database controls (Previous, Next, Save, Insert, etc!)
    ss.record('Journal.entry_date', label='Date:'),
    ss.record('Journal.mood_id', sg.Combo, label='My mood:', size=(30,10), auto_size_text=False),
    ss.record('Journal.title', size=(71,1)),
    ss.record('Journal.entry', sg.MLine, size=(71,20))
]

win=sg.Window('Journal example', layout, finalize=True)
db=ss.Database('journal.db', win, sql_commands=sql) #<=== ONE SIMPLE CHANGE!!!
# Now we just give the new databasase a name - "journal.db" in this case.  If journal.db is not present
# when this code is run, then a new one is created using the commands supplied to the sql_commands keyword argument.
# If journal.db does exist, then it is used and the sql_commands are not run at all.

# Reverse the default sort order so new journal entries appear at the top
db['Journal'].set_order_clause('ORDER BY entry_date DESC')
Esempio n. 3
0
"""

# -------------------------
# CREATE PYSIMPLEGUI LAYOUT
# -------------------------
# Define the columns for the table selector
columns = ['pkAddresses', 'firstName', 'lastName', 'city', 'fkState']
headings = [
    'pk', 'First name:    ', 'Last name:     ', 'City:        ', 'State'
]
visible = [0, 1, 1, 1, 1]  # Hide the primary key column
layout = [
    ss.selector("sel",
                "Addresses",
                sg.Table,
                headings=headings,
                visible_column_map=visible,
                columns=columns,
                num_rows=10),
    ss.record("Addresses.fkGroupName",
              sg.Combo,
              auto_size_text=False,
              size=(30, 10)),
    ss.record("Addresses.firstName", label="First name:"),
    ss.record("Addresses.lastName", label="Last name:"),
    ss.record("Addresses.address1", label="Address 1:"),
    ss.record("Addresses.address2", label="Address 2:"),
    ss.record("Addresses.city", label="City/State:", size=(23, 1)) +
    ss.record("Addresses.fkState",
              element=sg.Combo,
              no_label=True,
Esempio n. 4
0
INSERT INTO "Person" ("name") VALUES ("Sally");
INSERT INTO "Person" ("name") VALUES ("Pat");

INSERT INTO "FavoriteColor" VALUES (1,1,1);
INSERT INTO "FavoriteColor" VALUES (2,1,2);
INSERT INTO "FavoriteColor" VALUES (3,1,4);
INSERT INTO "FavoriteColor" VALUES (4,2,3);
INSERT INTO "FavoriteColor" VALUES (5,2,5);
INSERT INTO "FavoriteColor" VALUES (6,2,6);
INSERT INTO "FavoriteColor" VALUES (7,3,7);
INSERT INTO "FavoriteColor" VALUES (8,3,6);
INSERT INTO "FavoriteColor" VALUES (9,3,4);
'''

person_layout = [
    ss.selector('sel_person', 'Person', size=(48, 10)),
    ss.actions('act_person', 'Person', edit_protect=False, search=False),
    ss.record('Person.name', label_above=True)
]
color_layout = [
    ss.selector('sel_color', 'Color', size=(48, 10)),
    ss.actions('act_color', 'Color', edit_protect=False, search=False),
    ss.record('Color.name', label_above=True)
]
headings = [
    'ID (this will be hidden)', 'Person            ', 'Favorite Color     '
]
vis = [0, 1, 1]
favorites_layout = [
    ss.selector('sel_favorite',
                'FavoriteColor',
Esempio n. 5
0
# PySimpleGUI™ layout code
headings = [
    'id', 'Name     ', 'Example                                          ',
    'Primary Color?'
]  # Table column widths can be set by the spacing of the headings!
visible = [0, 1, 1, 1]  # Hide the primary key column in the table
record_columns = [
    ss.record('Colors.name', label='Color name:'),
    ss.record('Colors.example', label='Example usage: '),
    ss.record('Colors.primary_color', label='Primary Color?', element=sg.CBox),
]
selectors = [
    ss.selector('tableSelector',
                'Colors',
                element=sg.Table,
                headings=headings,
                visible_column_map=visible,
                num_rows=10) +
    ss.selector('selector1', 'Colors', size=(15, 10)),
    ss.actions('colorActions', 'Colors'),
    ss.selector('selector2', 'Colors', element=sg.Slider, size=(26, 18)) +
    ss.selector('selector3', 'Colors', element=sg.Combo, size=(30, 10)),
]
layout = [
    [sg.Text(description)],
    [
        sg.Frame('Test out all of these selectors and watch the magic!',
                 selectors)
    ],
    [sg.Col(record_columns, vertical_alignment='t')],
]