<commit_before>
from .map import MapView
from . import icons

import pythongis as pg
import tk2

class TableGUI(tk2.Tk):
    def __init__(self, *args, **kwargs):
        tk2.basics.Tk.__init__(self, *args, **kwargs)

        self.browser = TableBrowser(self)
        self.browser.pack(fill="both", expand=1)

        self.state('zoomed')

class SimpleMapViewerGUI(tk2.Tk):
    # new experimental version
    def __init__(self, mapp, time=False, *args, **kwargs):
        tk2.basics.Tk.__init__(self, *args, **kwargs)

        ###
        mapframe = tk2.Frame(self)
        mapframe.pack(side='left', fill='both', expand=1)

        layersframe = tk2.Frame(self)
        layersframe.pack(side='right', fill='y', expand=0)
        
        mapview = self.mapview = pg.app.map.MapView(mapframe, mapp)
        mapview.pack(fill="both", expand=1)

        bottombar = tk2.Label(mapframe) #, background='red')
        bottombar.pack(fill='x', expand=0)

        layerscontrol = pg.app.controls.StaticLayersControl(layersframe)
        layerscontrol.pack(fill='y', 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)

        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(mapframe)
        progbar.pack(side="left", padx=4, pady=4)

        def startprog():
            progbar.start()
        def stopprog():
            progbar.stop()
        mapview.onstart = startprog
        mapview.onfinish = stopprog

        coords = tk2.Label(mapframe)
        coords.pack(side="right", padx=4, pady=4)

        def showcoords(event):
            x,y = mapview.mouse2coords(event.x, event.y)
            coords["text"] = "%s, %s" % (x,y)
        self.winfo_toplevel().bind("<Motion>", showcoords, "+")

        if False:#time:<commit_msg>Fix coordtext bug and make it selectable<commit_after>
from .map import MapView
from . import icons

import pythongis as pg
import tk2

class TableGUI(tk2.Tk):
    def __init__(self, *args, **kwargs):
        tk2.basics.Tk.__init__(self, *args, **kwargs)

        self.browser = TableBrowser(self)
        self.browser.pack(fill="both", expand=1)

        self.state('zoomed')

class SimpleMapViewerGUI(tk2.Tk):
    # new experimental version
    def __init__(self, mapp, time=False, *args, **kwargs):
        tk2.basics.Tk.__init__(self, *args, **kwargs)

        ###
        mapframe = tk2.Frame(self)
        mapframe.pack(side='left', fill='both', expand=1)

        layersframe = tk2.Frame(self)
        layersframe.pack(side='right', fill='y', expand=0)
        
        mapview = self.mapview = pg.app.map.MapView(mapframe, mapp)
        mapview.pack(fill="both", expand=1)

        bottombar = tk2.Label(mapframe) #, background='red')
        bottombar.pack(fill='x', expand=0)

        layerscontrol = pg.app.controls.StaticLayersControl(layersframe)
        layerscontrol.pack(fill='y', 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)

        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(mapframe)
        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(mapframe, 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:
{'fraction_non_alphanumeric': 0.15225472765475997, 'fraction_numerical': 0.020365282042993375, 'mean_word_length': 3.055045871559633, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '85261', 'n_tokens_mistral': 2145, 'n_tokens_neox': 2058, 'n_words': 323}