Showing posts with label wxPython. Show all posts
Showing posts with label wxPython. Show all posts

Monday, October 24, 2011

So many things!

I did a lot last week.


The next version of the Kiosk code is up on my github now. I cleaned things up to the point where customizing it is easy thanks to configparser. Why have I never seen this library before?


Here's a sample configuration file.

# Kiosk Settings
# cycler settings...
[kiosk_cycler]

# location of where to toss things

file_location = /Users/fossrit/Desktop

# host to ping to test for a working internet connection
ping_host = www.google.com

# number of times to retry a connection. -1 for unending attempts
ping_counter = 3

# number of seconds to wait in between ping attempts
ping_timer = 30

# list of hosts for the feeds. Follows the format:
# host : /location
# candidate feeds are delimited by commas.
feed_hosts = foss.rit.edu : /files/bookmarks.rss, cs.rit.edu : /~ear7631/feed.rss



And here's the python code to parse it.


parser = SafeConfigParser()
parser.read('kiosk_config')
file_location = parser.get('kiosk_cycler', 'file_location')
ping_host = parser.get('kiosk_cycler', 'ping_host')

ping_counter = int(parser.get('kiosk_cycler', 'ping_counter'))

ping_timer = int(parser.get('kiosk_cycler', 'ping_timer'))
feed_hosts_dirty = parser.get('kiosk_cycler', 'feed_hosts')


Easy, isn't it? I was also messing around with wxWoof, too, and finally got around to tinkering with wxPython a bit more. You can look at the full code here, but I really just wanted to share how easy adding drag-and-drop functionality is. My goal was to make a button that, not only brought up a file selection if clicked, but had file recognized drag-and-drop implemented as well. All that really needs to be done is hook up a FileDropTarget to your container, which handles the magic.
self.boxButton.SetDropTarget(self.dropTarget) self.dropTarget = FileDropTarget(self.boxButton)

After that it's just a matter of hooking up the OnDropFiles function your FileDropTarget.


I've now started working with html5 forms, jquery, and the twisted web framework, so there will be posts on my experiences with these in the coming days.


Tuesday, September 20, 2011

wxWoof

Rochester's getting colder. Autumn is here. I like that.

This past Saturday was the big Software Freedom event. I had a few people ask me about the spin, grab copies, so I pointed them to the public repo and showed them what went on in creating it (my previous post was editing for some more details regarding the process). It was good fun. And so was the hackathon. I didn't really go in with any particular project in mind, so I decided to get started on working on something that I've been meaning to work on for quite some time.

Ever hear of woof?

It's a nifty python (2.7) script that turns your computer into a single-file distribution server. Or, should you want, archive directories for you, and host the archive. It's pretty simple, but really useful. Need to toss a file over on your other box, and don't have a USB drive with you? No problem, just run the script on the file. By default, the script hosts it on port 8080. All you need to do to grab the file is open up your browser of choice, and connect at the host's ip (displayed if you don't know off hand), and selected port. Easy. (If you want -really- impressive speeds, try sharing a network connection from the host, and connecting the two via ethernet. That's some nice file transfer speeds.)

Some of my friends saw me using it, and really loved the script, but aren't familiar with the command line at all, or even the concept of a directory path. The script could also use a little python 3 makeover. So, I took the opportunity to start looking into some gui libraries to put a simple front-end on the script.

There were a few options. If you can recall, I already messed around with pygtk2, which was very simple and powerful. It is, however, getting it to work in OSX 10.5 and later is annoying. I then looked into something more current and robust, and stumbled upon PyQt, based on the mammoth Qt framework by Nokia. In the end I decided to just use the tried and true wxPython libraries.

This wasn't without it's issues, either, though, as wxPython hasn't been updated to work properly with Python 64 bit installs. I actually had to create a little launcher that appropriately ran my ui correctly. This was accomplished by using the following script:

#! /usr/bin/env python

import subprocess

subprocess.call(["arch", "-i386", "python", "window.py"])



You can check out my very simple gui at the public repo if you're interested. Right now, I got something that works, but I'll continue to add to and improve the UI (as well as clean up the script) over time and post more about it in the near future. Chances are I'll take a look at wxDesigner and wxGlade.