def new_notebook(): notebook = Aduct.Notebook() icon = Gtk.Image.new_from_icon_name("list-add", 2) notebook.set_action_button(icon, 1) notebook.connect("action-clicked", show_popover_notebook) # show_popover_notebook is a function like show_popover_element. return notebook
def load_interface(wid): from json import load with open("qtk.ui") as fp: ui_dict = load(fp) creator_maps = { "type": { "element": (new_element, (), {}), "bin": (new_bin, (), {}), "notebook": (new_notebook, (), {}), "paned": (new_paned, (), {}), } } 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)
def add_to_paned(wid, position): global last_widget element = new_element() paned = new_paned() if position == 0: paned.set_orientation(0) Aduct.add_to_paned(last_widget, element, paned, 1) elif position == 1: paned.set_orientation(0) Aduct.add_to_paned(last_widget, element, paned, 2) 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 if last_widget.type == "element": Aduct.change_child_at_element(last_widget, prov, child_name) elif last_widget.type == "notebook": element = new_element() Aduct.change_child_at_element(element, prov, child_name) Aduct.add_to_notebook(element, last_widget) element.show_all()
def new_element(): element = Aduct.Element() return element
def setUp(self): self.element = new_element() self.bin_ = Aduct.Bin()
def setUp(self): self.element = Aduct.Element()
def setUp(self): self.element = new_element() self.notebook = Aduct.Notebook()
def change_child_at_element(wid, prov, child_name): global last_widget Aduct.change_child_at_element(last_widget, prov, child_name)
def remove_element(wid): global last_widget Aduct.remove_element(last_widget, last_widget.get_parent())
def new_paned(orientation=0): paned = Aduct.Paned(orientation=orientation) return paned
def new_bin(): bin_ = Aduct.Bin() return bin_
def new_element(): element = Aduct.Element(margin=5) element.connect("action-clicked", show_popover_element) # show_popover_element is a function to show the popover for an element. return element
def add_to_notebook(wid, position): global last_widget notebook = new_notebook() notebook.set_tab_pos(position) Aduct.add_to_notebook(last_widget, notebook)
def save_interface(wid): from json import dump with open("qtk.ui", "w") as fp: ui_dict = Aduct.get_interface(top_level) dump(ui_dict, fp, indent=2)
def setUp(self): self.element_1 = new_element() self.element_2 = new_element() self.paned = Aduct.Paned()