def __init__(self, context): tk2.Tk.__init__(self) self.context = context self.meshes = [] self.scale = 1 self.fovy = 30 self.near = 1 self.far = 10 _top = tk2.Label(self, text="PhauxGL 3D Viewer") _top.pack(side="top", fill="x") _main = tk2.Frame(self) _main.pack(side="top", fill="x") self.canvas = canvas = tk.Canvas(_main, width=context.Width, height=context.Height) canvas.pack(side="left", fill="both") self._imgid = self.canvas.create_image((0, 0), anchor='nw') self.right = tk2.Frame(_main, width="300") self.right.pack(side="right", fill="both") def move_eye(event): print event.x, event.y x, y = self.xyimg.pixel2coord(event.x, event.y) self.eye.X, self.eye.Y = x, y self.render() self.xymap = tk2.Label(self.right, text="XY Map:") self.xymap.pack() self.xymap.bind('<Button>', move_eye)
def __init__(self, master=None, filepath=""): tk2.Window.__init__(self, master) title = tk2.Label(self, text="Load File:") title.pack() filearea = tk2.Frame(self) filearea.pack(fill="both", expand=1) self.filepath = tk2.basics.Entry(filearea, default=filepath, label="Filepath") self.filepath.pack(side="left", fill="x", expand=1) def browse(): fp = tk2.filedialog.askopenfilename() if fp: self.filepath.set(fp) self.browsebut = tk2.basics.Button(filearea, text="Browse", command=browse) self.browsebut.pack(side="right") optionsarea = tk2.Frame(self) optionsarea.pack(fill="both", expand=1) self.encoding = tk2.basics.Dropdown(optionsarea, label="Encoding", values=["latin", "utf8"]) self.encoding.set("latin") self.encoding.pack() butarea = tk2.Frame(self) butarea.pack() def ok(): self.load() self.destroy() self.okbut = tk2.basics.OkButton(self, command=ok) self.okbut.pack(side="right") def cancel(): self.destroy() self.cancelbut = tk2.basics.CancelButton(self, command=cancel) self.cancelbut.pack(side="left")
def __init__(self, *args, **kwargs): tk2.basics.Tk.__init__(self, *args, **kwargs) self.top = tk2.Frame(self) self.top.pack(side='top', fill='x', expand=1) self.top.place(relx=0, relwidth=1, rely=0, relheight=0.6) self.query = QueryEditor(self.top) self.query.pack(side='left', fill='both', expand=1) self.query.app = self self.info = DataInfo(self.top) self.info.pack(side='right', fill='both', expand=1) self.info.app = self self.bottom = tk2.Frame(self) #self.bottom.pack(side='bottom', fill='x', expand=1) self.bottom.place(relx=0, relwidth=1, rely=0.6, relheight=0.4) self.browser = TableBrowser(self.bottom) #self.browser.pack(side='left', fill="both", expand=1) self.browser.place(relx=0, relwidth=0.6, rely=0, relheight=1) self.browser.app = self self.graphics = GraphicsViewer(self.bottom, width=100) #self.graphics.pack(side='right', fill='both', expand=1) self.graphics.place(relx=0.6, relwidth=0.4, rely=0, relheight=1) self.graphics.app = self self.connect(':memory:') # bindings def dndfunc(event): filepath = list(event.data)[0] self.connect(filepath) self.winfo_toplevel().bind_dnddrop(dndfunc, "Files", event='<Drop>') self.winfo_toplevel().bind('<Control-Return>', lambda e: self.query.run_query()) self.state('zoomed')
import tk2 root = tk2.Tk() root.center() frame = tk2.Frame(root) frame.pack() entry = tk2.Text(frame) entry.pack() def handle(event): print type(event.data), event.data for f in event.data: event.widget.insert("insert", f + "\n") entry.bind_dnddrop(handle, "Files") #"Text") root.mainloop()
def identify(self, x, y): print "identify: ", x, y infowin = tk2.Window() infoframe = tk2.ScrollFrame(infowin) infoframe.pack(fill="both", expand=1) title = tk2.Label(infoframe, text="Hits for coordinates: %s, %s" % (x, y)) title.pack(fill="x", expand=1) anyhits = None for layer in self.mapview.renderer.layers: print layer if isinstance(layer.data, pg.VectorData): feats = None if layer.data.type == "Polygon": from shapely.geometry import Point p = Point(x, y) feats = [ feat for feat in layer.data.quick_overlap([x, y, x, y]) if feat.get_shapely().intersects(p) ] else: # need a closest algorithm raise NotImplementedError( "Point and line identify not yet implemented") if feats: anyhits = True layerframe = tk2.Frame(infoframe, label=layer.data.name) layerframe.pack(fill="both", expand=1) browser = builder.TableBrowser(layerframe) browser.pack(fill="both", expand=1) browser.table.populate(fields=layer.data.fields, rows=[f.row for f in feats]) elif isinstance(layer.data, pg.RasterData): values = [ layer.data.get(x, y, band).value for band in layer.data.bands ] if any(values): anyhits = True layerframe = tk2.Frame(infoframe, label=layer.data.name) layerframe.pack(fill="both", expand=1) col, row = layer.data.geo_to_cell(x, y) cellcol = tk2.Label(layerframe, text="Column: %s" % col) cellcol.pack(fill="x", expand=1) cellrow = tk2.Label(layerframe, text="Row: %s" % row) cellrow.pack(fill="x", expand=1) for bandnum, val in enumerate(values): text = "Band %i: \n\t%s" % (bandnum, val) valuelabel = tk2.Label(layerframe, text=text) valuelabel.pack(fill="both", expand=1) if not anyhits: infowin.destroy()
def identify(self, bbox): print "identify: ", bbox infowin = tk2.Window() infowin.wm_geometry("500x300") #infowin.state('zoomed') wrap = tk2.Label(infowin) wrap.pack(fill="x", expand=1) title = tk2.Label(wrap, text="Coordinates:") title.pack() coords = tk2.Entry(wrap, width=75, justify='center', state='readonly') if bbox[:2] == bbox[2:]: text = '{}, {}'.format(*bbox[:2]) else: text = '{}, {}, {}, {}'.format(*bbox) coords.set(text) coords.pack(padx=4, pady=8) ribbon = tk2.Ribbon(infowin, anchor='wn') ribbon.pack(fill="both", expand=1) # find coord distance for approx 5 pixel uncertainty pixelbuff = 10 p1 = self.mapview.renderer.pixel2coord(0, 0) p2 = self.mapview.renderer.pixel2coord(pixelbuff, 0) coorddist = self.mapview.renderer.drawer.measure_dist(p1, p2) # add uncertainty buffer around bbox from shapely.geometry import box d = coorddist x, y, x2, y2 = bbox bbox = x - d, y - d, x2 + d, y2 + d rect = box(*bbox) anyhits = None for layer in self.mapview.renderer.layers: if not layer.visible: continue print layer if isinstance(layer.data, pg.VectorData): feats = [ feat for feat in layer.data.quick_overlap(bbox) if feat.get_shapely().intersects(rect) ] if feats: anyhits = True shortname = layer.data.name.replace( '\\', '/').split('/')[-1] # in case of path _tab = ribbon.add_tab(shortname) _frame = tk2.Frame(_tab) #, label=layer.data.name) _frame.pack(fill='both', expand=1) browser = builder.TableBrowser(_frame) browser.pack(fill="both", expand=1) browser.table.populate(fields=layer.data.fields, rows=[f.row for f in feats]) elif isinstance(layer.data, pg.RasterData): crop = layer.data.manage.crop(bbox) #print crop, crop.bands[0].summarystats() #crop.bands[0].render(600,400).img.show() if crop: # unfinished anyhits = True hist = crop.bands[0].histogram(600, 400, bins=100) shortname = layer.data.name.replace( '\\', '/').split('/')[-1] # in case of path _tab = ribbon.add_tab(shortname) _frame = tk2.Frame(_tab) #, label=layer.data.name) _frame.pack(fill='both', expand=1) graph = tk2.Label(_frame, image=hist.img) graph.pack(fill="both", expand=1) ## values = [layer.data.get(x, y, band).value for band in layer.data.bands] ## if any((v != None for v in values)): ## anyhits = True ## shortname = layer.data.name.replace('\\','/').split('/')[-1] # in case of path ## _tab = ribbon.add_tab(shortname) ## _frame = tk2.Frame(_tab) #, label=layer.data.name) ## _frame.pack(fill='both', expand=1) ## ## col,row = layer.data.geo_to_cell(x, y) ## cellcol = tk2.Label(_frame, text="Column: %s" % col ) ## cellcol.pack(fill="x", expand=1) ## cellrow = tk2.Label(_frame, text="Row: %s" % row ) ## cellrow.pack(fill="x", expand=1) ## ## for bandnum,val in enumerate(values): ## text = "Band %i: \n\t%s" % (bandnum, val) ## valuelabel = tk2.Label(_frame, text=text) ## valuelabel.pack(fill="both", expand=1) if not anyhits: infowin.destroy()
def layer_decor(self, widget): """ Default way to decorate each layer with extra widgets Override method to customize. """ widget.pack(fill="x", expand=1) frame = tk2.Frame(widget) frame.pack(fill='both', expand=1) # top name part nameframe = tk2.Label(frame) nameframe.pack(side="top") # middle image part imframe = tk2.Label(frame) imframe.pack(side="top") #tkim = pg.app.icons.get('zoom_global.png', width=200, height=200) import PIL, PIL.Image, PIL.ImageTk lyr = widget.item #lyr.render(width=300, height=150, bbox=[lyr.bbox[0],lyr.bbox[3],lyr.bbox[2],lyr.bbox[1]]) #w,h = self.mapview.renderer.width, self.mapview.renderer.height #w,h = w//6, h//6 w, h = 150, 75 if lyr.img: im = lyr.img.resize( (w, h), resample=PIL.Image.BILINEAR ) #.transform(lyr.img.size, PIL.Image.AFFINE, [1,0.9,0, 0,1,0, 0,0,1]) tkim = PIL.ImageTk.PhotoImage(im) else: tkim = icons.get('zoom_global.png', width=h, height=h) thumb = tk2.basics.Label(imframe, image=tkim) thumb.tkim = tkim thumb.pack(side="bottom") i = len(self.mapview.renderer.layers ) - self.mapview.renderer.layers.get_position(lyr) laynum = tk2.Label(nameframe, text=i) laynum.pack(side="left") visib = tk2.basics.Checkbutton(nameframe) visib.select() def toggle(): lyr = widget.item lyr.visible = not lyr.visible if lyr.visible: self.mapview.renderer.render_one(lyr) self.mapview.renderer.update_draworder() self.mapview.update_image() visib["command"] = toggle visib.pack(side="left") text = widget.item.data.name text = text.replace('\\', '/').split('/')[-1] # in case of path name = tk2.basics.Label(nameframe, text=text, width=20, wraplength=115) name.pack(side="left", fill="x", expand=1) zoombut = tk2.basics.Button( nameframe, command=lambda: self.mapview.zoom_bbox(lyr.bbox, log=True)) zoombut.set_icon(icons.iconpath("zoom_rect.png"), width=15, height=15) zoombut.pack(side='left') def browse(): win = tk2.Window() win.state('zoom') lyr = widget.item browser = builder.DatasetTableBrowser(win, lyr.data, limit=None) browser.pack(fill="both", expand=1) browsebut = tk2.basics.Button(nameframe, command=browse) browsebut.set_icon(icons.iconpath("datatable.png"), width=15, height=15) browsebut.pack(side='left') confbut = tk2.basics.Button(nameframe) confbut.set_icon(icons.iconpath("config2.png"), width=15, height=15) confbut.pack(side='left') def delete(): self.remove_layer(lyr) dropbut = tk2.basics.Button(nameframe, command=delete) dropbut.set_icon(icons.iconpath("delete.png"), width=15, height=15) dropbut.pack(side='left') transpframe = tk2.Label(frame) transpframe.pack(side="top") #transplabel = tk2.Label(transpframe, text="Transparency") #transplabel.pack(side="left") def update_transp(value): value = float(value) / 5.0 lyr = widget.item lyr.transparency = value if lyr.visible: self.mapview.renderer.render_one(lyr) self.mapview.renderer.update_draworder() self.mapview.update_image() transp = tk2.Slider(transpframe, from_=0, to=5, value=widget.item.transparency, command=update_transp) transp.pack(side="right")
def proj_decor(self, widget): """ Default way to decorate each layer with extra widgets Override method to customize. """ widget.pack(fill="x", expand=1) frame = tk2.Frame(widget) frame.pack(fill='both', expand=1) # top name part nameframe = tk2.Label(frame) nameframe.pack(side="top") # middle image part imframe = tk2.Label(frame) imframe.pack(side="top") #tkim = pg.app.icons.get('zoom_global.png', width=200, height=200) import PIL, PIL.Image, PIL.ImageTk lyr = widget.item #lyr.render(width=300, height=150, bbox=[lyr.bbox[0],lyr.bbox[3],lyr.bbox[2],lyr.bbox[1]]) w, h = self.mapview.renderer.width, self.mapview.renderer.height w, h = w // 6, h // 6 if self.mapview.renderer.img: im = self.mapview.renderer.img.resize( (w, h), resample=PIL.Image.BILINEAR ) #.transform(lyr.img.size, PIL.Image.AFFINE, [1,0.9,0, 0,1,0, 0,0,1]) tkim = PIL.ImageTk.PhotoImage(im) else: tkim = icons.get('zoom_global.png', width=h, height=h) thumb = tk2.basics.Label(imframe, image=tkim) thumb.tkim = tkim thumb.pack(side="bottom") selector = tk2.basics.Radiobutton(nameframe, variable=self.chosen, value=widget.item) def choose(): crs = widget.item self.chosen.set(crs) # update the var self.mapview.renderer.crs = crs self.mapview.renderer.zoom_auto() self.mapview.threaded_rendering() self.hide_projections() selector["command"] = choose selector.pack(side="left") imframe.bind('<Button-1>', lambda e: choose(), '+') thumb.bind('<Button-1>', lambda e: choose(), '+') if hasattr(widget.item, 'proj'): name = widget.item.proj.name.ogc_wkt else: name = widget.item.datum.name.ogc_wkt text = name text = text.replace('_', ' ') name = tk2.basics.Label(nameframe, text=text, width=20, wraplength=115) name.pack(side="left", fill="x", expand=1) confbut = tk2.basics.Button(nameframe) confbut.set_icon(icons.iconpath("config2.png"), width=15, height=15) confbut.pack(side='left')
def layer_decor(self, widget): """ Default way to decorate each layer with extra widgets Override method to customize. """ widget.pack(fill="x", expand=1) # left image/name part left = tk2.Frame(widget) left.pack(side="left") #tkim = pg.app.icons.get('zoom_global.png', width=200, height=200) import PIL, PIL.Image, PIL.ImageTk lyr = widget.item #lyr.render(width=300, height=150, bbox=[lyr.bbox[0],lyr.bbox[3],lyr.bbox[2],lyr.bbox[1]]) #w,h = self.mapview.renderer.width, self.mapview.renderer.height #w,h = w/4, h/4 w, h = 150, 75 if lyr.img: im = lyr.img.resize( (w, h), resample=PIL.Image.BILINEAR ) #.transform(lyr.img.size, PIL.Image.AFFINE, [1,0.9,0, 0,1,0, 0,0,1]) tkim = PIL.ImageTk.PhotoImage(im) else: tkim = icons.get('zoom_global.png', width=w, height=h) thumb = tk2.basics.Label(left, image=tkim) thumb.tkim = tkim thumb.pack(side="bottom") i = len(self.mapview.renderer.layers ) - self.mapview.renderer.layers.get_position(lyr) laynum = tk2.Label(left, text=i) laynum.pack(side="left") visib = tk2.basics.Checkbutton(left) visib.select() def toggle(): lyr = widget.item lyr.visible = not lyr.visible if lyr.visible: self.mapview.renderer.render_one(lyr) self.mapview.renderer.update_draworder() self.mapview.update_image() visib["command"] = toggle visib.pack(side="left") text = widget.item.data.name if len(text) > 30: text = "..." + text[-27:] name = tk2.basics.Label(left, text=text) name.pack(side="left", fill="x", expand=1) # right paramaters and controls right = tk2.Frame(widget) right.pack(side="right", fill="y", expand=1) _datframe = tk2.Frame(right, label="Data") _datframe.pack(side="left", fill="y", expand=1) dfilt = pg.app.controls.LayerFilterControl(_datframe, layer=lyr) dfilt.pack(side="top") def browse(): from . import builder win = tk2.Window() win.state('zoom') browser = builder.TableBrowser(win) browser.pack(fill="both", expand=1) lyr = widget.item fields = lyr.data.fields rows = (feat.row for feat in lyr.features()) # respects the filter browser.table.populate(fields, rows) browse = tk2.basics.Button(_datframe, text="Browse Dataset", command=browse) browse.pack(pady=20) # fillcolor _fillcolframe = tk2.Frame(right, label="Fillcolor") _fillcolframe.pack(side="left", fill="y", expand=1) _fillcoltypes = tk2.Ribbon(_fillcolframe) _fillcoltypes.pack(side="left", fill="y", expand=1) _fillcolsingle = _fillcoltypes.add_tab("Single Color") _ = tk2.Label(_fillcolsingle, text="Color") _.pack(side="top") fillcol = tk2.ColorButton(_fillcolsingle) fillcol.pack(side="top") _ = tk2.Label(_fillcolsingle, text="Transparency") _.pack(side="top") filltransp = tk2.Slider(_fillcolsingle) filltransp.pack(side="top") _fillcolgrad = _fillcoltypes.add_tab("Color Gradient") fillcolbrk = tk2.Entry(_fillcolgrad, label="Gradient") fillcolbrk.pack(side="top") fillcolval = tk2.Entry(_fillcolgrad, label="Attribute") fillcolval.pack(side="top") fillcolbrk = tk2.Entry(_fillcolgrad, label="Breaks") fillcolbrk.pack(side="top") fillcolexc = tk2.Entry(_fillcolgrad, label="Exclude") fillcolexc.pack(side="top") _fillcolgrad = _fillcoltypes.add_tab("Categories") fillcolbrk = tk2.Entry(_fillcolgrad, label="Colors") fillcolbrk.pack(side="top") fillcolval = tk2.Entry(_fillcolgrad, label="Attribute") fillcolval.pack(side="top") fillcolexc = tk2.Entry(_fillcolgrad, label="Exclude") fillcolexc.pack(side="top") # initiate with styleoptions realfillcol = lyr.styleoptions.get('fillcolor') if realfillcol: if isinstance(realfillcol, dict): # breaks if realfillcol['breaks'] == 'unique': # ... _fillcoltypes.switch(tabname="Categories") else: # ... _fillcoltypes.switch(tabname="Color Gradient") else: fillcol.set_color(realfillcol[:3]) _fillcoltypes.switch(tabname="Single Color")
def __init__(self, mapp, time=False, *args, **kwargs): tk2.basics.Tk.__init__(self, *args, **kwargs) ### panes = tk2.tk.PanedWindow(self, orient=tk2.tk.HORIZONTAL) panes.pack(fill='both', expand=1) mainframe = tk2.Frame(self) #panes.add_pane() # #mainframe.pack(fill='both', expand=0) #side='left', fill='both', expand=1) panes.add(mainframe, stretch='always') layersframe = tk2.Frame(self) #panes.add_pane() # #layersframe.pack(fill='both', expand=0) #side='right', fill='y', expand=0) panes.add(layersframe, stretch='always', width=140) # arbitrary #panes.paneconfig(mainframe, width=400) #panes.paneconfig(layersframe, width=100) #panes.sash_place(0, 500, 500) ### mapframe = tk2.Frame( mainframe) #bd=10, relief='flat') #, background='black') mapframe.pack(fill='both', expand=1) mapview = self.mapview = pg.app.map.MapView(mapframe, mapp) mapview.pack(fill="both", expand=1) bottombar = self.bottombar = tk2.Label(mainframe) #, background='red') bottombar.pack(fill='x', expand=0) layerscontrol = pg.app.controls.StaticLayersControl(layersframe) layerscontrol.pack(fill='both', expand=1) #place(relx=0.99, rely=0.02, anchor="ne") mapview.add_control(layerscontrol) layerscontrol.set_layers(mapp.layers) navigcontrol = pg.app.controls.NavigateControl(bottombar) navigcontrol.pack(side='left') mapview.add_control(navigcontrol) def ask_save(): filepath = tk2.filedialog.asksaveasfilename() mapview.renderer.img.save(filepath) savebut = tk2.Button(bottombar, command=ask_save) savebut.set_icon(icons.iconpath("save.png"), width=40, height=40) savebut.pack( side="right" ) #pack(fill='y', expand=1, side="right") #place(relx=0.02, rely=0.02, anchor="nw") identcontrol = pg.app.controls.IdentifyControl(bottombar) identcontrol.pack( side="right") #place(relx=0.98, rely=0.11, anchor="ne") mapview.add_control(identcontrol) measurecontrol = pg.app.controls.MeasureControl(bottombar) measurecontrol.pack( side="right") #place(relx=0.98, rely=0.11, anchor="ne") mapview.add_control(measurecontrol) projcontrol = pg.app.controls.MapProjectionControl(bottombar) projcontrol.pack( side="right") #place(relx=0.98, rely=0.11, anchor="ne") mapview.add_control(projcontrol) zoomhistcontrol = pg.app.controls.ZoomHistoryControl(navigcontrol) zoomhistcontrol.pack( fill='y', expand=1, side="right" ) #pack(fill='y', expand=1, side="right") #place(relx=0.02, rely=0.02, anchor="nw") mapview.add_control(zoomhistcontrol) #zoomcontrol = pg.app.controls.ZoomControl(navigcontrol) #zoomcontrol.pack(fill='y', expand=1, side="right") #pack(fill='y', expand=1, side="right") #place(relx=0.02, rely=0.02, anchor="nw") #mapview.add_control(zoomcontrol) ########### progbar = tk2.progbar.NativeProgressbar(mainframe) progbar.pack(side="left", padx=4, pady=4) def startprog(): progbar.start() def stopprog(): progbar.stop() mapview.onstart = startprog mapview.onfinish = stopprog coords = tk2.Entry(mainframe, width=30, state='readonly') coords.pack(side="right", padx=4, pady=4) def showcoords(event): x, y = mapview.mouse2coords(event.x, event.y) coords.set("%s, %s" % (x, y)) self.mapview.bind("<Motion>", showcoords, "+") if False: #time: # must be dict timecontrol = pg.app.controls.TimeControl(mapview) #, **time) timecontrol.place(relx=0.5, rely=0.98, anchor="s") mapview.add_control(timecontrol) def dndfunc(event): for filepath in event.data: layerscontrol.add_layer(filepath) self.winfo_toplevel().bind_dnddrop(dndfunc, "Files", event='<Drop>') # done self.state('zoomed')
def __init__(self, mapp, time=False, *args, **kwargs): tk2.basics.Tk.__init__(self, *args, **kwargs) self.ribbon = tk2.Ribbon(self) #self.ribbon.pack(fill="x", padx=15, pady=5) _hometab = self.ribbon.add_tab('Home') viewmode = tk2.Frame(_hometab, label="View Mode") viewmode.pack(side='left') mode2d = tk2.Button(viewmode) mode2d.set_icon(icons.iconpath('flatmap.jfif'), width=40, height=40) mode2d.pack(side='left') modelyr = tk2.Button(viewmode) modelyr.set_icon(icons.iconpath('layers.png'), width=40, height=40) modelyr.pack(side='left') mode3d = tk2.Button(viewmode) mode3d.set_icon(icons.iconpath('3d icon.png'), width=40, height=40) mode3d.pack(side='left') ### self.map = MultiLayerMap(self, mapp, time=time) self.map.pack(fill="both", expand=1) ### ## _filtertab = self.ribbon.add_tab('Filters') ## layers = tk2.scrollwidgets.OrderedList(_filtertab) ## layers.pack(fill="both", expand=1) ## def filter_options(widget): ## widget.pack(fill="x", expand=1) ## ## # left image/name part ## left = tk2.Frame(widget) ## left.pack(side="left") ## ## #tkim = pg.app.icons.get('zoom_global.png', width=200, height=200) ## lyr = widget.item ## lyr.render(width=300, height=150) ## im = lyr.img ## lyr.img = None ## print im, im.mode ## import PIL, PIL.ImageTk ## tkim = PIL.ImageTk.PhotoImage(im) ## thumb = tk2.basics.Label(left, image=tkim) ## thumb.tkim = tkim ## thumb.pack(side="top") ## ## text = widget.item.data.name ## if len(text) > 30: ## text = "..."+text[-27:] ## name = tk2.basics.Label(left, text=text) ## name.pack(side="bottom") ## ## # right paramaters and controls ## right = tk2.Frame(widget) ## right.pack(side="right") ## ## dfilt = pg.app.controls.LayerFilterControl(right, layer=lyr) ## dfilt.pack(side="left", fill="y", expand=1) ## ## for lyr in self.map.mapp.layers: ## layers.add_item(lyr, filter_options) ### ## _styletab = self.ribbon.add_tab('Styling') ## layers = tk2.scrollwidgets.OrderedList(_styletab, title="Layer Styles:") ## layers.pack(fill="both", expand=1) ## def style_options(widget): ## widget.pack(fill="x", expand=1) ## ## # left image/name part ## left = tk2.Frame(widget) ## left.pack(side="left") ## ## text = widget.item.data.name ## if len(text) > 30: ## text = "..."+text[-27:] ## name = tk2.basics.Label(left, text=text) ## name.pack(side="top") ## ## #tkim = pg.app.icons.get('zoom_global.png', width=200, height=200) ## import PIL, PIL.Image, PIL.ImageTk ## lyr = widget.item ## lyr.render(width=300, height=150, bbox=[lyr.bbox[0],lyr.bbox[3],lyr.bbox[2],lyr.bbox[1]]) ## im = lyr.img #.transform(lyr.img.size, PIL.Image.AFFINE, [1,0.9,0, 0,1,0, 0,0,1]) ## lyr.img = None ## print im, im.mode ## tkim = PIL.ImageTk.PhotoImage(im) ## thumb = tk2.basics.Label(left, image=tkim) ## thumb.tkim = tkim ## thumb.pack(side="bottom") ## ## # right paramaters and controls ## right = tk2.Frame(widget) ## right.pack(side="right", fill="y", expand=1) ## ## _filtframe = tk2.Frame(right, label="Filtering") ## _filtframe.pack(side="left", fill="y", expand=1) ## dfilt = pg.app.controls.LayerFilterControl(_filtframe, layer=lyr) ## dfilt.pack(side="top") ## ## # fillcolor ## _fillcolframe = tk2.Frame(right, label="Fillcolor") ## _fillcolframe.pack(side="left", fill="y", expand=1) ## _fillcoltypes = tk2.Ribbon(_fillcolframe) ## _fillcoltypes.pack(side="left", fill="y", expand=1) ## ## _fillcolsingle = _fillcoltypes.add_tab("Single Color") ## _ = tk2.Label(_fillcolsingle, text="Color") ## _.pack(side="top") ## fillcol = tk2.ColorButton(_fillcolsingle) ## fillcol.pack(side="top") ## _ = tk2.Label(_fillcolsingle, text="Transparency") ## _.pack(side="top") ## filltransp = tk2.Slider(_fillcolsingle) ## filltransp.pack(side="top") ## ## _fillcolgrad = _fillcoltypes.add_tab("Color Gradient") ## fillcolbrk = tk2.Entry(_fillcolgrad, label="Gradient") ## fillcolbrk.pack(side="top") ## fillcolval = tk2.Entry(_fillcolgrad, label="Field Value") ## fillcolval.pack(side="top") ## fillcolbrk = tk2.Entry(_fillcolgrad, label="Value Breaks") ## fillcolbrk.pack(side="top") ## fillcolexc = tk2.Entry(_fillcolgrad, label="Exclude") ## fillcolexc.pack(side="top") ## ## _fillcolgrad = _fillcoltypes.add_tab("Categories") ## fillcolbrk = tk2.Entry(_fillcolgrad, label="Colors") ## fillcolbrk.pack(side="top") ## fillcolval = tk2.Entry(_fillcolgrad, label="Field Value") ## fillcolval.pack(side="top") ## fillcolexc = tk2.Entry(_fillcolgrad, label="Exclude") ## fillcolexc.pack(side="top") ## ## # initiate with styleoptions ## realfillcol = lyr.styleoptions.get('fillcolor') ## if realfillcol: ## if isinstance(realfillcol, dict): ## # breaks ## if realfillcol['breaks'] == 'unique': ## # ... ## _fillcoltypes.switch(tabname="Categories") ## else: ## # ... ## _fillcoltypes.switch(tabname="Color Gradient") ## else: ## fillcol.set_color(realfillcol[:3]) ## _fillcoltypes.switch(tabname="Single Color") ## ## for lyr in reversed(self.map.mapp.layers): ## layers.add_item(lyr, style_options) ## ## ### ## self.ribbon.switch(tabname='Map') self.state('zoomed')