我们从Python开源项目中,提取了以下49个代码示例,用于说明如何使用gi.repository.Gtk.ScrolledWindow()。
def generate_accounts_list(self): """ Generate an account ListBox inside of a ScrolledWindow """ apps = self.app.db.fetch_apps() count = len(apps) self.scrolled_win = Gtk.ScrolledWindow() self.accounts = [] for app in apps: account = Account(app, self.app.db) self.accounts.append(account) self.app.observable.register(account) self.accounts_list = AccountsList(self.window, self.accounts) self.scrolled_win.add_with_viewport(self.accounts_list) self.pack_start(self.scrolled_win, True, True, 0)
def __init__(self, *args, **kwargs): super().__init__(*args, default_width=640, default_height=480, **kwargs) self.switcher = NeovimBufferBar() self.set_titlebar(Gtk.HeaderBar(show_close_button=True, custom_title=self.switcher)) vbox = Gtk.Box(parent=self, orientation=Gtk.Orientation.VERTICAL) self.notebook = NeovimTabBar(parent=vbox) self.viewport = NeovimViewport(parent=Gtk.ScrolledWindow(parent=vbox)) self.terminal = NeovimTerminal(parent=self.viewport, expand=True) self.terminal.connect('child-exited', lambda *_: self.close()) self.terminal.connect('nvim-attached', lambda _, nvim: self.emit('nvim-setup', nvim))
def add_treeview(self): num_columns = [float for x in range(len(self.data.columns))] liststore = Gtk.ListStore(*num_columns) for ref in self.data.values.tolist(): liststore.append(ref) treeview = Gtk.TreeView.new_with_model(liststore) for i, column_title in enumerate(self.data.columns): renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(column_title, renderer, text=i) treeview.append_column(column) self.scrollable_treelist = Gtk.ScrolledWindow() self.scrollable_treelist.add(treeview) self.scrollable_treelist.set_vexpand(True) self.scrollable_treelist.set_hexpand(True) self.verticalbox.pack_start(self.scrollable_treelist, True, True, 0) self.verticalbox.show_all()
def __init__(self, window): Gtk.ScrolledWindow.__init__(self) # Parent window self._window = window # Tree view self._tree_view = Gtk.TreeView(Gtk.ListStore(int, int, str, str)) self._tree_view.set_headers_visible(False) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Message", renderer, text=2, background=3) self._tree_view.append_column(column) self._tree_view.connect("row-activated", self.on_row_activated) self.add(self._tree_view) self.show_all()
def __init__(self, statistics, heading): Gtk.ScrolledWindow.__init__(self) self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.vbox = Gtk.VBox(False, 0) self.vbox.set_spacing(gu.PAD) self.vbox.set_border_width(gu.PAD) self.add_with_viewport(self.vbox) hbox = Gtk.HBox(False, 0) hbox.set_spacing(gu.hig.SPACE_SMALL) im = Gtk.Image.new_from_file("graphics/applications-system.svg") self.g_settings_button = b = Gtk.Button() b.connect('clicked', self.on_delete_statistics) b.add(im) hbox.pack_start(b, False, False, 0) self.g_heading = Gtk.Label(label=heading) self.g_heading.set_alignment(0.0, 0.5) self.g_heading.set_name("StatisticsH1") hbox.pack_start(self.g_heading, False, False, 0) self.vbox.pack_start(hbox, False, False, 0) self.m_statistics = statistics self.g_tables = Gtk.VBox(False, 0) self.g_tables.show() self.vbox.pack_start(self.g_tables, True, True, 0) self.show_all()
def on_menuitem_custom_activate(self, widget): self.custom_window = Gtk.Window() self.custom_window.set_default_size(640, 480) self.custom_window.set_position(Gtk.WindowPosition.CENTER) self.custom_window.set_title("Custom CSS") self.custom_vbox = Gtk.VBox() self.custom_scroller = Gtk.ScrolledWindow() self.custom_button = Gtk.Button("Apply") self.custom_vbox.pack_end(self.custom_button, False, False, 0) self.custom_text_view = Gtk.TextView() self.custom_text_buffer = Gtk.TextBuffer() self.custom_text_buffer.set_text(self.custom_css) self.custom_text_view.set_buffer(self.custom_text_buffer) self.custom_scroller.add(self.custom_text_view) self.custom_vbox.pack_start(self.custom_scroller, True, True, 0) self.custom_window.add(self.custom_vbox) self.custom_window.show_all() self.custom_button.connect("clicked", self.apply_custom_css, self.custom_window, self.custom_text_buffer)
def create_textview(self): scrolledwindow = Gtk.ScrolledWindow() scrolledwindow.set_hexpand(True) scrolledwindow.set_vexpand(True) self.grid.attach(scrolledwindow, 0, 1, 3, 1) self.textview = Gtk.TextView() self.textbuffer = self.textview.get_buffer() self.textbuffer.set_text("This is some text inside of a Gtk.TextView. " + "Select text and click one of the buttons 'bold', 'italic', " + "or 'underline' to modify the text accordingly.") scrolledwindow.add(self.textview) self.tag_bold = self.textbuffer.create_tag("bold", weight=Pango.Weight.BOLD) self.tag_italic = self.textbuffer.create_tag("italic", style=Pango.Style.ITALIC) self.tag_underline = self.textbuffer.create_tag("underline", underline=Pango.Underline.SINGLE) self.tag_found = self.textbuffer.create_tag("found", background="yellow")
def __init__(self, choices, change_handler=None): self.model = gtk.ListStore(GObject.TYPE_STRING) self._values = [] for label, value in choices: self.model.append((label,)) self._values.append(value) renderer = gtk.CellRendererText() self.control = gtk.ScrolledWindow() self.control.show() self._treeview = gtk.TreeView(self.model) self._treeview.show() self.control.add(self._treeview) self.control.set_shadow_type(gtk.ShadowType.ETCHED_OUT) self.control.set_policy(gtk.PolicyType.AUTOMATIC, gtk.PolicyType.AUTOMATIC) # Sadly there seems to be no way to adjust the size of the ScrolledWindow to its content. # The default size of the ScrolledWindow is too small (making it hard to select the model). self.control.set_size_request(200, -1) column = gtk.TreeViewColumn() column.pack_start(renderer, expand=False) column.set_attributes(renderer, text=0) self._treeview.append_column(column) self._treeview.set_headers_visible(False) self._selection = self._treeview.get_selection() self._selection.set_mode(gtk.SelectionMode.MULTIPLE) self.connect("changed", change_handler, self._selection)
def create_textview(self): self.vbox_left1.add(self.text_grid) scrolledwindow = Gtk.ScrolledWindow() scrolledwindow.set_hexpand(True) scrolledwindow.set_vexpand(True) self.text_grid.attach(scrolledwindow, 0, 1, 3, 1) self.textview = Gtk.TextView() spellchecker = SpellChecker(self.textview,locale.getdefaultlocale()[0]) self.textbuffer = self.textview.get_buffer() scrolledwindow.add(self.textview) self.tag_bold = self.textbuffer.create_tag("bold", weight=Pango.Weight.BOLD) self.tag_italic = self.textbuffer.create_tag("italic", style=Pango.Style.ITALIC) self.tag_underline = self.textbuffer.create_tag("underline", underline=Pango.Underline.SINGLE) self.tag_found = self.textbuffer.create_tag("found", background="yellow") self.textview.connect("key_release_event",self.on_key_release)
def create_window(self): self.dialog = Gtk.Dialog(None, None, Gtk.DialogFlags.MODAL) self.dialog.set_decorated(False) # scrolledwindow = Gtk.ScrolledWindow() scrolledwindow.set_can_focus(False) scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolledwindow.set_shadow_type(Gtk.ShadowType.ETCHED_OUT) self.dialog.vbox.pack_start(scrolledwindow, Gtk.AttachOptions.SHRINK, Gtk.AttachOptions.SHRINK,0) # self.store = Gtk.ListStore(str) for value in self.values: self.store.append([value]) self.tree = Gtk.TreeView(self.store) self.tree.set_headers_visible(False) self.tree.set_can_focus(False) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(title=None,cell_renderer=renderer, text=0) self.tree.append_column(column) # scrolledwindow.add(self.tree) self.tree.connect('focus-out-event',self.on_focus_out) self.dialog.connect('focus-out-event',self.on_focus_out) self.tree.connect('cursor-changed',self.on_cursor_changed) self.dialog.show_all()
def __init__(self): Gtk.ScrolledWindow.__init__(self) self.view = Gtk.IconView() self.list = Gtk.ListStore(Pixbuf, str) self.view.set_model(self.list) self.view.set_pixbuf_column(0) self.view.set_text_column(1) self.view.set_activate_on_single_click(True) self.view.set_item_width(100) self.menu = Gtk.Menu() copy = Gtk.MenuItem('Copy') copy.connect('activate', self.copy) paste = Gtk.MenuItem('Paste') paste.connect('activate', self.paste) self.menu.append(copy) self.menu.append(paste) self.view.add_events(Gdk.EventMask.BUTTON_PRESS_MASK) self.view.connect('button-press-event', self.show_menu) self.view.set_vexpand(True) self.view.set_hexpand(True) self.add(self.view) self.view.connect('item-activated', self.row_activated)
def __init__(self): Gtk.ScrolledWindow.__init__(self) self.list = Gtk.ListStore(str, bool) self.view = Gtk.TreeView(self.list) self.view.set_hexpand(True) text_renderer = Gtk.CellRendererText() check_renderer = Gtk.CellRendererToggle() name_column = Gtk.TreeViewColumn('Gtk color list', text_renderer, text=0) check_column = Gtk.TreeViewColumn('', check_renderer, active=1) self.view.append_column(check_column) self.view.append_column(name_column) self.view.connect('row-activated', self.row_activated) self.add(self.view) names = ['active_text_color', 'inactive_text_color', 'active_text_shadow_color', 'inactive_text_shadow_color', 'active_border_color', 'inactive_border_color', 'active_color_1', 'active_color_2', 'active_highlight_1', 'active_highlight_2', 'active_mid_1', 'active_mid_2', 'active_shadow_1', 'active_shadow_2', 'inactive_color_1', 'inactive_color_2', 'inactive_highlight_1', 'inactive_highlight_2', 'inactive_mid_1', 'inactive_mid_2', 'inactive_shadow_1', 'inactive_shadow_2'] for name in names: self.list.append([name, False])
def refresh_liststore(self, tp): for i in self.tabs[self.current_page][0]: if type(i) == Gtk.ScrolledWindow: for t in i: if type(t) == Gtk.TreeView: ls = t.get_model() ls.clear() if tp == 1: l = bookmarksview() if tp == 2: l = cookiesview() if tp == 3: l = historyview() for a in l: ls.append(list(a)) t.set_model(ls)
def get_clean_page(self, page, name, status): page = self.tabs[page][0] for child in page.url_box.get_children(): child.destroy() list = ["frame_main"] if not status: list.append("frame_status") page.iconified_vte.destroy() for i in page: if not i.get_name() in list and\ not type(i) == gi.overrides.Gtk.ScrolledWindow: page.remove(i) scrolled_window = page.scrolled_window for i in scrolled_window: scrolled_window.remove(i) scrolled_window.set_name(name) return scrolled_window
def __init__(self, tracker, url, tab_id): self.alive = True self.tracker = tracker self.uuid = tab_id self.plug = Gtk.Plug() self.plug.connect("destroy", Gtk.main_quit) self.webview = WebKit.WebView() settings = self.webview.get_settings() settings.set_property("enable-developer-extras", True) #settings.set_property("enable-webgl", True) self.webview.connect("load-started", self.load_start_event) self.webview.connect("notify::title", self.push_title_change) scrolled_window = Gtk.ScrolledWindow() scrolled_window.add(self.webview) self.plug.set_default_size(800, 600) self.plug.add(scrolled_window) self.plug.show_all() self.send("attach_event", plug_id = str(self.plug.get_id())) self.navigate_event(url)
def __init__(self, include_progress_ui=False): super(ScrolledWebkitWindow, self).__init__() # get webkit self.webkit = LocaleAwareWebView() settings = self.webkit.get_settings() settings.set_property("enable-plugins", False) # add progress UI if needed if include_progress_ui: self._add_progress_ui() # create main webkitview self.scroll = Gtk.ScrolledWindow() self.scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.pack_start(self.scroll, True, True, 0) # embed the webkit view in a scrolled window self.scroll.add(self.webkit) self.show_all()
def get_test_container_window(): win = Gtk.Window() win.set_size_request(500, 300) f = FlowableGrid() import buttons for i in range(10): t = buttons.CategoryTile("test", "folder") f.add_child(t) scroll = Gtk.ScrolledWindow() scroll.add_with_viewport(f) win.add(scroll) win.show_all() win.connect("destroy", lambda x: Gtk.main_quit()) return win
def get_test_window(): from softwarecenter.testutils import get_test_gtk3_icon_cache icons = get_test_gtk3_icon_cache() view = PendingPane(icons) # gui scroll = Gtk.ScrolledWindow() scroll.add_with_viewport(view) win = Gtk.Window() win.add(scroll) view.grab_focus() win.set_size_request(500, 200) win.show_all() win.connect("destroy", Gtk.main_quit) return win
def __init__(self): super(ServerWindow, self).__init__(\ orientation = Gtk.Orientation.VERTICAL, spacing = 6) self.entry = CmdEntry() self.entry.connect('send', self.__cb) self.text = Gtk.TextView() self.text.set_editable(False) self.text.set_cursor_visible(False) self.text.set_wrap_mode(Gtk.WrapMode.WORD) self.__setup_tags(self.text.get_buffer()) scr = Gtk.ScrolledWindow() scr.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scr.add(self.text) scr.set_can_focus(False) self.text.set_can_focus(False) self.pack_start(scr, True, True, 0) self.pack_start(self.entry, False, True, 0)
def add_new_feed_tab(self, title, entries): scrolled_window = Gtk.ScrolledWindow() container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) label = Gtk.Label(title) for entry in entries: box = create_feed_entry(entry.title, entry.link, entry.description) box.show() container.add(box) label.show() scrolled_window.add(container) scrolled_window.set_vexpand(True) scrolled_window.set_overlay_scrolling(False) # show manly scrollbars self.notebook.append_page(scrolled_window, label) scrolled_window.show_all()
def __init__(self): Gtk.Window.__init__(self, title='My Window Title') self.connect('delete-event', Gtk.main_quit) store = Gtk.ListStore(str, str, str, str) self.populate_store(store) self.treeview = Gtk.TreeView(model=store) renderer = Gtk.CellRendererText() column_catalog = Gtk.TreeViewColumn('Catalog Name', renderer, text=0) column_catalog.set_sort_column_id(0) self.treeview.append_column(column_catalog) column_dbname = Gtk.TreeViewColumn('Database Name', renderer, text=1) column_dbname.set_sort_column_id(1) self.treeview.append_column(column_dbname) column_charset = Gtk.TreeViewColumn('Character Set', renderer, text=2) column_charset.set_sort_column_id(2) self.treeview.append_column(column_charset) column_collation = Gtk.TreeViewColumn('Collation', renderer, text=3) column_collation.set_sort_column_id(3) self.treeview.append_column(column_collation) scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy( Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scrolled_window.add(self.treeview) scrolled_window.set_min_content_height(200) self.add(scrolled_window) self.show_all() # Add data to ListStore
def __init__(self, lat=39.36873, lon=-2.417274645879, units='F'): self.images = {} self.echo = True Gtk.Window.__init__(self) self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.set_title(comun.APP) self.set_default_size(900, 600) self.set_icon_from_file(comun.ICON) self.connect('destroy', self.close_application) # vbox = Gtk.VBox(spacing=5) self.get_content_area().add(vbox) hbox1 = Gtk.HBox() vbox.pack_start(hbox1, True, True, 0) self.scrolledwindow1 = Gtk.ScrolledWindow() self.scrolledwindow1.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.scrolledwindow1.set_shadow_type(Gtk.ShadowType.IN) hbox1.pack_start(self.scrolledwindow1, True, True, 0) self.viewer = WebKit.WebView() self.scrolledwindow1.add(self.viewer) self.scrolledwindow1.set_size_request(900, 600) self.viewer.connect('title-changed', self.title_changed) self.viewer.open('file://' + comun.HTML) self.lat = lat self.lon = lon self.units = units self.set_focus(self.viewer) self.show_all() self.message_queue = queue.Queue() while Gtk.events_pending(): Gtk.main_iteration() self.show_all() self.inicialize() self.run() self.destroy() # ################################################################### # #########################ENGINE#################################### # ###################################################################
def generate(self): self.scrolled_win = Gtk.ScrolledWindow() self.generate_accounts_list() self.generate_search_bar()
def __init__(self, configuration, channels): Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL) self.set_homogeneous(False) self.tool_bar = Gtk.Toolbar() self.pack_start(self.tool_bar, False, True, 0) tool = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_ADD, Gtk.IconSize.BUTTON), "Add") tool.connect("clicked", self.on_add_clicked) self.tool_bar.insert(tool, -1) tool = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_DELETE, Gtk.IconSize.BUTTON), "Delete") tool.connect("clicked", self.on_delete_clicked) self.tool_bar.insert(tool, -1) self.content = Gtk.ListBox() self.scrollTree = Gtk.ScrolledWindow() self.scrollTree.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.scrollTree.add_with_viewport(self.content) self.scrollTree.set_min_content_height(100) self.pack_start(self.scrollTree, True, True, 0) self.configuration = configuration self.channels = channels self.sbrick = None self.functionGroups = [] for group in configuration: fg = FunctionGroupBox(group, channels) # self.pack_start(fg, False, True, 0) self.content.add(fg) self.functionGroups.append(fg)
def __init__(self): Gtk.Frame.__init__(self) self.sbrick = None self.set_label("SBrick Information") self.store = Gtk.ListStore(str, str) self.iterSBrickID = self.store.append(["SBrick BlueGiga ID", "--"]) self.iterHardwareVersion = self.store.append(["Hardware Version", "--"]) self.iterSoftwareVersion = self.store.append(["Software Version", "--"]) self.iterNeedAuthentication = self.store.append(["Need Authentication", "--"]) self.iterIsAuthenticated = self.store.append(["Is Authenticated", "--"]) self.iterAuthenticationTimeout = self.store.append(["Authentication Timeout", "--"]) self.iterInputVoltage = self.store.append(["Input Voltage", "--"]) self.iterTemperature = self.store.append(["Temperature", "--"]) self.iterPowerCycles = self.store.append(["Power Cycles", "--"]) self.iterWatchdogTimeout = self.store.append(["Watchdog Timeout", "--"]) self.iterUpTime = self.store.append(["Up Time", "--"]) self.iterThermalLimit = self.store.append(["Thermal Limit", "--"]) self.listView = Gtk.TreeView(self.store) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Item", renderer, text=0) self.listView.append_column(column) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Value", renderer, text=1) self.listView.append_column(column) self.scrollTree = Gtk.ScrolledWindow() self.scrollTree.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.scrollTree.add_with_viewport(self.listView) self.scrollTree.set_min_content_height(100) self.add(self.scrollTree) self.set_sensitive(False)
def __init__(self, configuration, sbrick_communications_store): Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL, spacing=3, margin=0) self.set_homogeneous(False) self.configuration = configuration self.sbrick_communications_store = sbrick_communications_store self.tool_bar = Gtk.Toolbar() self.pack_start(self.tool_bar, False, True, 0) self.action_play_all = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_MEDIA_PLAY, Gtk.IconSize.BUTTON), "Play All") self.action_play_all.connect("clicked", self.on_play_all_clicked) self.tool_bar.insert(self.action_play_all, -1) self.action_stop_all = Gtk.ToolButton.new(Gtk.Image.new_from_stock(Gtk.STOCK_MEDIA_STOP, Gtk.IconSize.BUTTON), "Stop All") self.action_stop_all.connect("clicked", self.on_stop_all_clicked) self.tool_bar.insert(self.action_stop_all, -1) self.content = Gtk.ListBox() self.scrollTree = Gtk.ScrolledWindow() self.scrollTree.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.scrollTree.add_with_viewport(self.content) self.scrollTree.set_min_content_height(100) self.pack_start(self.scrollTree, True, True, 0) self.sequence_count = 0 if self.configuration is not None: for sbrick in self.configuration: stepbox = SequencePlayerBox(sbrick, sbrick_communications_store) stepbox.connect("sequence_finished", self.on_sequence_finished) self.content.add(stepbox) self.sequence_count = self.sequence_count + 1 self.playing = False self.playing_sequence = None self.playing_index = -1
def do_load(self, workbench): print('Builder Workbench Addin: Load Bracer plugin workbench') editor = workbench.get_perspective_by_name('editor') dock_pane = Ide.EditorPerspective.get_utilities(editor) dock_widget = Dazzle.DockWidget(title=_('Rust Docs'), icon_name='accessories-dictionary-symbolic', visible=True, expand=False) Bracer.dock_widget = dock_widget if Bracer.settings.get_boolean('prefs-documentation'): if Bracer.settings.get_boolean('prefs-markdown'): Bracer._MARKDOWN_CSS = Bracer.get_data('resources/markdown.css') Bracer._HL_GITHUB_CSS = Bracer.get_data('resources/github.css') Bracer._MARKED_JS = Bracer.get_data('resources/marked.js') Bracer._HL_JS = Bracer.get_data('resources/hljs.js') Bracer._MARKDOWN_VIEW_JS = Bracer.get_data('resources/markdown-view.js') webview = WebKit2.WebView(visible=True, expand=True) Bracer.dock_webview = webview settings = webview.get_settings() settings.enable_html5_local_storage = False Bracer.dock_widget.add(Bracer.dock_webview) Ide.LayoutPane.add(dock_pane, Bracer.dock_widget) else: dock_text_widget = Gtk.TextView(visible=True, expand=True) Bracer.dock_text_widget = dock_text_widget scrolled = Gtk.ScrolledWindow(visible=True) scrolled.add(Bracer.dock_text_widget) Bracer.dock_widget.add(scrolled) Ide.LayoutPane.add(dock_pane, Bracer.dock_widget)
def __init__(self): Gtk.ScrolledWindow.__init__(self) self.g_textbuffer = Gtk.TextBuffer() self.g_textbuffer.create_tag('h1', weight=Pango.Weight.BOLD, size=16*Pango.SCALE) self.g_textview = Gtk.TextView(buffer=self.g_textbuffer) self.add(self.g_textview)
def add_nonwrapped_text(self, text): self._make_primary_bold() self._parsep() sc = Gtk.ScrolledWindow() l = Gtk.Label() l.set_markup('<span font_family="monospace">%s</span>' % escape(text)) l.set_line_wrap(False) l.set_alignment(0.0, 0.5) l.show() sc.add_with_viewport(l) self.msg_vbox.pack_start(sc, True, True, 0) sc.show_all() sc.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER) h = l.get_ancestor(Gtk.Viewport).size_request().height max_lines = 5 lines = text.count("\n") + 1 # This is the space the horizontal scrollbar takes scrollbar_height = (sc.get_hscrollbar().size_request().height + sc.style_get_property("scrollbar-spacing")) if lines <= max_lines: # make the scrollwin so high that it can display all lines sc.set_size_request(-1, h) else: sc.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) sc.set_size_request(-1, int(h * max_lines / lines)) adj = sc.get_hscrollbar().get_adjustment() def f(scrollbar, event): sc.set_size_request(-1, int(h * max_lines / lines) + scrollbar_height) scrollbar.disconnect(self._hscroll_expose_id) # f is called if the horizontal scrollbar is visible. This because we # need to allocate space for the scrollbar too. self._hscroll_expose_id = sc.get_hscrollbar().connect('expose-event', f)
def __init__(self): Gtk.ScrolledWindow.__init__(self) self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self._on_focus_in_blocked = False self.m_min_width = 500 self.m_min_height = 300 self.set_size_request(self.m_min_width, self.m_min_height) self.m_linkbuttons = [] self.g_searchentry = None
def __init__(self, model, parent): Gtk.VBox.__init__(self) self.m_model = model self.m_parent = parent sc = Gtk.ScrolledWindow() sc.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.pack_start(sc, True, True, 0) self.g_column_box = Gtk.HBox() self.g_column_box.set_spacing(gu.hig.SPACE_LARGE) self.g_column_box.set_border_width(gu.hig.SPACE_SMALL) # We pack column into this box sc.add_with_viewport(self.g_column_box) self.show_all() if model: self.update_from_model()
def show_path_info(self, w): if not self.g_path_info_dlg: self.g_path_info_dlg = Gtk.Dialog(_("_File locations").replace("_", ""), self, buttons=(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)) sc = Gtk.ScrolledWindow() sc.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER) self.g_path_info_dlg.vbox.pack_start(sc, True, True, 0) # vbox = gu.hig_dlg_vbox() sc.add_with_viewport(vbox) box1, box2 = gu.hig_category_vbox(_("_File locations").replace("_", "")) vbox.pack_start(box1, True, True, 0) sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL) # statistics.sqlite # win32 solfegerc # win32 langenviron.txt box2.pack_start(gu.hig_label_widget(_("Solfege application data:"), Gtk.Label(label=filesystem.app_data()), sizegroup), False, False, 0) box2.pack_start(gu.hig_label_widget(_("Solfege user data:"), Gtk.Label(label=filesystem.user_data()), sizegroup), False, False, 0) box2.pack_start(gu.hig_label_widget(_("Solfege config file:"), Gtk.Label(label=filesystem.rcfile()), sizegroup), False, False, 0) box2.pack_start(gu.hig_label_widget(_("Solfege installation directory:"), Gtk.Label(label=os.getcwdu()), sizegroup), False, False, 0) box2.pack_start(gu.hig_label_widget(_("User manual in HTML format:"), Gtk.Label(label=os.path.join(os.getcwdu(), "help")), sizegroup), False, False, 0) box2.pack_start(gu.hig_label_widget("gtk:", Gtk.Label(label=str(Gtk)), sizegroup), False, False, 0) box2.pack_start(gu.hig_label_widget("pyalsa:", Gtk.Label(label=str(alsaseq)), sizegroup), False, False, 0) box2.pack_start(gu.hig_label_widget("PYTHONHOME", Gtk.Label(os.environ.get('PYTHONHOME', 'Not defined')), sizegroup), False, False, 0) self.g_path_info_dlg.show_all() def f(*w): self.g_path_info_dlg.hide() return True self.g_path_info_dlg.connect('response', f) self.g_path_info_dlg.connect('delete-event', f) sc.set_size_request(min(vbox.size_request().width + gu.hig.SPACE_LARGE * 2, Gdk.Screen.width() * 0.9), vbox.size_request().height)
def __init__(self, main, title='Search results'): super(SearchDialog,self).__init__(title, main.window, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_OK,Gtk.ResponseType.ACCEPT)) # the cancel button self.butt_cancel = self.action_area.get_children()[0] self.butt_cancel.connect("clicked", lambda x: self.destroy()) # Positions self.resize(400, 400) self.set_position(Gtk.WindowPosition.CENTER) ui.gtk3.common.set_bokken_icon(self) # Log TextView ################################################################# self.output_text = Gtk.TextView(buffer=None) self.output_text.set_wrap_mode(Gtk.WrapMode.NONE) self.output_text.set_editable(False) self.output_buffer = self.output_text.get_buffer() self.scrolled_window = Gtk.ScrolledWindow() self.scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.ALWAYS) self.scrolled_window.is_visible = True # Add Textview to Scrolled Window self.scrolled_window.add_with_viewport(self.output_text) #self.vbox.pack_start(self.output_text, True, True, 0) self.vbox.pack_start(self.scrolled_window, True, True, 0) self.show_all()
def __init__(self, title='Add comment'): super(CommentsDialog,self).__init__(title, None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)) # the cancel button self.butt_cancel = self.action_area.get_children()[1] self.butt_cancel.connect("clicked", lambda x: self.destroy()) # Positions self.resize(400, 200) self.set_position(Gtk.WindowPosition.CENTER) ui.gtk3.common.set_bokken_icon(self) # Log TextView ################################################################# self.input_text = Gtk.TextView(buffer=None) self.input_text.set_wrap_mode(Gtk.WrapMode.NONE) self.input_text.set_left_margin(10) self.input_buffer = self.input_text.get_buffer() self.scrolled_window = Gtk.ScrolledWindow() self.scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.scrolled_window.is_visible = True # Add Textview to Scrolled Window self.scrolled_window.add_with_viewport(self.input_text) #self.vbox.pack_start(self.input_text, True, True, 0) self.vbox.pack_start(self.scrolled_window, True, True, 0) self.show_all()
def create_tree(self): # Scrolled Window self.sw = Gtk.ScrolledWindow() self.sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN) self.sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.store = Gtk.ListStore(str, str) self.tree = Gtk.TreeView(self.store) self.sw.add(self.tree) self.tree.set_rules_hint(True) # Connect right click popup search menu self.popup_handler = self.tree.connect('button-press-event', self.popup_menu) # Create the column bblocks = Gtk.TreeViewColumn() bblocks.set_title("Basic Blocks") cell = Gtk.CellRendererText() bblocks.pack_start(cell, True) bblocks.add_attribute(cell, "text", 0) self.treestore = Gtk.TreeStore(str) # Add column to tree self.tree.append_column(bblocks) self.tree.set_model(self.treestore) self.tree.expand_all()
def __init__(self, parent=None, title='', description='', long_description=''): Gtk.Window.__init__(self, title=title) self.set_parent(parent) self.set_transient_for(parent) self.set_destroy_with_parent(False) self.set_default_size(600, 500) self.vbox = Gtk.VBox(spacing=0) self.add(self.vbox) self.text_buffer = Gtk.TextBuffer() self.text_buffer.insert_at_cursor(description) self.text_buffer.insert_at_cursor( '\n\n' + '############################################################' + '\n') self.text_buffer.insert_at_cursor( 'Complete file implementing the input method follows here:\n') self.text_buffer.insert_at_cursor( '############################################################' + '\n') self.text_buffer.insert_at_cursor(long_description) self.text_view = Gtk.TextView() self.text_view.set_buffer(self.text_buffer) self.text_view.set_editable(False) self.text_view.set_cursor_visible(False) self.text_view.set_justification(Gtk.Justification.LEFT) self.text_view.set_wrap_mode(Gtk.WrapMode.WORD) self.scrolledwindow = Gtk.ScrolledWindow() self.scrolledwindow.set_hexpand(True) self.scrolledwindow.set_vexpand(True) self.scrolledwindow.add(self.text_view) self.vbox.pack_start(self.scrolledwindow, True, True, 0) self.close_button = Gtk.Button(stock=Gtk.STOCK_CLOSE) self.close_button.connect("clicked", self.on_close_button_clicked) self.hbox = Gtk.HBox(spacing=0) self.hbox.pack_end(self.close_button, False, False, 0) self.vbox.pack_start(self.hbox, False, False, 5)
def __init__(self, **kwargs): super().__init__( default_width=800, default_height=400, **kwargs ) self.add_dialog = None action = Gio.SimpleAction.new('add-application', None) self.add_action(action) action.connect('activate', self.on_add_application) header = Gtk.HeaderBar(show_close_button=True, title=_('DRI Configuration')) add_btn = Gtk.Button.new_from_icon_name('list-add-symbolic', Gtk.IconSize.BUTTON) add_btn.props.action_name = 'win.add-application' header.pack_start(add_btn) header.show_all() self.set_titlebar(header) box = Gtk.Box(Gtk.Orientation.HORIZONTAL) sidebar = Gtk.StackSidebar() sw = Gtk.ScrolledWindow(child=sidebar, hscrollbar_policy=Gtk.PolicyType.NEVER) box.pack_start(sw, False, True, 0) stack = Gtk.Stack() # Just a basic mockup conf = dri.DRIConfig('/etc/drirc') device = conf.devices[0] for app in device.apps: # TODO: Group these by device pane = ApplicationPane(app, visible=True) stack.add_titled(pane, app.name, app.name) sidebar.props.stack = stack sw = Gtk.ScrolledWindow(child=stack) box.pack_start(sw, True, True, 0) box.show_all() self.add(box)
def on_menuitem_feedback_activate(self, widget): window_feedback = Gtk.Window() window_feedback.set_title("Feedback Form") window_feedback.set_default_size(640, 640) window_feedback.set_position(Gtk.WindowPosition.CENTER) feedback_browser = WebKit.WebView() feedback_browser.connect("console-message", self._javascript_console_message) # Suppress .js output feedback_scroller = Gtk.ScrolledWindow() feedback_scroller.add(feedback_browser) window_feedback.add(feedback_scroller) feedback_browser.open("https://jamiemcgowan.typeform.com/to/ng5Lhc") window_feedback.show_all()
def setup_viewer(self): self.viewer_grid = Gtk.Grid() scroll_window = Gtk.ScrolledWindow() scroll_window.set_vexpand(True) scroll_window.set_hexpand(True) self.viewer_grid.attach(scroll_window, 0, 0, 1, 1) self.courses_grid = courseGrid(self.course_manager.user['display_years']) scroll_window.add(self.courses_grid) self.columns = {} for year in range(1,self.course_manager.user['display_years']+1): for pos, quarter in enumerate(["fall", "winter", "spring", "summer"]): column_id = self.column_template.format(year, quarter) column = self.courses_grid.year_map[year].quarter_map[pos] # For drag and drop column.drag_dest_set_target_list(None) column.drag_dest_add_text_targets() column.connect('button-press-event', self.box_clicked) column.connect("drag-data-received", self.on_drag_data_received) self.columns[column_id] = column.box self.interface_switcher.insert_page(self.viewer_grid, None, 0)
def create_synonyms_flowbox(self): label_Synonyms=Gtk.Label() label_Synonyms.set_markup("<u><b>Synonyms</b></u>") self.vbox_left2.pack_start(label_Synonyms,False,True,0) self.scrolled=Gtk.ScrolledWindow() self.scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.flowbox=Gtk.FlowBox() self.flowbox.set_valign(Gtk.Align.START) self.flowbox.set_max_children_per_line(7) self.flowbox.set_selection_mode(Gtk.SelectionMode.NONE) self.toggle_button_list=[] for i in range(100): x=Gtk.ToggleButton(label=str(i)) self.toggle_button_list.append(x) for i in range(100): self.toggle_button_list[i].connect('clicked',self.toggle_button_clicked) for i in self.toggle_button_list: self.flowbox.add(i) self.scrolled.add(self.flowbox) self.add(self.scrolled) self.vbox_left2.pack_start(self.scrolled,True,True,0) #########signal callback functions######################
def __init__(self, item): super().__init__() self.set_name('LinksButton') self.set_label('%i links' % len(item.links)) self.set_halign(Gtk.Align.START) self.set_valign(Gtk.Align.END) self.set_margin_left(5) self.set_margin_bottom(5) self.connect('activate-link', self._on_activate_link) style_context = self.get_style_context() style_context.remove_class('text-button') style_context.remove_class('button') self._weakref = weakref.ref(item) self._box = Gtk.Box() self._box.set_orientation(Gtk.Orientation.VERTICAL) height_request = 300 if len(self.item.links) <= 5: height_request = 150 scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy( Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC ) scrolled_window.set_size_request(300, height_request) scrolled_window.add(self._box) scrolled_window.show_all() self._popover = Gtk.Popover() self._popover.set_relative_to(self) self._popover.add(scrolled_window) self.populate()
def __init__(self, name: str, title: str, subtitle: str, width: int, height: int, header_buttons: dict, is_parent: bool): """Initialize Window class""" super(Window, self).__init__(title=title) self._name = name self._title = title self._subtitle = subtitle self._width = width self._height = height if header_buttons: self._header = HeaderBar(self._title, self._subtitle, header_buttons) self.set_titlebar(self._header.render) else: self._header = None self._is_parent = is_parent # self.set_resizable(False) self.set_size_request(self._width, self._height) self.set_position(Gtk.WindowPosition.CENTER) self.set_border_width(10) self.set_name(self._name) self._scrolled = Gtk.ScrolledWindow() self._scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self._box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10) self._box.set_homogeneous(False) self.add(self._scrolled) self._scrolled.add(self._box) if self._is_parent: self.connect("delete-event", Gtk.main_quit)
def createScrollbar(Treeview): Scrollbar = Gtk.ScrolledWindow() Scrollbar.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) Scrollbar.set_vexpand(True) Scrollbar.add(Treeview) return Scrollbar # creating subFrame in Vulkan Tab
def __init__(self,url): self.code = None Gtk.Dialog.__init__(self) self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.set_title(comun.APP) self.set_icon_from_file(comun.ICON) # vbox = Gtk.VBox(spacing = 5) self.get_content_area().add(vbox) hbox1 = Gtk.HBox() vbox.pack_start(hbox1,True,True,0) # self.scrolledwindow1 = Gtk.ScrolledWindow() self.scrolledwindow1.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.scrolledwindow1.set_shadow_type(Gtk.ShadowType.IN) hbox1.pack_start(self.scrolledwindow1,True,True,0) # self.viewer = WebKit.WebView() self.scrolledwindow1.add(self.viewer) self.scrolledwindow1.set_size_request(600,420) self.viewer.connect('navigation-policy-decision-requested', self.on_navigation_requested) self.viewer.open(url) # self.show_all() #################################################################### #########################BROWSER#################################### ####################################################################
def __init__(self): Gtk.ScrolledWindow.__init__(self) self.view = Gtk.DrawingArea() self.view.set_hexpand(True) self.view.set_vexpand(True) self.view.set_events(Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventType.MOTION_NOTIFY | Gdk.EventMask.POINTER_MOTION_MASK) self.view.connect('draw', self.draw) self.view.connect('button-press-event', self.press) self.view.connect('motion-notify-event', self.motion) self.add(self.view)
def build_scrollable_popover(pos, width, height): popover = Gtk.Popover() popover.set_position(pos) scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scrolled_window.set_size_request(width, height) popover.add(scrolled_window) return popover
def __init__(self, mainapp): self._mainapp = mainapp self.config = mainapp.config self.draw = mainapp.draw self.default_size = self.config["misc"]["dsize"] self.last_size = (-1, -1) self.tag_image_bytedata = None # window setup self.overlay = Gtk.Overlay() self.image = Gtk.Image() self.scrolled = Gtk.ScrolledWindow() self.scrolled.add(self.image) self.overlay.add(self.scrolled) self.overlay.add_overlay(self.draw.area) self.va = self.scrolled.get_vadjustment() self.ha = self.scrolled.get_hadjustment() self.rebuild_window() # fix this if not self.config["image"]["show"]: self.overlay.remove(self.scrolled) # Base window properties
def __setup_ui(self, win): btn_setting = Gtk.Button("Settings") btn_setting.set_margin_right(self.HORIZONTAL_MARGIN) btn_reload = Gtk.Button("Reload") btn_box = Gtk.HBox() btn_box.add(btn_setting) btn_box.add(btn_reload) self._listbox = Gtk.TreeView(self._list_store) self._listbox.set_headers_visible(False) self._listbox.connect("row-activated", self.__row_activated) self._scrollable = Gtk.ScrolledWindow() self._scrollable.add(self._listbox) self.__fill_listbox() self._frame = Gtk.Frame() self._frame.add(self._scrollable) self._frame.set_border_width(1) self._frame.set_margin_bottom(self.VERTICAL_MARGIN) vbox = Gtk.VBox() vbox.pack_start(self._frame, 1, 1, 1) vbox.pack_end(btn_box, 0, 0, 0) vbox.set_margin_top(self.VERTICAL_MARGIN) vbox.set_margin_bottom(self.VERTICAL_MARGIN) vbox.set_margin_left(self.VERTICAL_MARGIN) vbox.set_margin_right(self.VERTICAL_MARGIN) win.add(vbox) return btn_reload, btn_setting