0

So it's working and all but on start up it does one loop through and starts all the functions (Contact, Location and reservdel) before it "stabilizes" as it should. not sure what i'm doing wrong. `

import PySimpleGUI as sg
from location import location_l as lc
from contact import contact_l as cc
from MALL_reserv_01 import mall_r as mr


def menus():
    #sg.LOOK_AND_FEEL_TABLE['Theme'] = {'BACKGROUND': '#6E7A82',
    #                                       'TEXT': '#000000',
    #                                       'INPUT': '#FFFFFF',
    #                                       'TEXT_INPUT': '#000000',
    #                                       'SCROLL': '#FFBF00',
    #                                       'BUTTON': ('#0E0E11', '#6E7A82'),
    #                                       'PROGRESS': ('#0E0E11', '#6E7A82'),
    #                                       'BORDER': 1, 'SLIDER_DEPTH': 0, 'PROGRESS_DEPTH': 0, }
    #sg.theme('Theme')
    sg.set_options(element_padding=(0, 0))

    #----- Menu Defination -----#
    menu_def = [['&File', ['&Open     Ctrl-O', '&Save     Ctrl-S', '&Properties', 'E&xit']],
                ['&Generators', ['&Contact', '&Location']],
                ['&Mallar', ['&Reservdel']],
                ['&Help', '&About...'], ]

    #----- GUI Definition -----#
    layout = [
        [sg.Menu(menu_def, tearoff=False, pad=(200, 1))],
    ]

    window = sg.Window('Generator',
                       layout,
                       default_element_size=(12, 1),
                       default_button_element_size=(12, 1),
                       margins=(155, 10))

    #----- Loop & Process button menu choices -----#
    while True:
        event, values = window.read()
        if event == sg.WIN_CLOSED or event == 'Exit':
            break
        #----- Process menu choices -----#
        if event == 'About...':
            window.disappear()
            sg.popup('About this program', 'Version 0.1',
                     'PySimpleGUI Version', sg.version, grab_anywhere=True)
            window.reappear()
        if event == 'Contact':
            cc()
        if event == 'Location':
            lc()
        if event == 'Reservdel':
            mr()

    window.close()

menus()

`

Thankful for any help!

I'm very new to programming in general so might be something wrong in how i call the functions from the other scripts? But since it works after one loop through i ruled it out but maybe I'm wrong.

def location_l():

layout = [
        [sg.Text('Latitude', background_color='#007FC3', text_color='#F39200', size=(14, 1), font='bold')],
        [sg.Input(size=(25, 1), key='-Latitude-')],
        [sg.Text('Longitude', background_color='#007FC3', text_color='#F39200', size=(14, 1), font='bold')],
        [sg.Input(size=(25, 1), key='-Longitude-')],
        [sg.Text('Location', background_color='#007FC3', text_color='#F39200', size=(14, 1), font='bold')],
        [sg.Input(size=(25, 1), key='-Location-')],
        [sg.Button('Generate Location QR', button_color=('#0E0E11', '#6E7A82'))],
    ]

window = sg.Window('Location QR', layout, margins=(35, 10), background_color='#007FC3')


def local_location():
        input_lat = float(values['-Latitude-'])
        input_long = float(values['-Longitude-'])
        input_location = values['-Location-']

        latitude, longitude = input_lat, input_long
        geo_uri = helpers.make_geo_data(latitude, longitude)
        geo_uri
        qrcode = segno.make(geo_uri, error='H')
        qrcode.designator
        '4-H'
        qrcode.save(f'{input_location.lower()}.png', scale=3, dark='black')

while True:
    event, values = window.read()
    if event == 'Exit' or event == sg.WIN_CLOSED:
        break
    if event == 'Generate Location QR':
        local_location()
window.close()

This in one of the called functions, if that helps.

mikthebug
  • 1
  • 1
  • It's probably something in the `location` or `contact` modules. – Peter Wood Nov 17 '22 at 20:49
  • hmm, the other scripts are also scripts like this one how can be run separately, maybe that why? although if that's the problem I'm instead stuck on how to make them callable. @PeterWood – mikthebug Nov 17 '22 at 21:00
  • [Make Python module callable](https://stackoverflow.com/questions/45034815/make-python-module-callable) – Peter Wood Nov 17 '22 at 21:31
  • 1
    @PeterWood Thanks! that worked like a charm and i have learnt something new! – mikthebug Nov 18 '22 at 06:26

0 Answers0