Python Forum
[PyGUI] How to reuse a window layout based on mysql rowcount?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGUI] How to reuse a window layout based on mysql rowcount?
#1
Good morning,
Please excuse my ignorance I have tried searching the forums to no avail.

I'm trying to generate multiple windows using pysimplegui based on a mysql select statement

There are two rows, what im struggling with is the window generation, im not sure how to implement a new window re using a window layout.

This is my test code
def resultslayout():

    mycursor = mydb.cursor()
    mycursor.execute("SELECT * FROM testtable")
    myresult = mycursor.fetchall()
    count = mycursor.rowcount
    for row in myresult:
        layout2 = [[sg.Text(row[1]+" Rowcount = " + str(count))],
                   [sg.OK()],
                   ]
    window = sg.Window('Second Form', layout2)
    event, values = window.read()
    window.close()
This generates two windows, but the same mysql result, I'm guessing i need to move the window layout out of the for loop and replace it with the window generation BUT this causes an error in regards to reusing old window layouts.

What is the correct way?

I would like a new window generated based on the row count.

Thanks for your time.
Reply


Messages In This Thread
How to reuse a window layout based on mysql rowcount? - by retroisbest - Nov-08-2021, 12:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Interaction between Matplotlib window, Python prompt and TKinter window NorbertMoussy 3 1,017 Mar-17-2024, 09:37 AM
Last Post: deanhystad
  [PyQt] How to clip layout to sides and bottom of main window? Valmont 9 5,240 Mar-24-2021, 10:00 PM
Last Post: deanhystad
  pyqt5 layout Nickd12 8 3,853 Jan-18-2021, 09:09 AM
Last Post: Axel_Erfurt
  tkinter window and turtle window error 1885 3 6,966 Nov-02-2019, 12:18 PM
Last Post: 1885
  Python GUI layout off between different OS shift838 5 3,905 Jan-02-2019, 02:53 AM
Last Post: shift838
  PyQt5: Add Variable Number of Rows to Layout Based on Python Dictionary kennybassett 2 4,927 Oct-02-2018, 02:05 PM
Last Post: Alfalfa
  update a variable in parent window after closing its toplevel window gray 5 9,460 Mar-20-2017, 10:35 PM
Last Post: Larz60+
  [Tkinter] grid layout neech 8 18,191 Oct-14-2016, 07:06 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020