def change_new_map(self, name, map_source): """ Change the current map with a new provider This map is not supported by osm-gps-map name : the name of the provider map_source : the url to search for tiles """ try: self.osm.layer_remove_all() self.osm.image_remove_all() self.vbox.remove(self.osm) self.osm.destroy() except: pass tiles_path = os.path.join(config.get('geography.path'), name) if not os.path.isdir(tiles_path): try: os.makedirs(tiles_path, 0o755) # create dir like mkdir -p except: ErrorDialog(_("Can't create " "tiles cache directory for '%s'.") % constants.MAP_TITLE[self.current_map], parent=self.uistate.window) http_proxy = get_env_var('http_proxy') if 0: self.osm = DummyMapNoGpsPoint() else: if http_proxy: self.osm = osmgpsmap.Map(tile_cache=tiles_path, proxy_uri=http_proxy, repo_uri=map_source) else: self.osm = osmgpsmap.Map(tile_cache=tiles_path, repo_uri=map_source) self.osm.props.tile_cache = osmgpsmap.MAP_CACHE_AUTO current_map = osmgpsmap.MapOsd(show_dpad=False, show_zoom=True) self.end_selection = None self.osm.layer_add(current_map) self.osm.layer_add(DummyLayer()) self.selection_layer = self.add_selection_layer() self.kml_layer = self.add_kml_layer() self.lifeway_layer = self.add_lifeway_layer() self.marker_layer = self.add_marker_layer() self.date_layer = self.add_date_layer() self.message_layer = self.add_message_layer() self.cross_map = osmgpsmap.MapOsd(show_crosshair=False) self.set_crosshair(config.get("geography.show_cross")) self.osm.set_center_and_zoom(config.get("geography.center-lat"), config.get("geography.center-lon"), config.get("geography.zoom")) self.osm.connect('button_release_event', self.map_clicked) self.osm.connect('button_press_event', self.map_clicked) self.osm.connect("motion-notify-event", self.motion_event) self.osm.connect('changed', self.zoom_changed) self.update_shortcuts(True) self.osm.show() self.vbox.pack_start(self.osm, True, True, 0) self.goto_handle(handle=None)
def change_map(self, obj, map_type): """ Change the current map """ if obj is not None: self.osm.layer_remove_all() self.osm.image_remove_all() self.vbox.remove(self.osm) self.osm.destroy() tiles_path = os.path.join(config.get('geography.path'), constants.TILES_PATH[map_type]) if not os.path.isdir(tiles_path): try: os.makedirs(tiles_path, 0o755) # create dir like mkdir -p except: ErrorDialog( _("Can't create " # parent-OK "tiles cache directory for '%s'.") % constants.MAP_TITLE[map_type], parent=self.uistate.window) config.set("geography.map_service", map_type) self.current_map = map_type http_proxy = get_env_var('http_proxy') if 0: self.osm = DummyMapNoGpsPoint() else: if http_proxy: self.osm = osmgpsmap.Map( tile_cache=tiles_path, proxy_uri=http_proxy, map_source=constants.MAP_TYPE[map_type]) else: self.osm = osmgpsmap.Map( tile_cache=tiles_path, map_source=constants.MAP_TYPE[map_type]) self.osm.props.tile_cache = osmgpsmap.MAP_CACHE_AUTO current_map = osmgpsmap.MapOsd(show_dpad=False, show_zoom=True) self.end_selection = None self.osm.layer_add(current_map) self.osm.layer_add(DummyLayer()) self.selection_layer = self.add_selection_layer() self.kml_layer = self.add_kml_layer() self.lifeway_layer = self.add_lifeway_layer() self.marker_layer = self.add_marker_layer() self.date_layer = self.add_date_layer() self.message_layer = self.add_message_layer() self.cross_map = osmgpsmap.MapOsd(show_crosshair=False) self.set_crosshair(config.get("geography.show_cross")) self.osm.set_center_and_zoom(config.get("geography.center-lat"), config.get("geography.center-lon"), config.get("geography.zoom")) self.osm.connect('button_release_event', self.map_clicked) self.osm.connect('button_press_event', self.map_clicked) self.osm.connect("motion-notify-event", self.motion_event) self.osm.connect('changed', self.zoom_changed) self.update_shortcuts(True) self.osm.show() self.vbox.pack_start(self.osm, True, True, 0) self.goto_handle(handle=None)
def set_crosshair(self, active): """ Show or hide the crosshair ? """ if active: self.osm.layer_remove(self.cross_map) self.cross_map = osmgpsmap.MapOsd(show_crosshair=True) self.osm.layer_add(self.cross_map) else: self.osm.layer_remove(self.cross_map) self.cross_map = osmgpsmap.MapOsd(show_crosshair=False) self.osm.layer_add(self.cross_map)
def __init__(self, core, conn): self.core = core self.conn = conn self.builder = Gtk.Builder() self.builder.add_from_file("./gweatherrouting/ui/gtk/mainwindow.glade") self.builder.connect_signals(self) self.window = self.builder.get_object("main-window") self.window.connect("delete-event", self.quit) self.window.set_default_size(1024, 600) self.window.show_all() # self.window.maximize () self.map = self.builder.get_object("map") self.map.set_center_and_zoom(39., 9., 6) self.gribMapLayer = GribMapLayer(self.core.gribManager) self.map.layer_add(self.gribMapLayer) self.map.layer_add( OsmGpsMap.MapOsd(show_dpad=True, show_zoom=True, show_crosshair=False)) self.statusbar = self.builder.get_object("status-bar") MainWindowTime.__init__(self) MainWindowRouting.__init__(self) MainWindowTrack.__init__(self) MainWindowPOI.__init__(self) Gdk.threads_init() self.core.connect('boatPosition', self.boatInfoHandler)
def __init__(self): Gtk.Window.__init__(self, type=Gtk.WindowType.TOPLEVEL) self.connect('destroy', lambda x: Gtk.main_quit()) self.set_default_size(500, 500) self.set_title('osmgpsmap tests') self.vbox = Gtk.VBox(False, 0) self.add(self.vbox) if 0: self.osm = DummyMapNoGpsPoint() else: self.osm = osmgpsmap.Map() self.osm.layer_add( osmgpsmap.MapOsd(show_dpad=True, show_zoom=True, show_crosshair=True, show_coordinates=True, show_scale=True)) self.osm.layer_add(DummyLayer()) self.vbox.pack_start(self.osm, True, True, 0) #btn_home = Gtk.Button(stock=Gtk.STOCK_HOME) #btn_home.connect('clicked', self.on_btn_home_clicked) punto_pucarani = [-16.411514, -68.487633] punto_cota_cota = [-16.538275, -68.069592]
def test_layer(self): osd = OsmGpsMap.MapOsd(show_zoom=True, show_coordinates=False, show_scale=False, show_dpad=True, show_gps_in_dpad=True) self.osm.layer_add(osd) self.osm.layer_remove(osd)
def set_crosshair(self, active): """ Show or hide the crosshair ? """ if active: self.cross_map = osmgpsmap.MapOsd(show_crosshair=True) self.osm.layer_add(self.cross_map) # The two following are to force the map to update self.osm.zoom_in() self.osm.zoom_out() else: self.osm.layer_remove(self.cross_map)
def setup_map(self): # map = self._mapbox.map self.layer_osd = ogm.MapOsd(show_dpad=True, show_zoom=True, show_crosshair=True, show_coordinates=True, show_scale=True) self.map.layer_add(self.layer_osd) max_zoom = self.map.props.max_zoom self.map.set_center_and_zoom(self.launch_site[0], self.launch_site[1], max_zoom) # map.props.record_trip_history = True # map.props.show_trip_history = True self.map.connect('button_press_event', self.on_button_press)
def __init__(self, database, host, *args, **kwargs): super(OSM, self).__init__(*args, **kwargs) """ single host geolocation map widget """ self.layer_add( osmgpsmap.MapOsd(show_dpad=True, show_zoom=True, show_crosshair=True)) self.props.has_tooltip = True self.host = host self.database = database self.show() self.set_property("height-request", 450)
def init_osm(self): if self.config["source"] != "custom": self.osm = OsmGpsMap.Map() self.set_source(self.config["source"]) else: self.osm = OsmGpsMap.Map(repo_uri=self.config["custom_source_url"], min_zoom=self.config["custom_source_min"], max_zoom=self.config["custom_source_max"]) self.osd = OsmGpsMap.MapOsd(show_zoom=True, show_coordinates=False, show_scale=False, show_dpad=True, show_gps_in_dpad=True) self.osm.layer_add(self.osd) self.osm.connect('button-press-event', self.on_map_pressed) self.osm.set_keyboard_shortcut(OsmGpsMap.MapKey_t.UP, Gdk.keyval_from_name("Up")) self.osm.set_keyboard_shortcut(OsmGpsMap.MapKey_t.DOWN, Gdk.keyval_from_name("Down")) self.osm.set_keyboard_shortcut(OsmGpsMap.MapKey_t.LEFT, Gdk.keyval_from_name("Left")) self.osm.set_keyboard_shortcut(OsmGpsMap.MapKey_t.RIGHT, Gdk.keyval_from_name("Right")) self.osm.set_keyboard_shortcut(OsmGpsMap.MapKey_t.ZOOMIN, Gdk.keyval_from_name("Page_Up")) self.osm.set_keyboard_shortcut(OsmGpsMap.MapKey_t.ZOOMOUT, Gdk.keyval_from_name("Page_Down")) self.osm.connect('changed', self.on_changed) try: self.osm.set_property('user-agent', self.user_agent) except TypeError: # osm-gps-map <= 1.1.0 pass self.coordinates = {} for mac in list(self.markers.keys()): marker = self.markers[mac] del self.markers[mac] self.add_marker(marker.key, marker.color, marker.lat, marker.lon) self.widget = self.osm
def __init__(self, core, conn): self.core = core self.conn = conn self.timeControl = TimeControl() self.settingsManager = SettingsManager() self.builder = Gtk.Builder() self.builder.add_from_file( os.path.abspath(os.path.dirname(__file__)) + "/mainwindow.glade") self.builder.connect_signals(self) self.window = self.builder.get_object("main-window") self.window.connect("delete-event", self.quit) self.window.set_default_size(1024, 600) self.window.show_all() # self.window.maximize () self.map = self.builder.get_object("map") self.map.set_center_and_zoom(39., 9., 6) self.chartManager = ChartManager(self.map) self.chartManager.loadBaseChart() self.map.layer_add(self.chartManager) self.gribMapLayer = GribMapLayer(self.core.gribManager, self.timeControl) self.map.layer_add(self.gribMapLayer) self.map.layer_add( OsmGpsMap.MapOsd(show_dpad=True, show_zoom=True, show_crosshair=False)) self.statusbar = self.builder.get_object("status-bar") MainWindowTime.__init__(self) MainWindowRouting.__init__(self) MainWindowTrack.__init__(self) MainWindowPOI.__init__(self) Gdk.threads_init() self.core.connect('boatPosition', self.boatInfoHandler)
def __init__(self): super(Window, self).__init__() self.connect('destroy', Gtk.main_quit) self.set_default_size(500, 500) self.set_title('OsmGpsMap test') punto_cota_cota = [-16.538275, -68.069592] self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.add(self.box) self.map = osmgpsmap.Map() self.box.pack_start(self.map, True, True, 0) self.layer_osd = osmgpsmap.MapOsd(show_dpad=True, show_zoom=True, show_crosshair=True, show_coordinates=True, show_scale=True) self.map.layer_add(self.layer_osd) max_zoom, min_zoom = self.map.props.max_zoom, self.map.props.min_zoom print(max_zoom, min_zoom) self.map.set_center_and_zoom(punto_cota_cota[0], punto_cota_cota[1], max_zoom) self.map_track = osmgpsmap.MapTrack() self.point = osmgpsmap.MapPoint() self.point.set_degrees(punto_cota_cota[0], punto_cota_cota[1]) self.map_track.add_point(self.point) # print(self.map_track.get_points()) self.map.track_add(self.map_track) # self.box.pack_start(self.map_track, True, True, 0) # self.grid = Gtk.Grid() # self.box.pack_start(self.grid, True, True, 0) self.lbl_coords = Gtk.Label("Coordenadas") self.box.pack_start(self.lbl_coords, False, True, 0)
def __init__(self, config): assert isinstance(config, Configuration) self.meta = None self.original_position = (0, 0) self.config = config # Set the Glade file builder = Gtk.Builder() builder.add_from_file(get_resource("exifgpseditor.glade")) handlers = { "quit": (lambda _: Gtk.main_quit()), "apply": (lambda _: self.save_image()), "redraw": (lambda _: self.move_to(None)), "origin": (lambda _: self.move_to(self.original_position)), "previous": (lambda _: self.move_to(self.config.previous_position)) } builder.connect_signals(handlers) # Get the Main Window, and connect the "destroy" event self.win_exifgpseditor = builder.get_object("win_exifgpseditor") self.win_exifgpseditor.connect('destroy', lambda x: Gtk.main_quit()) # Add zoom buttons and target to the map self.themap = builder.get_object("map_gps") self.themap.layer_add( OsmGpsMap.MapOsd( show_zoom=True, show_crosshair=True ) ) # Get the image widget self.img_preview = builder.get_object("img_preview") self.win_exifgpseditor.show_all()
def init_ui(self): BaseDialog.init_ui(self) # vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 5) self.grid.attach(vbox, 0, 0, 1, 1) hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 5) vbox.pack_start(hbox, False, False, 0) # self.entry1 = Gtk.Entry() self.entry1.set_width_chars(60) self.entry1.set_property('primary_icon_name', 'edit-find-symbolic') self.entry1.set_property('secondary_icon_name', 'edit-clear-symbolic') self.entry1.set_property('primary_icon_tooltip_text', _('Search location')) self.entry1.set_property('secondary_icon_tooltip_text', _('Clear location')) self.entry1.set_tooltip_text(_('Input the name of your city')) self.entry1.connect('icon-press', self.on_icon_press) self.entry1.connect('activate', self.on_button1_clicked) hbox.pack_start(self.entry1, True, True, 0) # button1 = Gtk.Button.new_with_label(_('Search')) button1.connect('clicked', self.on_button1_clicked) hbox.pack_start(button1, False, False, 0) # button2 = Gtk.Button.new_with_label(_('Find me')) button2.connect('clicked', self.on_button2_clicked) hbox.pack_start(button2, False, False, 0) self.expander = Gtk.Expander(label=_('Locations found')) self.expander.set_expanded(False) vbox.pack_start(self.expander, False, False, 0) # frame = Gtk.Frame() framebox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 50) framebox.add(frame) self.expander.add(framebox) self.expander.connect("notify::expanded", self.on_expander_expanded) # scrolledwindow0 = Gtk.ScrolledWindow() scrolledwindow0.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolledwindow0.set_shadow_type(Gtk.ShadowType.ETCHED_OUT) scrolledwindow0.set_size_request(450, 100) frame.add(scrolledwindow0) # city, county, country, latitude, longitude store = Gtk.ListStore(str, str, str, float, float) store.set_sort_column_id(2, Gtk.SortType.ASCENDING) self.treeview = Gtk.TreeView(model=store) self.treeview.set_reorderable(True) treeviewcolumn0 = Gtk.TreeViewColumn(_('City'), Gtk.CellRendererText(), text=0) treeviewcolumn0.set_reorderable(True) treeviewcolumn0.set_sort_column_id(0) treeviewcolumn1 = Gtk.TreeViewColumn(_('State'), Gtk.CellRendererText(), text=1) treeviewcolumn1.set_reorderable(True) treeviewcolumn1.set_sort_column_id(1) treeviewcolumn2 = Gtk.TreeViewColumn(_('Country'), Gtk.CellRendererText(), text=2) treeviewcolumn2.set_reorderable(True) treeviewcolumn2.set_sort_column_id(2) self.treeview.append_column(treeviewcolumn0) self.treeview.append_column(treeviewcolumn1) self.treeview.append_column(treeviewcolumn2) self.treeview.connect('cursor-changed', self.ontreeviewcursorchanged) scrolledwindow0.add(self.treeview) # # scrolledwindow = Gtk.ScrolledWindow() scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolledwindow.set_shadow_type(Gtk.ShadowType.IN) vbox.pack_start(scrolledwindow, True, True, 0) # self.viewer = OsmGpsMap.Map() self.viewer.layer_add( OsmGpsMap.MapOsd(show_dpad=True, show_zoom=True, show_crosshair=True)) # connect keyboard shortcuts self.viewer.set_keyboard_shortcut(OsmGpsMap.MapKey_t.FULLSCREEN, Gdk.keyval_from_name("F11")) self.viewer.set_keyboard_shortcut(OsmGpsMap.MapKey_t.UP, Gdk.keyval_from_name("Up")) self.viewer.set_keyboard_shortcut(OsmGpsMap.MapKey_t.DOWN, Gdk.keyval_from_name("Down")) self.viewer.set_keyboard_shortcut(OsmGpsMap.MapKey_t.LEFT, Gdk.keyval_from_name("Left")) self.viewer.set_keyboard_shortcut(OsmGpsMap.MapKey_t.RIGHT, Gdk.keyval_from_name("Right")) scrolledwindow.add(self.viewer) scrolledwindow.set_size_request(550, 550) if self.latitude and self.longitude: if self.location is not None and len(self.location) > 0: self.entry1.set_text(self.location) else: self.do_search_location(self.latitude, self.longitude) else: self.search_location2() self.set_wait_cursor() self.search_string = '' print('============================') print(self.location, self.latitude, self.longitude) print('============================')
def __init__(self, app, afile=None): Gtk.ApplicationWindow.__init__(self, application=app) self.qrcode_file = None self.frames = None self.background = None self.scale = 100 self.pbuf = None self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.set_title(comun.APP) self.set_icon_from_file(comun.ICON) self.set_resizable(False) self.set_default_size(600, 600) self.connect('destroy', self.close_application) hbox = Gtk.HBox(spacing=5) hbox.set_border_width(5) frame = Gtk.Frame() set_margins(frame, 5) self.add(frame) self.main_stack = Gtk.Stack.new() self.main_stack.set_transition_type( Gtk.StackTransitionType.UNDER_RIGHT) frame.add(self.main_stack) self.stack = Gtk.Stack.new() self.stack.set_transition_type(Gtk.StackTransitionType.UNDER_DOWN) self.main_stack.add_named(self.stack, 'Data') grid1 = Gtk.Grid() set_margins(grid1, 10) grid1.set_margin_right(10) self.stack.add_named(grid1, QRType.TEXT.name) label1 = Gtk.Label(_('Set text to encode: ')) label1.set_alignment(0, .5) grid1.attach(label1, 0, 0, 1, 1) self.entry12 = Gtk.Entry() self.entry12.set_alignment(0) self.entry12.set_width_chars(40) grid1.attach(self.entry12, 1, 0, 1, 1) grid2 = Gtk.Grid() set_margins(grid2, 10) self.stack.add_named(grid2, QRType.GEOLOCATION.name) scrolledwindow0 = Gtk.ScrolledWindow() scrolledwindow0.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolledwindow0.set_shadow_type(Gtk.ShadowType.ETCHED_OUT) scrolledwindow0.set_size_request(550, 550) grid2.attach( scrolledwindow0, 0, 0, 1, 1, ) self.viewer = OsmGpsMap.Map() self.viewer.layer_add( OsmGpsMap.MapOsd(show_dpad=True, show_zoom=True, show_crosshair=True)) # connect keyboard shortcuts self.viewer.set_keyboard_shortcut(OsmGpsMap.MapKey_t.FULLSCREEN, Gdk.keyval_from_name("F11")) self.viewer.set_keyboard_shortcut(OsmGpsMap.MapKey_t.UP, Gdk.keyval_from_name("Up")) self.viewer.set_keyboard_shortcut(OsmGpsMap.MapKey_t.DOWN, Gdk.keyval_from_name("Down")) self.viewer.set_keyboard_shortcut(OsmGpsMap.MapKey_t.LEFT, Gdk.keyval_from_name("Left")) self.viewer.set_keyboard_shortcut(OsmGpsMap.MapKey_t.RIGHT, Gdk.keyval_from_name("Right")) scrolledwindow0.add(self.viewer) scrolledwindow0.set_size_request(550, 550) grid3 = Gtk.Grid() set_margins(grid3, 10) self.stack.add_named(grid3, QRType.TELEPHONE_NUMBER.name) label1 = Gtk.Label(_('Set number to encode:')) label1.set_alignment(0, .5) grid3.attach(label1, 0, 0, 1, 1) # self.entry13 = Gtk.Entry() self.entry13.set_alignment(0) self.entry13.set_width_chars(40) grid3.attach(self.entry13, 1, 0, 1, 1) grid4 = Gtk.Grid() set_margins(grid4, 10) self.stack.add_named(grid4, QRType.EMAIL.name) label1 = Gtk.Label(_('Set email:')) label1.set_alignment(0, .5) grid4.attach(label1, 0, 0, 1, 1) self.entry14 = Gtk.Entry() self.entry14.set_alignment(0) self.entry14.set_width_chars(40) grid4.attach(self.entry14, 1, 0, 1, 1) grid5 = Gtk.Grid() set_margins(grid5, 10) self.stack.add_named(grid5, QRType.URL.name) label1 = Gtk.Label(_('Set url:')) label1.set_alignment(0, .5) grid5.attach(label1, 0, 0, 1, 1) self.entry15 = Gtk.Entry() self.entry15.set_alignment(0) self.entry15.set_width_chars(40) grid5.attach(self.entry15, 1, 0, 1, 1) grid6 = Gtk.Grid() set_margins(grid6, 10) self.stack.add_named(grid6, QRType.WIFI_LOGIN.name) label1 = Gtk.Label(_('SSID/Network name:')) label1.set_alignment(0, .5) grid6.attach(label1, 0, 0, 1, 1) self.entry161 = Gtk.Entry() self.entry161.set_alignment(0) self.entry161.set_width_chars(40) grid6.attach(self.entry161, 1, 0, 1, 1) label1 = Gtk.Label(_('Password:'******'Network type:')) label1.set_alignment(0, .5) grid6.attach(label1, 0, 2, 1, 1) self.liststore163 = Gtk.ListStore(str, str) self.liststore163.append([_('WEP'), 'WEP']) self.liststore163.append([_('WPA/WPA2'), 'WPA']) self.liststore163.append([_('No encryption'), 'nopass']) self.combobox163 = Gtk.ComboBox.new() self.combobox163.set_model(self.liststore163) cell163 = Gtk.CellRendererText() self.combobox163.pack_start(cell163, True) self.combobox163.add_attribute(cell163, 'text', 0) select_value_in_combo(self.combobox163, 'wpa') grid6.attach(self.combobox163, 1, 2, 1, 1) grid7 = Gtk.Grid() set_margins(grid7, 10) self.stack.add_named(grid7, QRType.SMS.name) label1 = Gtk.Label(_('Telephone Number:')) label1.set_alignment(0, .5) grid7.attach(label1, 0, 0, 1, 1) # self.entry171 = Gtk.Entry() self.entry171.set_alignment(0) self.entry171.set_width_chars(40) grid7.attach(self.entry171, 1, 0, 1, 1) # label1 = Gtk.Label(_('SMS Message:')) label1.set_alignment(0, .5) grid7.attach(label1, 0, 1, 1, 1) # scrolledwindow_sms = Gtk.ScrolledWindow() scrolledwindow_sms.set_hexpand(True) scrolledwindow_sms.set_vexpand(True) scrolledwindow_sms.set_shadow_type(type=Gtk.ShadowType.ETCHED_IN) scrolledwindow_sms.set_size_request(550, 550) grid7.attach( scrolledwindow_sms, 0, 2, 2, 2, ) self.entry172 = Gtk.TextView() scrolledwindow_sms.add(self.entry172) grid8 = Gtk.Grid() set_margins(grid8, 10) self.stack.add_named(grid8, QRType.EMAIL_MESSAGE.name) label1 = Gtk.Label(_('Email:')) label1.set_alignment(0, .5) grid8.attach(label1, 0, 0, 1, 1) # self.entry181 = Gtk.Entry() self.entry181.set_alignment(0) self.entry181.set_width_chars(40) grid8.attach(self.entry181, 1, 0, 1, 1) # label1 = Gtk.Label(_('Subject:')) label1.set_alignment(0, .5) grid8.attach(label1, 0, 1, 1, 1) # self.entry182 = Gtk.Entry() self.entry182.set_alignment(0) self.entry182.set_width_chars(40) grid8.attach(self.entry182, 1, 1, 1, 1) # label1 = Gtk.Label(_('Body:')) label1.set_alignment(0, .5) grid8.attach(label1, 0, 2, 1, 1) # scrolledwindow_email = Gtk.ScrolledWindow() scrolledwindow_email.set_hexpand(True) scrolledwindow_email.set_vexpand(True) scrolledwindow_email.set_shadow_type(type=Gtk.ShadowType.ETCHED_IN) scrolledwindow_email.set_size_request(550, 300) grid8.attach(scrolledwindow_email, 0, 3, 2, 2) self.entry183 = Gtk.TextView() scrolledwindow_email.add(self.entry183) grid9 = Gtk.Grid() set_margins(grid9, 10) self.stack.add_named(grid9, QRType.VCARD.name) labels_card = { '01': _('Fist name'), '02': _('Last name'), '03': _('Job title'), '04': _('Telephone Number (work)'), '05': _('Fax Number (work)'), '06': _('Cell Phone'), '07': _('Email Address (work)'), '08': _('Website Address'), '09': _('Organization'), '10': _('Street Address (work)'), '11': _('City'), '12': _('State'), '13': _('Zip/Postcode'), '14': _('Country'), '15': _('Notes') } self.entries_vcard = {} for i, key in enumerate(sorted(labels_card.keys())): label1 = Gtk.Label(labels_card[key] + ':') label1.set_alignment(0, .5) grid9.attach(label1, 0, i, 1, 1) # self.entries_vcard[key] = Gtk.Entry() self.entries_vcard[key].set_alignment(0) self.entries_vcard[key].set_width_chars(40) grid9.attach(self.entries_vcard[key], 1, i, 1, 1) self.scrolled_code = Gtk.ScrolledWindow.new() self.scrolled_code.set_size_request(550, 550) self.main_stack.add_named(self.scrolled_code, 'Code') self.image = Gtk.Image() self.connect('key-release-event', self.on_key_release_event) self.scrolled_code.add_with_viewport(self.image) self.init_menu(hbox) self.init_headerbar() self.show_all() self.do_center()
def __init__(self, ui_dir, files): self.local_tz = LocalTimezone() self.recent = Gtk.RecentManager.get_default() self.wTree = Gtk.Builder() self.wTree.set_translation_domain('gpxviewer') self.wTree.add_from_file("%sgpxviewer.ui" % ui_dir) signals = { "on_windowMain_destroy": self.quit, "on_menuitemQuit_activate": self.quit, "on_menuitemOpen_activate": self.open_gpx, "on_menuitemZoomIn_activate": self.zoom_map_in, "on_buttonZoomIn_clicked": self.zoom_map_in, "on_menuitemZoomOut_activate": self.zoom_map_out, "on_buttonZoomOut_clicked": self.zoom_map_out, "on_menuitemAbout_activate": self.open_about_dialog, "on_checkmenuitemShowSidebar_toggled": self.show_sidebar_toggled, "on_menuitemShowStatistics_activate": self.show_statistics, "on_buttonTrackAdd_clicked": self.button_track_add_clicked, "on_buttonTrackDelete_clicked": self.button_track_delete_clicked, "on_buttonTrackProperties_clicked": self.button_track_properties_clicked, "on_buttonTrackInspect_clicked": self.button_track_inspect_clicked, } self.mainWindow = self.wTree.get_object("windowMain") self.mainWindow.set_icon_from_file("%sgpxviewer.svg" % ui_dir) self.mainWindow.set_title(_("GPX Viewer")) i = self.wTree.get_object("checkmenuitemCenter") i.connect("toggled", self.auto_center_toggled) self.autoCenter = i.get_active() self.ui_dir = ui_dir self.map = OsmGpsMap.Map(tile_cache=os.path.join( GLib.get_user_cache_dir(), 'gpxviewer', 'tiles')) self.map.layer_add( OsmGpsMap.MapOsd(show_dpad=False, show_zoom=False, show_scale=True, show_coordinates=False)) self.wTree.get_object("hbox_map").pack_start(self.map, True, True, 0) sb = self.wTree.get_object("statusbar1") # move zoom control into apple like slider self.zoomSlider = MapZoomSlider(self.map) self.zoomSlider.show_all() a = Gtk.Alignment.new(0.5, 0.5, 1.0, 1.0) a.set_padding(0, 0, 0, 4) a.add(self.zoomSlider) a.show_all() sb.pack_end(a, False, False, padding=4) # animate a spinner when downloading tiles try: self.spinner = Gtk.Spinner() self.spinner.props.has_tooltip = True self.spinner.connect("query-tooltip", self.on_spinner_tooltip) self.map.connect("notify::tiles-queued", self.update_tiles_queued) self.spinner.set_size_request( *Gtk.icon_size_lookup(Gtk.IconSize.MENU)[:2]) sb.pack_end(self.spinner, False, False, 0) except AttributeError: self.spinner = None self.wTree.connect_signals(signals) # add open with external tool submenu items and actions programs = { 'josm': N_('JOSM Editor'), 'merkaartor': N_('Merkaartor'), } submenu_open_with = Gtk.Menu() for prog, progname in programs.items(): submenuitem_open_with = Gtk.MenuItem(_(progname)) submenu_open_with.append(submenuitem_open_with) submenuitem_open_with.connect("activate", self.open_with_external_app, prog) submenuitem_open_with.show() self.wTree.get_object('menuitemOpenBy').set_submenu(submenu_open_with) self.trackManager = _TrackManager() self.trackManager.connect("track-added", self.on_track_added) self.trackManager.connect("track-removed", self.on_track_removed) self.wTree.get_object("menuitemHelp").connect( "activate", lambda *a: show_url("https://answers.launchpad.net/gpxviewer")) self.wTree.get_object("menuitemTranslate").connect( "activate", lambda *a: show_url( "https://translations.launchpad.net/gpxviewer")) self.wTree.get_object("menuitemReportProblem").connect( "activate", lambda *a: show_url( "https://bugs.launchpad.net/gpxviewer/+filebug")) self.tv = Gtk.TreeView(self.trackManager.model) self.tv.get_selection().connect("changed", self.on_selection_changed) self.tv.append_column( Gtk.TreeViewColumn("Track Name", Gtk.CellRendererText(), text=self.trackManager.NAME_IDX)) self.wTree.get_object("scrolledwindow1").add(self.tv) self.sb = self.wTree.get_object("vbox_sidebar") self.hide_spinner() self.hide_track_selector() self.lazyLoadFiles(files) self.map.show() self.mainWindow.show()
def __init__(self): self.path = os.path.dirname(__file__) # print(self.path) Gtk.Window.__init__(self, type=Gtk.WindowType.TOPLEVEL) self.maximize() self.set_title('OpenStreetMap GPS Mapper') self.vbox = Gtk.HBox() self.add(self.vbox) self.osm = OsmGpsMap.Map() self.osm.props.map_source = 1 self.osm.set_center_and_zoom(50.154422760009766, -5.0655341148376465, 12) self.osm.layer_add( OsmGpsMap.MapOsd(show_zoom=True, show_crosshair=True, show_scale=True)) self.osm.connect('button_press_event', self.on_mouse_click) self.osm.connect('button_release_event', self.on_mouse_click) self.osm.set_keyboard_shortcut(OsmGpsMap.MapKey_t.FULLSCREEN, Gdk.keyval_from_name("F11")) self.osm.set_keyboard_shortcut(OsmGpsMap.MapKey_t.UP, Gdk.keyval_from_name("Up")) self.osm.set_keyboard_shortcut(OsmGpsMap.MapKey_t.DOWN, Gdk.keyval_from_name("Down")) self.osm.set_keyboard_shortcut(OsmGpsMap.MapKey_t.LEFT, Gdk.keyval_from_name("Left")) self.osm.set_keyboard_shortcut(OsmGpsMap.MapKey_t.RIGHT, Gdk.keyval_from_name("Right")) gps_button = Gtk.ToggleButton() gps_button.set_label('GPS') gps_button.connect('clicked', self.get_location) cache_button = Gtk.Button() cache_button.set_label('Cache') cache_button.connect('clicked', self.cache_clicked) map_type_store = Gtk.ListStore(str) map_type = Gtk.ComboBoxText() map_type.set_model(map_type_store) mapTypes = [ 'OSM', 'Topo', 'Google', 'Satellite', ] for mapType in mapTypes: map_type_store.append([mapType]) map_type.set_active(0) map_type.connect('changed', self.change_map_type) gpx_button = Gtk.Button() gpx_button.set_label('Load GPX') gpx_button.connect('clicked', self.upload_gpx) self.plot_button = Gtk.ToggleButton() self.plot_button.set_label('Plot track') self.plot_button.connect('clicked', self.plotButton) self.len_label = Gtk.Label() geosearch_input = Gtk.SearchEntry() geosearch_input.set_width_chars(24) geosearch_input.connect("activate", self.geoSearch) self.gpx_save = Gtk.Button() self.gpx_save.set_label('Save GPX') self.gpx_save.connect('clicked', self.gpx) ors_lbl = Gtk.Label(margin_top=10) ors_lbl.set_markup('<b>ORS routing</b>') search_lbl = Gtk.Label(margin_top=10) search_lbl.set_markup('<b>Search</b>') maptype_lbl = Gtk.Label(margin_top=10) maptype_lbl.set_markup('<b>Map type</b>') ors_profile_store = Gtk.ListStore(str) self.ors_profile = Gtk.ComboBoxText() self.ors_profile.set_model(ors_profile_store) orsProfiles = [ 'foot-walking', 'foot-hiking', 'cycling-mountain', 'cycling-road', 'driving-car' ] for orsProfile in orsProfiles: ors_profile_store.append([orsProfile]) self.ors_profile.set_active(0) self.ors_profile.connect('changed', self.ors_call) self.pref_select_shortest = Gtk.RadioButton( ).new_with_label_from_widget(None, 'Shortest') self.pref_select_shortest.connect('toggled', self.ors_call) self.pref_select_fastest = Gtk.RadioButton( ).new_with_label_from_widget(self.pref_select_shortest, 'Fastest') prefBox = Gtk.HBox() prefBox.pack_start(self.pref_select_shortest, False, False, 0) prefBox.pack_start(self.pref_select_fastest, False, False, 0) self.elev_button = Gtk.Button() self.elev_button.set_label('Elevation') self.elev_button.connect('clicked', self.elevation) self.dir_button = Gtk.Button() self.dir_button.set_label('Directions') self.dir_button.connect('clicked', self.dir) self.clear_button = Gtk.Button() self.clear_button.set_label('Clear') self.clear_button.connect('clicked', self.clear) self.infowindow = Gtk.VBox() self.infoLabel = Gtk.Label(margin=5) self.infoLabel.set_line_wrap(True) self.infoLabel.set_max_width_chars(23) self.infowindow.pack_start(self.infoLabel, False, False, 0) self.vbox.pack_end(self.osm, True, True, 0) hbox = Gtk.VBox(spacing=3) hbox.pack_start(self.plot_button, False, False, 0) hbox.pack_start(gpx_button, False, False, 0) hbox.pack_start(self.gpx_save, False, False, 0) hbox.pack_start(gps_button, False, False, 0) hbox.pack_start(ors_lbl, False, False, 0) hbox.pack_start(self.ors_profile, False, False, 0) hbox.pack_start(prefBox, False, False, 0) hbox.pack_start(self.elev_button, False, False, 0) hbox.pack_start(self.dir_button, False, False, 0) hbox.pack_start(self.clear_button, False, False, 0) hbox.pack_start(search_lbl, False, False, 0) hbox.pack_start(geosearch_input, False, False, 0) hbox.pack_start(maptype_lbl, False, False, 0) hbox.pack_start(map_type, False, False, 0) hbox.pack_start(self.infowindow, False, False, 0) hbox.pack_end(cache_button, False, False, 0) hbox.pack_end(self.len_label, False, False, 10) self.vbox.pack_start(hbox, False, False, 0) self.via_route = [] self.viaImage = []
def __init__(self): Gtk.Window.__init__(self, type=Gtk.WindowType.TOPLEVEL) self.set_default_size(500, 500) self.connect("destroy", lambda x: Gtk.main_quit()) self.set_title("OpenStreetMap GPS Mapper") self.vbox = Gtk.VBox(homogeneous=False, spacing=0) self.add(self.vbox) if 0: self.osm = DummyMapNoGpsPoint() else: self.osm = osmgpsmap.Map() self.osm.layer_add( osmgpsmap.MapOsd(show_dpad=True, show_zoom=True, show_crosshair=True) ) self.osm.set_property("map-source", osmgpsmap.MapSource_t.OPENSTREETMAP) self.osm.layer_add(DummyLayer()) self.last_image = None self.osm.connect("button_press_event", self.on_button_press) self.osm.connect("changed", self.on_map_change) # connect keyboard shortcuts self.osm.set_keyboard_shortcut( osmgpsmap.MapKey_t.FULLSCREEN, Gdk.keyval_from_name("F11") ) self.osm.set_keyboard_shortcut( osmgpsmap.MapKey_t.UP, Gdk.keyval_from_name("Up") ) self.osm.set_keyboard_shortcut( osmgpsmap.MapKey_t.DOWN, Gdk.keyval_from_name("Down") ) self.osm.set_keyboard_shortcut( osmgpsmap.MapKey_t.LEFT, Gdk.keyval_from_name("Left") ) self.osm.set_keyboard_shortcut( osmgpsmap.MapKey_t.RIGHT, Gdk.keyval_from_name("Right") ) # connect to tooltip self.osm.props.has_tooltip = True self.osm.connect("query-tooltip", self.on_query_tooltip) self.latlon_entry = Gtk.Entry() zoom_in_button = Gtk.Button.new_from_icon_name("zoom-in", Gtk.IconSize.BUTTON) zoom_in_button.connect("clicked", self.zoom_in_clicked) zoom_out_button = Gtk.Button.new_from_icon_name("zoom-out", Gtk.IconSize.BUTTON) zoom_out_button.connect("clicked", self.zoom_out_clicked) home_button = Gtk.Button.new_from_icon_name("go-home", Gtk.IconSize.BUTTON) home_button.connect("clicked", self.home_clicked) cache_button = Gtk.Button(label="Cache") cache_button.connect("clicked", self.cache_clicked) self.vbox.pack_start(self.osm, True, True, 0) hbox = Gtk.HBox(homogeneous=False, spacing=0) hbox.pack_start(zoom_in_button, False, True, 0) hbox.pack_start(zoom_out_button, False, True, 0) hbox.pack_start(home_button, False, True, 0) hbox.pack_start(cache_button, False, True, 0) # add ability to test custom map URIs ex = Gtk.Expander(label="<b>Map Repository URI</b>") ex.props.use_markup = True vb = Gtk.VBox() self.repouri_entry = Gtk.Entry() self.repouri_entry.set_text(self.osm.props.repo_uri) self.image_format_entry = Gtk.Entry() self.image_format_entry.set_text(self.osm.props.image_format) lbl = Gtk.Label( label="""Enter an repository URL to fetch map tiles \ from in the box below. Special metacharacters may be included in this url <i>Metacharacters:</i> \t#X\tMax X location \t#Y\tMax Y location \t#Z\tMap zoom (0 = min zoom, fully zoomed out) \t#S\tInverse zoom (max-zoom - #Z) \t#Q\tQuadtree encoded tile (qrts) \t#W\tQuadtree encoded tile (1234) \t#U\tEncoding not implemeted \t#R\tRandom integer, 0-4""" ) lbl.props.xalign = 0 lbl.props.use_markup = True lbl.props.wrap = True ex.add(vb) vb.pack_start(lbl, False, True, 0) hb = Gtk.HBox() hb.pack_start(Gtk.Label(label="URI: "), False, True, 0) hb.pack_start(self.repouri_entry, True, True, 0) vb.pack_start(hb, False, True, 0) hb = Gtk.HBox() hb.pack_start(Gtk.Label(label="Image Format: "), False, True, 0) hb.pack_start(self.image_format_entry, True, True, 0) vb.pack_start(hb, False, True, 0) gobtn = Gtk.Button(label="Load Map URI") gobtn.connect("clicked", self.load_map_clicked) vb.pack_start(gobtn, False, True, 0) self.show_tooltips = False cb = Gtk.CheckButton(label="Show Location in Tooltips") cb.props.active = self.show_tooltips cb.connect("toggled", self.on_show_tooltips_toggled) self.vbox.pack_end(cb, False, True, 0) cb = Gtk.CheckButton(label="Disable Cache") cb.props.active = False cb.connect("toggled", self.disable_cache_toggled) self.vbox.pack_end(cb, False, True, 0) self.vbox.pack_end(ex, False, True, 0) self.vbox.pack_end(self.latlon_entry, False, True, 0) self.vbox.pack_end(hbox, False, True, 0) GLib.timeout_add(500, self.print_tiles)
def __init__(self, parent=None, location=None, latitude=0, longitude=0): # *************************************************************** Gtk.Dialog.__init__(self, 'my-weather-indicator | ' + _('Where Am I')) self.set_modal(True) self.set_destroy_with_parent(True) self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT) self.add_button(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT) self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) # self.set_size_request(450, 350) self.connect('destroy', self.on_close_application) self.set_icon_from_file(comun.ICON) # self.lat = latitude self.lng = longitude self.locality = location # vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 5) self.get_content_area().add(vbox) # hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 5) vbox.pack_start(hbox, False, False, 0) # self.entry1 = Gtk.Entry() self.entry1.set_width_chars(60) self.entry1.set_property('primary_icon_name', 'edit-find-symbolic') self.entry1.set_property('secondary_icon_name', 'edit-clear-symbolic') self.entry1.set_property('primary_icon_tooltip_text', _('Search location')) self.entry1.set_property('secondary_icon_tooltip_text', _('Clear location')) self.entry1.set_tooltip_text(_('Input the name of your city')) self.entry1.connect('icon-press', self.on_icon_press) self.entry1.connect('activate', self.on_button1_clicked) hbox.pack_start(self.entry1, True, True, 0) # button1 = Gtk.Button.new_with_label(_('Search')) button1.connect('clicked', self.on_button1_clicked) hbox.pack_start(button1, False, False, 0) # button2 = Gtk.Button.new_with_label(_('Find me')) button2.connect('clicked', self.on_button2_clicked) hbox.pack_start(button2, False, False, 0) self.expander = Gtk.Expander(label=_('Locations found')) self.expander.set_expanded(False) vbox.pack_start(self.expander, False, False, 0) # frame = Gtk.Frame() framebox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 50) framebox.add(frame) self.expander.add(framebox) self.expander.connect("notify::expanded", self.on_expander_expanded) # scrolledwindow0 = Gtk.ScrolledWindow() scrolledwindow0.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolledwindow0.set_shadow_type(Gtk.ShadowType.ETCHED_OUT) scrolledwindow0.set_size_request(450, 100) frame.add(scrolledwindow0) # city, county, country, latitude, longitude store = Gtk.ListStore(str, str, str, float, float) store.set_sort_column_id(2, Gtk.SortType.ASCENDING) self.treeview = Gtk.TreeView(model=store) self.treeview.set_reorderable(True) treeviewcolumn0 = Gtk.TreeViewColumn(_('City'), Gtk.CellRendererText(), text=0) treeviewcolumn0.set_reorderable(True) treeviewcolumn0.set_sort_column_id(0) treeviewcolumn1 = Gtk.TreeViewColumn(_('State'), Gtk.CellRendererText(), text=1) treeviewcolumn1.set_reorderable(True) treeviewcolumn1.set_sort_column_id(1) treeviewcolumn2 = Gtk.TreeViewColumn(_('Country'), Gtk.CellRendererText(), text=2) treeviewcolumn2.set_reorderable(True) treeviewcolumn2.set_sort_column_id(2) self.treeview.append_column(treeviewcolumn0) self.treeview.append_column(treeviewcolumn1) self.treeview.append_column(treeviewcolumn2) self.treeview.connect('cursor-changed', self.ontreeviewcursorchanged) scrolledwindow0.add(self.treeview) # # scrolledwindow = Gtk.ScrolledWindow() scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolledwindow.set_shadow_type(Gtk.ShadowType.IN) vbox.pack_start(scrolledwindow, True, True, 0) # self.viewer = OsmGpsMap.Map() self.viewer.layer_add( OsmGpsMap.MapOsd(show_dpad=True, show_zoom=True, show_crosshair=True)) # connect keyboard shortcuts self.viewer.set_keyboard_shortcut(OsmGpsMap.MapKey_t.FULLSCREEN, Gdk.keyval_from_name("F11")) self.viewer.set_keyboard_shortcut(OsmGpsMap.MapKey_t.UP, Gdk.keyval_from_name("Up")) self.viewer.set_keyboard_shortcut(OsmGpsMap.MapKey_t.DOWN, Gdk.keyval_from_name("Down")) self.viewer.set_keyboard_shortcut(OsmGpsMap.MapKey_t.LEFT, Gdk.keyval_from_name("Left")) self.viewer.set_keyboard_shortcut(OsmGpsMap.MapKey_t.RIGHT, Gdk.keyval_from_name("Right")) scrolledwindow.add(self.viewer) scrolledwindow.set_size_request(550, 550) # self.show_all() # self.set_wait_cursor() self.search_string = '' self.locality = '' print('============================') print(location, latitude, longitude) print('============================') if latitude and longitude: self.latitude = latitude self.longitude = longitude self.viewer.set_center_and_zoom(self.lat, self.lng, 14) if location is not None and len(location) > 0: self.locality = location print(1) self.entry1.set_text(location) else: print(2) self.do_search_location(latitude, longitude) else: self.search_location2() self.set_normal_cursor()