本文整理汇总了Python中kano.gtk3.scrolled_window.ScrolledWindow.add_with_viewport方法的典型用法代码示例。如果您正苦于以下问题:Python ScrolledWindow.add_with_viewport方法的具体用法?Python ScrolledWindow.add_with_viewport怎么用?Python ScrolledWindow.add_with_viewport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kano.gtk3.scrolled_window.ScrolledWindow
的用法示例。
在下文中一共展示了ScrolledWindow.add_with_viewport方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from kano.gtk3.scrolled_window import ScrolledWindow [as 别名]
# 或者: from kano.gtk3.scrolled_window.ScrolledWindow import add_with_viewport [as 别名]
def __init__(self, size_x=400, size_y=150):
Gtk.Grid.__init__(self)
self.set_row_spacing(10)
self.set_column_spacing(10)
scroll = ScrolledWindow()
scroll.set_size_request(size_x, size_y)
scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
self.edit_list_store = Gtk.ListStore(str)
self.edit_list = Gtk.TreeView(self.edit_list_store)
self.edit_list.set_headers_visible(False)
renderer = Gtk.CellRendererText()
renderer.set_property('editable', True)
renderer.connect('edited', self._item_edited_handler)
renderer.connect('editing-started', self._item_edit_started)
renderer.connect('editing-canceled', self._item_edit_canceled)
column = Gtk.TreeViewColumn(cell_renderer=renderer, text=0)
self.edit_list.append_column(column)
self._add_btn = KanoButton(_("ADD"))
self._add_btn.connect('button-release-event', self.add)
self._rm_btn = KanoButton(_("REMOVE"))
self._set_rm_btn_state()
self._rm_btn.connect('button-release-event', self.rm)
scroll.add_with_viewport(self.edit_list)
self.attach(scroll, 0, 0, 2, 1)
self.attach(self._add_btn, 0, 1, 1, 1)
self.attach(self._rm_btn, 1, 1, 1, 1)
示例2: __add_scrolled_window
# 需要导入模块: from kano.gtk3.scrolled_window import ScrolledWindow [as 别名]
# 或者: from kano.gtk3.scrolled_window.ScrolledWindow import add_with_viewport [as 别名]
def __add_scrolled_window(self):
text = Gtk.TextView()
text.get_buffer().set_text(self.scrolled_text)
text.set_wrap_mode(Gtk.WrapMode.WORD)
text.set_editable(False)
scrolledwindow = ScrolledWindow()
scrolledwindow.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
scrolledwindow.add_with_viewport(text)
scrolledwindow.set_size_request(400, 200)
scrolledwindow.apply_styling_to_widget(wide=False)
return scrolledwindow
示例3: activate
# 需要导入模块: from kano.gtk3.scrolled_window import ScrolledWindow [as 别名]
# 或者: from kano.gtk3.scrolled_window.ScrolledWindow import add_with_viewport [as 别名]
def activate(_win):
project_list = ProjectList()
scrolledwindow = ScrolledWindow()
scrolledwindow.apply_styling_to_widget()
scrolledwindow.add_with_viewport(project_list.background)
scrolledwindow.set_size_request(734, 404)
_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
_box.pack_start(scrolledwindow, False, False, 0)
_win.pack_in_main_content(_box)
_win.show_all()
示例4: _generate_grid
# 需要导入模块: from kano.gtk3.scrolled_window import ScrolledWindow [as 别名]
# 或者: from kano.gtk3.scrolled_window.ScrolledWindow import add_with_viewport [as 别名]
def _generate_grid(self):
row_count = int(math.ceil(
float(len(self._DISPLAYED_SCREENS)) / self._col_count)
)
table = Gtk.Table(row_count, self._col_count, homogeneous=True,
hexpand=True, vexpand=True)
table.props.margin = 0
for idx, screen in enumerate(self._DISPLAYED_SCREENS):
row = idx / 2
col = idx % 2
screen.create_menu_button(self._change_screen_cb)
if row % 2:
style_class = 'appgrid_grey'
else:
style_class = 'appgrid_white'
screen.menu_button.button.get_style_context().add_class(style_class)
screen.refresh_menu_button()
table.attach(screen.menu_button.button,
col, col + 1, row, row + 1,
Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND,
Gtk.AttachOptions.FILL, 0, 0)
scrolled_window = ScrolledWindow(wide_scrollbar=True, vexpand=True,
hexpand=True)
scrolled_window.get_style_context().add_class('app-grid')
scrolled_window.add_with_viewport(table)
return scrolled_window
示例5: AppGrid
# 需要导入模块: from kano.gtk3.scrolled_window import ScrolledWindow [as 别名]
# 或者: from kano.gtk3.scrolled_window.ScrolledWindow import add_with_viewport [as 别名]
class AppGrid(Gtk.EventBox):
def __init__(self, main_win, apps_obj):
Gtk.EventBox.__init__(self, hexpand=True, vexpand=True)
style = self.get_style_context()
style.add_class('app-grid')
self._win = main_win
self._apps = apps_obj
self._num_apps = 0
self._sw = ScrolledWindow(hexpand=True, vexpand=True,
wide_scrollbar=True)
self._sw.props.margin_top = 7
self._sw.props.margin_bottom = 0
self._sw.props.margin_left = 0
self._sw.props.margin_right = 0
self._sw.props.border_width = 0
self._sw.set_shadow_type(Gtk.ShadowType.NONE)
self._box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self._sw.add_with_viewport(self._box)
self.add(self._sw)
def new_entry(self, app, sort_by="title", reverse=False):
if "colour" not in app:
if (self._num_apps % 2) == 0:
app["colour"] = "#f2914a"
else:
app["colour"] = "#f5a269"
self._num_apps += 1
entry = AppGridEntry(app, self._win, self._apps)
self._box.pack_start(entry, False, False, 0)
pos = 0
for child in self._box:
child_app_data = child.get_app_data()
# keep the special "want-more" entry at the bottom of the list
if "slug" in child_app_data and \
child_app_data["slug"] == "want-more":
break
if reverse:
if app[sort_by] > child_app_data[sort_by]:
break
else:
if app[sort_by] < child_app_data[sort_by]:
break
pos += 1
self._box.reorder_child(entry, pos)
entry.show_all()
return entry
def get_num(self):
return self._num_apps
示例6: show_results
# 需要导入模块: from kano.gtk3.scrolled_window import ScrolledWindow [as 别名]
# 或者: from kano.gtk3.scrolled_window.ScrolledWindow import add_with_viewport [as 别名]
def show_results(msg_upgraded, msg_added, msg_removed, debian_err_packages,
appstate_after_nonclean, python_ok, python_err):
# Create Gtk textiew with markdown
text_view = Gtk.TextView()
text_view.set_margin_top(10)
text_view.set_margin_bottom(20)
text_view.set_margin_left(20)
text_view.set_margin_right(20)
text_buffer = text_view.get_buffer()
bold_tag = text_buffer.create_tag("bold", weight=Pango.Weight.BOLD)
scrolled_window = ScrolledWindow()
scrolled_window.apply_styling_to_widget()
scrolled_window.add_with_viewport(text_view)
scrolled_window.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
scrolled_window.set_size_request(400, 200)
result_dialog = kano_dialog.KanoDialog("Update result", "",
widget=scrolled_window,
global_style=True)
result_dialog.dialog.set_icon_name("kano-updater")
result_dialog.dialog.set_title("Kano Updater")
if msg_upgraded:
text = "\nApps upgraded:\n"
add_text_to_end(text_buffer, text, bold_tag)
add_text_to_end(text_buffer, msg_upgraded)
if msg_added:
text = "\nApps added:\n"
add_text_to_end(text_buffer, text, bold_tag)
add_text_to_end(text_buffer, msg_added)
if msg_removed:
text = "\nApps removed:\n"
add_text_to_end(text_buffer, text, bold_tag)
add_text_to_end(text_buffer, msg_removed)
if debian_err_packages:
text = "\nApps with errors:\n"
add_text_to_end(text_buffer, text, bold_tag)
msg_error = "{}\n".format('\n'.join(debian_err_packages))
add_text_to_end(text_buffer, msg_error)
if appstate_after_nonclean:
text = "\nApps with non-clean state:\n"
add_text_to_end(text_buffer, text, bold_tag)
non_clean_list = '\n'.join(appstate_after_nonclean.iterkeys())
msg_non_clean_list = non_clean_list + "\n"
add_text_to_end(text_buffer, msg_non_clean_list)
if python_ok:
text = "\nPython modules upgraded:\n"
add_text_to_end(text_buffer, text, bold_tag)
python_modules = "{}\n".format('\n'.join(python_ok))
add_text_to_end(text_buffer, python_modules)
if python_err:
text = "\nPython modules with error:\n"
add_text_to_end(text_buffer, text, bold_tag)
err_list = '\n'.join(python_err)
msg_python_err = err_list + "\n"
add_text_to_end(text_buffer, msg_python_err)
if not (msg_upgraded or msg_added or msg_removed or debian_err_packages or
appstate_after_nonclean or python_ok or python_err):
add_text_to_end(text_buffer, "No updates needed this time.", bold_tag)
result_dialog.run()
while Gtk.events_pending():
Gtk.main_iteration()