def generate_profiles_page(self): """Create preference groups for profiles""" new_profile = Handy.PreferencesGroup(title=_("New profile")) self.custom_profiles = Handy.PreferencesGroup(title=_("User profiles")) self.system_profiles = Handy.PreferencesGroup( title=_("System profiles")) self.builtin_profiles = Handy.PreferencesGroup( title=_("Built-in profiles")) self.profile_overview.add(new_profile) self.profile_overview.add(self.custom_profiles) self.profile_overview.add(self.system_profiles) self.profile_overview.add(self.builtin_profiles) # Add entry for current profile prof_entry = Handy.ActionRow(title=_("Profile name")) save_me = Gtk.Button.new_from_icon_name("document-save", 1) save_me.set_sensitive(False) self.profile_name_entry = Gtk.Entry(placeholder_text=_("Name")) self.profile_name_entry.connect("changed", self.on_prof_name_changed, save_me) prof_entry.add(self.profile_name_entry) prof_entry.add(save_me) save_me.connect("clicked", self.on_save_profile_clicked) prof_entry.set_activatable_widget(save_me) new_profile.add(prof_entry) self._generate_profile_list()
def __init__(self, names): Gtk.Window.__init__(self, title=APP_NAME) self.set_default_size(800, 600) self.set_position(Gtk.WindowPosition.CENTER) hb = Handy.HeaderBar() hb.set_show_close_button(True) hb.props.title = APP_NAME self.set_titlebar(hb) button = Gtk.Button() button.add(Gtk.Image.new_from_icon_name( "document-new", Gtk.IconSize.BUTTON)) button.connect("clicked", self.on_new_clicked) # , args) hb.pack_start(button) button = Gtk.Button() button.add(Gtk.Image.new_from_icon_name( "help-symbolic", Gtk.IconSize.BUTTON)) button.connect("clicked", self.on_about_clicked) hb.pack_end(button) scrolled = Gtk.ScrolledWindow() scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.add(scrolled) self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) Gtk.StyleContext.add_class(self.vbox.get_style_context(), "linked") scrolled.add(self.vbox) options = ["Won", "Lost", "Draw"] self.group = [] for name in range(len(names)): self.group = Handy.PreferencesGroup() self.group.set_title(names[name]) for i in range(3): self.adjustment = Gtk.Adjustment() self.adjustment.set_value(0) self.adjustment.set_lower(-10000) self.adjustment.set_upper(10000) self.adjustment.set_step_increment(1) self.adjustment.set_page_increment(10) self.adjustment.set_page_size(0) self.player_spin = Gtk.SpinButton() self.player_spin.set_adjustment(self.adjustment) self.player_spin.set_digits(0) self.player_spin.set_value(0) self.row = Handy.ActionRow() self.row.set_title(options[i]) self.row.add_action(self.player_spin) self.row.set_activatable_widget(self.player_spin) self.group.add(self.row) self.vbox.pack_start(self.group, True, True, 0)
def __init__(self, **kwargs): super().__init__(**kwargs) self.connect("destroy", Gtk.main_quit) self.show_all() Scroll = Gtk.ScrolledWindow() self.add(Scroll) Scroll.show() Scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) vp = Gtk.Viewport() Scroll.add(vp) vp.show() self.clamp = Handy.Clamp() self.clamp.set_property("can_focus", False) self.clamp.set_property("margin-bottom", 8) self.clamp.set_property("margin-start", 8) self.clamp.set_property("margin-end", 8) self.clamp.set_property("margin-top", 8) self.clamp.set_property("expand", True) self.clamp.set_property("maximum-size", 600) self.clamp.set_property("tightening-threshold", 300) self.clamp.show() vp.add(self.clamp) self.book_list = Handy.PreferencesGroup() self.book_list.set_property("expand", True) self.book_list.set_property("can_focus", False) self.clamp.add(self.book_list) self.book_list.show() yaml_file_name = os.path.join(pkgdatadir, "test.yaml") with open(yaml_file_name) as file: obj = yaml.load(file, Loader=yaml.FullLoader) objects = genMenu(obj) if isinstance(objects, list): for item in objects: self.book_list.add(toGUI(item)) elif isinstance(objects, menuGroup): self.book_list.add(toGUI(objects)) self.maximize()
def _setup(self): self.props.visible = True self.props.transition_type = Gtk.StackTransitionType.CROSSFADE self._permissions = None self._manager = Gio.VolumeMonitor.get() self._manager.connect("mount-added", self._on_mount_added) self._manager.connect("mount-removed", self._on_mount_removed) # begin UI structure self._groups_box = Gtk.Box() self._groups_box.props.expand = True self._groups_box.props.visible = True self._groups_box.props.orientation = Gtk.Orientation.VERTICAL self._message_box = Gtk.Box() self._message_box.props.expand = True self._message_box.props.visible = True self._message_box.props.orientation = Gtk.Orientation.VERTICAL self._places_group = Handy.PreferencesGroup() self._places_group.props.title = _("Places") self._places_group.props.visible = True self._devices_group = Handy.PreferencesGroup() self._devices_group.props.title = _("Devices") self._devices_group.props.visible = True self._devices_group.get_style_context().add_class("devices-group") # places if self._has_permission_for(self.HOME_PERMISSION): self._add_place( self._places_group, "user-home-symbolic", _("Home"), self.PORTFOLIO_HOME_DIR, ) if self._has_permission_for( self.DOWNLOAD_PERMISSION) and self.XDG_DOWNLOAD: self._add_place( self._places_group, "folder-download-symbolic", os.path.basename(self.XDG_DOWNLOAD), self.XDG_DOWNLOAD, ) if self._has_permission_for( self.DOCUMENTS_PERMISSION) and self.XDG_DOCUMENTS: self._add_place( self._places_group, "folder-documents-symbolic", os.path.basename(self.XDG_DOCUMENTS), self.XDG_DOCUMENTS, ) if self._has_permission_for( self.PICTURES_PERMISSION) and self.XDG_PICTURES: self._add_place( self._places_group, "folder-pictures-symbolic", os.path.basename(self.XDG_PICTURES), self.XDG_PICTURES, ) if self._has_permission_for(self.MUSIC_PERMISSION) and self.XDG_MUSIC: self._add_place( self._places_group, "folder-music-symbolic", os.path.basename(self.XDG_MUSIC), self.XDG_MUSIC, ) if self._has_permission_for( self.VIDEOS_PERMISSION) and self.XDG_VIDEOS: self._add_place( self._places_group, "folder-videos-symbolic", os.path.basename(self.XDG_VIDEOS), self.XDG_VIDEOS, ) if self._has_permission_for( self.TRASH_PERMISSION) and self._has_trash(): self._add_place( self._places_group, "user-trash-symbolic", self.XDG_TRASH_NAME, self.XDG_TRASH, ) # devices if self._has_permission_for(self.HOST_PERMISSION): self._add_place( self._devices_group, "drive-harddisk-ieee1394-symbolic", _("System"), self.PORTFOLIO_SYSTEM_DIR, ) if self._has_permission_for( self.HOST_PERMISSION) and self._is_flatpak(): self._add_place( self._devices_group, "drive-harddisk-ieee1394-symbolic", _("Host"), self.PORTFOLIO_SYSTEM_DIR_FLATPAK, ) for mount in self._manager.get_mounts(): if mount.get_root().get_path() not in [ self.PORTFOLIO_SYSTEM_DIR, self.PORTFOLIO_HOME_DIR, ]: self._add_place( self._devices_group, "drive-removable-media-symbolic", mount.get_name(), mount.get_root().get_path(), mount, ) self._groups_box.add(self._places_group) self._groups_box.add(self._devices_group) # no places message message = Gtk.Label() message.props.expand = True message.props.visible = True message.props.label = _("No places found") message.get_style_context().add_class("no-places") self._message_box.add(message) # finalize UI structure self.add_named(self._groups_box, "groups") self.add_named(self._message_box, "message") # update visibility self._update_stack_visibility() self._update_places_group_visibility() self._update_device_group_visibility()
gi.require_version('Handy', '0.0') gi.require_version('Gtk', '3.0') from gi.repository import Gtk, Handy # https://lazka.github.io/pgi-docs/#Handy-0.0/functions.html#Handy.init Handy.init() # https://lazka.github.io/pgi-docs/#Handy-0.0/classes/PreferencesWindow.html window = Handy.PreferencesWindow() window.set_default_size(500, 500) #window.set_border_width(10) # # https://lazka.github.io/pgi-docs/#Handy-0.0/classes/PreferencesGroup.html group1 = Handy.PreferencesGroup() group1.set_title("My Group") box = Gtk.ListBox() # row1 = Handy.ActionRow() row1.set_title("Page 1 Stuff") box.insert(row1, -1) group1.add(box) # New tab page (creates a tab in the header bar) # page1 = Handy.PreferencesPage()
# https://lazka.github.io/pgi-docs/#Handy-0.0/functions.html#Handy.init Handy.init() # https://lazka.github.io/pgi-docs/#Handy-0.0/classes/PreferencesWindow.html window = Handy.PreferencesWindow() window.set_default_size(500, 500) # Create a page (tab) # https://lazka.github.io/pgi-docs/#Handy-0.0/classes/PreferencesPage.html page1 = Handy.PreferencesPage() page1.set_title("Folder Settings") page1.set_icon_name("folder") # Create a Group (our first group) # https://lazka.github.io/pgi-docs/#Handy-0.0/classes/PreferencesGroup.html browsegroup = Handy.PreferencesGroup() browsegroup.set_title("Browsing") # Create List Box (specifically for browsing group) browsebox = Gtk.ListBox() browsebox.set_selection_mode(Gtk.SelectionMode.NONE) # Create a Toggle Button switch = Gtk.Switch() switch.set_active(True) # Create a Row row1 = Handy.ActionRow() row1.set_title("Enable Smooth Scaling") row1.add_action(switch)