Skip to content

Commit

Permalink
Airframe Editor
Browse files Browse the repository at this point in the history
  • Loading branch information
dewagter committed Feb 11, 2013
1 parent 5c6887f commit 757aa23
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 10 deletions.
86 changes: 76 additions & 10 deletions sw/tools/ac_edit/ac_edit.py
@@ -1,34 +1,100 @@
#!/usr/bin/env python

PAPARAZZI_HOME = "../../../"


import pygtk
pygtk.require('2.0')
import gtk
import glob

from lxml import etree
#from elementtree.ElementTree import parse

class Base:
def process(self, widget):
print "Button Process"
list_of_firmwares = glob.glob( PAPARAZZI_HOME + "conf/firmwares/*.makefile" )
for firm in list_of_firmwares:
print firm.replace(".makefile","").replace(PAPARAZZI_HOME + "conf/firmwares/", "")
for firm in list_of_firmwares:
self.combo.append_text( firm.replace(".makefile","").replace(PAPARAZZI_HOME + "conf/firmwares/", "") )

try:
tree = etree.parse( PAPARAZZI_HOME + "conf/airframes/CDW/classix.xml")
root = tree.getroot()
self.label1.set_text(root.tag)
except (IOError, etree.XMLSyntaxError) :
self.error()
#elem = tree.getroot()

def combo_changed(self, widget):
print "Changed Combo"
self.textbox.set_text(widget.get_active_text())


def textchanged(self, widget):
self.label1.set_text(self.textbox.get_text())

def about(self, widget):
about = gtk.AboutDialog();
about.set_program_name("Paparazzi Airframe Editor")
about.set_version("0.1")
about.set_copyright("(c) GPL v2")
about.set_comments("Airframe Editor")
about.set_website("http://paparazzi.github.com/")
about.set_logo(gtk.gdk.pixbuf_new_from_file("../../../data/pictures/penguin_icon.png"))
about.run()
about.destroy()

def error(self):
err_msg = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE,
"Error Loading XML" )
err_msg.run()
err_msg.destroy()

def destroy(self, widget, data=None):
print "You clicked close"
gtk.main_quit()

def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_size_request(800,600)
# self.window.set_size_request(800,600)
self.window.set_title("Paparazzi Airframe File Editor")

self.button1 = gtk.Button("Exit")
self.button1.connect("clicked", self.destroy)
self.button1.set_tooltip_text("Close application")
self.btnExit = gtk.Button("Exit")
self.btnExit.connect("clicked", self.destroy)
self.btnExit.set_tooltip_text("Close application")

self.button2 = gtk.Button("Run")
self.button2.connect("clicked", self.process)
self.btnRun = gtk.Button("Run")
self.btnRun.connect("clicked", self.process)

self.btnAbout = gtk.Button("About")
self.btnAbout.connect("clicked", self.about)

self.toolbar = gtk.HBox()
self.toolbar.pack_start(self.btnRun)
self.toolbar.pack_start(self.btnAbout)
self.toolbar.pack_start(self.btnExit)

self.combo = gtk.combo_box_entry_new_text()
self.combo.append_text("Entry 1")
self.combo.append_text("Entry 2")
self.combo.connect("changed", self.combo_changed)

self.label1 = gtk.Label("")

self.textbox = gtk.Entry()
self.textbox.connect("changed",self.textchanged)

fixed = gtk.Fixed()
fixed.put(self.button1, 20,20)
fixed.put(self.button2, 80,20)
self.box1 = gtk.VBox()
self.box1.pack_start(self.toolbar)
self.box1.pack_start(self.label1)
self.box1.pack_start(self.textbox)
self.box1.pack_start(self.combo)

self.window.add(fixed)
self.window.add(self.box1)
self.window.show_all()
self.window.connect("destroy", self.destroy)

Expand Down
27 changes: 27 additions & 0 deletions sw/tools/ac_edit/filechooser.py
@@ -0,0 +1,27 @@
#!/usr/bin/env python

import pygtk, gtk

if gtk.pygtk_version < (2,3,90):
print "Please upgrade your pygtk"
raise SystemExit

dialog = gtk.FileChooserDialog( "Open ...", None,
gtk.FILE_CHOOSER_ACTION_OPEN,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN, gtk.RESPONSE_OK))

dialog.set_default_response(gtk.RESPONSE_OK)

filter = gtk.FileFilter()
filter.set_name("Airframe File")
filter.add_pattern("*.xml")
dialog.add_filter(filter)

response = dialog.run()
if response == gtk.RESPONSE_OK:
print dialog.get_filename(), " Selected"
elif response == gtk.RESPONSE_CANCEL:
print "No file selected"

dialog.destroy()

0 comments on commit 757aa23

Please sign in to comment.