fallback tk support

This commit is contained in:
j 2012-01-17 13:20:50 +05:30
parent 74eed215b5
commit 98581f7ec9
3 changed files with 59 additions and 40 deletions

View file

@ -33,7 +33,7 @@ def main(config):
backend = Backend(config)
root = Server(base, backend)
site = Site(root)
port = 2620
interface = '127.0.0.1'
port = int(backend.get('port', '2620'))
interface = backend.get('port', '127.0.0.1')
reactor.listenTCP(port, site, interface=interface)
reactor.run()

View file

@ -3,7 +3,7 @@
import os
from server import actions, json_response
import ui
from ui import ui
def init(backend, site, data):
response = {}

View file

@ -1,10 +1,16 @@
# encoding: utf-8
# vi:si:et:sw=4:sts=4:ts=4
import pygtk
pygtk.require('2.0')
import gtk
try:
import pygtk
pygtk.require('2.0')
import gtk
use_gtk = True
except:
import tkFileDialog
use_gtk = False
def selectFolder(data):
class GtkUI:
def selectFolder(self, data):
dialog = gtk.FileChooserDialog("Select Folder..",
None,
gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
@ -23,7 +29,7 @@ def selectFolder(data):
print "done"
return filename
def selectFile(data):
def selectFile(self, data):
dialog = gtk.FileChooserDialog("Select File..",
None,
gtk.FILE_CHOOSER_ACTION_OPEN,
@ -41,3 +47,16 @@ def selectFile(data):
dialog.destroy()
print "done"
return filename
class TkUI:
def selectFolder(self, data):
return tkFileDialog.askdirectory()
def selectFile(self, data):
return tkFileDialog.askopenfilename()
if use_gtk:
ui = GtkUI()
else:
ui = TkUI()