def buildActionbar(self): self.revealer = Gtk.Revealer() self.revealer.set_reveal_child(False) self.box.pack_end(self.revealer, False, False, 0) self.actionbar = Gtk.ActionBar() self.actionbar.set_hexpand(True) self.revealer.add(self.actionbar) checkbuttonHeading = Gtk.CheckButton(label="Toon koppen") checkbuttonHeading.set_active( self.calendar.get_property("show-heading")) checkbuttonHeading.connect("toggled", self.onShowHeadingChange) self.actionbar.pack_start(checkbuttonHeading) checkbuttonDayNames = Gtk.CheckButton(label="Toon dagen") checkbuttonDayNames.set_active( self.calendar.get_property("show-day-names")) checkbuttonDayNames.connect("toggled", self.onShowDayChange) self.actionbar.pack_start(checkbuttonDayNames) checkbuttonPreventChange = Gtk.CheckButton( label="Vergrendel maand/jaar") checkbuttonPreventChange.set_active( self.calendar.get_property("no-month-change")) checkbuttonPreventChange.connect("toggled", self.onPreventMonthChange) self.actionbar.pack_start(checkbuttonPreventChange) checkbuttonShowWeeks = Gtk.CheckButton(label="Toon weeknummers") checkbuttonShowWeeks.set_active( self.calendar.get_property("show-week-numbers")) checkbuttonShowWeeks.connect("toggled", self.onShowWeeksChange) self.actionbar.pack_start(checkbuttonShowWeeks)
def __init__(self): Gtk.Frame.__init__(self) self.set_hexpand(False) grid = Gtk.Grid() grid.set_orientation(Gtk.Orientation.VERTICAL) self.add(grid) scrolled = Gtk.ScrolledWindow() scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scrolled.set_vexpand(True) scrolled.set_hexpand(True) scrolled.set_shadow_type(Gtk.ShadowType.NONE) grid.add(scrolled) self.activity_list = ActivityList() scrolled.add(self.activity_list) # revealer self.revealer = Gtk.Revealer() self.revealer.set_transition_type(Gtk.RevealerTransitionType.SLIDE_UP) grid.add(self.revealer) bar = Gtk.ActionBar() self.revealer.add(bar) # TODO: add upload button self.delete_button = Gtk.Button('Delete') self.delete_button.get_style_context().add_class('destructive-action') self.delete_button.set_sensitive(False) bar.pack_end(self.delete_button)
def __init__(self, parent=None, allow_moving=True): Gtk.Frame.__init__(self) self.parent = parent self.allow_moving = allow_moving self.perform_scroll = False self.add_callback = None self.delete_callback = None self.activate_callback = None ## ListBox vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.add(vbox) self.listbox = Gtk.ListBox() self.listbox.set_selection_mode(Gtk.SelectionMode.SINGLE) self.listbox.connect('size-allocate', self.on_size_allocate) self.listbox.connect('row-activated', self.on_row_activated) scrolled_window = Gtk.ScrolledWindow() scrolled_window.add(self.listbox) vbox.pack_start(scrolled_window, True, True, 0) ## ActionBar actionbar = Gtk.ActionBar() vbox.pack_end(actionbar, False, False, 0) default_buttons_box = ButtonBox(linked=True) actionbar.pack_start(default_buttons_box) if allow_moving: # 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.connect('clicked', self.on_move_up_button_clicked) default_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.connect('clicked', self.on_move_down_button_clicked) default_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.connect('clicked', self.on_delete_button_clicked) default_buttons_box.add(self.delete_button) # Clear all self.clear_all_button = Gtk.Button() self.clear_all_button.set_tooltip_text('Clear all') self.clear_all_button.set_image( Gtk.Image(icon_name='edit-clear-all-symbolic')) self.clear_all_button.connect('clicked', self.on_clear_all_button_clicked) default_buttons_box.add(self.clear_all_button) # Initialise default buttons status self.reset_buttons() # Buttons box self.buttons_box = ButtonBox(linked=True) actionbar.pack_end(self.buttons_box)
def build_action_bar(self): action_bar = Gtk.ActionBar() add_btn = Gtk.Button(_("New Location")) add_btn.connect("clicked", self.dialog_add) add_btn.get_style_context().add_class("location-btn-add") action_bar.pack_start(add_btn) self.window.layout.pack_end(action_bar, False, False, 0)
def addActions(self): self.actions = Gtk.ActionBar() self.grid.attach(self.actions, 0, self.row, 3, 1) self.applyButton = Gtk.Button.new_with_mnemonic("_Apply") self.resetButton = Gtk.Button.new_with_mnemonic("_Reset") self.actions.pack_end(self.applyButton) self.actions.pack_end(self.resetButton) self.resetButton.connect("clicked", self.reset) self.applyButton.connect("clicked", self.apply)
def init_action_bar(self): self.action_bar = Gtk.ActionBar() self.emoji_preview_box = Gtk.Box( spacing=GRID_SIZE, margin=GRID_SIZE, orientation=Gtk.Orientation.HORIZONTAL) self.previewed_emoji_label = Gtk.Label(" ") self.previewed_emoji_label.set_name("previewed_emoji_label") self.previewed_emoji_label.set_alignment(0, 0.2) self.emoji_preview_box.pack_start(self.previewed_emoji_label, False, False, 0) self.emoji_preview_box_text = Gtk.Box( spacing=0, orientation=Gtk.Orientation.VERTICAL) self.previewed_emoji_name_label = Gtk.Label( " ", ellipsize=Pango.EllipsizeMode.END) self.previewed_emoji_name_label.set_name("previewed_emoji_name_label") self.previewed_emoji_name_label.set_alignment(0, 0.2) self.emoji_preview_box_text.pack_start(self.previewed_emoji_name_label, False, False, 0) self.previewed_emoji_shortcode_label = Gtk.Label( " ", ellipsize=Pango.EllipsizeMode.END) self.previewed_emoji_shortcode_label.set_name( "previewed_emoji_shortcode_label") self.previewed_emoji_shortcode_label.set_alignment(0, 0.2) self.emoji_preview_box_text.pack_start( self.previewed_emoji_shortcode_label, False, False, 0) self.emoji_preview_box.pack_start(self.emoji_preview_box_text, False, False, 0) self.action_bar.pack_start(self.emoji_preview_box) self.selected_box = Gtk.Box(spacing=GRID_SIZE, margin=GRID_SIZE, margin_bottom=0, expand=False) self.emoji_append_list_preview = Gtk.Label( " ", max_width_chars=25, ellipsize=Pango.EllipsizeMode.START) self.emoji_append_list_preview.set_name("emoji_append_list_preview") self.selected_box.pack_start(self.emoji_append_list_preview, False, False, 0) self.action_bar.pack_end(self.selected_box) self.action_bar.show_all() self.selected_box.hide() self.app_container.pack_end(self.action_bar, False, False, 0)
def __init__(self, window_obj, system, added): self.window_obj = window_obj self.environment = self.window_obj.environment self.system = system self.added = added self.window_obj.hide_list() for child in self.window_obj.header_bar.get_children(): child.set_sensitive(False) self.rendered_fields = [] self.action_bar = Gtk.ActionBar() btn_save = Gtk.Button() btn_save.set_label('Save') btn_save.set_image( Gtk.Image.new_from_icon_name('document-save', Gtk.IconSize.BUTTON)) btn_save.set_always_show_image(True) btn_save.show() btn_save.connect("clicked", self.handler_save) btn_back = Gtk.Button() btn_back.set_label('Cancel') btn_back.set_image( Gtk.Image.new_from_icon_name('object-rotate-left', Gtk.IconSize.BUTTON)) btn_back.set_always_show_image(True) btn_back.show() btn_back.connect("clicked", self.handler_cancel) btn_delete = Gtk.Button() btn_delete.set_label('Delete') btn_delete.set_image( Gtk.Image.new_from_icon_name('edit-delete', Gtk.IconSize.BUTTON)) btn_delete.set_always_show_image(True) btn_delete.show() btn_delete.connect("clicked", self.handler_delete) self.action_bar.pack_start(btn_save) self.action_bar.set_center_widget(btn_back) if self.added: self.action_bar.pack_end(btn_delete) self.window_obj.vbox_main.pack_end(self.action_bar, False, False, 0) self.action_bar.show() self.hbox_key_file = None self.combobox_auth_method = None
def init_components(self): container = self.get_content_area() # labels container.pack_start(Gtk.Label('Locations'), False, False, 0) help_label = Gtk.Label() help_label.set_markup( '<span font_size="10240" font_weight="light">double click any cell to edit</span>' ) container.pack_start(help_label, False, False, 0) # tree view self.treeview_container = Gtk.ScrolledWindow() self.treeview_container.set_vexpand(True) locations = app_state.get_locations() self.store = Gtk.ListStore(str, str, str, str) for loc in locations: self.store.append(loc) self.treeview = Gtk.TreeView(model=self.store) for i, column_title in enumerate( ["Id", "Location Name", "Latitude", "Longitude"]): renderer = Gtk.CellRendererText() if i == 0: column = Gtk.TreeViewColumn(column_title, renderer, text=i) column.props.visible = False else: renderer.props.editable = True renderer.connect("edited", self.text_edited_handler(i)) column = Gtk.TreeViewColumn(column_title, renderer, text=i) column.set_min_width(50) column.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE) column.set_resizable(True) self.treeview.append_column(column) self.treeview_container.add(self.treeview) container.pack_start(self.treeview_container, True, True, 10) # action bar action_bar = Gtk.ActionBar() add_button = Gtk.Button.new_from_icon_name("list-add-symbolic", Gtk.IconSize.LARGE_TOOLBAR) add_button.connect('clicked', self.add_button_clicked) action_bar.pack_start(add_button) delete_button = Gtk.Button.new_from_icon_name( "edit-delete-symbolic", Gtk.IconSize.LARGE_TOOLBAR) delete_button.connect('clicked', self.delete_button_clicked) action_bar.pack_start(delete_button) container.pack_end(action_bar, False, False, 5) self.show_all()
def build(self) -> None: self.container = Gtk.Box(visible=True, orientation="vertical", name=self.name) self.action_bar = Gtk.ActionBar(visible=True) self.action_bar.pack_end(CloseButton(self.name)) self.action_bar.pack_end(SplitViewButton(self.name, True)) self.action_bar.pack_end(SplitViewButton(self.name, False)) self.scroller = Gtk.ScrolledWindow(visible=True, shadow_type='in', propagate_natural_width=True) self.container.pack_start(self.action_bar, False, True, 0) self.container.pack_start(self.scroller, True, True, 0)
def build_action_bar(self): action_bar = Gtk.ActionBar() self.builder.expose_object("actionbar", action_bar) self.window.layout.pack_end(action_bar, False, False, 0) apply_btn = Gtk.Button.new_from_stock(Gtk.STOCK_SAVE) apply_btn.connect("clicked", self.update_setting) apply_btn.get_style_context().add_class("suggested-action") action_bar.pack_end(apply_btn) cancel_btn = Gtk.Button.new_from_stock(Gtk.STOCK_CANCEL) cancel_btn.connect("clicked", self.reset) action_bar.pack_end(cancel_btn) action_bar.show_all() action_bar.hide()
def __init__(self): Gtk.Window.__init__(self, skip_pager_hint=True, skip_taskbar_hint=True) #self.set_decorated(False) self.set_default_size(400, 200) # self.set_keep_below(True) self.set_decorated(False) screen = self.get_screen() rgba = screen.get_rgba_visual() self.set_visual(rgba) self.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0, 0, 0, 0)) self.connect('destroy', lambda x: Gtk.main_quit()) self.box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0) self.box.set_homogeneous(False) poetry = random_poetry(random_author()) formatted_poetry = formatting(poetry) n_lines = len(poetry['lines']) if n_lines * 15 > 1000: n_lines = 20 y = 1000 - n_lines * 13 self.move(50, y) label = Gtk.Label() label.set_markup(formatted_poetry) # label.set_markup("<span foreground = \"orange\" font_desc=\"Lunchtime Doubly So regular 11\"> Once upon a midnight dreary, while I pondered, weak and weary,\rOver many a quaint and curious volume of forgotten lore\rWhile I nodded, nearly napping, suddenly there came a tapping, \rAs of some one gently rapping, rapping at my chamber door.Tis some visitor, \rI muttered, tapping at my chamber door Only this and nothing more. </span>") self.box.pack_start(label, True, True, 0) self.add(self.box) self.abar = Gtk.ActionBar() self.box.pack_end(self.abar, False, False, 0) #self.build_contents() # Finalize the window itself # self.set_titlebar(self.headerbar()) #self.set_title("Foreign Package Installer") #self.set_icon_name("system-software-install") #self.set_position(Gtk.WindowPosition.CENTER) self.show_all()
def __init__(self, interface, item): super().__init__(orientation=Gtk.Orientation.VERTICAL) self.interface = interface self.item = item self.serializer = librpc.Serializer('json') self.font = Pango.FontDescription('monospace 10') self.current = self.read() self.new = Gtk.TreeView() self.actions = Gtk.ActionBar() self.change = Gtk.Button('Set value') self.actions.pack_start(self.change) self.pack_start(Gtk.Label('Current value:'), False, True, 0) self.pack_start(scrolled(self.current), True, True, 0) self.pack_start(Gtk.Label('New value:'), False, True, 0) self.pack_start(scrolled(self.new), True, True, 0) self.pack_start(self.actions, False, False, 0) self.show_all()
def __init__(self, owner): Gtk.Revealer.__init__(self) self.owner = owner self.action_bar = Gtk.ActionBar() self.add(self.action_bar) self.progresslabel = Gtk.Label("") self.progresslabel.set_valign(Gtk.Align.CENTER) self.progresslabel.set_halign(Gtk.Align.START) self.progresslabel.set_property("yalign", 0.5) self.progresslabel.set_property("xalign", 0.0) self.progresslabel.set_margin_start(6) self.progresslabel.set_margin_end(8) self.progresslabel.set_margin_top(4) self.progresslabel.set_margin_bottom(4) self.action_bar.pack_start(self.progresslabel) self.progressbar = Gtk.ProgressBar() self.progressbar.set_fraction(0.6) self.progressbar.set_valign(Gtk.Align.CENTER) self.progressbar.set_margin_end(20) self.progressbar.set_margin_top(6) self.progressbar.set_margin_bottom(4) self.action_bar.pack_end(self.progressbar) self.progressbar.set_size_request(350, -1) self.invalidate_all() self.operations = dict() self.update_ui() self.cb = None self.link = comar.Link() self.pmanager = self.link.System.Manager['pisi'] self.link.listenSignals("System.Manager", self.pisi_callback) self.current_operations = None self.downloaded = 0 self.current_package = None
def __init__(self): Gtk.Window.__init__(self, title="Ns3 mmWave HBF Frame Visualization Tool") self.set_default_size(800, 100) self.connect("destroy", Gtk.main_quit) self.frameFocused = 0 self.maxFrames = 10 self.frameInfoCache = {} self.workingfilename = "TCP-SBF-PAD4-HARQ.log" self.maxLayer = 1 grid = Gtk.Grid() self.add(grid) self.drawingArea = MyDrawingAreaFrame() grid.attach(self.drawingArea, 0, 0, 1, 1) self.actionbar = Gtk.ActionBar() self.actionbar.set_hexpand(True) grid.attach(self.actionbar, 0, 1, 1, 1) self.fChooser = Gtk.FileChooserButton() self.fChooser.connect("file-set", self.file_selected) self.actionbar.pack_start(self.fChooser) self.bButton = Gtk.Button(label="<=") self.bButton.connect("clicked", self.bk_button_clicked) self.actionbar.pack_start(self.bButton) self.subframeLabel = Gtk.Label("Subframe: ") self.actionbar.pack_start(self.subframeLabel) self.subframeNuminput = Gtk.SpinButton(value=0, wrap=True, numeric=True) self.subframeNuminput.set_range(0, self.maxFrames - 1) self.subframeNuminput.connect("value-changed", self.sf_num_input) self.actionbar.pack_start(self.subframeNuminput) self.maxframeLabel = Gtk.Label("/%d" % (self.maxFrames)) self.actionbar.pack_start(self.maxframeLabel) self.fButton = Gtk.Button(label="=>") self.fButton.connect("clicked", self.fw_button_clicked) self.actionbar.pack_start(self.fButton)
def set_main_widgets(self, container): main_box = Gtk.VBox() # Action Bar action_bar = Gtk.ActionBar() swap_feed_source_bttn = Gtk.Button("Sources") swap_feed_source_bttn.connect("clicked", self.swap_feed_source_bttn) action_bar.add(swap_feed_source_bttn) #action_bar.add(Gtk.Label("Category:")) #action_bar.add(Gtk.ComboBox.new_with_entry()) #action_bar.add(Gtk.Label("Site:")) #action_bar.add(Gtk.ComboBox.new_with_entry()) # ListBox self.scrolled_window = Gtk.ScrolledWindow() # Add to the view main_box.pack_start(action_bar, False, False, 0) main_box.pack_start(self.scrolled_window, True, True, 0) container.add2(main_box)
def __init__(self, grid, code) -> None: self.buffer = code.get_buffer() self.code = code self.tree_store = Gtk.TreeStore(str, int, int) self.tree_view = Gtk.TreeView(model=self.tree_store) self.select = self.tree_view.get_selection() self.select.connect("changed", self.on_tree_selection_changed) self.buffer.connect("new-line", self.refresh) renderer_text = Gtk.CellRendererText() renderer_pic = Gtk.CellRendererPixbuf() self.column = Gtk.TreeViewColumn() self.column.pack_start(renderer_pic, False) self.column.pack_end(renderer_text, True) self.column.add_attribute(renderer_text, "text", 0) self.column.set_cell_data_func(renderer_pic,self.render_pix_buf) self.tree_view.append_column(self.column) self.button_box = Gtk.ActionBar() self.button_refresh = Gtk.Button.new_with_label(label="Refresh") self.button_refresh.set_relief(Gtk.ReliefStyle.NONE) self.button_refresh.connect("clicked", self.refresh) self.button_box.add(self.button_refresh) self.scrollable_treelist = Gtk.ScrolledWindow() self.scrollable_treelist.set_vexpand(True) self.scrollable_treelist.set_hexpand(True) self.scrollable_treelist.add(self.tree_view) grid.attach(self.scrollable_treelist, 0, 0, 3, 10) grid.attach_next_to( self.button_box, self.scrollable_treelist,Gtk.PositionType.BOTTOM, 3, 1) self.grid = grid # self.grid.set_column_homogeneous(True) self.grid.set_hexpand(True) self.button_box.set_hexpand(True) self.button_box.set_vexpand(False) # grid.set_row_spacing(6) self.grid.set_row_homogeneous(True) self.grid.show_all()
def __init__(self): Gtk.Window.__init__(self) self.set_title("ActionBar") self.set_default_size(200, 200) self.connect("destroy", Gtk.main_quit) grid = Gtk.Grid() self.add(grid) label = Gtk.Label() label.set_vexpand(True) grid.attach(label, 0, 0, 1, 1) actionbar = Gtk.ActionBar() actionbar.set_hexpand(True) grid.attach(actionbar, 0, 1, 1, 1) button = Gtk.Button("Cut") actionbar.pack_start(button) button = Gtk.Button("Copy") actionbar.pack_start(button) button = Gtk.Button("Paste") actionbar.pack_end(button)
def __init__(self): Gtk.Window.__init__(self) self.get_settings().set_property("gtk-application-prefer-dark-theme", True) self.connect('destroy', lambda x: Gtk.main_quit()) # Layout self.box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0) self.add(self.box) self.abar = Gtk.ActionBar() self.box.pack_end(self.abar, False, False, 0) self.build_contents() # Finalize the window itself self.set_titlebar(self.headerbar()) self.set_title("Foreign Package Installer") self.set_icon_name("system-software-install") self.set_size_request(600, 450) self.set_position(Gtk.WindowPosition.CENTER) self.show_all()
def __init__(self): Gtk.Window.__init__(self, title="ASCIIPlayback") self.set_default_size(0, 0) if len(sys.argv) > 1: self.filename = sys.argv[1] self.player = ASCIIPlayback(ASCIImation(filename=self.filename)) else: self.filename = "" blank_asciimation = ASCIImation(font_family='monospace', size=[19, 3]) blank_asciimation.frames.append( Frame(text='\n No file loaded! \n')) self.player = ASCIIPlayback(asciimation=blank_asciimation) self.hb = Gtk.HeaderBar() self.update_headerbar() button = Gtk.Button(image=Gtk.Image.new_from_gicon( Gio.ThemedIcon( name="document-open-symbolic"), Gtk.IconSize.BUTTON)) button.connect("clicked", self.do_open) self.hb.pack_start(button) box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.video = GtkASCIIPlayer(self.player) box.pack_start(self.video, True, True, 0) ab = Gtk.ActionBar() self.controls = GtkASCIIControls(self.player) ab.set_center_widget(self.controls) box.pack_end(ab, False, False, 0) self.add(box)
def __init__(self, model: HMIModel): super(SAOPControlWindow, self).__init__(default_width=500, default_height=400, title="SAOP HMI") self.hmi_model = model self.hmi_model.set_controller(self) ## Actions self.plan_button = Gtk.Button(label="Create") self.plan_button.connect("clicked", self.on_plan_clicked) self.cancel_button = Gtk.Button(label="Stop") self.cancel_button.connect("clicked", self.on_cancel_clicked) self.home_button = Gtk.Button(label="Go home") self.home_button.connect("clicked", self.on_home_clicked, None) self.home_button.set_sensitive(False) self.home_more_button = Gtk.MenuButton.new() self.home_more_button.set_direction(Gtk.ArrowType.UP) self.home_more_button.set_use_popover(True) self.propagate_button = Gtk.Button(label="Propagate") self.propagate_button.connect("clicked", self.on_propagate_clicked) self.action_bar = Gtk.ActionBar() self.action_bar.pack_start(Gtk.Label("Plan:")) self.action_bar.pack_start(self.plan_button) self.action_bar.pack_start(self.cancel_button) home_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) Gtk.StyleContext.add_class(home_box.get_style_context(), "linked") home_box.pack_start(self.home_button, False, False, 0) home_box.pack_start(self.home_more_button, False, False, 0) self.action_bar.pack_start(home_box) self.action_bar.pack_start( Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)) self.action_bar.pack_start(Gtk.Label("Wildfire:")) self.action_bar.pack_start(self.propagate_button) ## Visualization control # Empty drawing area that will be replaced by a matplotlib figure default_fig = matplotlib.figure.Figure() self.canvas = FigureCanvas(default_fig) self.navigation_toolbar = NavigationToolbar(self.canvas, self) # Visualization Checkboxes scrolled_flowbox = Gtk.ScrolledWindow() scrolled_flowbox.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) flowbox = Gtk.FlowBox() flowbox.set_valign(Gtk.Align.START) flowbox.set_max_children_per_line(30) flowbox.set_selection_mode(Gtk.SelectionMode.NONE) # Checkboxes def toggle_pause(button): self.set_update_plot(not button.props.active) pause_toggle = Gtk.ToggleButton("Pause") pause_toggle.props.active = False pause_toggle.connect("toggled", toggle_pause) pause_toggle.toggled() flowbox.add(pause_toggle) display_label = Gtk.Label("Display:") flowbox.add(display_label) def toggle_elevation(button): self.hmi_model.elevation_map.drawable = button.get_active() elevation_toggle = SAOPControlWindow._check_button_with_action( "Elevation", toggle_elevation) flowbox.add(elevation_toggle) def toggle_wildfire(button): self.hmi_model.wildfire_map.drawable = button.get_active() wildfire_toggle = SAOPControlWindow._check_button_with_action( "Wildfire", toggle_wildfire) flowbox.add(wildfire_toggle) def toggle_wildfire_observed(button): self.hmi_model.wildfire_map_observed.drawable = button.get_active() wildfire_observed_toggle = SAOPControlWindow._check_button_with_action( "Observed wildfire", toggle_wildfire_observed) flowbox.add(wildfire_observed_toggle) def toggle_wildfire_predicted(button): self.hmi_model.wildfire_map_predicted.drawable = button.get_active( ) wildfire_predicted_toggle = SAOPControlWindow._check_button_with_action( "Predicted wildfire", toggle_wildfire_predicted) flowbox.add(wildfire_predicted_toggle) def toggle_uav(button): self.hmi_model.uav_state.drawable = button.get_active() uav_toggle = SAOPControlWindow._check_button_with_action( "UAV", toggle_uav) flowbox.add(uav_toggle) def toggle_trails(button): self.hmi_model.uav_trail.drawable = button.get_active() trail_toggle = SAOPControlWindow._check_button_with_action( "UAV trails", toggle_trails) flowbox.add(trail_toggle) def toggle_plan(button): self.hmi_model.trajectories.drawable = button.get_active() plan_toggle = SAOPControlWindow._check_button_with_action( "Plan", toggle_plan) flowbox.add(plan_toggle) scrolled_flowbox.add(flowbox) self.figure_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0, border_width=0) self.figure_box.pack_start(self.navigation_toolbar, False, True, 0) self.figure_box.pack_start(self.canvas, True, True, 0) self.figure_box.pack_start(scrolled_flowbox, False, False, 0) ## Side panel right_panel = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) # View of ROS logs log_textview = Gtk.TextView() log_textview.set_editable(False) log_textview.set_monospace(True) log_textview.set_wrap_mode(Gtk.WrapMode.WORD_CHAR) self.log_textbuffer = log_textview.get_buffer() self.tag_bold = self.log_textbuffer.create_tag( "bold", weight=Pango.Weight.BOLD) log_scrolled = Gtk.ScrolledWindow() log_scrolled.add(log_textview) right_panel.pack_start(log_scrolled, True, True, 0) # UAV controls # self.content_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6, # border_width=12) self.content_panned = Gtk.Paned(orientation=Gtk.Orientation.HORIZONTAL) self.content_panned.pack1(self.figure_box, True, True) self.content_panned.pack2(right_panel, False, True) box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0, border_width=0) box.pack_start(self.content_panned, True, True, 0) box.pack_start(self.action_bar, False, False, 0) self.add(box)
def sidebar(self): left = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) expander_scroll = Gtk.ScrolledWindow() expander_scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) expander_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) expander = RevealerExpander("_View") view = Gtk.ListBox() view.set_selection_mode(Gtk.SelectionMode.NONE) optionsize = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL) row = Gtk.ListBoxRow() hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12) row.add(hbox) label = Gtk.Label("Loop", xalign=0) switch = Gtk.Switch() switch.set_active(True) hbox.pack_start(label, True, True, 12) hbox.pack_start(switch, False, True, 12) Gtk.StyleContext.add_class(row.get_style_context(), "option") view.add(row) row = Gtk.ListBoxRow() hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12) row.add(hbox) label = Gtk.Label("ms/frame", xalign=0) spin = Gtk.SpinButton.new_with_range(0, 1000, 5) spin.set_value(100) optionsize.add_widget(spin) hbox.pack_start(label, True, True, 12) hbox.pack_start(spin, False, True, 12) Gtk.StyleContext.add_class(row.get_style_context(), "option") view.add(row) row = Gtk.ListBoxRow() hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12) row.add(hbox) label = Gtk.Label("Font", xalign=0) font = Gtk.FontButton.new_with_font("Courier New 12") optionsize.add_widget(font) hbox.pack_start(label, True, True, 12) hbox.pack_start(font, False, False, 12) Gtk.StyleContext.add_class(row.get_style_context(), "option") view.add(row) row = Gtk.ListBoxRow() hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12) row.add(hbox) label = Gtk.Label("Width", xalign=0) spin = Gtk.SpinButton.new_with_range(1, 1000, 1) spin.set_value(20) optionsize.add_widget(spin) hbox.pack_start(label, True, True, 12) hbox.pack_start(spin, False, True, 12) Gtk.StyleContext.add_class(row.get_style_context(), "option") view.add(row) row = Gtk.ListBoxRow() hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12) row.add(hbox) label = Gtk.Label("Height", xalign=0) spin = Gtk.SpinButton.new_with_range(1, 1000, 1) spin.set_value(10) optionsize.add_widget(spin) hbox.pack_start(label, True, True, 12) hbox.pack_start(spin, False, True, 12) Gtk.StyleContext.add_class(row.get_style_context(), "option") view.add(row) expander.add(view) expander.set_expanded(True) expander_box.add(expander) expander = RevealerExpander("_Color") expander.add(Gtk.ColorButton()) expander_box.add(expander) expander = RevealerExpander("_Frame") expander.add(Gtk.FontButton()) expander_box.add(expander) expander = RevealerExpander("_Layer") expander.add(Gtk.FontButton()) expander_box.add(expander) expander = RevealerExpander("_Replace") expander.add(Gtk.FontButton()) expander_box.add(expander) expander_scroll.add(expander_box) left.pack_start(expander_scroll, True, True, 0) ab = Gtk.ActionBar() ab.set_center_widget(self.stack_switcher) left.pack_end(ab, False, False, 0) self.hsize_group.add_widget(left) return left
def __init__(self, app): View.__init__(self, app) self.selected_locations = [] self.known_paths = set() self._set_title() self.box = Gtk.ListBox() self.box.set_selection_mode(Gtk.SelectionMode.NONE) self.box.set_hexpand(True) self.box.set_placeholder(Gtk.Label('No locations mounted.')) self.box.set_valign(Gtk.Align.FILL) self.box.set_vexpand(True) self.chooser_button = IconButton('list-add-symbolic', 'Add Location') self.chooser_button.connect('clicked', self.on_chooser_button_clicked) self.file_chooser = Gtk.FileChooserWidget() self.file_chooser.set_select_multiple(True) self.file_chooser.set_action(Gtk.FileChooserAction.SELECT_FOLDER) self.file_chooser.set_create_folders(False) self.stack = Gtk.Stack() self.stack.set_transition_type(Gtk.StackTransitionType.SLIDE_UP) scw = Gtk.ScrolledWindow() scw.add(self.box) self.stack.add_named(scw, 'list') self.stack.add_named(self.file_chooser, 'chooser') self.box.set_activate_on_single_click(True) self.box.set_filter_func(self._filter_func) self.box.connect('row-activated', self.on_row_clicked) self.search_entry.connect('search-changed', self.on_search_changed) self.volume_monitor = Gio.VolumeMonitor.get() self.recent_mgr = Gtk.RecentManager.get_default() self.recent_mgr.connect('changed', self.refill_entries) self.volume_monitor.connect('volume-changed', self.refill_entries) self.volume_monitor.connect('drive-changed', self.refill_entries) self.volume_monitor.connect('mount-changed', self.refill_entries) self.refill_entries() run_button = IconButton('edit-find-symbolic', 'Scan folders') run_button.connect('clicked', self._run_clicked) run_button.get_style_context().add_class( Gtk.STYLE_CLASS_SUGGESTED_ACTION) del_button = IconButton('user-trash-symbolic', 'Remove from list') del_button.connect('clicked', self._del_clicked) self.selected_label = Gtk.Label() self.selected_label.get_style_context().add_class( Gtk.STYLE_CLASS_DIM_LABEL) action_bar = Gtk.ActionBar() action_bar.pack_start(del_button) action_bar.set_center_widget(self.selected_label) action_bar.pack_end(run_button) self.revealer = Gtk.Revealer() self.revealer.add(action_bar) self.revealer.set_hexpand(True) self.revealer.set_halign(Gtk.Align.FILL) grid = Gtk.Grid() grid.attach(self.stack, 0, 0, 1, 1) grid.attach(self.revealer, 0, 1, 1, 1) self.add(grid)
def __init__(self, style_css=None, *args, **kwargs): super(Gtk.ApplicationWindow, self).__init__(*args, **kwargs) self.set_icon_from_file('resources/images/icon128.png') self.set_size_request(1000, -1) self.results = [] # Create the header bar. self.header = Gtk.HeaderBar() self.header.set_title('Natural One') self.header.set_show_close_button(True) self.set_titlebar(self.header) # Create the stack. self.stack = Gtk.Stack() self.stack.set_vexpand(False) self.stack.set_hexpand(False) self.stack.set_size_request(475, 1) self.stack.set_transition_type( Gtk.StackTransitionType.SLIDE_LEFT_RIGHT, ) self.stack_switcher = Gtk.StackSwitcher() self.stack_switcher.set_stack(self.stack) self.header.set_custom_title(self.stack_switcher) win_pane = Gtk.Paned(orientation=Gtk.Orientation.HORIZONTAL) win_pane.pack1(self.stack, True, False) self.add(win_pane) # Create the header buttons. header_btn_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) header_btn_box.set_hexpand(False) Gtk.StyleContext.add_class( header_btn_box.get_style_context(), 'linked', ) self.header.pack_end(header_btn_box) self.reset_btn = Gtk.Button() self.reset_btn.add(load_symbolic('edit-undo')) self.reset_btn.set_tooltip_text('Reset all fields') header_btn_box.add(self.reset_btn) self.clear_btn = Gtk.Button() self.clear_btn.add(load_symbolic('edit-clear')) self.clear_btn.set_tooltip_text('Clear rolls') header_btn_box.add(self.clear_btn) # Create the Basic grid. dice_grid = Gtk.Grid() dice_grid.set_row_spacing(18) dice_grid.set_column_spacing(12) dice_grid.set_border_width(18) # Create the dice: d4 d4_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( 'resources/images/d4.png', 60, 60, True, ) d4_img = Gtk.Image.new_from_pixbuf(d4_pixbuf) dice_grid.attach(d4_img, 0, 0, 1, 1) self.d4_count_ent = Gtk.Entry() self.d4_count_ent.set_placeholder_text('1') self.d4_count_ent.set_width_chars(4) self.d4_count_ent.props.xalign = 0.5 dice_grid.attach_next_to( self.d4_count_ent, d4_img, Gtk.PositionType.RIGHT, 1, 1, ) d4_d_lbl = Gtk.Label('d4') dice_grid.attach_next_to( d4_d_lbl, self.d4_count_ent, Gtk.PositionType.RIGHT, 1, 1, ) d4_plus_lbl = Gtk.Label('+') dice_grid.attach_next_to( d4_plus_lbl, d4_d_lbl, Gtk.PositionType.RIGHT, 1, 1, ) self.d4_mod_ent = Gtk.Entry() self.d4_mod_ent.set_placeholder_text('0') self.d4_mod_ent.set_width_chars(4) self.d4_mod_ent.props.xalign = 0.5 dice_grid.attach_next_to( self.d4_mod_ent, d4_plus_lbl, Gtk.PositionType.RIGHT, 1, 1, ) self.d4_btn = Gtk.Button('Roll') dice_grid.attach_next_to( self.d4_btn, self.d4_mod_ent, Gtk.PositionType.RIGHT, 1, 1, ) # Create the dice: d6 d6_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( 'resources/images/d6.png', 60, 60, True, ) d6_img = Gtk.Image.new_from_pixbuf(d6_pixbuf) dice_grid.attach_next_to(d6_img, d4_img, Gtk.PositionType.BOTTOM, 1, 1) self.d6_count_ent = Gtk.Entry() self.d6_count_ent.set_placeholder_text('1') self.d6_count_ent.set_width_chars(4) self.d6_count_ent.props.xalign = 0.5 dice_grid.attach_next_to( self.d6_count_ent, d6_img, Gtk.PositionType.RIGHT, 1, 1, ) d6_d_lbl = Gtk.Label('d6') dice_grid.attach_next_to( d6_d_lbl, self.d6_count_ent, Gtk.PositionType.RIGHT, 1, 1, ) d6_plus_lbl = Gtk.Label('+') dice_grid.attach_next_to( d6_plus_lbl, d6_d_lbl, Gtk.PositionType.RIGHT, 1, 1, ) self.d6_mod_ent = Gtk.Entry() self.d6_mod_ent.set_placeholder_text('0') self.d6_mod_ent.set_width_chars(4) self.d6_mod_ent.props.xalign = 0.5 dice_grid.attach_next_to( self.d6_mod_ent, d6_plus_lbl, Gtk.PositionType.RIGHT, 1, 1, ) self.d6_btn = Gtk.Button('Roll') dice_grid.attach_next_to( self.d6_btn, self.d6_mod_ent, Gtk.PositionType.RIGHT, 1, 1, ) # Create the dice: d8 d8_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( 'resources/images/d8.png', 60, 60, True, ) d8_img = Gtk.Image.new_from_pixbuf(d8_pixbuf) dice_grid.attach_next_to(d8_img, d6_img, Gtk.PositionType.BOTTOM, 1, 1) self.d8_count_ent = Gtk.Entry() self.d8_count_ent.set_placeholder_text('1') self.d8_count_ent.set_width_chars(4) self.d8_count_ent.props.xalign = 0.5 dice_grid.attach_next_to( self.d8_count_ent, d8_img, Gtk.PositionType.RIGHT, 1, 1, ) d8_d_lbl = Gtk.Label('d8') dice_grid.attach_next_to( d8_d_lbl, self.d8_count_ent, Gtk.PositionType.RIGHT, 1, 1, ) d8_plus_lbl = Gtk.Label('+') dice_grid.attach_next_to( d8_plus_lbl, d8_d_lbl, Gtk.PositionType.RIGHT, 1, 1, ) self.d8_mod_ent = Gtk.Entry() self.d8_mod_ent.set_placeholder_text('0') self.d8_mod_ent.set_width_chars(4) self.d8_mod_ent.props.xalign = 0.5 dice_grid.attach_next_to( self.d8_mod_ent, d8_plus_lbl, Gtk.PositionType.RIGHT, 1, 1, ) self.d8_btn = Gtk.Button('Roll') dice_grid.attach_next_to( self.d8_btn, self.d8_mod_ent, Gtk.PositionType.RIGHT, 1, 1, ) # Create the dice: d10 d10_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( 'resources/images/d10.png', 60, 60, True, ) d10_img = Gtk.Image.new_from_pixbuf(d10_pixbuf) dice_grid.attach_next_to( d10_img, d8_img, Gtk.PositionType.BOTTOM, 1, 1, ) self.d10_count_ent = Gtk.Entry() self.d10_count_ent.set_placeholder_text('1') self.d10_count_ent.set_width_chars(4) self.d10_count_ent.props.xalign = 0.5 dice_grid.attach_next_to( self.d10_count_ent, d10_img, Gtk.PositionType.RIGHT, 1, 1, ) d10_d_lbl = Gtk.Label('d10') dice_grid.attach_next_to( d10_d_lbl, self.d10_count_ent, Gtk.PositionType.RIGHT, 1, 1, ) d10_plus_lbl = Gtk.Label('+') dice_grid.attach_next_to( d10_plus_lbl, d10_d_lbl, Gtk.PositionType.RIGHT, 1, 1, ) self.d10_mod_ent = Gtk.Entry() self.d10_mod_ent.set_placeholder_text('0') self.d10_mod_ent.set_width_chars(4) self.d10_mod_ent.props.xalign = 0.5 dice_grid.attach_next_to( self.d10_mod_ent, d10_plus_lbl, Gtk.PositionType.RIGHT, 1, 1, ) self.d10_btn = Gtk.Button('Roll') dice_grid.attach_next_to( self.d10_btn, self.d10_mod_ent, Gtk.PositionType.RIGHT, 1, 1, ) # Create the dice: d12 d12_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( 'resources/images/d12.png', 60, 60, True, ) d12_img = Gtk.Image.new_from_pixbuf(d12_pixbuf) dice_grid.attach_next_to( d12_img, d10_img, Gtk.PositionType.BOTTOM, 1, 1, ) self.d12_count_ent = Gtk.Entry() self.d12_count_ent.set_placeholder_text('1') self.d12_count_ent.set_width_chars(4) self.d12_count_ent.props.xalign = 0.5 dice_grid.attach_next_to( self.d12_count_ent, d12_img, Gtk.PositionType.RIGHT, 1, 1, ) d12_d_lbl = Gtk.Label('d12') dice_grid.attach_next_to( d12_d_lbl, self.d12_count_ent, Gtk.PositionType.RIGHT, 1, 1, ) d12_plus_lbl = Gtk.Label('+') dice_grid.attach_next_to( d12_plus_lbl, d12_d_lbl, Gtk.PositionType.RIGHT, 1, 1, ) self.d12_mod_ent = Gtk.Entry() self.d12_mod_ent.set_placeholder_text('0') self.d12_mod_ent.set_width_chars(4) self.d12_mod_ent.props.xalign = 0.5 dice_grid.attach_next_to( self.d12_mod_ent, d12_plus_lbl, Gtk.PositionType.RIGHT, 1, 1, ) self.d12_btn = Gtk.Button('Roll') dice_grid.attach_next_to( self.d12_btn, self.d12_mod_ent, Gtk.PositionType.RIGHT, 1, 1, ) # Create the dice: d20 d20_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( 'resources/images/d20.png', 60, 60, True, ) d20_img = Gtk.Image.new_from_pixbuf(d20_pixbuf) dice_grid.attach_next_to( d20_img, d12_img, Gtk.PositionType.BOTTOM, 1, 1, ) self.d20_count_ent = Gtk.Entry() self.d20_count_ent.set_placeholder_text('1') self.d20_count_ent.set_width_chars(4) self.d20_count_ent.props.xalign = 0.5 dice_grid.attach_next_to( self.d20_count_ent, d20_img, Gtk.PositionType.RIGHT, 1, 1, ) d20_d_lbl = Gtk.Label('d20') dice_grid.attach_next_to( d20_d_lbl, self.d20_count_ent, Gtk.PositionType.RIGHT, 1, 1, ) d20_plus_lbl = Gtk.Label('+') dice_grid.attach_next_to( d20_plus_lbl, d20_d_lbl, Gtk.PositionType.RIGHT, 1, 1, ) self.d20_mod_ent = Gtk.Entry() self.d20_mod_ent.set_placeholder_text('0') self.d20_mod_ent.set_width_chars(4) self.d20_mod_ent.props.xalign = 0.5 dice_grid.attach_next_to( self.d20_mod_ent, d20_plus_lbl, Gtk.PositionType.RIGHT, 1, 1, ) self.d20_btn = Gtk.Button('Roll') dice_grid.attach_next_to( self.d20_btn, self.d20_mod_ent, Gtk.PositionType.RIGHT, 1, 1, ) # Create the dice: custom dq_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( 'resources/images/general.png', 60, 60, True, ) dq_img = Gtk.Image.new_from_pixbuf(dq_pixbuf) dice_grid.attach_next_to( dq_img, d20_img, Gtk.PositionType.BOTTOM, 1, 1, ) self.dq_count_ent = Gtk.Entry() self.dq_count_ent.set_placeholder_text('1') self.dq_count_ent.set_width_chars(4) self.dq_count_ent.props.xalign = 0.5 dice_grid.attach_next_to( self.dq_count_ent, dq_img, Gtk.PositionType.RIGHT, 1, 1, ) dq_box = Gtk.Box() dq_d_lbl = Gtk.Label('d') dq_d_lbl.set_alignment(1, 0.5) dq_box.add(dq_d_lbl) self.dq_size_ent = Gtk.Entry() self.dq_size_ent.set_width_chars(4) self.dq_size_ent.props.xalign = 0.5 self.dq_size_ent.set_margin_left(5) self.dq_error_popover = Gtk.Popover() self.dq_error_popover.set_relative_to(self.dq_size_ent) dq_box.add(self.dq_size_ent) dice_grid.attach_next_to( dq_box, self.dq_count_ent, Gtk.PositionType.RIGHT, 1, 1, ) dq_plus_lbl = Gtk.Label('+') dice_grid.attach_next_to( dq_plus_lbl, dq_box, Gtk.PositionType.RIGHT, 1, 1, ) self.dq_mod_ent = Gtk.Entry() self.dq_mod_ent.set_placeholder_text('0') self.dq_mod_ent.set_width_chars(4) self.dq_mod_ent.props.xalign = 0.5 dice_grid.attach_next_to( self.dq_mod_ent, dq_plus_lbl, Gtk.PositionType.RIGHT, 1, 1, ) self.dq_btn = Gtk.Button('Roll') dice_grid.attach_next_to( self.dq_btn, self.dq_mod_ent, Gtk.PositionType.RIGHT, 1, 1, ) # Create the minimum value entry. min_value_lbl = Gtk.Label('Minimum value') min_value_lbl.set_alignment(1, 0.5) dice_grid.attach_next_to( min_value_lbl, dq_img, Gtk.PositionType.BOTTOM, 2, 1, ) self.min_value_ent = Gtk.Entry() self.min_value_ent.set_placeholder_text('No minimum value') dice_grid.attach_next_to( self.min_value_ent, min_value_lbl, Gtk.PositionType.RIGHT, 4, 1, ) # Create the modifier check box. self.dice_mod_chk = Gtk.CheckButton('Add modifier to every roll') self.dice_mod_chk.set_active(True) self.dice_mod_chk.set_halign(Gtk.Align.CENTER) self.dice_mod_chk.set_hexpand(True) dice_grid.attach_next_to( self.dice_mod_chk, min_value_lbl, Gtk.PositionType.BOTTOM, 6, 1, ) # Create the Combat grid. combat_grid = Gtk.Grid() combat_grid.set_row_spacing(5) combat_grid.set_column_spacing(12) combat_grid.set_border_width(18) # Create the attack roll main label. atk_lbl = Gtk.Label() atk_lbl.set_markup('<span size="x-large">Attack Rolls</span>') atk_lbl.set_alignment(0, 0.5) atk_lbl.set_margin_bottom(5) combat_grid.add(atk_lbl) # Create the number of attacks row. num_atks_lbl = Gtk.Label('Attack count') num_atks_lbl.set_alignment(1, 0.5) combat_grid.attach_next_to( num_atks_lbl, atk_lbl, Gtk.PositionType.BOTTOM, 1, 1, ) self.num_atks_ent = Gtk.Entry() self.num_atks_ent.set_hexpand(True) self.num_atks_ent.set_placeholder_text('1') combat_grid.attach_next_to( self.num_atks_ent, num_atks_lbl, Gtk.PositionType.RIGHT, 3, 1, ) # Create the modifiers row. mod_atks_lbl = Gtk.Label('Modifiers') mod_atks_lbl.set_alignment(1, 0.5) combat_grid.attach_next_to( mod_atks_lbl, num_atks_lbl, Gtk.PositionType.BOTTOM, 1, 1, ) self.mod_atks_ent = Gtk.Entry() self.mod_atks_ent.set_hexpand(True) self.mod_atks_ent.set_placeholder_text('0') combat_grid.attach_next_to( self.mod_atks_ent, mod_atks_lbl, Gtk.PositionType.RIGHT, 3, 1, ) # Create the critical range row. crit_atks_lbl = Gtk.Label('Critical range') crit_atks_lbl.set_alignment(1, 0.5) combat_grid.attach_next_to( crit_atks_lbl, mod_atks_lbl, Gtk.PositionType.BOTTOM, 1, 1, ) crit_atks_box = Gtk.Box(Gtk.Orientation.HORIZONTAL) self.crit_atks_ent = Gtk.Entry() self.crit_atks_ent.set_hexpand(True) self.crit_atks_ent.set_placeholder_text('20') crit_20_atks_lbl = Gtk.Label('- 20') crit_20_atks_lbl.set_alignment(1, 0.5) crit_20_atks_lbl.set_margin_left(5) crit_atks_box.pack_start(self.crit_atks_ent, True, True, 0) crit_atks_box.pack_start(crit_20_atks_lbl, False, False, 0) combat_grid.attach_next_to( crit_atks_box, crit_atks_lbl, Gtk.PositionType.RIGHT, 3, 1, ) # Create the critical options rows. crit_opt_atks_lbl = Gtk.Label('Critical options') crit_opt_atks_lbl.set_alignment(1, 0.5) combat_grid.attach_next_to( crit_opt_atks_lbl, crit_atks_lbl, Gtk.PositionType.BOTTOM, 1, 1, ) self.confirm_atks_chk = Gtk.CheckButton('Confirm critical hits') self.confirm_atks_chk.set_active(True) combat_grid.attach_next_to( self.confirm_atks_chk, crit_opt_atks_lbl, Gtk.PositionType.RIGHT, 3, 1, ) crit_opt_atks_placeholder = Gtk.Label('') combat_grid.attach_next_to( crit_opt_atks_placeholder, crit_opt_atks_lbl, Gtk.PositionType.BOTTOM, 1, 1, ) self.stop_atks_chk = Gtk.CheckButton('Stop on critical fail') self.stop_atks_chk.set_active(True) combat_grid.attach_next_to( self.stop_atks_chk, crit_opt_atks_placeholder, Gtk.PositionType.RIGHT, 3, 1, ) # Create the attack roll button. atk_btn_placeholder = Gtk.Label('') combat_grid.attach_next_to( atk_btn_placeholder, crit_opt_atks_placeholder, Gtk.PositionType.BOTTOM, 2, 1 ) self.atk_btn = Gtk.Button('Roll') combat_grid.attach_next_to( self.atk_btn, atk_btn_placeholder, Gtk.PositionType.RIGHT, 2, 1, ) # Create the damage roll main label. dam_lbl = Gtk.Label() dam_lbl.set_markup('<span size="x-large">Damage Rolls</span>') dam_lbl.set_alignment(0, 0.5) dam_lbl.set_margin_top(15) dam_lbl.set_margin_bottom(5) combat_grid.attach_next_to( dam_lbl, atk_btn_placeholder, Gtk.PositionType.BOTTOM, 4, 1, ) # Create the system row. sys_dam_lbl = Gtk.Label('System') sys_dam_lbl.set_alignment(1, 0.5) combat_grid.attach_next_to( sys_dam_lbl, dam_lbl, Gtk.PositionType.BOTTOM, 1, 1, ) sys_btn_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) sys_btn_box.set_hexpand(True) Gtk.StyleContext.add_class(sys_btn_box.get_style_context(), 'linked') self.sys_dam_cbox = Gtk.ComboBoxText.new() self.sys_dam_cbox.set_hexpand(True) sys_btn_box.add(self.sys_dam_cbox) self.sys_manage_btn = Gtk.Button() self.sys_manage_btn.add(load_symbolic('document-properties')) self.sys_manage_btn.set_tooltip_text('Add and manage systems') sys_btn_box.add(self.sys_manage_btn) combat_grid.attach_next_to( sys_btn_box, sys_dam_lbl, Gtk.PositionType.RIGHT, 3, 1, ) # Create the weapon row. weap_dam_lbl = Gtk.Label('Weapon') weap_dam_lbl.set_alignment(1, 0) combat_grid.attach_next_to( weap_dam_lbl, sys_dam_lbl, Gtk.PositionType.BOTTOM, 1, 1, ) dam_scroll_win = Gtk.ScrolledWindow() dam_scroll_win.set_hexpand(True) dam_scroll_win.set_vexpand(True) self.weap_dam_store = Gtk.TreeStore(str) self.weap_dam_tree = Gtk.TreeView() self.weap_dam_tree.set_model(self.weap_dam_store) self.weap_dam_tree.set_headers_visible(False) dam_scroll_win.add(self.weap_dam_tree) weap_dam_crend = Gtk.CellRendererText() weap_dam_col = Gtk.TreeViewColumn('Weapons', weap_dam_crend, text=0) self.weap_dam_tree.append_column(weap_dam_col) combat_grid.attach_next_to( dam_scroll_win, weap_dam_lbl, Gtk.PositionType.RIGHT, 3, 1, ) self.weap_error_popover = Gtk.Popover() self.weap_error_popover.set_relative_to(self.weap_dam_tree) # Create the number of attacks row. num_dam_lbl = Gtk.Label('Attack count') num_dam_lbl.set_alignment(1, 0.5) combat_grid.attach_next_to( num_dam_lbl, weap_dam_lbl, Gtk.PositionType.BOTTOM, 1, 1, ) self.num_dam_ent = Gtk.Entry() self.num_dam_ent.set_hexpand(True) self.num_dam_ent.set_placeholder_text('1') combat_grid.attach_next_to( self.num_dam_ent, num_dam_lbl, Gtk.PositionType.RIGHT, 3, 1, ) # Create the damage modifier row. mod_dam_lbl = Gtk.Label('Modifiers') mod_dam_lbl.set_alignment(1, 0.5) combat_grid.attach_next_to( mod_dam_lbl, num_dam_lbl, Gtk.PositionType.BOTTOM, 1, 1, ) self.mod_dam_ent = Gtk.Entry() self.mod_dam_ent.set_hexpand(True) self.mod_dam_ent.set_placeholder_text('0') combat_grid.attach_next_to( self.mod_dam_ent, mod_dam_lbl, Gtk.PositionType.RIGHT, 3, 1, ) # Create the minimum value row. min_dam_lbl = Gtk.Label('Minimum value') min_dam_lbl.set_alignment(1, 0.5) combat_grid.attach_next_to( min_dam_lbl, mod_dam_lbl, Gtk.PositionType.BOTTOM, 1, 1, ) self.min_dam_ent = Gtk.Entry() self.min_dam_ent.set_hexpand(True) self.min_dam_ent.set_placeholder_text('No minimum value') combat_grid.attach_next_to( self.min_dam_ent, min_dam_lbl, Gtk.PositionType.RIGHT, 3, 1, ) # Create the size row. size_lbl = Gtk.Label('Size') size_lbl.set_alignment(1, 0.5) combat_grid.attach_next_to( size_lbl, min_dam_lbl, Gtk.PositionType.BOTTOM, 1, 1, ) size_store = Gtk.ListStore(str, int) for size in SIZE_PROGRESSION: size_store.append(size) self.size_cbox = Gtk.ComboBox.new_with_model(size_store) self.size_cbox.set_active(SizeProgression.MEDIUM) size_renderer = Gtk.CellRendererText() self.size_cbox.pack_start(size_renderer, True) self.size_cbox.add_attribute(size_renderer, 'text', 0) combat_grid.attach_next_to( self.size_cbox, size_lbl, Gtk.PositionType.RIGHT, 3, 1, ) # Create the damage roll button. dam_btn_placeholder = Gtk.Label('') combat_grid.attach_next_to( dam_btn_placeholder, size_lbl, Gtk.PositionType.BOTTOM, 2, 1, ) dam_btn_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) dam_btn_box.set_hexpand(True) Gtk.StyleContext.add_class(dam_btn_box.get_style_context(), 'linked') self.crit_dam_btn = Gtk.ToggleButton() self.crit_dam_btn.add(load_symbolic('starred')) self.crit_dam_btn.set_tooltip_text('Roll a critical hit') self.crit_dam_btn.set_active(False) dam_btn_box.add(self.crit_dam_btn) self.dam_btn = Gtk.Button('Roll') self.dam_btn.set_hexpand(True) dam_btn_box.add(self.dam_btn) combat_grid.attach_next_to( dam_btn_box, dam_btn_placeholder, Gtk.PositionType.RIGHT, 2, 1, ) # Create the Templates grid. templates_grid = Gtk.Grid() templates_grid.set_row_spacing(0) templates_grid.set_column_spacing(12) templates_grid.set_border_width(18) # Create the template list main label. list_lbl = Gtk.Label() list_lbl.set_markup('<span size="x-large">Templates</span>') list_lbl.set_alignment(0, 0.5) list_lbl.set_margin_bottom(10) templates_grid.add(list_lbl) # Create the template list. templates_scroll_win = Gtk.ScrolledWindow() templates_scroll_win.set_hexpand(True) templates_scroll_win.set_vexpand(True) templates_grid.attach_next_to( templates_scroll_win, list_lbl, Gtk.PositionType.BOTTOM, 1, 1, ) self.template_store = Gtk.ListStore(int, str, int) self.template_tree = Gtk.TreeView(model=self.template_store) self.template_tree.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE) self.template_tree.set_reorderable(True) renderer = Gtk.CellRendererText() renderer.set_padding(5, 5) column = Gtk.TreeViewColumn('Name', renderer, text=1) column.set_expand(True) self.template_tree.append_column(column) renderer = Gtk.CellRendererText() renderer.set_padding(5, 5) column = Gtk.TreeViewColumn('Rolls', renderer, text=2) self.template_tree.append_column(column) templates_scroll_win.add(self.template_tree) # Create the template list action bar. self.template_action_bar = Gtk.ActionBar() self.template_action_bar.get_style_context().add_class( 'inline-toolbar' ) templates_grid.attach_next_to( self.template_action_bar, templates_scroll_win, Gtk.PositionType.BOTTOM, 1, 1, ) # Create the template list buttons. template_edit_btn_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) Gtk.StyleContext.add_class( template_edit_btn_box.get_style_context(), 'linked', ) self.template_action_bar.pack_start(template_edit_btn_box) self.new_btn = Gtk.Button() self.new_btn.add(load_symbolic('list-add')) self.new_btn.set_tooltip_text('Create a new template') template_edit_btn_box.add(self.new_btn) self.list_edit_btn = Gtk.Button() self.list_edit_btn.add(load_symbolic('edit')) self.list_edit_btn.set_tooltip_text('Edit selected template') self.list_edit_btn_popover = Gtk.Popover() self.list_edit_btn_popover.set_relative_to(self.list_edit_btn) template_edit_btn_box.add(self.list_edit_btn) self.list_delete_btn = Gtk.Button() self.list_delete_btn.add(load_symbolic('list-remove')) self.list_delete_btn.set_tooltip_text('Delete selected template') self.list_delete_btn_popover = Gtk.Popover() self.list_delete_btn_popover.set_relative_to(self.list_delete_btn) template_edit_btn_box.add(self.list_delete_btn) template_file_btn_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) Gtk.StyleContext.add_class( template_file_btn_box.get_style_context(), 'linked', ) self.template_action_bar.pack_start(template_file_btn_box) self.list_save_btn = Gtk.Button() self.list_save_btn.add(load_symbolic('document-save')) self.list_save_btn.set_tooltip_text('Export templates') template_file_btn_box.add(self.list_save_btn) self.list_open_btn = Gtk.Button() self.list_open_btn.add(load_symbolic('document-open')) self.list_open_btn.set_tooltip_text('Import templates') template_file_btn_box.add(self.list_open_btn) template_roll_btn_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) Gtk.StyleContext.add_class( template_roll_btn_box.get_style_context(), 'linked', ) self.list_crit_btn = Gtk.ToggleButton() self.list_crit_btn.add(load_symbolic('starred')) self.list_crit_btn.set_tooltip_text('Apply critical hit') self.list_crit_btn.set_active(False) template_roll_btn_box.add(self.list_crit_btn) self.list_roll_btn = Gtk.Button('Roll template') self.list_roll_btn.set_tooltip_text('Roll selected template') template_roll_btn_box.add(self.list_roll_btn) self.template_action_bar.pack_end(template_roll_btn_box) # Create the template drag and drop help text. drag_list_lbl = Gtk.Label( 'Drag and drop to rearrange templates', ) drag_list_lbl.set_margin_top(10) drag_list_lbl.set_margin_bottom(10) templates_grid.attach_next_to( drag_list_lbl, self.template_action_bar, Gtk.PositionType.BOTTOM, 1, 1, ) # Create the quick roll main label. qck_lbl = Gtk.Label() qck_lbl.set_markup('<span size="x-large">Quick Roll</span>') qck_lbl.set_alignment(0, 0.5) qck_lbl.set_margin_bottom(10) templates_grid.attach_next_to( qck_lbl, drag_list_lbl, Gtk.PositionType.BOTTOM, 1, 1, ) # Create the quick roll input and button. qck_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) Gtk.StyleContext.add_class(qck_box.get_style_context(), 'linked') self.qck_ent = Gtk.Entry() self.qck_ent.set_hexpand(True) self.qck_ent.set_tooltip_text( 'Quick rolls allow the faster input of more complex sequences. ' 'For example, this will roll two groups of dice, one with an ' 'additional multiplier:\n\n' '(3d6+4)*2 + (2d4)' ) qck_box.add(self.qck_ent) self.qck_error_popover = Gtk.Popover() self.qck_error_popover.set_relative_to(self.qck_ent) self.qck_btn = Gtk.Button('Roll') qck_box.add(self.qck_btn) templates_grid.attach_next_to( qck_box, qck_lbl, Gtk.PositionType.BOTTOM, 1, 1, ) # Create the Initiative grid. init_grid = Gtk.Grid() init_grid.set_row_spacing(18) init_grid.set_column_spacing(12) init_grid.set_border_width(18) # Create the add initiative grid. add_init_grid = Gtk.Grid() add_init_grid.set_row_spacing(5) add_init_grid.set_column_spacing(12) init_grid.add(add_init_grid) # Create the add initiative label. add_init_lbl = Gtk.Label() add_init_lbl.set_markup('<span size="x-large">Add Initiative</span>') add_init_lbl.set_alignment(0, 0.5) add_init_grid.attach(add_init_lbl, 0, 0, 1, 1) # Create the initiative mode box. mode_init_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) mode_init_box.set_margin_top(5) mode_init_box.props.halign = Gtk.Align.CENTER add_init_grid.attach_next_to( mode_init_box, add_init_lbl, Gtk.PositionType.BOTTOM, 1, 1, ) # Create the initiative mode radiobuttons. self.roll_init_rbtn = Gtk.RadioButton.new_with_label_from_widget( None, 'Roll initiative', ) self.roll_init_rbtn.set_margin_left(10) self.add_init_rbtn = Gtk.RadioButton.new_with_label_from_widget( self.roll_init_rbtn, 'Add initiative directly', ) mode_init_box.pack_start(self.roll_init_rbtn, False, False, 0) mode_init_box.pack_start(self.add_init_rbtn, False, False, 0) # Create the roll initiative grid. roll_init_grid = Gtk.Grid() roll_init_grid.set_row_spacing(5) roll_init_grid.set_column_spacing(12) add_init_grid.attach_next_to( roll_init_grid, mode_init_box, Gtk.PositionType.BOTTOM, 1, 1, ) # Create the name label and entry. name_init_lbl = Gtk.Label('Name') name_init_lbl.set_alignment(1, 0.5) roll_init_grid.attach(name_init_lbl, 0, 0, 1, 1) self.name_init_ent = Gtk.Entry() self.name_init_ent.set_hexpand(True) roll_init_grid.attach_next_to( self.name_init_ent, name_init_lbl, Gtk.PositionType.RIGHT, 1, 1, ) self.name_init_error_popover = Gtk.Popover() self.name_init_error_popover.set_relative_to(self.name_init_ent) # Create the modifier label and entry. self.mod_init_lbl = Gtk.Label('Modifier') self.mod_init_lbl.set_alignment(1, 0.5) roll_init_grid.attach_next_to( self.mod_init_lbl, name_init_lbl, Gtk.PositionType.BOTTOM, 1, 1, ) mod_init_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) Gtk.StyleContext.add_class(mod_init_box.get_style_context(), 'linked') self.mod_init_ent = Gtk.Entry() self.mod_init_ent.set_hexpand(True) self.mod_init_ent.set_placeholder_text('0') mod_init_box.add(self.mod_init_ent) self.roll_init_btn = Gtk.Button('Roll') mod_init_box.add(self.roll_init_btn) roll_init_grid.attach_next_to( mod_init_box, self.mod_init_lbl, Gtk.PositionType.RIGHT, 1, 1, ) # Create the sorting check box. self.sort_init_chk = Gtk.CheckButton( 'Automatically sort initiatives when added', ) self.sort_init_chk.set_halign(Gtk.Align.CENTER) self.sort_init_chk.set_hexpand(True) self.sort_init_chk.set_margin_top(5) self.sort_init_chk.set_active(True) add_init_grid.attach_next_to( self.sort_init_chk, roll_init_grid, Gtk.PositionType.BOTTOM, 1, 1, ) # Create the initiative list grid. list_init_grid = Gtk.Grid() list_init_grid.set_row_spacing(0) list_init_grid.set_column_spacing(12) init_grid.attach_next_to( list_init_grid, add_init_grid, Gtk.PositionType.BOTTOM, 1, 1, ) # Create the initiative list label. list_init_lbl = Gtk.Label() list_init_lbl.set_markup('<span size="x-large">Initiatives</span>') list_init_lbl.set_alignment(0, 0.5) list_init_lbl.set_margin_bottom(10) list_init_grid.attach(list_init_lbl, 0, 0, 1, 1) # Create the initiative list. init_scroll_win = Gtk.ScrolledWindow() init_scroll_win.set_hexpand(True) init_scroll_win.set_vexpand(True) list_init_grid.attach_next_to( init_scroll_win, list_init_lbl, Gtk.PositionType.BOTTOM, 1, 1, ) self.init_store = Gtk.ListStore(int, str, int) self.init_tree = Gtk.TreeView(model=self.init_store) self.init_tree.set_reorderable(True) self.init_tree.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE) renderer = Gtk.CellRendererText() renderer.set_padding(5, 5) column = Gtk.TreeViewColumn('Name', renderer, text=1) column.set_expand(True) self.init_tree.append_column(column) renderer = Gtk.CellRendererText() renderer.set_padding(5, 5) column = Gtk.TreeViewColumn('Initiative', renderer, text=2) self.init_tree.append_column(column) init_scroll_win.add(self.init_tree) # Create the initiative list action bar. self.init_action_bar = Gtk.ActionBar() self.init_action_bar.get_style_context().add_class("inline-toolbar") list_init_grid.attach_next_to( self.init_action_bar, init_scroll_win, Gtk.PositionType.BOTTOM, 1, 1, ) # Create the initiative list buttons. init_btn_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) Gtk.StyleContext.add_class(init_btn_box.get_style_context(), 'linked') self.init_action_bar.pack_start(init_btn_box) self.remove_init_btn = Gtk.Button() self.remove_init_btn.add(load_symbolic('list-remove')) self.remove_init_btn.set_tooltip_text('Remove selected initiative') init_btn_box.add(self.remove_init_btn) self.clear_init_btn = Gtk.Button() self.clear_init_btn.add(load_symbolic('edit-clear')) self.clear_init_btn.set_tooltip_text('Clear all initiatives') init_btn_box.add(self.clear_init_btn) # Create the initiative drag and drop help text. drag_init_lbl = Gtk.Label( 'Drag and drop to rearrange initiatives', ) drag_init_lbl.set_margin_top(10) list_init_grid.attach_next_to( drag_init_lbl, self.init_action_bar, Gtk.PositionType.BOTTOM, 1, 1, ) # Create the results display. self.results_scroll_win = Gtk.ScrolledWindow() self.results_scroll_win.set_hexpand(True) self.results_scroll_win.set_vexpand(True) self.results_scroll_win.set_size_request(550, -1) self.results_store = Gtk.ListStore(str) self.results_tree = Gtk.TreeView(model=self.results_store) self.results_tree.set_headers_visible(False) renderer = Gtk.CellRendererText() renderer.set_padding(12, 12) column = Gtk.TreeViewColumn('Name', renderer, markup=0) column.set_expand(True) column.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE) self.results_tree.append_column(column) self.results_scroll_win.add(self.results_tree) win_pane.pack2(self.results_scroll_win, True, True) # Create the CSS provider. self.style_provider = Gtk.CssProvider() self.style_context = Gtk.StyleContext() self.style_context.add_provider_for_screen( Gdk.Screen.get_default(), self.style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION, ) self.style_provider.load_from_data(style_css) # Set up the stack. self.stack.add_titled(dice_grid, 'basic', 'Basic') self.stack.add_titled(combat_grid, 'combat', 'Combat') self.stack.add_titled(templates_grid, 'templates', 'Templates') self.stack.add_titled(init_grid, 'initiative', 'Initiatives')
def __init__(self, trk, trkview, parent): super(ControllersView, self).__init__() self.set_orientation(Gtk.Orientation.VERTICAL) self.sw = Gtk.ScrolledWindow() self.parent = parent self.trk = trk self.extras = trk.extras self.ctrl_names = trk.extras["ctrl_names"] self.trkview = trkview self.capturing = False self.box = Gtk.Box() self.box.set_orientation(Gtk.Orientation.VERTICAL) self.box.set_homogeneous(False) self.box.set_spacing(2) self.sw.add(self.box) self.pack_start(self.sw, True, True, 0) self.new_ctrl = Gtk.ActionBar() button = Gtk.Button() icon = Gio.ThemedIcon(name="list-add") image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON) button.add(image) button.connect("clicked", self.on_add_clicked) self.new_ctrl.pack_start(button) self.capture_button = Gtk.ToggleButton() self.capture_button.set_tooltip_markup(cfg.tooltip_markup % ("capture")) icon = Gio.ThemedIcon(name="media-record") image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON) self.capture_button.add(image) self.capture_button.connect("toggled", self.on_capture_toggled) self.new_ctrl.pack_start(self.capture_button) self.new_ctrl_adj = Gtk.Adjustment(1, 0, 127, 1.0, 1.0) self.new_ctrl_button = Gtk.SpinButton() self.new_ctrl_button.set_adjustment(self.new_ctrl_adj) self.new_ctrl_adj.set_value(1) self.new_ctrl_adj.connect("value-changed", self.on_new_ctrl_changed) self.new_ctrl.pack_start(self.new_ctrl_button) self.new_ctrl_entry = Gtk.Entry() self.new_ctrl_entry.set_text("") self.new_ctrl.pack_end(self.new_ctrl_entry) self.last_ctrl = cfg.default_ctrl_name # self.ctrl_names = self.extras["ctrl_names"] self.new_ctrl_menu = Gtk.Menu() i = 0 for n, c in mod.ctrls.items(): m = Gtk.MenuItem(n) sub = Gtk.Menu() parn = n # parent's name for c, n in c.items(): mitm = Gtk.MenuItem("%3d %s" % (c, n)) mitm.connect("activate", self.on_menuitem_activate) mitm.parn = parn mitm.show() sub.append(mitm) sub.show() m.set_submenu(sub) m.show() self.new_ctrl_menu.append(m) i += 1 self.new_ctrl_menu.show() self.new_ctrl_menu_button = Gtk.MenuButton() # self.new_ctrl_menu_button.connect("clicked", self.on_menu_popped) self.new_ctrl_menu_button.set_popup(self.new_ctrl_menu) self.new_ctrl.pack_end(self.new_ctrl_menu_button) self.pack_end(self.new_ctrl, False, False, 0) self.rebuild() self.show_all()
def main_content(self): stack = Gtk.Stack() stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT) stack.set_transition_duration(250) self.stack_switcher = Gtk.StackSwitcher() self.stack_switcher.set_stack(stack) #### Edit panel #### edit = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) edit_window = Gtk.ScrolledWindow() edit_flow = Gtk.FlowBox() edit_flow.set_homogeneous(False) edit_flow.set_column_spacing(12) edit_flow.set_row_spacing(12) frame = FrameEdit() edit_flow.add(frame) frame = FrameEdit() edit_flow.add(frame) frame = FrameEdit() edit_flow.add(frame) frame = FrameEdit() edit_flow.add(frame) frame = FrameEdit() edit_flow.add(frame) frame = FrameEdit() edit_flow.add(frame) frame = FrameEdit() edit_flow.add(frame) frame = FrameEdit() edit_flow.add(frame) edit_window.add(edit_flow) edit.pack_start(edit_window, True, True, 0) ab = Gtk.ActionBar() ab_buttons = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) Gtk.StyleContext.add_class(ab_buttons.get_style_context(), "linked") button = Gtk.Button(image=Gtk.Image.new_from_gicon( Gio.ThemedIcon(name="edit-undo-symbolic"), Gtk.IconSize.BUTTON)) ab_buttons.add(button) button = Gtk.Button(image=Gtk.Image.new_from_gicon( Gio.ThemedIcon(name="edit-redo-symbolic"), Gtk.IconSize.BUTTON)) ab_buttons.add(button) button = Gtk.Button(image=Gtk.Image.new_from_gicon( Gio.ThemedIcon(name="list-add-symbolic"), Gtk.IconSize.BUTTON)) ab_buttons.add(button) button = Gtk.Button(image=Gtk.Image.new_from_gicon( Gio.ThemedIcon(name="list-remove-symbolic"), Gtk.IconSize.BUTTON)) ab_buttons.add(button) button = Gtk.Button(image=Gtk.Image.new_from_gicon( Gio.ThemedIcon(name="edit-copy-symbolic"), Gtk.IconSize.BUTTON)) ab_buttons.add(button) button = Gtk.Button(image=Gtk.Image.new_from_gicon( Gio.ThemedIcon(name="edit-paste-symbolic"), Gtk.IconSize.BUTTON)) ab_buttons.add(button) ab.set_center_widget(ab_buttons) edit.pack_end(ab, False, False, 0) stack.add_titled(edit, "edit", "Edit") #### Preview panel #### preview = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.video = GtkASCIIPlayer(self.player) preview.pack_start(self.video, True, False, 0) ab = Gtk.ActionBar() self.controls = GtkASCIIControls(self.player) ab.set_center_widget(self.controls) preview.pack_end(ab, False, False, 0) stack.add_titled(preview, "preview", "Preview") return stack
def base_actionbar(self, namespace): actionbar = Gtk.ActionBar() actionbar.set_hexpand(0) self.container_name_space(actionbar, namespace) return actionbar
def __init__(self): Gtk.Window.__init__(self) self.lightThemeName = settings["themes"]["lightTheme"] self.darkThemeName = settings["themes"]["darkTheme"] headerBar = Gtk.HeaderBar() headerBar.set_show_close_button(True) headerBar.props.title = "Theme Changer" self.set_titlebar(headerBar) mainFrame = Gtk.Grid() self.add(mainFrame) gridUpper = Gtk.Grid(margin=7, column_spacing=7, row_spacing=5) mainFrame.attach(gridUpper, 0, 0, 4, 1) gridLower = Gtk.Grid() mainFrame.attach(gridLower, 0, 1, 4, 1) self.set_resizable(False) self.bottomButtons = Gtk.ActionBar() self.exitButton = Gtk.Button(label="Exit") self.exitButton.connect("clicked", Gtk.main_quit) self.saveButton = Gtk.Button(label="Save") self.saveButton.connect("clicked", self.writeSettings) self.spaceLabelAB = Gtk.Label( label=" " ) self.bottomButtons.pack_start(self.saveButton) self.bottomButtons.pack_start(self.spaceLabelAB) self.bottomButtons.pack_end(self.exitButton) gridLower.add(self.bottomButtons) #Theme setting buttons self.darkButton = Gtk.Button(label="Dark Theme") self.darkButton.connect("clicked", self.applyDarkTheme) self.lightButton = Gtk.Button(label="Light Theme") self.lightButton.connect("clicked", self.applyLightTheme) #Dark theme chooser self.showDarkChoiceLabel = Gtk.Label(label="Choose a GTK dark theme:") self.darkCombo = Gtk.ComboBoxText() self.darkCombo.connect("changed", self.writeDarkTheme) #Light theme chooser self.showLightChoiceLabel = Gtk.Label( label="Choose a GTK light theme:") self.lightCombo = Gtk.ComboBoxText() self.lightCombo.connect("changed", self.writeLightTheme) #Time settings self.showCautionTimeLabel = Gtk.Label( label="Use military time for the time stamps.") self.showCautionTimeConvertionLabel = Gtk.Label( label="18:00 -> 1800 | 06:00 -> 0600") #Light time settings self.showLightTimeChoiceLabel = Gtk.Label(label="Light time:") self.lightChangeTimeSet = Gtk.Entry() self.lightChangeTimeSet.connect("activate", self.writeLightTime) #Dark time settings self.showDarkTimeChoiceLabel = Gtk.Label(label="Dark time:") self.darkChangeTimeSet = Gtk.Entry() self.darkChangeTimeSet.set_max_width_chars(5) self.darkChangeTimeSet.connect("activate", self.writeDarkТime) self.syncTimesWithJSON(self.lightChangeTimeSet, self.darkChangeTimeSet) #Theme search self.defaultpath = "/usr/share/themes/" themes = self.findThemes(self.defaultpath) self.syncThemesWithJSON(themes, self.darkCombo, self.lightCombo) gridUpper.attach(self.showCautionTimeLabel, 0, 0, 2, 1) gridUpper.attach(self.showCautionTimeConvertionLabel, 0, 1, 2, 1) gridUpper.attach(self.showDarkTimeChoiceLabel, 0, 2, 1, 1) gridUpper.attach_next_to(self.showLightTimeChoiceLabel, self.showDarkTimeChoiceLabel, 1, 1, 1) gridUpper.attach(self.darkChangeTimeSet, 0, 3, 1, 1) gridUpper.attach_next_to(self.lightChangeTimeSet, self.darkChangeTimeSet, 1, 1, 1) gridUpper.attach(self.showDarkChoiceLabel, 0, 4, 2, 1) gridUpper.attach(self.darkCombo, 0, 5, 2, 1) gridUpper.attach(self.showLightChoiceLabel, 0, 6, 2, 1) gridUpper.attach(self.lightCombo, 0, 7, 2, 1) gridUpper.attach(self.darkButton, 0, 8, 1, 1) gridUpper.attach_next_to(self.lightButton, self.darkButton, 1, 1, 1)
def __init__(self, application, image_size, max_image_count): Gtk.ApplicationWindow.__init__(self, application=application, title=__app_title__, type=Gtk.WindowType.TOPLEVEL) self.image_size = image_size self.max_image_count = max_image_count self.quit_requested = False self.maximize() accel = Gtk.AccelGroup() accel.connect(KEY_Escape, 0, 0, self.on_quit_requested) self.add_accel_group(accel) scrolled = Gtk.ScrolledWindow(hscrollbar_policy=Gtk.PolicyType.NEVER, vscrollbar_policy=Gtk.PolicyType.AUTOMATIC) mainbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) self.flowbox = ImageFlowBox(accel) actionbar = Gtk.ActionBar() rotate_left = Gtk.Button.new_from_icon_name('object-rotate-left', Gtk.IconSize.BUTTON) rotate_right = Gtk.Button.new_from_icon_name('object-rotate-right', Gtk.IconSize.BUTTON) eject = Gtk.Button.new_from_icon_name('media-eject', Gtk.IconSize.BUTTON) self.choose_folder = Gtk.FileChooserButton(title='Ordner auswählen', action=Gtk.FileChooserAction.SELECT_FOLDER) actionbar.pack_start(rotate_left) actionbar.pack_start(rotate_right) actionbar.pack_end(self.choose_folder) actionbar.pack_end(eject) rotate_left.connect('clicked', self.flowbox.on_rotate_clicked, PixbufRotation.COUNTERCLOCKWISE) rotate_right.connect('clicked', self.flowbox.on_rotate_clicked, PixbufRotation.CLOCKWISE) self.flowbox.connect('child_activated', self.on_item_activated) self.choose_folder.connect('file-set', self.on_file_set) eject.connect('clicked', application.unmount) scrolled.add(self.flowbox) self.loading_stack = Gtk.Stack(transition_type=Gtk.StackTransitionType.NONE) try: logo = self._get_resource_path("logo.svg") if logo is not None: loading_image = Gtk.Image.new_from_file(logo) self.loading_stack.add_named(loading_image, "loading") except GLib.Error as ex: # pylint: disable=E0712 print(ex, file=sys.stderr) self.loading_stack.add_named(scrolled, "imagebox") mainbox.set_focus_chain([self.loading_stack]) mainbox.pack_start(self.loading_stack, True, True, 0) mainbox.pack_end(actionbar, False, True, 0) self.add(mainbox) self.flowbox.grab_focus()
def __init__(self, transient_for, title='Preferences'): CustomDialog.__init__(self, transient_for=transient_for, title=title) self.parent = transient_for # Stack & Stack switcher vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) content_area = self.get_content_area() content_area.add(vbox) stack = Gtk.Stack() stack.set_margin_top(5) #stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT) #stack.set_transition_duration(1000) stack_switcher = Gtk.StackSwitcher() stack_switcher.set_stack(stack) vbox.pack_start(stack_switcher, True, True, 0) vbox.pack_start(stack, True, True, 0) ### General box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack.add_titled(box, 'general', 'General') ## Debug hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) box.add(hbox) hbox.add(Gtk.Label('<b>Debug</b>', xalign=0, use_markup=True)) debug_switch = Gtk.Switch() debug_switch.set_active(self.parent.settings['Debug']['Enabled']) debug_switch.connect('notify::active', self.on_debug_switch_activated) hbox.pack_end(debug_switch, False, False, 0) # Level self.debug_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) self.debug_box.set_margin_left(10) self.debug_box.set_sensitive(self.parent.settings['Debug']['Enabled']) box.add(self.debug_box) self.debug_box.add(Gtk.Label('Level')) debug_level_combo = CustomComboBox(['High', 'Normal', 'Low']) debug_level_combo.set_active(self.parent.settings['Debug']['Level']) debug_level_combo.connect( 'changed', lambda combo: settings.update_and_save(self.parent.settings, key='Debug', subkey='Level', value=combo.get_active())) self.debug_box.pack_end(debug_level_combo, False, False, 0) ## Game box.add(Gtk.Label('<b>Game</b>', xalign=0, use_markup=True)) # Keep game checkbox keep_game_on_unplug_check = Gtk.CheckButton( 'Keep game open when unplug') keep_game_on_unplug_check.set_margin_left(10) keep_game_on_unplug_check.set_active( self.parent.settings['Game']['KeepOpen']) keep_game_on_unplug_check.connect( 'clicked', lambda check: settings.update_and_save(self.parent.settings, key='Game', subkey='KeepOpen', value=check.get_active())) box.add(keep_game_on_unplug_check) ## Account box.add(Gtk.Label('<b>Account</b>', xalign=0, use_markup=True)) # Exit game checkbox exit_game_on_disconnect_check = Gtk.CheckButton( 'Exit game when disconnect') exit_game_on_disconnect_check.set_margin_left(10) exit_game_on_disconnect_check.set_active( self.parent.settings['Account']['ExitGame']) exit_game_on_disconnect_check.connect( 'clicked', lambda check: settings.update_and_save(self.parent.settings, key='Account', subkey='ExitGame', value=check.get_active())) box.add(exit_game_on_disconnect_check) ### Bot box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack.add_titled(box, 'bot', 'Bot') ## Job box.add(Gtk.Label('<b>Job</b>', xalign=0, use_markup=True)) # PodBar hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.set_margin_left(10) hbox.add(Gtk.Label('PodBar')) podbar_switch = Gtk.Switch() podbar_switch.set_active(self.parent.settings['Job']['EnablePodBar']) podbar_switch.connect('notify::active', self.on_podbar_switch_activated) hbox.pack_end(podbar_switch, False, False, 0) box.add(hbox) # MiniMap hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.set_margin_left(10) hbox.add(Gtk.Label('MiniMap')) minimap_switch = Gtk.Switch() minimap_switch.set_active(self.parent.settings['Job']['EnableMiniMap']) minimap_switch.connect('notify::active', self.on_minimap_switch_activated) hbox.pack_end(minimap_switch, False, False, 0) box.add(hbox) ## Farming box.add(Gtk.Label('<b>Farming</b>', xalign=0, use_markup=True)) # Save dragodindes images save_dragodindes_images_check = Gtk.CheckButton( 'Save dragodindes image') save_dragodindes_images_check.set_margin_left(10) save_dragodindes_images_check.set_active( self.parent.settings['Farming']['SaveDragodindesImages']) save_dragodindes_images_check.connect( 'clicked', lambda check: settings.update_and_save( self.parent.settings, key='Farming', subkey='SaveDragodindesImages', value=check.get_active())) box.add(save_dragodindes_images_check) ### Shortcuts box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack.add_titled(box, 'shortcuts', 'Shortcuts') ## Keyboard Shortcuts hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) hbox.add( Gtk.Label('<b>Keyboard Shortcuts</b>', xalign=0, use_markup=True)) box.add(hbox) # Switch shortcuts_switch = Gtk.Switch() shortcuts_switch.set_active(self.parent.settings['EnableShortcuts']) shortcuts_switch.connect('notify::active', self.on_shortcuts_switch_activated) hbox.pack_end(shortcuts_switch, False, False, 0) # TreeView model = Gtk.ListStore(str, str) text_renderer = Gtk.CellRendererText() columns = [ Gtk.TreeViewColumn('Action', text_renderer, text=0), Gtk.TreeViewColumn('Shortcut', text_renderer, text=1) ] self.shortcuts_tree_view = CustomTreeView(model, columns) self.shortcuts_tree_view.vbox.set_sensitive( self.parent.settings['EnableShortcuts']) self.shortcuts_tree_view.connect( 'button-press-event', self.on_shortcuts_tree_view_double_clicked) self.shortcuts_tree_view.connect( 'selection-changed', self.on_shortcuts_tree_view_selection_changed) # fill treeview for action in sorted(self.parent.settings['Shortcuts']): shortcut = self.parent.settings['Shortcuts'][action] self.shortcuts_tree_view.append_row([action, shortcut], select=False, scroll_to=False) box.pack_start(self.shortcuts_tree_view, True, True, 0) # ActionBar actionbar = Gtk.ActionBar() self.shortcuts_edit_button = Gtk.Button() self.shortcuts_edit_button.set_tooltip_text('Edit') self.shortcuts_edit_button.set_image( Gtk.Image(icon_name='document-edit-symbolic')) self.shortcuts_edit_button.set_sensitive(False) self.shortcuts_edit_button.connect( 'clicked', self.on_shortcuts_edit_button_clicked) actionbar.add(self.shortcuts_edit_button) self.shortcuts_tree_view.vbox.pack_end(actionbar, False, False, 0) self.show_all()
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()