def get_a_child(self, child_name): button_grid = Gtk.Grid(hexpand=True, margin=2) child_dict = {} child_dict["child_name"] = child_name child_dict["icon"] = Gtk.Image.new_from_icon_name( "document-properties-symbolic", 2 ) if child_name == "Vertical buttons": for y, name in enumerate(self.icon_names): icon = Gtk.Image.new_from_icon_name(name, 2) button = Gtk.Button(margin=2, relief=2) button.add(icon) button_grid.attach(button, 0, y, 1, 1) child_dict["header_child"] = None child_dict["child"] = button_grid elif child_name == "Horizontal buttons": for x, name in enumerate(self.icon_names): icon = Gtk.Image.new_from_icon_name(name, 2) button = Gtk.Button(margin=2, relief=2) button.add(icon) button_grid.attach(button, x, 0, 1, 1) child_dict["header_child"] = button_grid child_dict["child"] = Gtk.Label() return child_dict
def get_a_child(self, child_name): textview = Gtk.TextView(margin=5, buffer=self.buffer) scrolled = Gtk.ScrolledWindow(expand=True) scrolled.add(textview) icon = Gtk.Image.new_from_icon_name("folder", 2) fp_but = Gtk.FileChooserButton(title="Choose file", hexpand=True, halign=2) if self.path: fp_but.set_filename(self.path) fp_but.connect("file-set", self.change_text_at_buffer) self.file_choosers.append(fp_but) child_props = { "child_name": "TextView", "child": scrolled, "icon": icon, "header_child": fp_but, } return child_props
def get_a_child(self, child_name): child_dict = {"child_name": child_name, "provider": self} child_dict["child"] = Gtk.Label(label="Test Label") child_dict["icon"] = Gtk.Image.new_from_icon_name("test", 2) child_dict["header_child"] = Gtk.Label(label="Test Header") return child_dict
def get_child_from_props(self, props): child = Gtk.Label(label=props["child_label"]) header_child = Gtk.Label(label=props["header_label"]) icon = Gtk.Image.new_from_icon_name("test", 2) child_dict = { "child": child, "icon": icon, "header_child": header_child } return child_dict
def get_a_child(self, child_name): title = Gtk.Label(label="<b>Images</b>", use_markup=True) side_grid = Gtk.Grid() lb = Gtk.ListBox(expand=True) for name in self.row_names: label = Gtk.Label(label=name, halign=1) lb.prepend(label) side_grid.attach(title, 0, 0, 1, 1) side_grid.attach(lb, 0, 1, 1, 1) child_dict = {} child_dict["child_name"] = child_name child_dict["child"] = side_grid child_dict["header_child"] = None child_dict["icon"] = Gtk.Image.new_from_icon_name("image-x-generic-symbolic", 2) return child_dict
def get_a_child(self, child_name): label = Gtk.Label(margin=5, label="Hello world") icon = Gtk.Image.new_from_icon_name("glade", 2) child_props = { "child_name": "Label", "child": label, "icon": icon, "header_child": None, } return child_props
def get_a_child(self, child_name): img = Gtk.Image.new_from_file( "/home/j_arun_mani/Pictures/Abstracts and Stuff/Abstract 1.jpg" ) scrolled = Gtk.ScrolledWindow(expand=True, margin=2) scrolled.add(img) child_dict = {} child_dict["child_name"] = child_name child_dict["child"] = scrolled child_dict["header_child"] = None child_dict["icon"] = Gtk.Image.new_from_icon_name( "applications-graphics-symbolic", 2 ) return child_dict
def get_a_child(self, child_name): entry = Gtk.Entry(margin=5, text=self.text, editable=self.editable) entry.connect("changed", self.change_text) icon = Gtk.Image.new_from_icon_name("terminal", 2) # Choose whatever icon you want switch = Gtk.ToggleButton(label="Allow Edit", hexpand=True, halign=2, active=self.editable) switch.connect("toggled", self.toggle_editable) self.entries.append(entry) self.toggles.append(switch) child_props = { "child_name": "Entry", "child": entry, "icon": icon, "header_child": switch, } return child_props
import gi gi.require_version("GtkSource", "4") from gi.repository import GtkSource from Aduct import Gtk img = Gtk.Image.new_from_file( "/home/j_arun_mani/Pictures/Abstracts and Stuff/Abstract 1.jpg") scrolled = Gtk.ScrolledWindow(expand=True, margin=2) scrolled.add(img) lm = GtkSource.LanguageManager() lang = lm.get_language("rst") buf = GtkSource.Buffer(language=lang) textview = GtkSource.View(editable=True, buffer=buf, margin=5) title = Gtk.Label(label="<b>Images</b>", use_markup=True) side_grid = Gtk.Grid() lb = Gtk.ListBox(expand=True) row_names = ["Nature.png", "Seashore.jpg", "Overview.png", "Dynamite.png"] for name in row_names: label = Gtk.Label(label=name, halign=1) lb.prepend(label) side_grid.attach(title, 0, 0, 1, 1) side_grid.attach(lb, 0, 1, 1, 1) button_grid = Gtk.Grid(hexpand=True, margin=2) icon_names = [ "list-add-symbolic", "document-new-symbolic", "document-save-symbolic",
def test_add_child_err(self): wid = Gtk.Grid() self.assertRaises(TypeError, self.notebook.add_child, wid)
def test_replace_child_err_1(self): wid = Gtk.Grid() self.notebook.add_child(self.element) self.assertRaises(TypeError, self.notebook.replace_child, self.element, wid)
elif position == 2: paned.set_orientation(1) Aduct.add_to_paned(last_widget, element, paned, 1) elif position == 3: paned.set_orientation(1) Aduct.add_to_paned(last_widget, element, paned, 2) def change_child_at_element(wid, prov, child_name): global last_widget Aduct.change_child_at_element(last_widget, prov, child_name) # Making a model-button for each provider. provs = [ (Button_Provider, Gtk.ModelButton(text="Vertical buttons"), "Vertical buttons"), (Button_Provider, Gtk.ModelButton(text="Horizontal buttons"), "Horizontal buttons"), (Text_Provider, Gtk.ModelButton(text="Scratch pad"), "Scratch pad"), (Images_Provider, Gtk.ModelButton(text="Images"), "Images"), (Viewer_Provider, Gtk.ModelButton(text="Workspace"), "Workspace"), ] prov_grid = Gtk.Grid() # A grid to store them for y, (prov, modb, child_name) in enumerate(provs): prov_grid.attach(modb, 0, y, 1, 1) modb.connect("clicked", change_child_at_element, prov, child_name) prov_popover = Gtk.PopoverMenu() prov_popover.add(prov_grid) prov_grid.show_all()
} init_maps = { "provider": { "Provider A": A, "Provider B": B, "Provider C": C, None: None } } Aduct.set_interface(ui_dict, top_level, creator_maps, init_maps) provs = [ ( A, Gtk.ModelButton(text="Entry"), "Entry", ), # Making a model-button for each provider. (B, Gtk.ModelButton(text="TextView"), "TextView"), (C, Gtk.ModelButton(text="Label"), "Label"), ] prov_grid = Gtk.Grid() # A grid to store them for y, (prov, modb, child_name) in enumerate(provs): prov_grid.attach(modb, 0, y, 1, 1) modb.connect("clicked", change_child_at_element, prov, child_name) prov_popover = Gtk.PopoverMenu() prov_popover.add(prov_grid) prov_grid.show_all()
def __init__(self, name): super().__init__(name) self.file_choosers = [] self.buffer = Gtk.TextBuffer() self.path = None