diff --git a/start.py b/start.py
index 1d7038635c..198a45b6db 100755
--- a/start.py
+++ b/start.py
@@ -2,9 +2,9 @@
from __future__ import print_function
-import pygtk
-import gtk
-pygtk.require('2.0')
+import gi
+gi.require_version('Gtk', '3.0')
+from gi.repository import Gtk, GdkPixbuf
import os
@@ -105,22 +105,22 @@ class ConfChooser(object):
return
def about(self, widget):
- about_d = gtk.AboutDialog()
+ about_d = Gtk.AboutDialog()
about_d.set_program_name("Paparazzi Configuration Selector")
about_d.set_version("1.1")
about_d.set_copyright("(c) GPL v2")
about_d.set_comments("Select the active configuration")
about_d.set_website("http://paparazzi.github.com")
- about_d.set_logo(gtk.gdk.pixbuf_new_from_file(os.path.join(paparazzi.PAPARAZZI_HOME, "data/pictures/penguin_icon.png")))
+ about_d.set_logo(GdkPixbuf.Pixbuf.new_from_file(os.path.join(paparazzi.PAPARAZZI_HOME, "data/pictures/penguin_icon.png")))
about_d.run()
about_d.destroy()
def sure(self, widget, filename):
- dialog = gtk.MessageDialog(self.window, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, "Are you sure you want to delete?")
+ dialog = Gtk.MessageDialog(self.window, Gtk.DIALOG_DESTROY_WITH_PARENT, Gtk.MESSAGE_QUESTION, Gtk.BUTTONS_OK_CANCEL, "Are you sure you want to delete?")
dialog.format_secondary_text("File: " + filename)
response = dialog.run()
ret = False
- if response == gtk.RESPONSE_OK:
+ if response == Gtk.RESPONSE_OK:
ret = True
dialog.destroy()
return ret
@@ -278,33 +278,33 @@ class ConfChooser(object):
widget.set_active(current_selection)
def maintenance_window(self, widget):
- mtn_window = gtk.Window()
- mtn_window.set_position(gtk.WIN_POS_CENTER)
+ mtn_window = Gtk.Window()
+ mtn_window.set_position(Gtk.WindowPosition.CENTER)
mtn_window.set_size_request(750, 360)
mtn_window.set_title("Maintenance Tools")
- mnt_vbox = gtk.VBox()
+ mnt_vbox = Gtk.VBox()
- mnt_desc_label = gtk.Label("")
+ mnt_desc_label = Gtk.Label("")
desc_text = "Show module usage of all airframes in a selected conf file or all airframes " \
"with a specific board across all conf files."
mnt_desc_label.set_markup(desc_text)
mnt_desc_label.set_size_request(720, 40)
mnt_desc_label.set_line_wrap(True)
- mnt_conf_label = gtk.Label("Conf:")
+ mnt_conf_label = Gtk.Label("Conf:")
mnt_conf_label.set_size_request(100, 30)
- mnt_conf_file_combo = gtk.combo_box_new_text()
+ mnt_conf_file_combo = Gtk.ComboBoxText.new()
self.find_conf_files(mnt_conf_file_combo)
mnt_conf_file_combo.set_size_request(500, 30)
- mnt_board_label = gtk.Label("Board:")
+ mnt_board_label = Gtk.Label("Board:")
mnt_board_label.set_size_request(100, 30)
- mnt_board_file_combo = gtk.combo_box_new_text()
+ mnt_board_file_combo = Gtk.ComboBoxText.new()
self.find_board_files(mnt_board_file_combo)
mnt_board_file_combo.set_size_request(500, 30)
- mnt_conf_airframes = gtk.Label("")
+ mnt_conf_airframes = Gtk.Label("")
self.count_airframes_in_conf(mnt_conf_file_combo, mnt_conf_airframes)
mnt_conf_airframes.set_size_request(650, 180)
mnt_conf_airframes.set_line_wrap(True)
@@ -317,66 +317,67 @@ class ConfChooser(object):
mnt_combos = {"Conf": mnt_conf_file_combo, "Board": mnt_board_file_combo}
- mnt_confbar = gtk.HBox()
- mnt_confbar.pack_start(mnt_conf_label)
- mnt_confbar.pack_start(mnt_conf_file_combo)
- mnt_boardbar = gtk.HBox()
- mnt_boardbar.pack_start(mnt_board_label)
- mnt_boardbar.pack_start(mnt_board_file_combo)
- mnt_vbox.pack_start(mnt_desc_label)
- mnt_vbox.pack_start(mnt_confbar, False)
- mnt_vbox.pack_start(mnt_boardbar, False)
+ mnt_confbar = Gtk.HBox()
+ mnt_confbar.pack_start(mnt_conf_label, True, True, 0)
+ mnt_confbar.pack_start(mnt_conf_file_combo, True, True, 0)
+ mnt_boardbar = Gtk.HBox()
+ mnt_boardbar.pack_start(mnt_board_label, True, True, 0)
+ mnt_boardbar.pack_start(mnt_board_file_combo, True, True, 0)
+ mnt_vbox.pack_start(mnt_desc_label, True, True, 0)
+ mnt_vbox.pack_start(mnt_confbar, False, True, 0)
+ mnt_vbox.pack_start(mnt_boardbar, False, True, 0)
- btnModule = gtk.Button("Module\nUsage")
+ btnModule = Gtk.Button("Module\nUsage")
+ plop = Gtk.Button()
btnModule.connect("clicked", self.module_usage, mnt_combos)
btnModule.set_tooltip_text("More information on the modules used by these airframes")
- mnt_caexbar = gtk.HBox()
- mnt_caexbar.pack_start(mnt_conf_airframes)
- mnt_caexbar.pack_start(btnModule)
- mnt_vbox.pack_start(mnt_caexbar)
+ mnt_caexbar = Gtk.HBox()
+ mnt_caexbar.pack_start(mnt_conf_airframes, True, True, 0)
+ mnt_caexbar.pack_start(btnModule, True, True, 0)
+ mnt_vbox.pack_start(mnt_caexbar, True, True, 0)
- separator = gtk.HSeparator()
- mnt_vbox.pack_start(separator)
+ separator = Gtk.HSeparator()
+ mnt_vbox.pack_start(separator, True, True, 0)
- cbtnAirframes = gtk.CheckButton()
+ cbtnAirframes = Gtk.CheckButton()
cbtnAirframes.set_label("Airframes")
cbtnAirframes.set_active(True)
- cbtnFlightplans = gtk.CheckButton()
+ cbtnFlightplans = Gtk.CheckButton()
cbtnFlightplans.set_label("Flight plans")
cbtnFlightplans.set_active(True)
- cbtnBoards = gtk.CheckButton()
+ cbtnBoards = Gtk.CheckButton()
cbtnBoards.set_label("Boards")
cbtnBoards.set_active(True)
- cbtnModules = gtk.CheckButton()
+ cbtnModules = Gtk.CheckButton()
cbtnModules.set_label("Modules")
cbtnModules.set_active(False)
selectedOptions = {"Airframes": cbtnAirframes, "Flightplans": cbtnFlightplans,
"Boards": cbtnBoards, "Modules": cbtnModules}
- btnUntested = gtk.Button(None, "Show Untested Files")
+ btnUntested = Gtk.Button("Show Untested Files")
btnUntested.connect("clicked", self.show_untested, selectedOptions)
btnUntested.set_tooltip_text("For the selected options show the files not tested by any conf")
- untestedHBox = gtk.HBox()
- cbtnVBox = gtk.VBox()
- cbRowUpper = gtk.HBox()
- cbRowLower = gtk.HBox()
+ untestedHBox = Gtk.HBox()
+ cbtnVBox = Gtk.VBox()
+ cbRowUpper = Gtk.HBox()
+ cbRowLower = Gtk.HBox()
- cbRowUpper.pack_start(cbtnAirframes)
- cbRowUpper.pack_start(cbtnBoards)
- cbRowLower.pack_start(cbtnFlightplans)
- cbRowLower.pack_start(cbtnModules)
- cbtnVBox.pack_start(cbRowUpper)
- cbtnVBox.pack_start(cbRowLower)
- untestedHBox.pack_start(cbtnVBox)
- untestedHBox.pack_start(btnUntested)
+ cbRowUpper.pack_start(cbtnAirframes, True, True, 0)
+ cbRowUpper.pack_start(cbtnBoards, True, True, 0)
+ cbRowLower.pack_start(cbtnFlightplans, True, True, 0)
+ cbRowLower.pack_start(cbtnModules, True, True, 0)
+ cbtnVBox.pack_start(cbRowUpper, True, True, 0)
+ cbtnVBox.pack_start(cbRowLower, True, True, 0)
+ untestedHBox.pack_start(cbtnVBox, True, True, 0)
+ untestedHBox.pack_start(btnUntested, True, True, 0)
- mnt_vbox.pack_start(untestedHBox)
+ mnt_vbox.pack_start(untestedHBox, True, True, 0)
mtn_window.add(mnt_vbox)
mtn_window.show_all()
@@ -388,10 +389,10 @@ class ConfChooser(object):
# paparazzi process
self.pp = None
- self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+ self.window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
self.window.set_title("Paparazzi Configuration Chooser")
- self.my_vbox = gtk.VBox()
+ self.my_vbox = Gtk.VBox()
self.conf_xml = os.path.join(paparazzi.conf_dir, "conf.xml")
self.conf_personal_name = "conf_personal.xml"
@@ -405,74 +406,74 @@ class ConfChooser(object):
self.verbose = False
# MenuBar
- mb = gtk.MenuBar()
+ mb = Gtk.MenuBar()
# File
- filemenu = gtk.Menu()
+ filemenu = Gtk.Menu()
# File Title
- filem = gtk.MenuItem("File")
+ filem = Gtk.MenuItem("File")
filem.set_submenu(filemenu)
- exitm = gtk.MenuItem("Exit")
- exitm.connect("activate", gtk.main_quit)
+ exitm = Gtk.MenuItem("Exit")
+ exitm.connect("activate", Gtk.main_quit)
filemenu.append(exitm)
mb.append(filem)
# Help
- helpmenu = gtk.Menu()
+ helpmenu = Gtk.Menu()
# Help Title
- helpm = gtk.MenuItem("Help")
+ helpm = Gtk.MenuItem("Help")
helpm.set_submenu(helpmenu)
- aboutm = gtk.MenuItem("About")
+ aboutm = Gtk.MenuItem("About")
aboutm.connect("activate", self.about)
helpmenu.append(aboutm)
mb.append(helpm)
- self.my_vbox.pack_start(mb, False)
+ self.my_vbox.pack_start(mb, False, True, 0)
# Combo Bar
- self.conf_label = gtk.Label("Conf:")
+ self.conf_label = Gtk.Label("Conf:")
self.conf_label.set_size_request(100, 30)
- self.conf_file_combo = gtk.combo_box_new_text()
+ self.conf_file_combo = Gtk.ComboBoxText.new()
self.find_conf_files(self.conf_file_combo)
self.conf_file_combo.set_size_request(550, 30)
- self.btnDeleteConf = gtk.Button(None, gtk.STOCK_DELETE)
+ self.btnDeleteConf = Gtk.Button.new_from_stock(Gtk.STOCK_DELETE)
self.btnDeleteConf.connect("clicked", self.delete_conf)
self.btnDeleteConf.set_tooltip_text("Permanently Delete Conf")
- self.btnPersonalConf = gtk.Button(None, gtk.STOCK_COPY)
+ self.btnPersonalConf = Gtk.Button.new_from_stock(Gtk.STOCK_COPY)
self.btnPersonalConf.connect("clicked", self.personal_conf)
self.btnPersonalConf.set_tooltip_text("Create Personal Conf Based on Selected and Activate")
- self.confbar = gtk.HBox()
- self.confbar.pack_start(self.conf_label)
- self.confbar.pack_start(self.conf_file_combo)
- self.confbar.pack_start(self.btnDeleteConf)
- self.confbar.pack_start(self.btnPersonalConf)
- self.my_vbox.pack_start(self.confbar, False)
+ self.confbar = Gtk.HBox()
+ self.confbar.pack_start(self.conf_label, True, True, 0)
+ self.confbar.pack_start(self.conf_file_combo, True, True, 0)
+ self.confbar.pack_start(self.btnDeleteConf, True, True, 0)
+ self.confbar.pack_start(self.btnPersonalConf, True, True, 0)
+ self.my_vbox.pack_start(self.confbar, False, True, 0)
# Explain current conf config
- self.conf_explain = gtk.Label("")
+ self.conf_explain = Gtk.Label("")
self.update_conf_label()
self.conf_explain.set_size_request(0, 45)
- self.cfexbar = gtk.HBox()
- self.cfexbar.pack_start(self.conf_explain)
+ self.cfexbar = Gtk.HBox()
+ self.cfexbar.pack_start(self.conf_explain, True, True, 0)
- self.my_vbox.pack_start(self.cfexbar, False)
+ self.my_vbox.pack_start(self.cfexbar, False, True, 0)
# Count Airframes
- self.conf_airframes = gtk.Label("")
+ self.conf_airframes = Gtk.Label("")
self.count_airframes_in_conf(self.conf_file_combo, self.conf_airframes)
self.conf_airframes.set_size_request(650, 180)
self.conf_airframes.set_line_wrap(True)
@@ -480,104 +481,104 @@ class ConfChooser(object):
self.combo_list = {"combo": self.conf_file_combo, "list": self.conf_airframes}
self.conf_file_combo.connect("changed", self.changed_cb, self.combo_list)
- self.btnInfo = gtk.Button(None, "More\nInfo")
+ self.btnInfo = Gtk.Button("More\nInfo")
self.btnInfo.connect("clicked", self.more_info)
self.btnInfo.set_tooltip_text("More information on airframe files")
- self.btnMaintenance = gtk.Button(None, "Maintenance\n\tTools")
+ self.btnMaintenance = Gtk.Button("Maintenance\n\tTools")
self.btnMaintenance.connect("clicked", self.maintenance_window)
self.btnMaintenance.set_tooltip_text("Show maintenance tools")
- self.caexbar = gtk.HBox()
- self.caexbar.pack_start(self.conf_airframes)
- self.caexbar_btns = gtk.VBox()
- self.caexbar.pack_start(self.caexbar_btns)
- self.caexbar_btns.pack_start(self.btnInfo)
- self.caexbar_btns.pack_start(self.btnMaintenance)
+ self.caexbar = Gtk.HBox()
+ self.caexbar.pack_start(self.conf_airframes, True, True, 0)
+ self.caexbar_btns = Gtk.VBox()
+ self.caexbar.pack_start(self.caexbar_btns, True, True, 0)
+ self.caexbar_btns.pack_start(self.btnInfo, True, True, 0)
+ self.caexbar_btns.pack_start(self.btnMaintenance, True, True, 0)
- self.my_vbox.pack_start(self.caexbar, False)
+ self.my_vbox.pack_start(self.caexbar, False, True, 0)
# Controlpanel
- self.controlpanel_label = gtk.Label("Controlpanel:")
+ self.controlpanel_label = Gtk.Label("Controlpanel:")
self.controlpanel_label.set_size_request(100, 30)
- self.controlpanel_file_combo = gtk.combo_box_new_text()
+ self.controlpanel_file_combo = Gtk.ComboBoxText.new()
self.find_controlpanel_files()
self.controlpanel_file_combo.set_size_request(550, 30)
# window
- self.btnDeleteControl = gtk.Button(None, gtk.STOCK_DELETE)
+ self.btnDeleteControl = Gtk.Button.new_from_stock(Gtk.STOCK_DELETE)
self.btnDeleteControl.connect("clicked", self.delete_controlpanel)
self.btnDeleteControl.set_tooltip_text("Permanently Delete")
- self.btnPersonalControl = gtk.Button(None, gtk.STOCK_COPY)
+ self.btnPersonalControl = Gtk.Button.new_from_stock(Gtk.STOCK_COPY)
self.btnPersonalControl.connect("clicked", self.personal_controlpanel)
self.btnPersonalControl.set_tooltip_text("Create Personal Controlpanel Based on Selected and Activate")
- self.controlpanelbar = gtk.HBox(False)
- self.controlpanelbar.pack_start(self.controlpanel_label)
- self.controlpanelbar.pack_start(self.controlpanel_file_combo)
- self.controlpanelbar.pack_start(self.btnDeleteControl)
- self.controlpanelbar.pack_start(self.btnPersonalControl)
- self.my_vbox.pack_start(self.controlpanelbar, False)
+ self.controlpanelbar = Gtk.HBox(False)
+ self.controlpanelbar.pack_start(self.controlpanel_label, True, True, 0)
+ self.controlpanelbar.pack_start(self.controlpanel_file_combo, True, True, 0)
+ self.controlpanelbar.pack_start(self.btnDeleteControl, True, True, 0)
+ self.controlpanelbar.pack_start(self.btnPersonalControl, True, True, 0)
+ self.my_vbox.pack_start(self.controlpanelbar, False, True, 0)
# Explain current controlpanel config
- self.controlpanel_explain = gtk.Label("")
+ self.controlpanel_explain = Gtk.Label("")
self.update_controlpanel_label()
self.controlpanel_explain.set_size_request(0, 45)
- self.ctexbar = gtk.HBox()
- self.ctexbar.pack_start(self.controlpanel_explain)
+ self.ctexbar = Gtk.HBox()
+ self.ctexbar.pack_start(self.controlpanel_explain, True, True, 0)
- self.my_vbox.pack_start(self.ctexbar, False)
+ self.my_vbox.pack_start(self.ctexbar, False, True, 0)
# show backups button
- self.btnBackups = gtk.CheckButton("show backups")
+ self.btnBackups = Gtk.CheckButton("show backups")
self.btnBackups.connect("toggled", self.set_backups)
- self.my_vbox.pack_start(self.btnBackups, False)
+ self.my_vbox.pack_start(self.btnBackups, False, True, 0)
# show gui button
- self.btnPythonGUI = gtk.CheckButton("new python center (beta)")
- self.my_vbox.pack_start(self.btnPythonGUI, False)
+ self.btnPythonGUI = Gtk.CheckButton("new python center (beta)")
+ self.my_vbox.pack_start(self.btnPythonGUI, False, True, 0)
# Buttons
- self.btnAccept = gtk.Button("Set Active")
+ self.btnAccept = Gtk.Button("Set Active")
self.btnAccept.connect("clicked", self.accept)
self.btnAccept.set_tooltip_text("Set selected Conf/Control_Panel as Active")
- self.btnLaunch = gtk.Button("Launch Paparazzi with selected configuration")
+ self.btnLaunch = Gtk.Button("Launch Paparazzi with selected configuration")
self.btnLaunch.connect("clicked", self.launch)
self.btnLaunch.set_tooltip_text("Launch Paparazzi with current conf.xml and control_panel.xml")
- self.btnExit = gtk.Button("Exit")
- self.btnExit.connect("clicked", gtk.main_quit)
+ self.btnExit = Gtk.Button("Exit")
+ self.btnExit.connect("clicked", Gtk.main_quit)
self.btnExit.set_tooltip_text("Close application")
- self.toolbar = gtk.HBox()
+ self.toolbar = Gtk.HBox()
self.toolbar.set_size_request(0, 60)
- self.toolbar.pack_start(self.btnLaunch)
- self.toolbar.pack_start(self.btnAccept)
- self.toolbar.pack_start(self.btnExit)
+ self.toolbar.pack_start(self.btnLaunch, True, True, 0)
+ self.toolbar.pack_start(self.btnAccept, True, True, 0)
+ self.toolbar.pack_start(self.btnExit, True, True, 0)
- self.my_vbox.pack_start(self.toolbar, False)
+ self.my_vbox.pack_start(self.toolbar, False, True, 0)
# status bar
- self.statusbar = gtk.Statusbar()
+ self.statusbar = Gtk.Statusbar()
self.context_id = self.statusbar.get_context_id("info")
#self.statusbar.push(self.context_id, "Waiting for you to do something...")
- self.my_vbox.pack_end(self.statusbar, False)
+ self.my_vbox.pack_end(self.statusbar, False, True, 0)
# Bottom
self.window.add(self.my_vbox)
self.window.show_all()
- self.window.set_position(gtk.WIN_POS_CENTER_ALWAYS)
- self.window.connect("destroy", gtk.main_quit)
+ self.window.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
+ self.window.connect("destroy", Gtk.main_quit)
def main(self):
- gtk.main()
+ Gtk.main()
if self.pp:
self.pp.wait()
diff --git a/sw/tools/airframe_editor/airframe_editor.py b/sw/tools/airframe_editor/airframe_editor.py
index a53f32d58b..7eba433f48 100755
--- a/sw/tools/airframe_editor/airframe_editor.py
+++ b/sw/tools/airframe_editor/airframe_editor.py
@@ -2,9 +2,10 @@
from __future__ import print_function
-import pygtk
-import gtk
-pygtk.require('2.0')
+import gi
+gi.require_version('Gtk', '3.0')
+from gi.repository import Gtk, GdkPixbuf
+
from os import path
@@ -82,7 +83,7 @@ class AirframeEditor:
xml_airframe.fill_tree(self.xml, self.treestore)
def about(self, widget):
- gui_dialogs.about(paparazzi.home_dir)
+ gui_dialogs.about(paparazzi.PAPARAZZI_HOME)
def open(self, widget):
global airframe_file
@@ -125,18 +126,18 @@ class AirframeEditor:
def fill_tree_from_airframe(self):
# create a TreeStore with one string column to use as the model
- self.treestore = gtk.TreeStore(str, object)
+ self.treestore = Gtk.TreeStore(str, object)
# create the TreeView using treestore
- self.treeview = gtk.TreeView(self.treestore)
+ self.treeview = Gtk.TreeView(self.treestore)
# create the TreeViewColumn to display the data
- self.tvcolumn = gtk.TreeViewColumn('')
+ self.tvcolumn = Gtk.TreeViewColumn('')
# add self.tvcolumn to treeview
self.treeview.append_column(self.tvcolumn)
self.treeview.connect("cursor-changed", self.select)
- self.cell = gtk.CellRendererText()
+ self.cell = Gtk.CellRendererText()
self.tvcolumn.pack_start(self.cell, True)
self.tvcolumn.add_attribute(self.cell, 'text', 0)
self.treeview.set_reorderable(True)
@@ -144,15 +145,15 @@ class AirframeEditor:
def fill_datagrid_from_section(self):
# create a TreeStore with one string column to use as the model
- self.gridstore = gtk.ListStore(str, str, str, str, str)
+ self.gridstore = Gtk.ListStore(str, str, str, str, str)
- self.datagrid = gtk.TreeView(self.gridstore)
+ self.datagrid = Gtk.TreeView(self.gridstore)
- self.type_column = gtk.TreeViewColumn('Type')
- self.name_column = gtk.TreeViewColumn('Name')
- self.value_column = gtk.TreeViewColumn('Value')
- self.unit_column = gtk.TreeViewColumn('Unit')
- self.desc_column = gtk.TreeViewColumn('Description')
+ self.type_column = Gtk.TreeViewColumn('Type')
+ self.name_column = Gtk.TreeViewColumn('Name')
+ self.value_column = Gtk.TreeViewColumn('Value')
+ self.unit_column = Gtk.TreeViewColumn('Unit')
+ self.desc_column = Gtk.TreeViewColumn('Description')
self.datagrid.append_column(self.type_column)
self.datagrid.append_column(self.name_column)
@@ -161,16 +162,16 @@ class AirframeEditor:
self.datagrid.append_column(self.desc_column)
self.datagrid.connect("cursor-changed", self.select_section)
- self.type_cell = gtk.CellRendererText()
+ self.type_cell = Gtk.CellRendererText()
self.type_cell.Editable = False
- self.name_cell = gtk.CellRendererText()
+ self.name_cell = Gtk.CellRendererText()
self.name_cell.Editable = False
- self.value_cell = gtk.CellRendererText()
+ self.value_cell = Gtk.CellRendererText()
self.value_cell.Editable = True
self.value_cell.set_property("editable", True)
- self.unit_cell = gtk.CellRendererText()
+ self.unit_cell = Gtk.CellRendererText()
self.unit_cell.Editable = False
- self.desc_cell = gtk.CellRendererText()
+ self.desc_cell = Gtk.CellRendererText()
self.desc_cell.Editable = False
self.type_column.pack_start(self.type_cell, True)
@@ -190,170 +191,170 @@ class AirframeEditor:
def destroy(self, widget, data=None):
- gtk.main_quit()
+ Gtk.main_quit()
def __init__(self):
- self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+ self.window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
self.window.set_title("Paparazzi Airframe File Editor")
- self.my_vbox = gtk.VBox()
+ self.my_vbox = Gtk.VBox()
# MenuBar
- mb = gtk.MenuBar()
+ mb = Gtk.MenuBar()
# File
- filemenu = gtk.Menu()
+ filemenu = Gtk.Menu()
# File Title
- filem = gtk.MenuItem("File")
+ filem = Gtk.MenuItem("File")
filem.set_submenu(filemenu)
- openm = gtk.MenuItem("Open")
+ openm = Gtk.MenuItem("Open")
openm.connect("activate", self.open)
filemenu.append(openm)
- exitm = gtk.MenuItem("Exit")
- exitm.connect("activate", gtk.main_quit)
+ exitm = Gtk.MenuItem("Exit")
+ exitm.connect("activate", Gtk.main_quit)
filemenu.append(exitm)
mb.append(filem)
# Help
- helpmenu = gtk.Menu()
+ helpmenu = Gtk.Menu()
# Help Title
- helpm = gtk.MenuItem("Help")
+ helpm = Gtk.MenuItem("Help")
helpm.set_submenu(helpmenu)
- aboutm = gtk.MenuItem("About")
+ aboutm = Gtk.MenuItem("About")
aboutm.connect("activate", self.about)
helpmenu.append(aboutm)
mb.append(helpm)
- self.my_vbox.pack_start(mb, False)
+ self.my_vbox.pack_start(mb, False, True, 0)
##### Buttons
- self.btnExit = gtk.Button("Exit")
+ self.btnExit = Gtk.Button("Exit")
self.btnExit.connect("clicked", self.destroy)
self.btnExit.set_tooltip_text("Close application")
- self.btnOpen = gtk.Button("Open")
+ self.btnOpen = Gtk.Button("Open")
self.btnOpen.connect("clicked", self.open)
- self.btnRun = gtk.Button("Reorganize XML")
+ self.btnRun = Gtk.Button("Reorganize XML")
self.btnRun.connect("clicked", self.reorganize_xml)
- self.btnFirmwares = gtk.Button("Firmwares")
+ self.btnFirmwares = Gtk.Button("Firmwares")
self.btnFirmwares.connect("clicked", self.find_firmwares)
- self.btnSubSystem = gtk.Button("SubSystems")
+ self.btnSubSystem = Gtk.Button("SubSystems")
self.btnSubSystem.connect("clicked", self.find_subsystems)
- self.btnModules = gtk.Button("Add Modules")
+ self.btnModules = Gtk.Button("Add Modules")
self.btnModules.connect("clicked", self.find_modules)
- self.btnModuleDefines = gtk.Button("Define")
+ self.btnModuleDefines = Gtk.Button("Define")
self.btnModuleDefines.connect("clicked", self.find_module_defines)
- self.btnAbout = gtk.Button("About")
+ self.btnAbout = Gtk.Button("About")
self.btnAbout.connect("clicked", self.about)
- self.toolbar = gtk.HBox()
- self.toolbar.pack_start(self.btnOpen)
- self.toolbar.pack_start(self.btnRun)
- self.toolbar.pack_start(self.btnAbout)
- self.toolbar.pack_start(self.btnExit)
+ self.toolbar = Gtk.HBox()
+ self.toolbar.pack_start(self.btnOpen, True, True, 0)
+ self.toolbar.pack_start(self.btnRun, True, True, 0)
+ self.toolbar.pack_start(self.btnAbout, True, True, 0)
+ self.toolbar.pack_start(self.btnExit, True, True, 0)
- self.my_vbox.pack_start(self.toolbar, False)
+ self.my_vbox.pack_start(self.toolbar, False, True, 0)
- self.firmwares_combo = gtk.combo_box_entry_new_text()
+ self.firmwares_combo = Gtk.ComboBoxText.new_with_entry()
self.find_firmwares(self.firmwares_combo)
self.firmwares_combo.connect("changed", self.find_subsystems)
- self.subsystems_combo = gtk.combo_box_entry_new_text()
+ self.subsystems_combo = Gtk.ComboBoxText.new_with_entry()
- self.boards_combo = gtk.combo_box_entry_new_text()
+ self.boards_combo = Gtk.ComboBoxText.new_with_entry()
self.find_boards(self.boards_combo)
- self.firmwarebar = gtk.HBox()
- self.firmwarebar.pack_start(self.btnFirmwares)
- self.firmwarebar.pack_start(self.btnSubSystem)
- self.firmwarebar.pack_start(self.firmwares_combo)
- self.firmwarebar.pack_start(self.boards_combo)
- self.firmwarebar.pack_start(self.subsystems_combo)
+ self.firmwarebar = Gtk.HBox()
+ self.firmwarebar.pack_start(self.btnFirmwares, True, True, 0)
+ self.firmwarebar.pack_start(self.btnSubSystem, True, True, 0)
+ self.firmwarebar.pack_start(self.firmwares_combo, True, True, 0)
+ self.firmwarebar.pack_start(self.boards_combo, True, True, 0)
+ self.firmwarebar.pack_start(self.subsystems_combo, True, True, 0)
- self.modules_combo = gtk.combo_box_entry_new_text()
+ self.modules_combo = Gtk.ComboBoxText.new_with_entry()
self.find_modules(self.modules_combo)
self.modules_combo.connect("changed", self.find_module_defines)
- #self.modulebar = gtk.HBox()
- self.firmwarebar.pack_start(self.btnModules)
- self.firmwarebar.pack_start(self.btnModuleDefines)
- self.firmwarebar.pack_start(self.modules_combo)
+ #self.modulebar = Gtk.HBox()
+ self.firmwarebar.pack_start(self.btnModules, True, True, 0)
+ self.firmwarebar.pack_start(self.btnModuleDefines, True, True, 0)
+ self.firmwarebar.pack_start(self.modules_combo, True, True, 0)
- #self.my_vbox.pack_start(self.modulebar)
+ #self.my_vbox.pack_start(self.modulebar, True, True, 0)
- self.my_vbox.pack_start(self.firmwarebar, False)
+ self.my_vbox.pack_start(self.firmwarebar, False, True, 0)
##### Middle
- self.editor = gtk.HBox()
+ self.editor = Gtk.HBox()
self.fill_tree_from_airframe()
- self.scrolltree = gtk.ScrolledWindow()
- self.scrolltree.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ self.scrolltree = Gtk.ScrolledWindow()
+ self.scrolltree.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.scrolltree.add(self.treeview)
self.scrolltree.set_size_request(400,600)
- self.editor.pack_start(self.scrolltree)
+ self.editor.pack_start(self.scrolltree, True, True, 0)
self.fill_datagrid_from_section()
self.datagrid.set_size_request(900, 600)
- self.editor.pack_start(self.datagrid)
+ self.editor.pack_start(self.datagrid, True, True, 0)
- self.my_vbox.pack_start(self.editor)
+ self.my_vbox.pack_start(self.editor, True, True, 0)
- self.text_box = gtk.Label("")
+ self.text_box = Gtk.Label("")
self.text_box.set_size_request(600, 1000)
- self.scrolltext = gtk.ScrolledWindow()
- self.scrolltext.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ self.scrolltext = Gtk.ScrolledWindow()
+ self.scrolltext.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.scrolltext.add_with_viewport(self.text_box)
self.scrolltext.set_size_request(400, 100)
- self.my_vbox.pack_start(self.scrolltext)
+ self.my_vbox.pack_start(self.scrolltext, True, True, 0)
self.load_airframe_xml()
##### Bottom
- self.searchbar = gtk.HBox()
+ self.searchbar = Gtk.HBox()
- self.textbox = gtk.Entry()
+ self.textbox = Gtk.Entry()
#self.textbox.connect("changed",self.textchanged)
- self.btnSearch = gtk.Button("Search...")
+ self.btnSearch = Gtk.Button("Search...")
self.btnSearch.connect("clicked", self.search)
- self.searchbar.pack_start(self.textbox)
- self.searchbar.pack_start(self.btnSearch)
+ self.searchbar.pack_start(self.textbox, True, True, 0)
+ self.searchbar.pack_start(self.btnSearch, True, True, 0)
- self.my_vbox.pack_start(self.searchbar, False)
+ self.my_vbox.pack_start(self.searchbar, False, True, 0)
self.window.add(self.my_vbox)
self.window.show_all()
self.window.connect("destroy", self.destroy)
def main(self):
- gtk.main()
+ Gtk.main()
if __name__ == "__main__":
import sys
diff --git a/sw/tools/airframe_editor/gui_dialogs.py b/sw/tools/airframe_editor/gui_dialogs.py
index a281668d0c..121a4088d2 100644
--- a/sw/tools/airframe_editor/gui_dialogs.py
+++ b/sw/tools/airframe_editor/gui_dialogs.py
@@ -2,34 +2,32 @@
from __future__ import print_function
-import gtk
+import gi
+gi.require_version('Gtk', '3.0')
+from gi.repository import Gtk, GdkPixbuf
+
from os import path
-if gtk.pygtk_version < (2, 3, 90):
- print("Please upgrade your pygtk")
- raise SystemExit
-
-
def filechooser(pathname):
- dialog = gtk.FileChooserDialog("Open ...", None,
- gtk.FILE_CHOOSER_ACTION_OPEN,
- (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_OPEN, gtk.RESPONSE_OK))
+ dialog = Gtk.FileChooserDialog("Open ...", None,
+ Gtk.FileChooserAction.OPEN,
+ (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
- dialog.set_default_response(gtk.RESPONSE_OK)
+ dialog.set_default_response(Gtk.ResponseType.OK)
dialog.set_current_folder(pathname)
- filter = gtk.FileFilter()
+ filter = Gtk.FileFilter()
filter.set_name("Airframe File")
filter.add_pattern("*.xml")
dialog.add_filter(filter)
response = dialog.run()
filename = ""
- if response == gtk.RESPONSE_OK:
+ if response == Gtk.ResponseType.OK:
filename = dialog.get_filename()
- elif response == gtk.RESPONSE_CANCEL:
+ elif response == Gtk.ResponseType.CANCEL:
print("No file selected")
dialog.destroy()
@@ -37,21 +35,21 @@ def filechooser(pathname):
def error_loading_xml(s):
- err_msg = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT,
- gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE,
+ err_msg = Gtk.MessageDialog(None, Gtk.DIALOG_DESTROY_WITH_PARENT,
+ Gtk.MESSAGE_ERROR, Gtk.BUTTONS_CLOSE,
"Error Loading XML: " + s)
err_msg.run()
err_msg.destroy()
def about(home):
- about_d = gtk.AboutDialog()
+ about_d = Gtk.AboutDialog()
about_d.set_program_name("Paparazzi Airframe Editor")
about_d.set_version("0.1")
about_d.set_copyright("(c) GPL v2")
about_d.set_comments("Airframe Editor")
about_d.set_website("http://paparazzi.github.io")
- about_d.set_logo(gtk.gdk.pixbuf_new_from_file(path.join(home, "data/pictures/penguin_icon.png")))
+ about_d.set_logo(GdkPixbuf.Pixbuf.new_from_file(path.join(home, "data/pictures/penguin_icon.png")))
about_d.run()
about_d.destroy()
diff --git a/sw/tools/airframe_editor/xml_airframe.py b/sw/tools/airframe_editor/xml_airframe.py
index 0d6d9e6f0e..f73260abd6 100755
--- a/sw/tools/airframe_editor/xml_airframe.py
+++ b/sw/tools/airframe_editor/xml_airframe.py
@@ -3,7 +3,7 @@
from __future__ import print_function
import lxml.etree as ET
-import StringIO
+from io import StringIO
import xml_common
@@ -35,7 +35,7 @@ def find_or_add_group(source, target, search):
def reorganize_airframe_xml(airframe_xml):
- some_file_like_object = StringIO.StringIO("")
+ some_file_like_object = StringIO(u"")
airframe_xml_tree = ET.parse(some_file_like_object)
airframe = airframe_xml_tree.getroot()