Site Sponsors:
PyDAO's NEW Graphical User Interface 
The Soft9000/PyDAO ("PyDAO") project now allows us to quickly create a Python Class from either a GUI, API, textual (CSV, TDF, Enpiped, etc.) data file, or using a Python Dictionary.

Workflows include (1) creating stand-alone PyDAO projects, (2) extracting PyDAO projects from textual (CSV, etc.) data files, (3) creating database code from PyDAO projects, and (4) directly creating code from textual data files. Result output-locations can also be specified.

The generated code can be used to create / drop database schema (DDL,) as well as to import & work with (C.R.U.D & query) your designed / detected / updated projects.


Project Video:

[ view entry ] ( 652 views )   |  permalink  |  related link
REALLY easy data entry for Python... 
Had to share this one: Create a field-name dictionary, show the window, then enumerate-out the results.

Code: To see the code on GitHub, click here

[ view entry ] ( 831 views )   |  permalink  |  related link
Basic Subject Editor 
Building upon the techniques presented in our Graphical Command Line Editor, we decided to create a basic note-taking interface:

Here is the code:

from tkinter import *
from collections import OrderedDict
# Mission: Create a way to edit the subject & content of a message.

class EditorParams:
def __init__(self, *fields):
self.params = OrderedDict()
for field in fields:
self.params[field] = ''
self.params[EditorParams.EDITBOX] = ''

class Editor:
def __init__(self):
self._dict = None
self._isOk = None
self.last_row = None
self.text = None
self.eparams = None

def _okay(self):
self._isOk = True

def _cancel(self):
self._isOk = False

def Begin(eparams, title="Input"):
if not isinstance(eparams, EditorParams):
raise Exception("Begin: Instance of EditorParams expected.")

''' Create the frame, add the title, as well as the input fields.'''
self = Editor() = Tk()

self.eparams = eparams
if self.eparams.params[EditorParams.EDITBOX] is None:
self.eparams.params[EditorParams.EDITBOX] = ""

self._dict = OrderedDict()

if title:

self.last_row = 0
# zFields (A Label, plus an Entry, in a grid layout)
for ref in self.eparams.params:
if ref == EditorParams.EDITBOX:
obj = Label(, text=str(ref))
obj.grid(row=self.last_row, column=0)

if self.eparams.params[ref] is None:
self.eparams.params[ref] = ''

obj = Entry(, bd=5, width=50)
obj.grid(row=self.last_row, column=1)
obj.insert(0, self.eparams.params[ref])

self.last_row += 1
return self

def End(prompter):
''' Add the closing edit area, buttons, center, and pack the Frame.'''
if prompter.last_row is None:
return False
if isinstance(prompter, Editor) is False:
return False

# zNotepad
bottom = Frame(
bottom.grid(row=prompter.last_row, columnspan=2)
prompter.text = Text(bottom, height=25, width=50)
prompter.text.insert(END, prompter.eparams.params[EditorParams.EDITBOX])
prompter.last_row += 1

# zButtons (A Frame in the grid, plus the properly-centered pair of buttons)
bottom = Frame(
bottom.grid(row=prompter.last_row, columnspan=2)
btn = Button(bottom, text="Okay", command=prompter._okay)
btn.pack(side=LEFT, pady=12)

btn = Button(bottom, text="Cancel", command=prompter._cancel)
btn.pack(side=RIGHT, padx=10)

# zCenter (Close enough to make no odds?)
width =
height =
x = (width - / 2
y = (height - / 2"+%d+%d" % (x, y))

return True

def show(self):
from collections import OrderedDict
results = OrderedDict()
if self._isOk is not True:
return results

for ref in self._dict.keys():
results[ref] = (self._dict[ref]).get()
results[EditorParams.EDITBOX] = self.text.get("1.0", "end-1c")
return results

def Prompt(*fields, title="Input"):
''' Basic mission statement completed. '''
self = Editor.Begin(*fields, title=title)
if Editor.End(self) is False:
raise Exception("AddButtons: Unexpected Error.")

if __name__ == "__main__":
# Here is how we would use the Editor from a Console Program:
order = EditorParams("Preamble:", "Subject:")
order.params["Subject:"] = "of a modern ..."
order.params["Preamble:"] = "I am the very model ..."
order.params[EditorParams.EDITBOX] = "Python interface."
results = Editor.Prompt(order, title="Just Do It!")
if len(results) is 0:
print("Pressed Cancel - no values!")
print("Pressed Okay - got values!")
for ref in results:
print(ref, results[ref])

New to this edition is the "Model View Controller" flavor, wherein we need to create + provide an EditorParams so as to support the mission statement (i.e. adding notes to a data record.)


(NEW TODAY: Code now available on GitHub)

[ view entry ] ( 739 views )   |  permalink  |  related link

<<First <Back | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Next> Last>>