def create(self, path, accelerator=None, callback=None, *args): """ create a single menuitem and add it to one of the menus already created (or create a new one) """ last_slash = string.rfind(path, '/') if last_slash < 0: parentmenu = self.__w else: parentmenu = self.get_menu(path[:last_slash]) label = path[last_slash+1:] if label == '<separator>': item = gtk.GtkMenuItem() elif label[:7] == '<image:': end = string.find(label, '>') img_name = label[7:end] hbox = gtk.GtkHBox(spacing=2) try: hbox.pack_start(self.create_pixmap(img_name), expand=FALSE) except: print 'Unable to load menu pixmap: ' + img_name lbl = gtk.GtkLabel(label[end+1:]) lbl.set_justify(gtk.JUSTIFY_LEFT) hbox.pack_start(lbl, expand=FALSE) item = gtk.GtkMenuItem() item.add(hbox) item.show_all() elif label[:8] == '<toggle>': item = pguToggleMenuItem(label[8:]) elif label[:7] == '<check>': item = gtk.GtkCheckMenuItem(label[7:]) else: if parentmenu == self.__w: item = gtk.GtkMenuItem(label) else: hbox = gtk.GtkHBox() spc = gtk.GtkLabel('') spc.set_usize(22,18) hbox.pack_start(spc, expand=FALSE) lbl = gtk.GtkLabel(label) lbl.set_justify(gtk.JUSTIFY_LEFT) hbox.pack_start(lbl, expand=FALSE) item = gtk.GtkMenuItem() item.add(hbox) if label != '<nothing>': item.show() if accelerator: key, mods = self.parse_accelerator(accelerator) item.add_accelerator("activate", self.accelerator, key, mods, 'visible') if callback: apply(item.connect, ("activate", callback) + args) # right justify the help menu automatically if string.lower(label) == 'help' and parentmenu == self.__w: item.right_justify() parentmenu.append(item) self.__items[path] = item return item
def __init__(self, ok_cb=None, cancel_cb=None, cb_data=None, classify_type=CLASSIFY_EQUAL_INTERVAL): gtk.GtkWindow.__init__(self) self.set_title('Classification') self.user_ok_cb = ok_cb self.user_cancel_cb = cancel_cb self.user_cb_data = cb_data self.classify_type = classify_type self.set_border_width(6) #main vertical box vbox = gtk.GtkVBox(spacing=6) type_box = gtk.GtkHBox(spacing=6) type_box.pack_start(gtk.GtkLabel('Type:'), expand=gtk.FALSE) opt_menu = gtk.GtkOptionMenu() type_menu = gtk.GtkMenu() #using classification_types dictionary from gvclassification for i in range(len(classification_types)): for type in classification_types.iteritems(): if type[1] == i: item = gtk.GtkMenuItem(type[0]) item.connect('activate', self.type_menu_cb, classification_types[type[0]]) type_menu.append(item) opt_menu.set_menu(type_menu) opt_menu.set_history(classify_type) opt_menu.resize_children() type_box.pack_start(opt_menu) vbox.pack_start(type_box, expand=gtk.FALSE) #Number of classes classes_box = gtk.GtkHBox(spacing=6) classes_box.pack_start(gtk.GtkLabel('Number of classes:')) adj = gtk.GtkAdjustment(5, 2, 80, 1, 5, 5, 0) self.spinner = gtk.GtkSpinButton(adj) self.spinner.set_snap_to_ticks(gtk.TRUE) self.spinner.set_digits(0) classes_box.pack_start(self.spinner) vbox.pack_start(classes_box, expand=gtk.FALSE) #add the ok and cancel buttons button_box = gtk.GtkHButtonBox() ok_button = gtk.GtkButton("OK") ok_button.connect('clicked', self.ok_cb, cb_data) cancel_button = gtk.GtkButton("Cancel") cancel_button.connect('clicked', self.cancel_cb, cb_data) button_box.pack_start(ok_button) button_box.pack_start(cancel_button) vbox.pack_start(button_box, expand=gtk.FALSE) vbox.show_all() self.add(vbox) ok_button.set_flags(gtk.CAN_DEFAULT) ok_button.grab_default()
def init_create_gui_panel(self): # Basic Buttons... self.button_dict['Analyze'] = gtk.GtkButton('Analyze') self.show_list.append(self.button_dict['Analyze']) self.button_dict['Activate'] = gtk.GtkCheckButton('Activate') self.show_list.append(self.button_dict['Activate']) self.button_dict['Auto Update'] = gtk.GtkCheckButton('Auto Update') self.show_list.append(self.button_dict['Auto Update']) self.button_dict['Set Tool'] = gtk.GtkButton('Set Tool') self.show_list.append(self.button_dict['Set Tool']) # Basic Frames... # first frame self.frame_dict['base_frame1'] = gtk.GtkFrame() self.show_list.append(self.frame_dict['base_frame1']) hbox1 = gtk.GtkHBox(gtk.TRUE,5) self.show_list.append(hbox1) hbox1.pack_end(self.button_dict['Analyze'],gtk.TRUE,gtk.TRUE,0) self.frame_dict['base_frame1'].add(hbox1) # second frame- will contain roi or poi info self.frame_dict['base_frame2'] = gtk.GtkFrame() self.show_list.append(self.frame_dict['base_frame2']) # third frame self.frame_dict['base_frame3'] = gtk.GtkFrame(); self.show_list.append(self.frame_dict['base_frame3']) hbox3 = gtk.GtkHBox(gtk.TRUE,5) self.show_list.append(hbox3) hbox3.pack_start(self.button_dict['Activate'],gtk.TRUE,gtk.TRUE,0) hbox3.pack_start(self.button_dict['Auto Update'],gtk.TRUE,gtk.TRUE,0) hbox3.pack_start(self.button_dict['Set Tool'],gtk.TRUE,gtk.TRUE,0) self.frame_dict['base_frame3'].add(hbox3) # Top level panel... self.main_panel = gtk.GtkVBox(gtk.FALSE,5) self.main_panel.pack_start(self.frame_dict['base_frame1'],gtk.FALSE,gtk.FALSE,0) self.main_panel.pack_start(self.frame_dict['base_frame2'],gtk.FALSE,gtk.FALSE,0) self.main_panel.pack_end(self.frame_dict['base_frame3'],gtk.FALSE,gtk.FALSE,0) self.add(self.main_panel) self.show_list.append(self.main_panel)
def __init__(self, imgui, *args, **kw): apply(gtk.GtkWindow.__init__, (self, ) + args, kw) self.imgui = imgui self.accounts = [] vbox = gtk.GtkVBox(gtk.FALSE, 5) vbox.set_border_width(5) self.add(vbox) titles = ['Username', 'Online', 'Auto-Login', 'Gateway'] clist = gtk.GtkCList(len(titles), titles) clist.signal_connect("select_row", self.rowSelected) clist.set_shadow_type(gtk.SHADOW_OUT) scrolled = gtk.GtkScrolledWindow(None, None) scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS) vbox.pack_start(scrolled, gtk.TRUE, gtk.TRUE, 0) scrolled.add(clist) hb = gtk.GtkHBox(gtk.FALSE, 0) vbox.pack_start(hb, gtk.FALSE, gtk.TRUE, 0) addB = gtk.GtkButton("Add") modifyB = gtk.GtkButton("Modify") loginB = gtk.GtkButton("Logon") deleteB = gtk.GtkButton("Delete") map(hb.add, [addB, modifyB, loginB, deleteB]) self.imgui.im.connect(self.event_attach, "attach") self.imgui.im.connect(self.event_detach, "detach") self.signal_connect('destroy', gtk.mainquit, None)
def __init__(self, title): gtk.GtkWindow.__init__(self) self.set_title(title) self.vbox = gtk.GtkVBox() self.add(self.vbox) self.hbox = gtk.GtkHBox() self.vbox.pack_end(self.hbox)
def __init__(self, gui): Tab.__init__(self, gui, 'URLs') self._id = 'URLs' self._regexp = re.compile('(http://[^\s]+)', re.IGNORECASE) self._scrolled_win = gtk.GtkScrolledWindow() self._scrolled_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self._box.pack_start(self._scrolled_win) self._list = gtk.GtkList() self._list.set_selection_mode(gtk.SELECTION_BROWSE) self._scrolled_win.add_with_viewport(self._list) self._list.connect("select-child", self.selectCB) self._hbox = gtk.GtkHBox() self._open_button = gtk.GtkButton('open') self._hbox.pack_end(self._open_button, fill=gtk.FALSE, expand=gtk.FALSE) self._box.pack_end(self._hbox, fill=gtk.TRUE, expand=gtk.FALSE) self._box.show_all() self._addToNoteBook()
def __init__(self, gui, jid, title='a tab'): Tab.__init__(self, gui, title) self._id = str(jid.getStripped()) self._scroll = gtk.GtkScrolledWindow() self._txt = gtk.GtkText() self._txt.set_word_wrap(gtk.TRUE) self._scroll.add(self._txt) self._scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self._box.pack_start(self._scroll, fill=gtk.TRUE, expand=gtk.TRUE) self._hbox = gtk.GtkHBox() self._entry = gtk.GtkEntry() self._hbox.pack_start(self._entry, fill=gtk.TRUE, expand=gtk.TRUE) self._send_button = gtk.GtkButton('send') #self._send_button.connect('clicked', self._cb, self) #self._entry.connect('activate', self._cb, self ) self._hbox.pack_end(self._send_button, fill=gtk.FALSE, expand=gtk.FALSE) self._box.pack_end(self._hbox, fill=gtk.TRUE, expand=gtk.FALSE) self._box.show_all() self._addToNoteBook() self._entry.grab_focus()
def __init__(self, title=None, cols=80, rows=25, font=None): self.win = gtk.GtkWindow() self.win.connect("delete_event", gtk.mainquit) if title is None: title = "ZTerm" if font is None: font = ZTerm.default_font self.win.set_title(title) self.win.set_policy(gtk.FALSE, gtk.TRUE, gtk.TRUE) hbox = gtk.GtkHBox() self.win.add(hbox) hbox.show() term = gnome.zvt.ZvtTerm(cols, rows) term.set_scrollback(500) term.set_font_name(font) term.connect("child_died", child_died_event) hbox.pack_start(term) term.show() self.term = term scroll = gtk.GtkVScrollbar(term.adjustment) hbox.pack_start(scroll, expand=gtk.FALSE) scroll.show() charwidth = term.charwidth charheight = term.charheight self.win.set_geometry_hints(geometry_widget=term, min_width=2*charwidth, min_height=2*charheight, base_width=charwidth, base_height=charheight, width_inc=charwidth, height_inc=charheight) self.win.show()
def __init__(self, tips): gtk.GtkVBox.__init__(self) self.frames = {} self.tips = tips hbox = gtk.GtkHBox() hbox.set_border_width(spc) self.pack_start(hbox) label = gtk.GtkLabel("Input Geocoding: ") label.set_alignment(0, 0.5) hbox.pack_start(label) self.geocode_menu_list = ['Default', 'GCPs', 'Geotransform'] self.geocode_menu = gvutils.GvOptionMenu(self.geocode_menu_list, self.geotype_toggled_cb) self.tips.set_tip( self.geocode_menu, 'Default: Derive geocoding from input bands\n' + 'GCPs: Define new ground control points\n' + 'Geotransform: Define a new affine transformation') hbox.pack_start(self.geocode_menu) hbox.show_all() self.create_default_frame() self.create_gcp_frame() self.create_geotransform_frame() self.geocode_menu.set_history(0) self.geotype_toggled_cb() self.default_fname = None # dataset to use for default info self.default_geotransform = None self.default_gcps = None self.default_prj = ''
def makeoptmenu(name, opts, default=0, func=None): hbox = gtk.GtkHBox() label = gtk.GtkLabel(name) label.show() hbox.pack_start(label) menu = gtk.GtkMenu() def store(widget, data): self.values[name] = data if func: func(widget, data) for text, data in opts: menu_item = gtk.GtkMenuItem(text) menu_item.connect("activate", store, data) menu_item.show() menu.append(menu_item) option_menu = gtk.GtkOptionMenu() option_menu.set_menu(menu) option_menu.set_history(default) self.values[name] = opts[default][1] option_menu.show() hbox.pack_start(option_menu) hbox.show() return hbox
def create_view(name, plines, areas, raster): win = gtk.GtkWindow() win.set_title(name) win.set_policy(gtk.TRUE, gtk.TRUE, gtk.FALSE) shell = gtk.GtkVBox() win.add(shell) view = gview.GvViewArea() view.size(512,512) shell.pack_start(view, expand=gtk.TRUE) if raster: raster_layer = gview.GvRasterLayer(raster) view.add_layer(raster_layer) view.add_layer(gview.GvPqueryLayer()) view.add_layer(gview.GvAreaLayer(areas)) view.add_layer(gview.GvLineLayer(plines)) statusbar = gtk.GtkHBox() shell.pack_start(statusbar, expand=gtk.FALSE) label = gtk.GtkLabel() statusbar.pack_start(label, expand=gtk.FALSE, padding=3) tracker = gview.GvTrackTool(label) tracker.activate(view) view.connect('key-press-event', testmain_button_press) win.show_all() view.grab_focus() win.connect('delete-event', gtk.mainquit) gtk.quit_add_destroy(1, win) return view
def __init__(self, gui, title): Tab.__init__(self, gui, title) self._roster_selected = None self._online_icon, self._online_mask = \ gtk.create_pixmap_from_xpm( gui.get_window(), None,"online.xpm" ) self._offline_icon, self._offline_mask = \ gtk.create_pixmap_from_xpm( gui.get_window(), None,"offline.xpm" ) self._pending_icon, self._pending_mask = \ gtk.create_pixmap_from_xpm( gui.get_window(), None,"pending.xpm" ) self._rows = [] self._scroll = gtk.GtkScrolledWindow() self._ctree = gtk.GtkCTree(1, 0) self._ctree.set_column_width(0, 200) self._ctree.set_line_style(gtk.CTREE_LINES_NONE) self._ctree.set_expander_style(gtk.CTREE_EXPANDER_CIRCULAR) self._ctree.connect("select_row", self.rosterSelectCB) self.paint_tree() self._scroll.add(self._ctree) self._scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.FALSE) self._box.pack_start(self._scroll, fill=gtk.TRUE, expand=gtk.TRUE) self._hbox = gtk.GtkHBox() self._box.pack_end(self._hbox, fill=gtk.TRUE, expand=gtk.FALSE) self._box.show_all() self._addToNoteBook()
def __init__(self): self.canvas = None self.window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) self.window.set_title("jXPMap Editor") self.box0 = gtk.GtkVBox(gtk.FALSE, 0) menubar = self.buildMenuBar() self.box0.pack_start(menubar, gtk.FALSE, gtk.FALSE, 0) self.box1 = gtk.GtkHBox(gtk.FALSE, 0) self.box0.pack_start(self.box1, gtk.TRUE, gtk.TRUE, 0) self.window.add(self.box0) self.buildToolBar() #self.ActionMap() #self.buildInputMap() # The visual calls are needed to make sure drawing bitmaps # (draw_*_image) works # ... at least according to some documentation that doesn't look # entirely reliable gtk.push_rgb_visual() area = gtk.GtkDrawingArea() gtk.pop_visual() area.size(500, 500) self.box1.pack_start(area, gtk.TRUE, gtk.TRUE, 0) area.connect("expose-event", self.area_expose_cb) # Change the default background to black so that the window # doesn't flash badly when resizing style = area.get_style().copy() style.bg[gtk.STATE_NORMAL] = area.get_colormap().alloc(0, 0, 0) area.set_style(style) area.connect("button_press_event", self.mouse_event) area.connect("button_release_event", self.mouse_event) area.connect("motion_notify_event", self.mouse_event) area.connect("configure_event", self.configure_event) area.set_events(GDK.EXPOSURE_MASK | GDK.BUTTON_PRESS_MASK | GDK.BUTTON_RELEASE_MASK | GDK.POINTER_MOTION_MASK | GDK.POINTER_MOTION_HINT_MASK) # The HINT_MASK means there won't be a callback for every mouse # motion event, only after certain other events or after an explicit # reading of the location with x, y = window.pointer. # This helps to avoid getting a queue of events if they're not handled # quickly enough. area.show() self.zoom = 0 self.box1.show() self.box0.show() self.window.show() self.canvas = MapCanvas(area)
def __init__(self, im, desc): gtk.GtkWindow.__init__(self, gtk.WINDOW_TOPLEVEL) self.set_title(desc) self.im = im button = cbutton(desc, self.clicked) self.entry = gtk.GtkEntry() self.entry.connect('activate', self.clicked) hb = gtk.GtkHBox() hb.add(self.entry) hb.add(button) self.add(hb) self.show_all()
def reset_classification_list(self, *args): """Set the contents of class_list to the classification scheme in the classification object.""" #clear existing UI side items. self.class_list.clear_items(0, -1) del self.color_buttons, self.ranges, self.labels self.color_buttons = [] self.ranges = [] self.labels = [] cls = self.classification #prepare a default classification if one doesn't exist if cls.count == 0: cls.prepare_default(5) symbol = cls.get_symbol(0) #setup the column headers class_item = gtk.GtkListItem() set_widget_background(class_item, (1.0, 0.0, 0.0)) class_box = gtk.GtkHBox() clr_frm = gtk.GtkFrame() clr_frm.add(gtk.GtkLabel('Color')) clr_frm.set_shadow_type(gtk.SHADOW_OUT) if symbol is not None: sym_frm = gtk.GtkFrame() sym_frm.add(gtk.GtkLabel('Symbol')) sym_frm.set_shadow_type(gtk.SHADOW_OUT) scale_frm = gtk.GtkFrame() scale_frm.add(gtk.GtkLabel('Scale')) scale_frm.set_shadow_type(gtk.SHADOW_OUT) else: sym_frm = None scale_frm = None rng_frm = gtk.GtkFrame() rng_frm.add(gtk.GtkLabel('Range')) rng_frm.set_shadow_type(gtk.SHADOW_OUT) lbl_frm = gtk.GtkFrame() lbl_frm.add(gtk.GtkLabel('Label')) lbl_frm.set_shadow_type(gtk.SHADOW_OUT) self.add_classification_item(clr_frm, sym_frm, scale_frm, rng_frm, lbl_frm, gtk.FALSE) #for each class, create an entry in the list for n in range(cls.count): self.insert_class(n) self.class_list.show_all() if self.ramp is not None: self.apply_ramp(self.ramp)
def __init__(self, title='pygtk app', jabberObj=None, width=None, height=None): gtk.GtkWindow.__init__(self) self.set_title(title) if width is None: if gtk.screen_width() > 300: ## Fit the display width = 320 height = 200 else: width = 240 height = 300 self._tabs = [] self.cols = {} self.jabberObj = jabberObj self.roster_selected = None self.set_usize(width, height) self.connect("delete_event", self.quit) self.box = gtk.GtkVBox() self.add(self.box) self.box.show() self.tbox = gtk.GtkHBox() self.checkItemCalled = 0 self.init_menu() self.init_status_select() self.close_but = gtk.GtkButton('X') self.close_but.connect("clicked", self.closeTabCB) self.close_but.show() self.tbox.pack_end(self.close_but, fill=gtk.FALSE, expand=gtk.FALSE) self.tbox.show() self.box.pack_start(self.tbox, fill=gtk.FALSE, expand=gtk.FALSE) self.notebook = gtk.GtkNotebook() self.notebook.set_tab_pos(gtk.POS_BOTTOM) self.notebook.set_scrollable(gtk.TRUE) self.notebook.connect('switch_page', self.notebook_switched) self.box.pack_end(self.notebook, fill=gtk.TRUE, expand=gtk.TRUE) self._tabs.append(Roster_Tab(self, 'roster')) self.notebook.show() self.show()
def create_bar(self): ## Here we create the actual bar self.destroy_bar = 0 if not self.progressbox: self.progressbox = gtk.GtkVBox(gtk.TRUE, 10) ## Create the top label, if any if self.name_top and not self.label_top: self.label_top = gtk.GtkLabel() self.label_top.set_text(self.name_top) control_box.pack_start(self.label_top, gtk.TRUE, gtk.FALSE, 0) self.label_top.show() ## Create progress line self.progressline = gtk.GtkHBox(gtk.FALSE, 0) ## Create the progress bar self.progressbar = gtk.GtkProgressBar() self.progressbar.set_orientation(self.orientation) if self.type == "discrete": self.progress_discrete( ) ## if less than 10 things to do in the thread, make the bar discrete elif self.type == "active": self.back_and_forth_state(gtk.TRUE) self.progressbar.set_bar_style(self.style) self.progressline.pack_start(self.progressbar, gtk.TRUE, gtk.TRUE, 10) self.progressbox.pack_start(self.progressline, gtk.TRUE, gtk.TRUE, 0) self.progressbar.show() ## End of progress bar creation ## Stop button lives here self.stopbutton = gtk.GtkButton("Stop") self.stopbutton.connect("clicked", self.stop_it) self.progressline.pack_start(self.stopbutton, gtk.TRUE, gtk.TRUE, 20) self.stopbutton.show() self.progressline.show() ## Create the bottom label, if any if self.name_bottom and not self.label_bottom: self.label_bottom = gtk.GtkLabel() ## control_box.add(self.label_bottom) self.label_bottom.set_text(self.name_bottom) self.progressbox.pack_start(self.label_bottom, gtk.TRUE, gtk.TRUE, 0) self.label_bottom.show()
def __init__(self, gui, title='DEBUG'): Tab.__init__(self, gui, title) self._id = "DEBUG" self._scroll = gtk.GtkScrolledWindow() self._txt = gtk.GtkText() self._txt.set_word_wrap(gtk.TRUE) self._scroll.add(self._txt) self._scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self._box.pack_start(self._scroll, fill=gtk.TRUE, expand=gtk.TRUE) self._hbox = gtk.GtkHBox() self._box.show_all() self._addToNoteBook()
def mk_wnd(self, title): wnd = gtk.GtkWindow() wnd.set_title(title) self.box = gtk.GtkVBox() self.textbox = gtk.GtkHBox() e = gtk.GtkEntry() self.textentry = e e.show() self.textbox.pack_start(e) b = gtk.GtkButton('Lookup') def looker(button): self.lookup('', e.get_text()) b.connect('released', looker) b.show() self.textbox.pack_start(b) self.textbox.show() self.box.pack_start(self.textbox) def mk_sel_changed(fn): def sel_changed(l, fn=fn): sel = l.get_selection() if len(sel) > 0: s = sel[0].children()[0].get() (typ, val) = split_tv(s) fn(typ, val) return sel_changed def make_lb(text, fn, box): lb = gtk.GtkList() lb.show() frame = gtk.GtkFrame(text) frame.add(lb) frame.show() box.pack_start(frame) lb.connect('selection-changed', fn) return lb self.lb_head = make_lb('Head terms', mk_sel_changed(self.set_head), self.box) self.lb_rel = make_lb('Relations', mk_sel_changed(self.lookup), self.box) self.box.show() wnd.add(self.box) wnd.show() return wnd
def __init__(self, label=""): import pgutogglebutton gtk.GtkMenuItem.__init__( self ) hbox = gtk.GtkHBox( spacing = 2 ) self.tb = pgutogglebutton.pguToggleButton( ) self.tb.connect( 'toggled', self.toggled_cb) hbox.pack_start( self.tb, expand=FALSE ) evt_box = gtk.GtkEventBox() evt_box.connect( 'button-release-event', self.toggle_it ) lbl = gtk.GtkLabel( label ) evt_box.add( lbl ) hbox.pack_start( evt_box ) self.add( hbox ) self.show_all()
def create_gcp_frame(self): self.frames['GCPs'] = gtk.GtkFrame('') self.frames['GCPs'].set_shadow_type(gtk.SHADOW_NONE) vbox = gtk.GtkVBox() vbox.set_spacing(spc) self.frames['GCPs'].add(vbox) self.gcpgrid = pgugrid.pguGrid((3, 1, 0, 1, 7, 0, 0, 0, 3)) self.gcpgrid.set_usize(200, 200) self.gcplist = [] self.gcpgrid.set_source( self.gcplist, members=['Id', 'GCPPixel', 'GCPLine', 'GCPX', 'GCPY', 'GCPZ'], titles=['ID', 'Pixel', 'Line', 'X', 'Y', 'Z'], types=['string', 'float', 'float', 'float', 'float', 'float']) vbox.pack_start(self.gcpgrid) hbox = gtk.GtkHBox() hbox.set_spacing(spc) vbox.pack_start(hbox) self.add_gcp_button = gtk.GtkButton(' Add GCP ') self.add_gcp_button.connect('clicked', self.add_gcp_cb) hbox.pack_start(self.add_gcp_button, expand=gtk.FALSE) self.tips.set_tip(self.add_gcp_button, 'Add a new GCP') self.load_gcp_button = gtk.GtkButton('Load GCPs') self.tips.set_tip( self.load_gcp_button, 'Clear existing GCPs and load ' + 'new ones from a text file') self.load_gcp_button.connect('clicked', self.load_gcps_cb) hbox.pack_start(self.load_gcp_button, expand=gtk.FALSE) self.copy_gcp_button = gtk.GtkButton('Copy GCPs') self.copy_gcp_button.connect('clicked', self.copy_gcps_cb) self.tips.set_tip( self.copy_gcp_button, 'Clear existing GCPs and copy new ' + 'ones from another GDAL dataset') hbox.pack_start(self.copy_gcp_button, expand=gtk.FALSE) self.clear_gcp_button = gtk.GtkButton('Clear GCPs') self.clear_gcp_button.connect('clicked', self.clear_gcps) self.tips.set_tip(self.clear_gcp_button, 'Clear all GCPs') hbox.pack_start(self.clear_gcp_button, expand=gtk.FALSE) self.gcpprjbox = ProjectionBox(self.tips) vbox.pack_start(self.gcpprjbox) self.frames['GCPs'].show_all() self.pack_start(self.frames['GCPs'])
def __init__(self, title, wkt): gtk.GtkWindow.__init__(self) self.set_title(title) self.set_usize(350, 300) vbox = gtk.GtkVBox() self.add(vbox) self.text = gtk.GtkText() self.text.set_editable(gtk.TRUE) self.text.insert_defaults(wkt) vbox.pack_start(self.text) hbox = gtk.GtkHBox() vbox.pack_start(hbox, expand=gtk.FALSE) self.cancel_button = gtk.GtkButton(' Cancel ') self.ok_button = gtk.GtkButton(' OK ') hbox.pack_end(self.cancel_button, expand=gtk.FALSE) hbox.pack_end(self.ok_button, expand=gtk.FALSE) self.cancel_button.connect('clicked', self.quit) self.ok_button.connect('clicked', self.ok_cb) self.ret = None self.show_all()
def __init__(self, groupName, im): self.groupName = groupName self.im = im self.history = [''] self.histpos = 0 gtk.GtkWindow.__init__(self, gtk.WINDOW_TOPLEVEL) self.set_title("%s - Instance Messenger" % groupName) self.connect('destroy', self.leaveGroup) vb = gtk.GtkVBox() hb = gtk.GtkHBox() self.output = gtk.GtkText() self.output.set_word_wrap(gtk.TRUE) gtkutil.defocusify(self.output) hb.pack_start(gtkutil.scrollify(self.output), 1, 1, 1) userlist = gtk.GtkCList(1, ["Users"]) userlist.set_shadow_type(gtk.SHADOW_OUT) gtkutil.defocusify(userlist) hb.pack_start(gtkutil.scrollify(userlist), gtk.TRUE, gtk.TRUE, 0) # print self.im.remote.groups # for group in self.im.remote.groups: # if group.name == groupName: # for member in group.members: # userlist.append_items([member.name]) self.userlist = userlist vb.pack_start(hb, 1, 1, 1) self.input = gtk.GtkEntry() vb.pack_start(self.input, 0, 0, 1) #took this out so I can check in and not be broken #self.input.connect('key_press_event', self.processKey) self.input.connect('activate', self.sendMessage) self.add(vb) self.show_all()
def add_classification_item(self, clr, sym, scl, rng, lbl, delete_button=gtk.TRUE): """add a single row to the classification list. Optionally add a delete button that will delete that row from the classification. """ class_item = gtk.GtkListItem() class_box = gtk.GtkHBox() #explicitly size the first 5, let the last one fill the rest of the #space. clr.set_usize(70, -1) if sym is not None: sym.set_usize(70, -1) if scl is not None: scl.set_usize(70, -1) rng.set_usize(130, -1) lbl.set_usize(130, -1) class_box.pack_start(clr, expand=gtk.FALSE, fill=gtk.FALSE) if sym is not None: class_box.pack_start(sym, expand=gtk.FALSE, fill=gtk.FALSE) if scl is not None: class_box.pack_start(scl, expand=gtk.FALSE, fill=gtk.FALSE) class_box.pack_start(rng, expand=gtk.FALSE, fill=gtk.FALSE) class_box.pack_start(lbl, expand=gtk.FALSE, fill=gtk.FALSE) if delete_button: del_btn = gtk.GtkButton('x') del_btn.set_usize(45, -1) del_btn.connect('clicked', self.delete_item, class_item) class_box.pack_start(del_btn, expand=gtk.FALSE, fill=gtk.FALSE) class_box.add(gtk.GtkLabel('')) class_item.add(class_box) class_item.show() self.class_list.add(class_item)
def __init__(self, im): self.im = im # Set up the Contact List window. gtk.GtkWindow.__init__(self, gtk.WINDOW_TOPLEVEL) # Cheat, we'll do this correctly later -- self.signal_connect('destroy', gtk.mainquit, None) self.set_title("Instance Messenger") # self.set_usize(200,400) # Vertical Box packing vb = gtk.GtkVBox(gtk.FALSE, 5) # Contact List self.list = gtk.GtkCList(2, ["Status", "Contact"]) self.list.set_shadow_type(gtk.SHADOW_OUT) self.list.set_column_width(1, 150) self.list.set_column_width(0, 50) self.list.signal_connect("select_row", self.contactSelected) vb.pack_start(gtkutil.scrollify(self.list), gtk.TRUE, gtk.TRUE, 0) addContactButton = gtkutil.cbutton("Add Contact", self.addContactWindow) removeContactButton = gtkutil.cbutton("Remove Contact", self.removeContact) sendMessageButton = gtkutil.cbutton("Send Message", self.sendMessage) joinGroupButton = gtkutil.cbutton("Join Group", self.joinGroupWindow) hb = gtk.GtkHBox() hb.pack_start(addContactButton) hb.pack_start(removeContactButton) hb.pack_start(sendMessageButton) hb.pack_start(joinGroupButton) vb.pack_start(hb, gtk.FALSE, gtk.FALSE, 0) self.add(vb) self.show_all()
def __init__(self, title=None, cwd=None, dialog_type=FILE_OPEN, filter=None, app=None, multiselect=0): gtk.GtkWindow.__init__(self) if dialog_type >= FILE_OPEN and dialog_type <= DIRECTORY_SELECT: self.dialog_type = dialog_type else: self.dialog_type = FILE_OPEN self.filter = None #current filter self.filters = {} #active filter objects self.filter_keys = [] #ordered list of the names of the filters self.file_selection = [] self.multiselect = multiselect self.set_border_width(5) self.set_policy(as=gtk.FALSE, ag=gtk.FALSE, autos=gtk.TRUE) self.drives = None if title == None: if dialog_type == FILE_OPEN: title = nls.get('filedlg-title-open-file', 'Open File ...') elif dialog_type == FILE_SAVE: title = nls.get('filedlg-title-save-file', 'Save File ...') elif dialog_type == DIRECTORY_SELECT: title = nls.get('filedlg-title-select-directory', 'Select Directory ...') self.set_title(title) #setup the current working directory if cwd is None or not os.path.exists(cwd): cwd = gview.get_preference('working-directory') if cwd is None: cwd = os.getcwd() self.cwd = cwd #widgets vbox = gtk.GtkVBox(spacing=5) if dialog_type == FILE_OPEN or dialog_type == DIRECTORY_SELECT: lbl = gtk.GtkLabel(nls.get('filedlg-label-open-from', 'Open From:')) elif dialog_type == FILE_SAVE: lbl = gtk.GtkLabel(nls.get('filedlg-label-save-in', 'Save In:')) self.opt_menu = gtk.GtkOptionMenu() self.opt_menu.set_menu(gtk.GtkMenu()) hbox = gtk.GtkHBox() hbox.pack_start(lbl, expand=gtk.FALSE) hbox.pack_start(self.opt_menu) vbox.pack_start(hbox, expand = gtk.FALSE) self.list_directory = gtk.GtkCList() scr_directories = gtk.GtkScrolledWindow() scr_directories.add(self.list_directory) self.list_directory.connect('button-press-event', self.directory_selected_cb) if dialog_type == DIRECTORY_SELECT: self.list_files = None vbox.pack_start(scr_directories) else: self.list_files = gtk.GtkCList() if self.multiselect: self.list_files.set_selection_mode( gtk.SELECTION_EXTENDED ) scr_files = gtk.GtkScrolledWindow() scr_files.add(self.list_files) self.list_files.connect('button-press-event', self.file_clicked_cb) self.list_files.connect('select-row', self.file_selected_cb ) self.list_files.connect('unselect-row', self.file_unselected_cb ) pane = gtk.GtkHPaned() scr_directories.set_usize(100, -1) scr_files.set_usize(100, -1) pane.add1(scr_directories) pane.add2(scr_files) pane.set_position(200) vbox.pack_start(pane) widget = None if dialog_type == FILE_SAVE: self.txt_filename = gtk.GtkEntry() widget = self.txt_filename elif dialog_type == FILE_OPEN: combo = gtk.GtkCombo() combo.set_value_in_list(gtk.FALSE, gtk.FALSE) combo.disable_activate() if app is not None: rfl = app.get_rfl() rfl.insert(0, '') combo.set_popdown_strings( rfl ) self.txt_filename = combo.entry widget = combo if widget is not None: table = gtk.GtkTable(rows=2, cols=2) lbl = gtk.GtkLabel(nls.get('filedlg-label-file-name', 'File Name:')) self.txt_filename.connect('focus-out-event', self.map_path_cb) self.txt_filename.connect('key-press-event', self.map_path_cb) table.attach(lbl, 0, 1, 0, 1) table.attach(widget, 1, 2, 0, 1) lbl = gtk.GtkLabel(nls.get('filedlg-label-filter-extension', 'Filter extension:')) self.cmb_filter = pguCombo() self.set_filter(filter) self.cmb_filter.entry.connect('changed', self.filter_cb) table.attach(lbl, 0, 1, 1, 2) table.attach(self.cmb_filter, 1, 2, 1, 2) vbox.pack_start(table, expand=gtk.FALSE) if dialog_type == FILE_SAVE: self.ok_button = gtk.GtkButton(nls.get('filedlg-button-ok', 'OK')) elif dialog_type == FILE_OPEN: self.ok_button = gtk.GtkButton(nls.get('filedlg-button-open', 'Open')) elif dialog_type == DIRECTORY_SELECT: self.ok_button = gtk.GtkButton(nls.get('filedlg-button-ok', 'OK')) self.cancel_button = gtk.GtkButton(nls.get('filedlg-button-cancel', 'Cancel')) self.ok_button.connect('clicked', self.remove_grab) self.ok_button.connect('clicked', self.update_cwd) self.cancel_button.connect('clicked', self.remove_grab) btn_box = gtk.GtkHButtonBox() btn_box.pack_start(self.ok_button) btn_box.pack_start(self.cancel_button) vbox.pack_start(btn_box, expand=gtk.FALSE) self.add(vbox) self.show_all() #make modal gtk.grab_add(self) self.ok_button.set_flags(gtk.CAN_DEFAULT) self.ok_button.grab_default() self.set_usize(400, 400) self.menu_update = gtk.FALSE while gtk.events_pending(): gtk.mainiteration(FALSE) self.refresh_directory() self.connect('delete-event', self.quit) self.ok_button.connect('clicked', self.quit) self.cancel_button.connect('clicked', self.quit) self.publish('quit') self.add_events(gtk.GDK.KEY_PRESS_MASK) self.connect('key-press-event', self.key_press_cb) self.result = 'cancel'
def __init__(self, parent, tips): self.frame = gtk.GtkFrame('Raster Bands') self.tips = tips self.input_bands = get_list_of_bands_as_dict() self.output_bands = {} hbox1 = gtk.GtkHBox(spacing=spc) hbox1.set_border_width(spc) self.frame.add(hbox1) # source (input) srcvbox = gtk.GtkVBox(spacing=spc) label = gtk.GtkLabel('Input:') label.set_alignment(0, 0.5) srcvbox.pack_start(label, expand=gtk.FALSE) hbox1.pack_start(srcvbox) source_win = gtk.GtkScrolledWindow() source_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) source_win.set_usize(300, 200) srcvbox.pack_start(source_win) source_list = gtk.GtkList() source_list.set_selection_mode(gtk.SELECTION_MULTIPLE) source_win.add_with_viewport(source_list) source_list.append_items(self.input_bands.keys()) # signals sent up to top level so that defaults can # be updated. Defaults are updated whenever the output # bands are cleared, or the first one is specified. self.publish('output-bands-empty') self.publish('output-bands-notempty') def src_load(_button, *args): fname = GtkExtra.file_sel_box(title="Select GDAL Dataset") if fname is None: return ds = gdal.OpenShared(fname) if ds is None: gvutils.error('Not a valid gdal dataset!') return dict = {} for i in range(1, ds.RasterCount + 1): curband = fname + '.band[' + str(i) + ']' dict[gtk.GtkListItem(curband)] = (ds, i, curband) if srctoggle.get_active() == gtk.TRUE: slist = vrtutils.GetSimilarFiles(fname) for nname in slist: ds = gdal.OpenShared(nname) if ds is None: continue for i in range(1, ds.RasterCount + 1): curband = nname + '.band[' + str(i) + ']' dict[gtk.GtkListItem(curband)] = (ds, i, curband) self.add_input_bands(dict) def src_get_active_layers(_button, *args): size = None if len(self.input_bands) > 0: ckey = self.input_bands.keys()[0] size = (self.input_bands[ckey][0].RasterXSize, self.input_bands[ckey][0].RasterYSize) new_dict = get_list_of_bands_as_dict(size) self.add_input_bands(new_dict) def src_clear(_button, *args): self.clear_input_bands() self.source_list = source_list # source control buttons srcbbox = gtk.GtkHBox(spacing=spc) srcvbox.pack_start(srcbbox, expand=gtk.FALSE) load_btn = gtk.GtkButton("Load File") self.tips.set_tip(load_btn, 'Add bands from a file to the input list') srcbbox.pack_start(load_btn) load_btn.connect("clicked", src_load) act_btn = gtk.GtkButton("Views->List") self.tips.set_tip(act_btn, 'Add bands from views to the input list') srcbbox.pack_start(act_btn) act_btn.connect("clicked", src_get_active_layers) clear_btn = gtk.GtkButton("Clear") srcbbox.pack_start(clear_btn) clear_btn.connect("clicked", src_clear) srctoggle = gtk.GtkCheckButton("Include Similar") self.tips.set_tip( srctoggle, 'Include bands from same-size files ' + 'in the same directory when using Load File.') srcbbox.pack_start(srctoggle, expand=gtk.FALSE) srctoggle.set_active(gtk.TRUE) # destination btn_box = gtk.GtkVBox(spacing=10) btn_box.set_border_width(10) hbox1.pack_start(btn_box, expand=gtk.FALSE) btn_box.show() def dest_add(_button, *args): sel = source_list.get_selection() sel.reverse() # add in order of selection if len(self.output_bands.keys()) == 0: refreshflag = 1 else: refreshflag = 0 for i in sel: list_item = gtk.GtkListItem(self.input_bands[i][2]) self.dest_list.append_items([list_item]) list_item.show() self.dest_list.select_child(self.dest_list.children()[-1]) self.output_bands[list_item] = self.input_bands[i] if (refreshflag == 1) and (len(sel) > 0): self.notify('output-bands-notempty') def dest_del(_button, *args): selection = self.dest_list.get_selection() self.dest_list.remove_items(selection) for i in selection: del self.output_bands[i] i.destroy() rest = self.dest_list.children() if len(rest) > 0: self.dest_list.select_child(self.dest_list.children()[-1]) else: self.notify('output-bands-empty') def dest_raise(_button, *args): selection = self.dest_list.get_selection() if len(selection) != 1: return pos = self.dest_list.child_position(selection[0]) if pos < 1: return self.dest_list.remove_items(selection) self.dest_list.insert_items(selection, pos - 1) self.dest_list.select_item(pos - 1) def dest_lower(_button, *args): selection = self.dest_list.get_selection() if len(selection) != 1: return pos = self.dest_list.child_position(selection[0]) if pos > len(self.output_bands) - 2: return self.dest_list.remove_items(selection) self.dest_list.insert_items(selection, pos + 1) self.dest_list.select_item(pos + 1) add_btn = gtk.GtkButton("Add->") add_btn.connect("clicked", dest_add) # The label below just makes things align more nicely (adds space) btn_box.pack_start(gtk.GtkLabel(''), expand=gtk.FALSE) btn_box.pack_start(add_btn, expand=gtk.FALSE) destvbox = gtk.GtkVBox(spacing=spc) label = gtk.GtkLabel('Output:') label.set_alignment(0, 0.5) destvbox.pack_start(label, expand=gtk.FALSE) dest_win = gtk.GtkScrolledWindow() dest_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) dest_win.set_usize(300, 200) destvbox.pack_start(dest_win) hbox1.pack_start(destvbox) destbbox = gtk.GtkHBox(spacing=spc) destvbox.pack_start(destbbox, expand=gtk.FALSE) del_btn = gtk.GtkButton() del_btn.add( gtk.GtkPixmap(parent, os.path.join(gview.home_dir, 'pics', 'delete.xpm'))) del_btn.connect("clicked", dest_del) destbbox.pack_start(del_btn, expand=gtk.FALSE) r_btn = gtk.GtkButton() r_btn.add( gtk.GtkPixmap(parent, os.path.join(gview.home_dir, 'pics', 'raise.xpm'))) r_btn.connect("clicked", dest_raise) destbbox.pack_start(r_btn, expand=gtk.FALSE) l_btn = gtk.GtkButton() l_btn.add( gtk.GtkPixmap(parent, os.path.join(gview.home_dir, 'pics', 'lower.xpm'))) l_btn.connect("clicked", dest_lower) destbbox.pack_start(l_btn, expand=gtk.FALSE) self.dest_list = gtk.GtkList() self.dest_list.set_selection_mode(gtk.SELECTION_BROWSE) dest_win.add_with_viewport(self.dest_list) parent.shell.pack_start(self.frame)
def __init__(self): titles = ["Ingredients", "Amount"] self.flag = 0 window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL) window.set_usize(300, 150) window.set_title("GtkCList Example") window.connect("destroy", gtk.mainquit) vbox = gtk.GtkVBox(gtk.FALSE, 5) vbox.set_border_width(5) window.add(vbox) vbox.show() # Create a scrolled window to pack the CList widget into scrolled_window = gtk.GtkScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS) vbox.pack_start(scrolled_window, gtk.TRUE, gtk.TRUE, 0) scrolled_window.show() # Create the CList. For this example we use 2 columns clist = gtk.GtkCList(2, titles) # When a selection is made, we want to know about it. The callback # used is selection_made, and its code can be found further down clist.connect("select_row", self.selection_made) # It isn't necessary to shadow the border, but it looks nice :) clist.set_shadow_type(gtk.SHADOW_OUT) # What however is important, is that we set the column widths as # they will never be right otherwise. Note that the columns are # numbered from 0 and up (to 1 in this case). clist.set_column_width(0, 150) # Add the CList widget to the vertical box and show it. scrolled_window.add(clist) clist.show() # Create the buttons and add them to the window. See the button # tutorial for more examples and comments on this. hbox = gtk.GtkHBox(gtk.FALSE, 0) vbox.pack_start(hbox, gtk.FALSE, gtk.TRUE, 0) hbox.show() button_add = gtk.GtkButton("Add List") button_clear = gtk.GtkButton("Clear List") button_hide_show = gtk.GtkButton("Hide/Show titles") hbox.pack_start(button_add, gtk.TRUE, gtk.TRUE, 0) hbox.pack_start(button_clear, gtk.TRUE, gtk.TRUE, 0) hbox.pack_start(button_hide_show, gtk.TRUE, gtk.TRUE, 0) # Connect our callbacks to the three buttons button_add.connect_object("clicked", self.button_add_clicked, clist) button_clear.connect_object("clicked", self.button_clear_clicked, clist) button_hide_show.connect_object("clicked", self.button_hide_show_clicked, clist) button_add.show() button_clear.show() button_hide_show.show() # The interface is completely set up so we show the window and # enter the gtk_main loop. window.show()
def init_dialog(self): self.dialog = gtk.GtkWindow() self.dialog.set_title('GDAL Export Tool') self.dialog.set_border_width(10) self.tips = gtk.GtkTooltips() #self.dialog.set_default_size(500,400) self.dialog.set_policy(gtk.FALSE, gtk.TRUE, gtk.TRUE) # main shell mainshell = gtk.GtkHBox(spacing=1, homogeneous=gtk.FALSE) self.dialog.add(mainshell) self.show_list = [] self.adv_show_list = [] # advanced show list self.show_list.append(mainshell) #navigation shell navshell = gtk.GtkVBox(spacing=1, homogeneous=gtk.FALSE) mainshell.pack_start(navshell) self.show_list.append(navshell) self.frame_dict = {} self.button_dict = {} self.frame_dict['Files'] = gvutils.GvDataFilesFrame( 'Data Files', sel_list=('Input', 'Output')) self.frame_dict['Files'].set_border_width(5) self.frame_dict['Files'].set_spacings(5, 5) self.frame_dict['Files'].show_all() navshell.pack_start(self.frame_dict['Files']) self.show_list.append(self.frame_dict['Files']) bopt_frame = gtk.GtkFrame('Basic Options') self.frame_dict['Basic Options'] = bopt_frame self.show_list.append(bopt_frame) navshell.pack_start(bopt_frame, gtk.FALSE, gtk.FALSE, 0) bopt_table = gtk.GtkTable(2, 4, gtk.FALSE) bopt_table.set_border_width(5) bopt_table.set_row_spacings(5) bopt_table.set_col_spacings(5) bopt_frame.add(bopt_table) self.show_list.append(bopt_table) # Might be nice to have more formats below, but # this involves error checking to test for # supported data types, etc. fmtlabel = gtk.GtkLabel('Output Format: ') fmtlabel.set_alignment(0, 0.5) self.show_list.append(fmtlabel) bopt_table.attach(fmtlabel, 0, 1, 0, 1) self.format_list = [] hist_idx = 0 for iDriver in gdal.GetDriverList(): create = None try: create = iDriver.GetMetadata()["DCAP_CREATE"] except KeyError: try: create = iDriver.GetMetadata()["DCAP_CREATECOPY"] except KeyError: pass if create == "YES": if iDriver.ShortName == 'DTED': # DTED is a special case that needs certain # conditions to be valid. Skip it. continue self.format_list.append(iDriver.ShortName) self.format_list.sort() # Default to GTiff if possible try: hist_idx = self.format_list.index('GTiff') except ValueError: pass self.format_menu = gvutils.GvOptionMenu(self.format_list) self.format_menu.set_history(hist_idx) self.show_list.append(self.format_menu) bopt_table.attach(self.format_menu, 1, 2, 0, 1) self.button_dict['Format_help'] = gtk.GtkButton('Help') self.show_list.append(self.button_dict['Format_help']) bopt_table.attach(self.button_dict['Format_help'], 2, 3, 0, 1) reslabel = gtk.GtkLabel('Output Resolution: ') reslabel.set_alignment(0, 0.5) self.show_list.append(reslabel) bopt_table.attach(reslabel, 0, 1, 1, 2) self.res_list = ['Full', '1:2', '1:4', '1:8'] self.res_menu = gvutils.GvOptionMenu(self.res_list) bopt_table.attach(self.res_menu, 1, 2, 1, 2) self.show_list.append(self.res_menu) self.button_dict['Mode'] = gtk.GtkCheckButton('Advanced Options') navshell.pack_start(self.button_dict['Mode']) self.show_list.append(self.button_dict['Mode']) self.frame_dict['IP_window'] = DataWindowFrame(navshell) self.adv_show_list.append(self.frame_dict['IP_window']) iopt_frame = gtk.GtkFrame('Interactive Options') self.frame_dict['Interactive Options'] = iopt_frame self.adv_show_list.append(iopt_frame) navshell.pack_start(iopt_frame, gtk.FALSE, gtk.FALSE, 0) iopt_table = gtk.GtkTable(3, 3, gtk.FALSE) iopt_table.set_border_width(5) iopt_table.set_row_spacings(5) iopt_table.set_col_spacings(5) iopt_frame.add(iopt_table) self.adv_show_list.append(iopt_table) self.button_dict['IP_window'] = gtk.GtkCheckButton('Window Input File') iopt_table.attach(self.button_dict['IP_window'], 0, 2, 0, 1) self.adv_show_list.append(self.button_dict['IP_window']) self.button_dict['Scale'] = gtk.GtkCheckButton( 'Scale to View Settings') self.tips.set_tip( self.button_dict['Scale'], 'Scale the output bands ' + 'according to the min/max settings of the ' + 'currently active raster layer. This only ' + 'applies to real data.') iopt_table.attach(self.button_dict['Scale'], 0, 2, 1, 2) self.adv_show_list.append(self.button_dict['Scale']) self.button_dict['Refresh'] = gtk.GtkButton( 'Active Layer->Input Filename') self.tips.set_tip( self.button_dict['Refresh'], 'Set the input ' + 'filename to that of the currently active layer') iopt_table.attach(self.button_dict['Refresh'], 0, 1, 2, 3) self.adv_show_list.append(self.button_dict['Refresh']) self.button_dict['Enable_ROI'] = gtk.GtkButton('Draw ROI mode') self.tips.set_tip( self.button_dict['Enable_ROI'], 'Re-activate the ' + 'ROI mode used for interactive input file window definition') iopt_table.attach(self.button_dict['Enable_ROI'], 1, 2, 2, 3) self.adv_show_list.append(self.button_dict['Enable_ROI']) self.frame_dict['Other_Advanced'] = gtk.GtkFrame('') self.frame_dict['Other_Advanced'].set_shadow_type(gtk.SHADOW_NONE) self.adv_show_list.append(self.frame_dict['Other_Advanced']) oadvbox = gtk.GtkVBox(spacing=5, homogeneous=gtk.FALSE) oadvbox.set_border_width(5) self.adv_show_list.append(oadvbox) self.frame_dict['Other_Advanced'].add(oadvbox) otable = gtk.GtkTable(2, 3, gtk.FALSE) otable.set_row_spacings(5) otable.set_col_spacings(5) self.adv_show_list.append(otable) oadvbox.pack_start(otable) self._overview_list = ['None', 'Nearest', 'Average'] self.overview_menu = gvutils.GvOptionMenu(self._overview_list) ovrlabel = gtk.GtkLabel('Overviews:') self.tips.set_tip(self.overview_menu, 'Tiled overview creation options') ovrlabel.set_alignment(0, 0.5) self.adv_show_list.append(ovrlabel) otable.attach(ovrlabel, 0, 1, 0, 1) otable.attach(self.overview_menu, 1, 2, 0, 1) self.adv_show_list.append(self.overview_menu) self._geocode_list = ['Default', 'GCP', 'Geotransform'] self.geocoding_menu = gvutils.GvOptionMenu(self._geocode_list) geolabel = gtk.GtkLabel('Geocoding:') self.tips.set_tip( self.geocoding_menu, 'Specify the type of georeferencing ' + 'information to output. Default is to output ' + 'all available geocoding from the input file. ' + 'If GCP or Geotransform is selected, geocoding ' + 'information will only be output if it is of the ' + 'selected type. This may later be updated to ' + 'generate information of the specified form if ' + 'it is not present but can be accurately computed ' + 'from the existing information.') geolabel.set_alignment(0, 0.5) self.adv_show_list.append(geolabel) otable.attach(geolabel, 0, 1, 1, 2) otable.attach(self.geocoding_menu, 1, 2, 1, 2) self.adv_show_list.append(self.geocoding_menu) opthbox = gtk.GtkHBox(spacing=5, homogeneous=gtk.FALSE) self.adv_show_list.append(opthbox) oadvbox.pack_start(opthbox) optlabel = gtk.GtkLabel('Create Options:') optlabel.set_alignment(0, 0.5) self.adv_show_list.append(optlabel) self.optentry = gtk.GtkEntry() self.optentry.set_editable(editable=gtk.TRUE) self.optentry.set_usize(400, 25) self.optentry.set_text('') self.adv_show_list.append(self.optentry) opthbox.pack_start(optlabel) opthbox.pack_start(self.optentry) navshell.pack_start(self.frame_dict['Other_Advanced'], gtk.FALSE, gtk.FALSE, 0) echbox = gtk.GtkHBox(spacing=5, homogeneous=gtk.FALSE) echbox.set_border_width(3) navshell.pack_end(echbox, gtk.FALSE, gtk.FALSE, 0) self.show_list.append(echbox) self.button_dict['Close'] = gtk.GtkButton('Close') echbox.pack_end(self.button_dict['Close'], expand=gtk.TRUE) self.show_list.append(self.button_dict['Close']) self.button_dict['Export'] = gtk.GtkButton('Export') echbox.pack_end(self.button_dict['Export'], expand=gtk.TRUE) self.show_list.append(self.button_dict['Export']) self.button_dict['Format_help'].connect('clicked', self.format_help_cb) self.button_dict['Enable_ROI'].connect('clicked', self.set_roitool) self.button_dict['Refresh'].connect('clicked', self.refresh_fileinfo) self.button_dict['Export'].connect('clicked', self.export_cb) self.button_dict['Close'].connect('clicked', self.close) self.button_dict['IP_window'].connect('toggled', self.ip_window_toggled_cb) self.button_dict['Mode'].connect('toggled', self.mode_toggled_cb) self.button_dict['IP_window'].set_active(gtk.FALSE) self.button_dict['Mode'].set_active(gtk.FALSE) self.frame_dict['IP_window'].set_entry_sensitivities(gtk.FALSE) # Trap window close event self.dialog.connect('delete-event', self.close) for item in self.show_list: item.show() if self.button_dict['Mode'].get_active(): for item in self.adv_show_list: item.show() else: for item in self.adv_show_list: item.hide()
def __init__(self, app=None): gtk.GtkWindow.__init__(self) self.set_title('Compose Dataset') self.set_policy(gtk.FALSE, gtk.TRUE, gtk.TRUE) self.set_border_width(10) self.shell = gtk.GtkVBox(spacing=spc) self.add(self.shell) self.tips = gtk.GtkTooltips() self.input_frame = InputFrame(self, self.tips) self.show_list = [] self.adv_show_list = [] self.show_list.append(self.input_frame) self.app = app self.button_dict = {} self.button_dict['Mode'] = gtk.GtkCheckButton('Advanced Options') self.shell.pack_start(self.button_dict['Mode']) self.show_list.append(self.button_dict['Mode']) self.adv_notebook = gtk.GtkNotebook() self.shell.pack_start(self.adv_notebook) self.adv_show_list.append(self.adv_notebook) self.geo_frame = GeocodingFrame(self.tips) self.adv_notebook.append_page(self.geo_frame, gtk.GtkLabel('Geocoding')) echbox = gtk.GtkHBox(spacing=5, homogeneous=gtk.FALSE) echbox.set_border_width(3) self.shell.pack_end(echbox, gtk.FALSE, gtk.FALSE, 0) self.show_list.append(echbox) self.button_dict['Close'] = gtk.GtkButton('Close') echbox.pack_end(self.button_dict['Close'], expand=gtk.TRUE) self.button_dict['Save'] = gtk.GtkButton('Save VRT') echbox.pack_end(self.button_dict['Save'], expand=gtk.TRUE) self.button_dict['New'] = gtk.GtkButton('New View') echbox.pack_end(self.button_dict['New'], expand=gtk.TRUE) self.button_dict['Current'] = gtk.GtkButton('Current View') echbox.pack_end(self.button_dict['Current'], expand=gtk.TRUE) self.tips.set_tip(self.button_dict['Close'], 'Exit the Compose Dataset tool') self.tips.set_tip(self.button_dict['Save'], 'Create dataset and save to a VRT format file') self.tips.set_tip(self.button_dict['New'], 'Create dataset and display in a new view') self.tips.set_tip(self.button_dict['Current'], 'Create dataset and display in current view') for item in self.show_list: item.show_all() item.show() # geocode frame hides some of its contents self.geo_frame.show() self.button_dict['Save'].connect('clicked', self.create_cb, 'Save') self.button_dict['New'].connect('clicked', self.create_cb, 'New') self.button_dict['Current'].connect('clicked', self.create_cb, 'Current') self.button_dict['Close'].connect('clicked', self.close) self.button_dict['Mode'].connect('toggled', self.mode_toggled_cb) self.input_frame.subscribe('output-bands-empty', self.clear_defaults) self.input_frame.subscribe('output-bands-notempty', self.update_defaults) self.button_dict['Mode'].set_active(0) self.mode_toggled_cb() self.shell.show()