-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
ac_edit.py
executable file
·113 lines (89 loc) · 3.7 KB
/
ac_edit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env python
from __future__ import print_function
import pygtk
pygtk.require('2.0')
import gtk
import glob
from os import path, getenv
from lxml import etree
#from elementtree.ElementTree import parse
# if PAPARAZZI_HOME not set, then assume the tree containing this
# file is a reasonable substitute
paparazzi_home = getenv("PAPARAZZI_HOME", path.normpath(path.join(
path.dirname(path.abspath(__file__)),
'../../../')))
class Base:
def process(self, widget):
print("Button Process")
list_of_firmwares = glob.glob(path.join(paparazzi_home, "conf/firmwares/*.makefile"))
for firm in list_of_firmwares:
print(firm.replace(".makefile", "").replace(path.join(paparazzi_home, "conf/firmwares/"), ""))
for firm in list_of_firmwares:
self.combo.append_text(firm.replace(".makefile", "").replace(path.join(paparazzi_home, "conf/firmwares/"), ""))
try:
tree = etree.parse(path.join(paparazzi_home, "conf/airframes/CDW/classix.xml"))
root = tree.getroot()
self.label1.set_text(root.tag)
except (IOError, etree.XMLSyntaxError) :
raise
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(path.join(paparazzi_home, "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_title("Paparazzi Airframe File Editor")
self.btnExit = gtk.Button("Exit")
self.btnExit.connect("clicked", self.destroy)
self.btnExit.set_tooltip_text("Close application")
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)
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(self.box1)
self.window.show_all()
self.window.connect("destroy", self.destroy)
def main(self):
gtk.main()
if __name__ == "__main__":
base = Base()
base.main()