Ejemplo n.º 1
0
    def __init__(self, rlayer):

        gtk.GtkWindow.__init__(self)

        import gview

        self.rlayer = rlayer
        raster = rlayer.get_data()
        self.xsize = raster.get_dataset().RasterXSize
        self.ysize = raster.get_dataset().RasterYSize

        self.set_policy(gtk.TRUE, gtk.TRUE, gtk.FALSE)
        # self.set_usize(self.xsize, self.ysize)
        self.viewarea = gview.GvViewArea()
        self.viewarea.add_layer(self.rlayer)
        self.viewarea.size(self.xsize, self.ysize)
        shell = gtk.GtkVBox(spacing=0)
        self.add(shell)

        # Print menu
        menuf = GtkExtra.MenuFactory()
        self.menuf = menuf
        menuf.add_entries([('File/Print', None, self.print_cb)])

        shell.pack_start(menuf, expand=gtk.FALSE)

        shell.pack_start(self.viewarea)

        self.connect('delete-event', self.close)
        self.show_all()

        self.viewarea.fit_extents(0, self.ysize, self.xsize, -self.ysize)
Ejemplo n.º 2
0
    def add_py_menu(self, ew):
        def run(b=None, ew=ew, app=self):
            app.run_script(ew.fname)

        def dbg(b=None, ew=ew, app=self):
            app.debug_script(ew.fname)

        def prf(b=None, ew=ew, app=self):
            app.profile_script(ew.fname)

        py_menu = GtkExtra.MenuFactory(MENU_FACTORY_MENU)
        py_menu.add_entries([('Run...', None, run), ('Debug...', None, dbg),
                             ('Profile...', None, prf)])
        mi = GtkMenuItem('Python')
        ew.mf.insert(mi, 2)
        mi.show()
        mi.set_submenu(py_menu)
        ew.mf.hide()
        ew.mf.show()
Ejemplo n.º 3
0
 def __init__(self):
     GtkWindow.__init__(self, WINDOW_TOPLEVEL)
     self.connect("destroy", self.quit)
     self.connect("delete_event", self.quit)
     self.set_title("Python")
     self.set_usize(475, 325)
     self.main_box = GtkVBox()
     self.add(self.main_box)
     self.main_box.show()
     hdlbox = GtkHandleBox()
     self.main_box.pack_start(hdlbox, expand=FALSE)
     hdlbox.show()
     mf = GtkExtra.MenuFactory()
     mf.add_entries([
         ('File/New', '<control>N', self.file_new),
         ('File/Open...', '<control>O', self.file_open),
         ('File/<separator>', None, None),
         ('File/Exit', '<control>Q', self.file_exit),
         ('Edit/Copy', '<control>C', self.edit_copy),
         ('Edit/Paste', '<control>V', self.edit_paste),
         ('Edit/Clear', None, self.edit_clear),
         ('Python/Reload Module...', None, self.python_reload),
         ('Python/<separator>', None, None),
         ('Python/Run...', None, self.python_run),
         ('Python/Debug...', None, self.python_debug),
         ('Python/Profile...', None, self.python_prof),
         ('Help/About...', None, self.help_about),
     ])
     self.add_accel_group(mf.accelerator)
     hdlbox.add(mf)
     mf.show()
     self.mf = mf
     self.interp = gtkcons.Console(namespace={
         '__builtins__': __builtins__,
         '__name__': '__main__',
         '__doc__': None
     },
                                   quit_cb=self.quit)
     self.main_box.pack_start(self.interp)
     self.interp.show()
     self.interp.init()
     self.editwins = []
Ejemplo n.º 4
0
    def create_menu(self):
        mf = GtkExtra.MenuFactory()

        mf.add_entries([('File/New', '<control>N', self.file_new),
                        ('File/Open...', '<control>O', self.file_open),
                        ('File/Save', '<control>S', self.file_save),
                        ('File/Save As...', None, self.file_saveas),
                        ('File/<separator>', None, None),
                        ('File/Exit', '<control>Q', self.file_exit),
                        ('Edit/Cut', '<control>X', self.edit_cut),
                        ('Edit/Copy', '<control>C', self.edit_copy),
                        ('Edit/Paste', '<control>V', self.edit_paste),
                        ('Edit/Clear', None, self.edit_clear),
                        ('Edit/<separator>', None, None),
                        ('Edit/Find...', None, self.edit_find),
                        ('Edit/Find Next', None, self.edit_find_next),
                        ('Help/About...', None, self.help_about)])
        # activate key bindings ...
        self.add_accel_group(mf.accelerator)
        self.mf = mf
        return mf
Ejemplo n.º 5
0
def create_menu_bar(win):
    mf = GtkExtra.MenuFactory()
    mf.add_entries(menu_bar_array)
    win.add_accel_group(mf.accelerator)
    mf.show()
    return mf
Ejemplo n.º 6
0
    def setmode(self, mode):
        self.mode = mode
        if self.vbox and self.menubar and self.hbox:
            #print '**************************************************regen'
            self.vbox.remove(self.menubar)
            self.vbox.remove(self.hbox)
            self.menubar.destroy()
            self.hbox.destroy()
            self.ed = None
            vbox = self.vbox
            win = self.win
        else:
            #print '++++++++++++++++++++++++++++++++++++++++++++++++++  gen'
            ## create the top level window
            win = GtkWindow()
            win.set_title("Nemesis build system configuration tool")
            vbox = GtkVBox()
            self.mainvbox = win
            self.win = win
            self.vbox = vbox
            win.show()

        hbox = GtkHBox()
        self.hbox = hbox

        # set up Choices Editor
        if mode > 0:
            ch = ChoicesEditor(self, invisible=0)
            framech = GtkFrame('Choices Editor')
            framech.border_width(5)
            framech.add(ch)
            framech.show()
            hbox.pack_end(framech)
        else:
            ch = ChoicesEditor(self, invisible=1)

        self.ch = ch

        # set up menu bar
        menubar = GtkExtra.MenuFactory()
        l = [
            ('File/New Choices File', None, self.new_choices),
            ('File/Open Choices File', None, self.open_choices),
            ('File/<separator>', None, None),
            ('File/Exit', None, self.exit),
            ('Blueprint/Open Generic Blueprint', None, self.open_tree),
            ('Mode/Beginner', None, self.mode_beginner),
            ('Mode/Expert', None, self.mode_expert),
            ('Mode/Deity', None, self.mode_deity),
        ]

        if self.mode == 2:
            l = l + [
                ('Add/Program', None, self.new_program),
                ('Add/Module', None, self.new_module),
            ]

        l = l + [
            ('Help/Manual', None, self.help),
        ]
        menubar.add_entries(l)

        menubar.show()
        self.menubar = menubar
        print 'Setting up main window'
        # set up main window
        print 'packing'
        vbox.pack_start(menubar, fill=FALSE, expand=FALSE)
        vbox.pack_start(hbox)
        hbox.show()
        vbox.show()
        win.add(vbox)
        self.win = win
        # read the choices file
        frameitem = GtkFrame('Item Editor')
        frameitem.border_width(5)
        self.hbox2 = GtkHBox()

        # read the choices files, implicintly creating the choices editor
        self.ch.refresh_file()
        frameitem.add(self.hbox2)
        frameitem.show()
        self.hbox2.show()
        hbox.pack_start(frameitem)

        print 'Setting up item editor'
        self.setup_itemeditor()
        # the item editor must have been set up by this point, otherwise
        # reload blueprint will fail when it tries to point the Editor
        # at the new item
        self.reload_blueprint()