Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

SQL Query results in tkinter

import tkinter as tk

class Example(tk.Frame):
    def __init__(self, parent):
        tk.Frame.__init__(self, parent)
        b = tk.Button(self, text="Done!", command=self.upload_cor)
        b.pack()
        table = tk.Frame(self)
        table.pack(side="top", fill="both", expand=True)

        data = (
            (45417, "rodringof", "CSP L2 Review", 0.000394, "2014-12-19 10:08:12", "2014-12-19 10:08:12"),
            (45418, "rodringof", "CSP L2 Review", 0.000394, "2014-12-19 10:08:12", "2014-12-19 10:08:12"),
            (45419, "rodringof", "CSP L2 Review", 0.000394, "2014-12-19 10:08:12", "2014-12-19 10:08:12"),
            (45420, "rodringof", "CSP L2 Review", 0.000394, "2014-12-19 10:08:12", "2014-12-19 10:08:12"),
            (45421, "rodringof", "CSP L2 Review", 0.000394, "2014-12-19 10:08:12", "2014-12-19 10:08:12"),
            (45422, "rodringof", "CSP L2 Review", 0.000394, "2014-12-19 10:08:12", "2014-12-19 10:08:12"),
            (45423, "rodringof", "CSP L2 Review", 0.000394, "2014-12-19 10:08:12", "2014-12-19 10:08:12"),
        )

        self.widgets = {}
        row = 0
        for rowid, reviewer, task, num_seconds, start_time, end_time in (data):
            row += 1
            self.widgets[rowid] = {
                "rowid": tk.Label(table, text=rowid),
                "reviewer": tk.Label(table, text=reviewer),
                "task": tk.Label(table, text=task),
                "num_seconds_correction": tk.Entry(table),
                "num_seconds": tk.Label(table, text=num_seconds),
                "start_time": tk.Label(table, text=start_time),
                "end_time": tk.Label(table, text=start_time)
            }

            self.widgets[rowid]["rowid"].grid(row=row, column=0, sticky="nsew")
            self.widgets[rowid]["reviewer"].grid(row=row, column=1, sticky="nsew")
            self.widgets[rowid]["task"].grid(row=row, column=2, sticky="nsew")
            self.widgets[rowid]["num_seconds_correction"].grid(row=row, column=3, sticky="nsew")
            self.widgets[rowid]["num_seconds"].grid(row=row, column=4, sticky="nsew")
            self.widgets[rowid]["start_time"].grid(row=row, column=5, sticky="nsew")
            self.widgets[rowid]["end_time"].grid(row=row, column=6, sticky="nsew")

        table.grid_columnconfigure(1, weight=1)
        table.grid_columnconfigure(2, weight=1)
        # invisible row after last row gets all extra space
        table.grid_rowconfigure(row+1, weight=1)

    def upload_cor(self):
        for rowid in sorted(self.widgets.keys()):
            entry_widget = self.widgets[rowid]["num_seconds_correction"]
            new_value = entry_widget.get()
            print("%s: %s" % (rowid, new_value))

if __name__ == "__main__":
    root = tk.Tk()
    Example(root).pack(fill="both", expand=True)
    root.mainloop()
Comment

PREVIOUS NEXT
Code Example
Python :: How can I make portable python desktop application 
Python :: How to Export Sql Server Result to Excel in Python 
Python :: city of stars how many words in a song python code 
Python :: comprehension 
Python :: qmenu 
Python :: wpapi 
Python :: loop regex 
Python :: what does scalar.fit do 
Python :: python relative seek 
Python :: odoo 12 python version 
Python :: Which of the following is not a core data type in Python programming? 
Python :: Flask select which form to POST by button click 
Python :: How deploy Flask application on Webfaction 
Python :: how to make a typing effect in python 
Python :: check if id is present in elasticsearch using python 
Python :: discord.py main file setup 
Python :: ring Conversion Number 
Python :: text to ascii art generator python 
Python :: Python cut down OS path to certain part 
Python :: matplotlib plot dpi - change format to svg 
Python :: 0 
Python :: python launch ipython from script 
Python :: colorgram.py 1.2.0 
Python :: print single pixel from numpy 
Python :: python image processing and resizing 
Python :: python generate random password 
Python :: keras model predict list of input tensors 
Python :: blakyubeuiwbciwcqiby7ib.py 
Python :: sqlalchemy date beween 
Python :: python geodata visualize 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =