blog.humaneguitarist.org

discoveries in digital audio, music notation, and information encoding

Archive for the ‘laziness’ tag

geo this, geo that: easy acquisition of KML files with BatchGeo

leave a comment

Geolocation/geocoding is so "hip" these days. Everyone's so obsessed where where they and other things are. There's almost a comparison with 3-D filmmaking …

Funny. Not too many folks seem all that concerned with when things are.

Anyway …

At work, we have a database with all the libraries we serve and their addresses. And the other week we needed to quickly make a map with all their locations.

If necessity is the mother of invention, laziness is it's favorite uncle.

Enter BatchGeo. We were able to take those values from our database and get a map generated in minutes. But it gets better.

One of the nice things about this process is that in addition to a map, you also get a KML file download option. Taking this little XML file, it's a simple process (via XSL or other) to make a delimited file containing the inputted names of institutions and their latitude and longitude (altitude is also available).

From there, it's not brain surgery to get those coordinates into a database and using an SQL JOIN to be able to push out an institution's name and now its coordinates, too, whenever.

Just in case someone wants/needs to do something similar with an address book or a list of businesses, etc.

--------------

Related Content:

Written by nitin

January 28th, 2012 at 9:52 am

Posted in technophilia,XML

Tagged with , , , ,

dynamic menus with TKinter

leave a comment

So, I've been thinking about being lazy in regard to dynamic GUI menu creation with Python using TKinter.

… and I'm waiting for it to be 8:30 so I can watch the NBA playoffs.

Basically, I was trying to figure out if there was a way to create a simple button menu without having to re-write the code that creates a button for each and every function I wanted to use.

So with apologies to the real programmers out there – especially if you are a Chicago Bulls fan, here's what I got.

At least it works.

from Tkinter import *

class yadayadayada():

    def __init__(self, root):

        #create a List with a tuple for:
            #1) every button that needs to be created and
            #2) what function it executes
        listOfFunctions = [("hi",self.hi),("bye",self.bye),("what",self.what)]

        #TK stuff
        frame = Frame(root)
        frame.pack()

        #iterate thru List and create buttons dynamically
        i = 0
        for stuff in listOfFunctions:

            buttonText = listOfFunctions[i][0] #first value in tuple
            buttonAction = listOfFunctions[i][1] #second value in tuple

            #make the button and assign the command to execute
            self.makeButton = Button(frame, text=buttonText, command=buttonAction)
            self.makeButton.pack()

            i = i + 1

    #just some placeholder functions
    def hi(self):
        print ("hi")

    def bye(self):
        print ("bye")

    def what(self):
        print ("what now?")

#make it go
root = Tk()
yadayadayada = yadayadayada(root)
root.mainloop()
--------------

Related Content:

Written by nitin

May 22nd, 2011 at 7:24 pm

Switch to our mobile site