Friday, February 17, 2012

A cheesy application to check for new podcasts and transfer them to my Walkman

#! /usr/bin/env python

""" Version 0.02.02
        Just a simple file manipulation tool.
        Used in this instance as a Podcast updater.
        Still stuff to do - see TODO file"""

import sys, os, time, stat, shutil
import tkFileDialog, ttk, tkMessageBox
from Tkinter import *

Monday, February 13, 2012

Python Tkinter and Cleaned Up a Little.

So, after some massaging of the available information and examples, I now have a list (not necessarily a python list) of items in the feed. Instead of printing them, I'm going to insert them into the form.

Sunday, February 12, 2012

Using to Get Feed Info From a Website.

This is what I'm talking about with the documentation. I wanted to open the url and get the information from it. But how do you do that? I tried urllib2.urlopen(url[, data][, timeout]), but that didn't work. comes with a nice example program - and that is what I shamelessly copied.

Friday, February 10, 2012

A Way to Use Tkinter and Python

There's probably as many ways to learn as there are people.

I'm learning Python, and OOP, and Java and a ton of other things. There seems to be no end to the number of things of which I am ignorant. But I like Python - it fits my procedural style while giving me a transition into OOP.

There are a ton of great sites out there. Effbot has a kick-ass site. Python's documentation is very good. But my questions are often more practical than the intelligent stuff these guys talk about.

For example, this my first post, is all about writing the code for a Tkinter application. But I wanted to put the code for the GUI in one file and all the meat in another. Seems simple enough, and for most of the programmers out there it undoubtedly is. It's probably so easy, they don't feel the need to write about it. I, on the other hand, am baffled by easy stuff like this.

And so, I wrote a really simple application to do - well not much of anything. But it does contain a file which defines the application - two buttons and a text label. The other file contains an instance of the class and a function which reacts to a button press. I hope this helps someone.

file listing for - the gui portion of the project. So the idea is to write the GUI part - and then to more-or-less forget about it.

#! /usr/bin/env python

""" was written as an example of how to split a project
     into multiple files"""

import sys
from Tkinter import *

class Application(Frame):

        def __init__(self,master=None):
                Frame.__init__(self, master)

        def createWidgets(self):

            self.frame0 = Frame(self)
            self.label1 = Label(self.frame0, text="This is a text label.")
            self.label1.grid( row=0, column=0)

            self.button1 = Button(self.frame0, text = "Push Button")

            self.button2 = Button(self.frame0, text = "Quit" , command = self.quit)

And, its companion

#! /usr/bin/env python
from generic import *

app.master.title("Hello There")

def process(self):
     print ("process activated")

app.button1.bind("<Button-1>", process)


Next, I want to make the button go to a website. Where I'm going is to get a podcast feed list, and eventually i want to download them and play them. For now, I'll use Tkinter, but I'd prefer to use PyQt. I can't wait to figure out how to do that.