def create_tabs(self): log_notebook = Gtk.Notebook() log_notebook.set_border_width(2) self.vtable.attach(log_notebook, 0, 1, 3, 4) bot_notebook = Gtk.Notebook() bot_notebook.set_border_width(2) self.htable.attach(bot_notebook, 0, 1, 0, 1) # Log Tab/Page log_page = Gtk.ScrolledWindow() self.log_view = Gtk.TextView() self.log_view.set_border_width(5) self.log_view.set_editable(False) self.log_view.set_wrap_mode(Gtk.WrapMode.WORD) self.log_view.connect('size-allocate', self.log_view_auto_scroll) self.log_buf = self.log_view.get_buffer() self.red_text_tag = self.log_buf.create_tag('red', foreground='#dc3545') self.green_text_tag = self.log_buf.create_tag('green', foreground='#28a745') self.blue_text_tag = self.log_buf.create_tag('blue', foreground='#007bff') log_page.add(self.log_view) log_notebook.append_page(log_page, Gtk.Label('Log')) # Debug Tab self.debug_page = Gtk.ScrolledWindow() self.debug_view = Gtk.TextView() self.debug_view.set_border_width(5) self.debug_view.set_editable(False) self.debug_view.set_wrap_mode(Gtk.WrapMode.WORD) self.debug_view.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('black')) self.debug_view.modify_fg(Gtk.StateType.NORMAL, Gdk.color_parse('white')) self.debug_view.connect('size-allocate', self.debug_view_auto_scroll) self.debug_buf = self.debug_view.get_buffer() self.debug_page.add(self.debug_view) log_notebook.append_page(self.debug_page, Gtk.Label('Debug')) # Dev tools Tab if '--dev' in self.args: dev_tools_page = DevToolsWidget(self) log_notebook.append_page(dev_tools_page, Gtk.Label('Dev Tools')) log_notebook.show_all() log_notebook.set_current_page(2) ### Bot Tab bot_page = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) bot_page.set_border_width(10) bot_notebook.append_page(bot_page, Gtk.Label('Bot')) self.bot_widgets = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) bot_page.add(self.bot_widgets) ## Game Window self.bot_widgets.add(Gtk.Label('<b>Game Window</b>', xalign=0, use_markup=True)) game_window_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) self.bot_widgets.add(game_window_box) # ComboBox self.game_window_combo = Gtk.ComboBoxText() self.game_window_combo.set_margin_left(10) self.populate_game_window_combo() self.game_window_combo.connect('changed', self.on_game_window_combo_changed) game_window_box.pack_start(self.game_window_combo, True, True, 0) # Refresh self.refresh_button = Gtk.Button() self.refresh_button.set_image(Gtk.Image(icon_name='view-refresh')) self.refresh_button.set_tooltip_text('Refresh') self.refresh_button.connect('clicked', self.on_refresh_button_clicked) game_window_box.add(self.refresh_button) # Unplug self.unplug_button = Gtk.Button() self.unplug_button.set_image(Gtk.Image(icon_name='view-restore')) self.unplug_button.set_tooltip_text('Unplug') self.unplug_button.connect('clicked', self.on_unplug_button_clicked) game_window_box.add(self.unplug_button) # Plug if '--dev' in self.args: self.plug_button = Gtk.Button() self.plug_button.set_image(Gtk.Image(icon_name='window-new-symbolic')) self.plug_button.set_tooltip_text('Plug') self.plug_button.connect('clicked', self.on_plug_button_clicked) game_window_box.add(self.plug_button) ## Bot Path self.bot_widgets.add(Gtk.Label('<b>Bot Path</b>', xalign=0, use_markup=True)) bot_path_filechooserbutton = FileChooserButton(title='Choose bot path', filter=('Bot Path', '*.path')) bot_path_filechooserbutton.set_margin_left(10) bot_path_filechooserbutton.set_current_folder(tools.get_full_path('paths')) bot_path_filechooserbutton.connect('file-set', self.on_bot_path_changed) self.bot_widgets.add(bot_path_filechooserbutton) ## Start From Step hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.set_margin_left(10) self.bot_widgets.add(hbox) hbox.add(Gtk.Label('Start From Step')) self.step_spin_button = SpinButton(min=1, max=1000) self.step_spin_button.set_margin_left(10) hbox.pack_end(self.step_spin_button, False, False, 0) ## Repeat Path hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.set_margin_left(10) hbox.add(Gtk.Label('Repeat Path')) self.bot_widgets.add(hbox) # Switch self.repeat_switch = Gtk.Switch() self.repeat_switch.connect('notify::active', lambda switch, pspec: self.repeat_spin_button.set_sensitive(switch.get_active())) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) vbox.pack_start(self.repeat_switch, True, False, 0) hbox.add(vbox) # SpinButton self.repeat_spin_button = SpinButton(min=2, max=1000) self.repeat_spin_button.set_tooltip_text('Number of times') self.repeat_spin_button.set_sensitive(False) hbox.pack_end(self.repeat_spin_button, False, False, 0) ## Connect To Account hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.add(Gtk.Label('<b>Connect To Account</b>', xalign=0, use_markup=True)) self.bot_widgets.add(hbox) # Switch self.connect_to_account_switch = Gtk.Switch() self.connect_to_account_switch.connect('notify::active', lambda switch, pspec: self.connect_to_account_box.set_sensitive(switch.get_active())) hbox.pack_end(self.connect_to_account_switch, False, False, 0) # Box self.connect_to_account_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) self.connect_to_account_box.set_margin_left(10) self.connect_to_account_box.set_sensitive(False) self.bot_widgets.add(self.connect_to_account_box) # Account hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.add(Gtk.Label('Account')) self.connect_to_account_box.add(hbox) # Combo accounts_list = accounts.load() self.accounts_combo = TextValueComboBox(accounts_list, model=Gtk.ListStore(str, int), text_key='login', value_key='id', sort_key='position') self.accounts_combo.set_size_request(120, -1) hbox.pack_end(self.accounts_combo, False, False, 0) # Disconnect after hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.add(Gtk.Label('Disconnect after')) self.connect_to_account_box.add(hbox) # Switch self.disconnect_after_switch = Gtk.Switch() hbox.pack_end(self.disconnect_after_switch, False, False, 0) ## Pod self.podbar_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) bot_page.add(self.podbar_box) self.podbar_box.add(Gtk.Label('<b>Pod</b>', xalign=0, use_markup=True)) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.podbar_box.pack_start(vbox, True, True, 0) self.podbar = Gtk.ProgressBar() vbox.pack_start(self.podbar, True, False, 0) ## MiniMap self.minimap_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) bot_page.add(self.minimap_box) self.minimap_box.add(Gtk.Label('<b>MiniMap</b>', xalign=0, use_markup=True)) self.minimap = MiniMap(grid_size=(18, 18)) self.minimap.set_size_request(-1, 210) self.minimap.set_margin_left(10) self.minimap_box.add(self.minimap) ## Start button_box = ButtonBox(centered=True, linked=True) bot_page.pack_end(button_box, False, False, 0) self.start_button = Gtk.Button() self.start_button.set_tooltip_text('Start') self.start_button.set_image(Gtk.Image(icon_name='media-playback-start')) self.start_button.connect('clicked', self.on_start_button_clicked) button_box.add(self.start_button) ## Pause self.pause_button = Gtk.Button() self.pause_button.set_image(Gtk.Image(icon_name='media-playback-pause')) self.pause_button.set_tooltip_text('Pause') self.pause_button.set_sensitive(False) self.pause_button.connect('clicked', self.on_pause_button_clicked) button_box.add(self.pause_button) ## Stop self.stop_button = Gtk.Button() self.stop_button.set_image(Gtk.Image(icon_name='media-playback-stop')) self.stop_button.set_tooltip_text('Stop') self.stop_button.set_sensitive(False) self.stop_button.connect('clicked', self.on_stop_button_clicked) button_box.add(self.stop_button) ### Path Tab path_page = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) path_page.set_border_width(10) bot_notebook.append_page(path_page, Gtk.Label('Path')) ## Movement path_page.add(Gtk.Label('<b>Movement</b>', xalign=0, use_markup=True)) button_box = ButtonBox(orientation=Gtk.Orientation.VERTICAL, centered=True) path_page.add(button_box) # Up up_button = Gtk.Button() up_button.set_image(Gtk.Image(icon_name='go-up')) up_button.connect('clicked', lambda button: self.path_listbox.append_text('Move(UP)')) button_box.add(up_button) # Left left_button = Gtk.Button() left_button.set_image(Gtk.Image(icon_name='go-previous')) left_button.connect('clicked', lambda button: self.path_listbox.append_text('Move(LEFT)')) hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=40) hbox.add(left_button) button_box.add(hbox) # Right right_button = Gtk.Button() right_button.set_image(Gtk.Image(icon_name='go-next')) right_button.connect('clicked', lambda buton: self.path_listbox.append_text('Move(RIGHT)')) hbox.add(right_button) # Down down_button = Gtk.Button() down_button.set_image(Gtk.Image(icon_name='go-down')) down_button.connect('clicked', lambda button: self.path_listbox.append_text('Move(DOWN)')) button_box.add(down_button) ## Action path_page.add(Gtk.Label('<b>Action</b>', xalign=0, use_markup=True)) stack_listbox = StackListBox() path_page.add(stack_listbox) ## Enclos pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(tools.get_full_path('icons/enclos.png'), 24, 24) image = Gtk.Image(pixbuf=pixbuf) label = ImageLabel(image, 'Enclos') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # Location widget.add(Gtk.Label('<b>Location</b>', xalign=0, use_markup=True)) self.enclos_location_combo = CustomComboBox(data.Enclos, sort=True) self.enclos_location_combo.set_margin_left(10) widget.add(self.enclos_location_combo) # Type widget.add(Gtk.Label('<b>Type</b>', xalign=0, use_markup=True)) self.enclos_type_combo = CustomComboBox(data.EnclosType, sort=True) self.enclos_type_combo.set_margin_left(10) widget.add(self.enclos_type_combo) # Add add_button = Gtk.Button('Add') add_button.connect('clicked', lambda button: self.path_listbox.append_text('Enclos(location=%s,type=%s)' % (self.enclos_location_combo.get_active_text(), self.enclos_type_combo.get_active_text()))) button_box = ButtonBox(centered=True) button_box.add(add_button) widget.add(button_box) ## Zaap pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(tools.get_full_path('icons/zaap.png'), 24, 24) image = Gtk.Image(pixbuf=pixbuf) label = ImageLabel(image, 'Zaap') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # From widget.add(Gtk.Label('<b>From</b>', xalign=0, use_markup=True)) self.zaap_from_combo = CustomComboBox(data.Zaap['From'], sort=True) self.zaap_from_combo.set_margin_left(10) self.zaap_from_combo.connect('changed', lambda combo: combo.sync_with_combo(self.zaap_to_combo) ) widget.add(self.zaap_from_combo) # To widget.add(Gtk.Label('<b>To</b>', xalign=0, use_markup=True)) self.zaap_to_combo = CustomComboBox(data.Zaap['To'], sort=True) self.zaap_to_combo.set_margin_left(10) self.zaap_to_combo.connect('changed', lambda combo: combo.sync_with_combo(self.zaap_from_combo) ) widget.add(self.zaap_to_combo) # Add add_button = Gtk.Button('Add') add_button.connect('clicked', lambda button: self.path_listbox.append_text('Zaap(from=%s,to=%s)' % (self.zaap_from_combo.get_active_text(), self.zaap_to_combo.get_active_text()))) button_box = ButtonBox(centered=True) button_box.add(add_button) widget.add(button_box) ## Zaapi pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(tools.get_full_path('icons/destination.png'), 24, 24) image = Gtk.Image(pixbuf=pixbuf) label = ImageLabel(image, 'Zaapi') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # From widget.add(Gtk.Label('<b>From</b>', xalign=0, use_markup=True)) self.zaapi_from_combo = CustomComboBox(data.Zaapi['From'], sort=True) self.zaapi_from_combo.set_margin_left(10) self.zaapi_from_combo.connect('changed', lambda combo: combo.sync_with_combo(self.zaapi_to_combo, use_contains=True) ) widget.add(self.zaapi_from_combo) # To widget.add(Gtk.Label('<b>To</b>', xalign=0, use_markup=True)) self.zaapi_to_combo = CustomComboBox(data.Zaapi['To'], sort=True) self.zaapi_to_combo.set_margin_left(10) self.zaapi_to_combo.connect('changed', lambda combo: combo.sync_with_combo(self.zaapi_from_combo, use_contains=True) ) widget.add(self.zaapi_to_combo) # Add add_button = Gtk.Button('Add') add_button.connect('clicked', lambda button: self.path_listbox.append_text('Zaapi(from=%s,to=%s)' % (self.zaapi_from_combo.get_active_text(), self.zaapi_to_combo.get_active_text()))) button_box = ButtonBox(centered=True) button_box.add(add_button) widget.add(button_box) ## Collect pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(tools.get_full_path('icons/miner.png'), 24, 24) image = Gtk.Image(pixbuf=pixbuf) label = ImageLabel(image, 'Collect') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # Map widget.add(Gtk.Label('<b>Map</b>', xalign=0, use_markup=True)) self.collect_map_combo = CustomComboBox(maps.load(), sort=True) self.collect_map_combo.set_margin_left(10) widget.add(self.collect_map_combo) # Store Path widget.add(Gtk.Label('<b>Store Path</b>', xalign=0, use_markup=True)) # Combo hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.set_margin_left(10) self.collect_sp_combo_radio = Gtk.RadioButton() self.collect_sp_combo_radio.set_active(True) hbox.add(self.collect_sp_combo_radio) self.collect_sp_combo = CustomComboBox(data.BankPath, sort=True) self.collect_sp_combo.connect('changed', lambda combo: self.collect_sp_combo_radio.set_active(True)) hbox.pack_start(self.collect_sp_combo, True, True, 0) widget.add(hbox) # FileChooserButton hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.set_margin_left(10) self.collect_sp_filechooser_radio = Gtk.RadioButton(group=self.collect_sp_combo_radio) hbox.add(self.collect_sp_filechooser_radio) self.collect_sp_filechooserbutton = FileChooserButton(title='Choose store path', filter=('Store Path', '*.path')) self.collect_sp_filechooserbutton.set_current_folder(tools.get_full_path('paths')) self.collect_sp_filechooserbutton.connect('file-set', lambda filechooserbutton: self.collect_sp_filechooser_radio.set_active(True)) hbox.pack_start(self.collect_sp_filechooserbutton, True, True, 0) widget.add(hbox) # Add add_button = Gtk.Button('Add') add_button.connect('clicked', lambda button: self.path_listbox.append_text('Collect(map=%s,store_path=%s)' % (self.collect_map_combo.get_active_text(), self.collect_sp_combo.get_active_text() if self.collect_sp_combo_radio.get_active() else self.collect_sp_filechooserbutton.get_filename()))) button_box = ButtonBox(centered=True) button_box.add(add_button) widget.add(button_box) ## Click pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(tools.get_full_path('icons/arrow.png'), 24, 24) #pixbuf = Gdk.Cursor(Gdk.CursorType.ARROW).get_image().scale_simple(24, 24, GdkPixbuf.InterpType.BILINEAR) image = Gtk.Image(pixbuf=pixbuf) label = ImageLabel(image, 'Click') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # Twice hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.add(Gtk.Label('<b>Twice</b>', xalign=0, use_markup=True)) self.click_twice_switch = Gtk.Switch() hbox.pack_end(self.click_twice_switch, False, False, 0) widget.add(hbox) # Location hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.add(Gtk.Label('<b>Location</b>', xalign=0, use_markup=True)) cursor_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(tools.get_full_path('icons/crosshair.png'), 16, 16) #cursor_pixbuf = Gdk.Cursor(Gdk.CursorType.CROSSHAIR).get_image().scale_simple(18, 18, GdkPixbuf.InterpType.BILINEAR) self.select_button = Gtk.Button() self.select_button.set_size_request(40, -1) self.select_button.set_tooltip_text('Select') self.select_button.set_image(Gtk.Image(pixbuf=cursor_pixbuf)) self.select_button.connect('clicked', self.on_select_button_clicked) hbox.pack_end(self.select_button, False, False, 0) widget.add(hbox) ## Wait pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(tools.get_full_path('icons/hourglass.png'), 24, 24) image = Gtk.Image(pixbuf=pixbuf) label = ImageLabel(image, 'Wait') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # Pause Bot hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.add(Gtk.Label('<b>Pause Bot</b>', xalign=0, use_markup=True)) self.pause_bot_switch = Gtk.Switch() self.pause_bot_switch.connect('notify::active', lambda switch, pspec: self.duration_box.set_sensitive(not switch.get_active())) hbox.pack_end(self.pause_bot_switch, False, False, 0) widget.add(hbox) # Duration self.duration_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) label = Gtk.Label('<b>Duration</b>', xalign=0, use_markup=True) label.set_tooltip_text('(in seconds)') self.duration_box.add(label) self.duration_spin_button = SpinButton(min=1, max=60) self.duration_box.pack_end(self.duration_spin_button, False, False, 0) widget.add(self.duration_box) # Add add_button = Gtk.Button('Add') add_button.connect('clicked', lambda button: self.path_listbox.append_text('Wait(duration=%d,pause=%s)' % (0 if self.pause_bot_switch.get_active() else self.duration_spin_button.get_value_as_int(), self.pause_bot_switch.get_active()))) button_box = ButtonBox(centered=True) button_box.add(add_button) widget.add(button_box) ## Keyboard image = Gtk.Image(icon_name='input-keyboard', icon_size=Gtk.IconSize.LARGE_TOOLBAR) label = ImageLabel(image, 'Keyboard') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # Press Key hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) self.press_key_radio = Gtk.RadioButton() self.press_key_radio.add(Gtk.Label('<b>Press Key</b>', xalign=0, use_markup=True)) hbox.add(self.press_key_radio) self.key_label = Gtk.Label() hbox.add(self.key_label) widget.add(hbox) self.keys_combo = CustomComboBox(data.KeyboardShortcuts, sort=True) self.keys_combo.set_margin_left(10) self.keys_combo.connect('changed', lambda combo: ( self.key_label.set_text('(' + data.KeyboardShortcuts[combo.get_active_text()] + ')'), self.press_key_radio.set_active(True) ) ) widget.add(self.keys_combo) # Type Text self.type_text_radio = Gtk.RadioButton(group=self.press_key_radio) self.type_text_radio.add(Gtk.Label('<b>Type Text</b>', xalign=0, use_markup=True)) widget.add(self.type_text_radio) self.type_text_entry = Gtk.Entry(placeholder_text='Text') self.type_text_entry.set_margin_left(10) self.type_text_entry.set_width_chars(10) self.type_text_entry.connect('focus-in-event', lambda entry, event: self.type_text_radio.set_active(True)) widget.add(self.type_text_entry) # Add add_button = Gtk.Button('Add') add_button.connect('clicked', self.on_keyboard_add_button_clicked) button_box = ButtonBox(centered=True) button_box.add(add_button) widget.add(button_box) ## Connect image = Gtk.Image(icon_name='network-wired', icon_size=Gtk.IconSize.LARGE_TOOLBAR) label = ImageLabel(image, 'Connect') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # Account widget.add(Gtk.Label('<b>Account</b>', xalign=0, use_markup=True)) self.connect_accounts_combo = TextValueComboBox(accounts_list, model=Gtk.ListStore(str, int), text_key='login', value_key='id', sort_key='position') self.connect_accounts_combo.set_margin_left(10) widget.add(self.connect_accounts_combo) # Add add_button = Gtk.Button('Add') add_button.connect('clicked', lambda button: self.path_listbox.append_text('Connect(account_id=%s)' % self.connect_accounts_combo.get_active_value())) button_box = ButtonBox(centered=True) button_box.add(add_button) widget.add(button_box) ## Disconnect image = Gtk.Image(icon_name='network-idle', icon_size=Gtk.IconSize.LARGE_TOOLBAR) label = ImageLabel(image, 'Disconnect') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # Exit Game hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) widget.add(hbox) hbox.add(Gtk.Label('<b>Exit Game</b>', xalign=0, use_markup=True)) self.exit_game_switch = Gtk.Switch() hbox.pack_end(self.exit_game_switch, False, False, 0) # Add add_button = Gtk.Button('Add') add_button.connect('clicked', lambda button: self.path_listbox.append_text('Disconnect(%s)' % self.exit_game_switch.get_active())) button_box = ButtonBox(centered=True) button_box.add(add_button) widget.add(button_box) ## Separator path_page.add(Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL, margin=5)) ## Listbox self.path_listbox = CustomListBox() path_page.pack_end(self.path_listbox, True, True, 0) # Load load_path_button = Gtk.Button() load_path_button.set_tooltip_text('Load') load_path_button.set_image(Gtk.Image(icon_name='document-open')) load_path_button.connect('clicked', self.on_load_path_button_clicked) self.path_listbox.add_button(load_path_button) # Save self.save_path_button = Gtk.Button() self.save_path_button.set_tooltip_text('Save') self.save_path_button.set_sensitive(False) self.save_path_button.set_image(Gtk.Image(icon_name='document-save-as')) self.save_path_button.connect('clicked', self.on_save_path_button_clicked) self.path_listbox.add_button(self.save_path_button) self.path_listbox.on_add(self.on_path_listbox_add) self.path_listbox.on_delete(self.on_path_listbox_delete) ### Map Tab map_page = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) map_page.set_border_width(10) bot_notebook.append_page(map_page, Gtk.Label('Map')) ## View hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.add(Gtk.Label('<b>View</b>', xalign=0, use_markup=True)) map_page.add(hbox) # Options menu_image = MenuImage() hbox.add(menu_image) options_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) menu_image.set_widget(options_box) # Use data colors use_data_colors_check = Gtk.CheckButton('Use data colors') use_data_colors_check.connect('clicked', lambda button: self.map_view.set_use_origin_colors(button.get_active())) options_box.add(use_data_colors_check) # Add borders add_borders_check = Gtk.CheckButton('Add borders') add_borders_check.connect('clicked', lambda button: self.map_view.set_add_borders(button.get_active())) options_box.add(add_borders_check) # Map View self.map_view = MiniMap() map_page.pack_start(self.map_view, True, True, 0) ## Data map_page.add(Gtk.Label('<b>Data</b>', xalign=0, use_markup=True)) self.map_data_listbox = CustomListBox(allow_moving=False) map_page.pack_start(self.map_data_listbox, True, True, 0) # Select self.select_resource_button = Gtk.Button() self.select_resource_button.set_tooltip_text('Select resource') self.select_resource_button.set_image(Gtk.Image(pixbuf=cursor_pixbuf)) self.select_resource_button.connect('clicked', self.on_select_resource_button_clicked) self.map_data_listbox.add_button(self.select_resource_button) # Edit edit_map_button = MenuButton(icon_name='document-edit-symbolic') edit_map_button.set_tooltip_text('Edit') self.map_data_listbox.add_button(edit_map_button) button_box = ButtonBox(linked=True) edit_map_button.add(button_box) # Load load_map_button = Gtk.Button() load_map_button.set_tooltip_text('Load') load_map_button.set_image(Gtk.Image(icon_name='document-open')) load_map_button.connect('clicked', self.on_load_map_button_clicked) button_box.add(load_map_button) # Delete delete_map_button = Gtk.Button() delete_map_button.set_tooltip_text('Delete') delete_map_button.set_image(Gtk.Image(icon_name='edit-delete')) delete_map_button.connect('clicked', self.on_delete_map_button_clicked) button_box.add(delete_map_button) # Save self.save_map_button = Gtk.Button() self.save_map_button.set_tooltip_text('Save') self.save_map_button.set_sensitive(False) self.save_map_button.set_image(Gtk.Image(icon_name='document-save-as')) self.save_map_button.connect('clicked', self.on_save_map_button_clicked) self.map_data_listbox.add_button(self.save_map_button) self.map_data_listbox.on_add(self.on_map_data_listbox_add) self.map_data_listbox.on_delete(self.on_map_data_listbox_delete)
def __init__(self, transient_for, title='Accounts'): CustomDialog.__init__(self, transient_for=transient_for, title=title) self.parent = transient_for ### New vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) content_area = self.get_content_area() content_area.add(vbox) vbox.add(Gtk.Label('<b>New</b>', xalign=0, use_markup=True)) new_hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) vbox.add(new_hbox) new_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) new_hbox.pack_start(new_vbox, True, False, 0) ## Login hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) new_vbox.add(hbox) hbox.add(Gtk.Label('Login')) # Entry self.login_entry = Gtk.Entry() self.login_entry.connect('focus-in-event', lambda entry, event: self.error_box.hide()) hbox.pack_end(self.login_entry, False, False, 0) ## Password hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) new_vbox.add(hbox) hbox.add(Gtk.Label('Password')) # Show password show_password_button = Gtk.Button() show_password_button.set_tooltip_text('Show password') show_password_button.set_image( Gtk.Image(icon_name='channel-insecure-symbolic')) show_password_button.set_relief(Gtk.ReliefStyle.NONE) show_password_button.connect('clicked', self.on_show_password_button_clicked) hbox.add(show_password_button) # Entry self.password_entry = Gtk.Entry(visibility=False) self.password_entry.connect('focus-in-event', lambda entry, event: self.error_box.hide()) hbox.pack_end(self.password_entry, False, False, 0) ## Error box self.error_box = MessageBox(color='red') new_vbox.add(self.error_box) ## Add add_button = Gtk.Button('Add') add_button.set_image(Gtk.Image(icon_name='list-add-symbolic')) add_button.connect('clicked', self.on_add_button_clicked) button_box = Gtk.ButtonBox(orientation=Gtk.Orientation.HORIZONTAL, layout_style=Gtk.ButtonBoxStyle.CENTER) button_box.add(add_button) new_vbox.add(button_box) ### Accounts vbox.add(Gtk.Label('<b>Accounts</b>', xalign=0, use_markup=True)) ## TreeView model = Gtk.ListStore(int, str, str) text_renderer = Gtk.CellRendererText() columns = [ Gtk.TreeViewColumn('ID', text_renderer, text=0), Gtk.TreeViewColumn('Login', text_renderer, text=1), Gtk.TreeViewColumn('Password', text_renderer, text=2) ] self.tree_view = CustomTreeView(model, columns) self.tree_view.set_size_request(400, 160) self.tree_view.connect('selection-changed', self.on_tree_view_selection_changed) vbox.pack_start(self.tree_view, True, True, 0) # fill treeview for account in sorted(accounts.load(), key=lambda item: item['position']): pwd = '*' * len(account['pwd']) self.tree_view.append_row([account['id'], account['login'], pwd], select=False) ## ActionBar actionbar = Gtk.ActionBar() self.tree_view.vbox.pack_end(actionbar, False, False, 0) buttons_box = ButtonBox(linked=True) actionbar.add(buttons_box) # Move up self.move_up_button = Gtk.Button() self.move_up_button.set_tooltip_text('Move up') self.move_up_button.set_image(Gtk.Image(icon_name='go-up-symbolic')) self.move_up_button.set_sensitive(False) self.move_up_button.connect('clicked', self.on_move_up_button_clicked) buttons_box.add(self.move_up_button) # Move down self.move_down_button = Gtk.Button() self.move_down_button.set_tooltip_text('Move down') self.move_down_button.set_image( Gtk.Image(icon_name='go-down-symbolic')) self.move_down_button.set_sensitive(False) self.move_down_button.connect('clicked', self.on_move_down_button_clicked) buttons_box.add(self.move_down_button) # Delete self.delete_button = Gtk.Button() self.delete_button.set_tooltip_text('Delete') self.delete_button.set_image( Gtk.Image(icon_name='edit-delete-symbolic')) self.delete_button.set_sensitive(False) self.delete_button.connect('clicked', self.on_delete_button_clicked) buttons_box.add(self.delete_button) self.show_all() self.error_box.hide()