本文整理汇总了Python中gtk.HBox.pack_start方法的典型用法代码示例。如果您正苦于以下问题:Python HBox.pack_start方法的具体用法?Python HBox.pack_start怎么用?Python HBox.pack_start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk.HBox
的用法示例。
在下文中一共展示了HBox.pack_start方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: password_dialog
# 需要导入模块: from gtk import HBox [as 别名]
# 或者: from gtk.HBox import pack_start [as 别名]
class password_dialog(Dialog):
def __init__(self, parent, icon):
Dialog.__init__(self, "GtkPacman Login", parent,
DIALOG_MODAL | DIALOG_DESTROY_WITH_PARENT,
(STOCK_OK, RESPONSE_ACCEPT, STOCK_CANCEL, RESPONSE_REJECT))
self.set_icon(pixbuf_new_from_file(icon))
self._setup_layout()
def _setup_layout(self):
self.password_entry = Entry()
self.password_entry.set_visibility(False)
self.password_entry.set_invisible_char('*')
info_label = Label(' Enter root password ')
self.hbox = HBox()
self.vbox.pack_start(info_label)
self.vbox.pack_start(self.password_entry)
self.vbox.pack_start(self.hbox)
self.show_all()
def show_warning(self):
image = Image()
image.set_from_stock(STOCK_STOP, ICON_SIZE_BUTTON)
warning_label = Label(' Invalid Password! ')
self.hbox.pack_start(image, False, False, 10)
self.hbox.pack_start(warning_label, False, False, 0)
self.show_all()
示例2: create_encoding_box
# 需要导入模块: from gtk import HBox [as 别名]
# 或者: from gtk.HBox import pack_start [as 别名]
def create_encoding_box(combobox):
from i18n import msg0157
from gtk import Label, HBox
label = Label(msg0157)
label.set_use_underline(True)
hbox = HBox(homogeneous=False, spacing=10)
hbox.pack_start(label, False, False, 0)
hbox.pack_start(combobox, True, True, 0)
return hbox
示例3: create_menuitem
# 需要导入模块: from gtk import HBox [as 别名]
# 或者: from gtk.HBox import pack_start [as 别名]
def create_menuitem(string, stock_id=None):
from gtk import MenuItem, Image, HBox, Label
hbox = HBox(spacing=7)
hbox.set_property("border-width", 2)
if stock_id:
image = Image()
image.set_property("stock", stock_id)
hbox.pack_start(image, False, False, 0)
label = Label(string)
label.set_property("use-underline", True)
hbox.pack_start(label, False, False, 0)
menuitem = MenuItem()
menuitem.add(hbox)
return menuitem
示例4: create_button
# 需要导入模块: from gtk import HBox [as 别名]
# 或者: from gtk.HBox import pack_start [as 别名]
def create_button(stock_id, string):
from gtk import HBox, Image, Label, ICON_SIZE_BUTTON, Alignment
alignment = Alignment()
alignment.set_property("xalign", 0.5)
alignment.set_property("yalign", 0.5)
hbox = HBox(False, 3)
if stock_id:
image = Image()
image.set_from_stock(stock_id, ICON_SIZE_BUTTON)
hbox.pack_start(image, False, False, 0)
label = Label(string)
label.set_property("use-underline", True)
hbox.pack_start(label, False, False, 0)
alignment.add(hbox)
return alignment
示例5: quiz
# 需要导入模块: from gtk import HBox [as 别名]
# 或者: from gtk.HBox import pack_start [as 别名]
def quiz(self, widget=None):
"""Quiz the user on a random subset of the playlist."""
subset = sample(self.playlist, self.num_songs)
clipStarts = [randrange(0, int(_length(i)) - _clip_length, 1)
for i in subset]
log.debug("Clip starts: %s" % clipStarts)
self.answers = [{'artist': _artist(i), 'title': _title(i),
'genre': _genre(i), 'year': _year(i)} for i in subset]
artist_pool = set(_artist(i) for i in subset)
title_pool = set(_title(i) for i in subset)
date_pool = set(_year(i) for i in subset)
genre_pool = set(_genre(i) for i in subset)
self.responses = []
# Set up quiz_vbox. Remove old children if they're lying around.
for child in self.quiz_vbox.get_children():
self.quiz_vbox.remove(child)
for i in xrange(self.num_songs):
widget = HBox();
artist_cb = combo_box_new_text()
for artist in artist_pool:
artist_cb.append_text(artist)
title_cb = combo_box_new_text()
for title in title_pool:
title_cb.append_text(title)
date_cb = combo_box_new_text()
for date in date_pool:
date_cb.append_text(date)
genre_cb = combo_box_new_text()
for genre in genre_pool:
genre_cb.append_text(genre)
widget.pack_start(artist_cb)
widget.pack_start(title_cb)
widget.pack_start(date_cb)
widget.pack_start(genre_cb)
self.quiz_vbox.pack_start(widget)
self.quiz_vbox.show_all()
self.notebook.next_page()
# Look into doing follow-up code (running the quiz) with a callback
# registered to the notebook's "switch-page" signal.
# Prepare quiz to run in a separate thread.
self.thread = Thread(target=self.play_subset,
kwargs={'subset':subset, 'clipStarts':clipStarts})
self.thread.start()
示例6: __init__
# 需要导入模块: from gtk import HBox [as 别名]
# 或者: from gtk.HBox import pack_start [as 别名]
def __init__(self):
HBox.__init__(self)
MDSplusWidget.__init__(self)
HBox.set_homogeneous(self,False)
self.node_state=CheckButton('')
self.button=Button()
HBox.pack_start(self,self.node_state,False,False,0)
HBox.pack_start(self,self.button,False,False,0)
HBox.pack_start(self,Label(''),True,False,0)
if not guibuilder:
self.button.connect("clicked",self.popupXd)
self.button.connect("realize",self.setButtonLabel)
示例7: initXdbox
# 需要导入模块: from gtk import HBox [as 别名]
# 或者: from gtk.HBox import pack_start [as 别名]
def initXdbox(self):
self.xdbox=Window()
try:
self.xdbox.set_title(str(self.node))
except:
pass
vbox=VBox()
self.xdbox.expr=MDSplusExprWidget()
vbox.pack_start(self.xdbox.expr,True,True,20)
close=Button(stock=STOCK_CLOSE)
close.connect("clicked",self.xdbox_close)
redo=Button(stock=STOCK_REDO)
redo.connect("clicked",self.xdbox_redo)
cancel=Button(stock=STOCK_CANCEL)
cancel.connect("clicked",self.xdbox_cancel)
hbox=HBox()
hbox.pack_start(close,False,False,20)
hbox.pack_start(redo,False,False,20)
hbox.pack_start(cancel,False,False,20)
vbox.pack_start(hbox,False,False,20)
self.xdbox.add(vbox)
self.xdbox.expr.set_text(self.node_value())
示例8: __init__
# 需要导入模块: from gtk import HBox [as 别名]
# 或者: from gtk.HBox import pack_start [as 别名]
def __init__(self, node=None, value=None):
Window.__init__(self)
MDSplusWidget.__init__(self)
if node is not None:
self.node = node
else:
self.value = value
hbtop = HBox(homogeneous=False)
self.on = CheckButton(label="On")
self.parent_on = CheckButton(label="Parent")
self.parent_on.set_sensitive(False)
self.path = MDSplusPathWidget()
if node is not None:
self.path._node = self._node
hbtags = HBox(homogeneous=False)
self.tags = Entry()
self.tags.set_width_chars(60)
expression_menu = self.dtype_menu(tuple(), varname="dtype_expression", no_show=True)
axis_menu = self.dtype_menu(("Range",), varname="dtype_axis", no_show=True)
window_menu = self.dtype_menu(("Window",), varname="dtype_window", no_show=True)
dispatch_menu = self.dtype_menu(("Dispatch",), varname="dtype_dispatch", no_show=True)
action_menu = self.dtype_menu(("Action",), varname="dtype_action", no_show=True)
task_menu = self.dtype_menu(("Method", "Routine"), varname="dtype_task", no_show=True)
any_menu = self.dtype_menu(
("Range", "Window", "Dispatch", "Action", "Method", "Routine"), varname="dtype_any", no_show=True
)
menus = (
self.dtype_expression,
self.dtype_axis,
self.dtype_dispatch,
self.dtype_action,
self.dtype_task,
self.dtype_window,
self.dtype_any,
)
hbtop.pack_start(self.on, False, False, 10)
hbtop.pack_start(self.parent_on, False, False, 10)
hbtop.pack_start(self.path, False, False, 0)
hbtags.pack_start(Label("Tags:"), False, False, 10)
hbtags.pack_start(self.tags, False, False, 0)
self.action = MDSplusActionWidget()
self.windoww = MDSplusWindowWidget()
self.sequential = MDSplusSequentialWidget()
self.expression = MDSplusExpressionWidget()
self.method = MDSplusMethodWidget()
self.routine = MDSplusRoutineWidget()
self.dispatch = MDSplusDispatchWidget()
self.range = MDSplusRangeWidget()
self.widgets = (
self.action,
self.sequential,
self.expression,
self.method,
self.routine,
self.dispatch,
self.range,
self.windoww,
)
self.ok = Button(stock=STOCK_OK)
self.cancel = Button(stock=STOCK_CANCEL)
self.redo = Button(stock=STOCK_REDO)
self.ok.connect("clicked", self.do_ok)
self.cancel.connect("clicked", self.do_cancel)
self.redo.connect("clicked", self.do_redo)
hb2 = HBox()
hb2.add(self.ok)
hb2.add(self.redo)
hb2.add(self.cancel)
vb = VBox(homogeneous=False)
vb.set_border_width(10)
vb.pack_start(hbtop, False, False, 0)
vb.pack_start(hbtags, False, False, 0)
vb.pack_start(expression_menu, False, False, 0)
vb.pack_start(axis_menu, False, False, 0)
vb.pack_start(window_menu, False, False, 0)
vb.pack_start(dispatch_menu, False, False, 0)
vb.pack_start(action_menu, False, False, 0)
vb.pack_start(task_menu, False, False, 0)
vb.pack_start(any_menu, False, False, 0)
for w in self.widgets:
w.set_no_show_all(True)
vb.pack_start(w, False, False, 0)
vb.pack_start(hb2, False, False, 20)
self.add(vb)
self.do_redo(self.redo)
self.putOnApply = True
self.nidOffset = -1
示例9: inHBox
# 需要导入模块: from gtk import HBox [as 别名]
# 或者: from gtk.HBox import pack_start [as 别名]
def inHBox(self, w):
hb = HBox()
hb.pack_start(w, False, False, 0)
return hb
示例10: __on_plugin_directories_button_click
# 需要导入模块: from gtk import HBox [as 别名]
# 或者: from gtk.HBox import pack_start [as 别名]
def __on_plugin_directories_button_click(self, button):
"""Present a dialog to the user for selecting extra plugin directories
and process the request."""
dia = Dialog('Plugin Directories',
None, DIALOG_MODAL,
(STOCK_OK, RESPONSE_OK,
STOCK_CANCEL, RESPONSE_CANCEL ) )
dia.resize(500, 300)
dia.vbox.set_spacing(8)
# Setup the tree view of plugin directories.
model = ListStore(str) # each row contains a single string
tv = TreeView(model)
cell = CellRendererText()
column = TreeViewColumn('Directory', cell, text = 0)
tv.append_column(column)
dia.vbox.pack_start(tv)
# Populate the tree view.
plugin_directories = \
get_plugins_directories_from_config(self.config, self.config_path)
for plugin_directory in plugin_directories:
row = (plugin_directory,)
model.append(row)
modify_box = HBox(spacing = 8)
# Setup the remove directory button.
remove_button = Button('Remove')
remove_button.set_sensitive(False) # no directory selected initially
remove_button.connect('clicked', self.__on_remove, tv)
modify_box.pack_end(remove_button, expand = False)
tv.connect('cursor-changed', self.__on_select, remove_button)
# Setup the add directory button.
add_button = Button('Add')
add_button.connect('clicked', self.__on_add, tv)
modify_box.pack_end(add_button, expand = False)
dia.vbox.pack_start(modify_box, expand = False)
# Setup the "already included directories" label.
included_label = Label('Plugins in the PYTHONPATH are already ' +
'available to BoKeep.')
# Use a horizontal box to left-justify the label. For some reason,
# the label's set_justification property doesn't work for me.
label_box = HBox()
label_box.pack_start(included_label, expand = False)
dia.vbox.pack_start(label_box, expand = False)
dia.show_all()
dia_result = dia.run()
if dia_result == RESPONSE_OK:
# Remove the old plugin directories from the program's path.
plugin_directories = \
get_plugins_directories_from_config(self.config,
self.config_path)
for plugin_directory in plugin_directories:
path.remove(plugin_directory)
# Get the new plugin directories from the dialog.
plugin_directories = []
for row in model:
plugin_directory = row[0]
plugin_directories.append(plugin_directory)
# Update the BoKeep PYTHONPATH so that new plugins can be loaded and
# populate the list of possible new plugins.
for plugin_directory in plugin_directories:
path.append(plugin_directory)
self.__populate_possible_plugins()
# Save the new plugin directories in the configuration file.
set_plugin_directories_in_config(self.config,
self.config_path, plugin_directories)
dia.destroy()
示例11: Base
# 需要导入模块: from gtk import HBox [as 别名]
# 或者: from gtk.HBox import pack_start [as 别名]
class Base(object):
def __init__(self):
from gtk import Window,WINDOW_TOPLEVEL,Button,Label,HBox,Entry,VBox,VSeparator
self.window = Window(WINDOW_TOPLEVEL)
self.window.set_title("Slideshow")
self.window.connect("delete_event", self.delete_event)
self.window.set_border_width(10)
self.vbox = VBox(False, 0)
self.window.add(self.vbox)
self.hbox1 = HBox(False, 0)
self.vbox.pack_start(self.hbox1, True, True, 1)
self.hbox = HBox(False, 0)
self.vbox.pack_start(self.hbox, False, False, 1)
self.hbox2 = HBox(False, 0)
self.vbox.pack_start(self.hbox2, True, True, 1)
self.label = Label('Identifikační číslo:')
self.hbox.pack_start(self.label, False, False, 1)
self.label.show()
self.editable = Entry()
self.editable.connect('key_press_event', self.key_press_event)
self.hbox.pack_start(self.editable, True, True, 1)
self.editable.show()
self.button = Button("Začít")
self.button.connect("clicked", self.callback)
self.button.set_receives_default(True)
self.button.set_can_focus(True)
self.hbox.pack_start(self.button, False, False, 1)
self.button.show()
self.hbox1.show()
self.hbox.show()
self.hbox2.show()
self.vbox.show()
self.window.show()
def delete_event(self, widget, event, data=None):
gtk.main_quit()
return False
def key_press_event(self, widget, event):
from gtk.gdk import keyval_from_name,keyval_name
if event.keyval in (keyval_from_name('Return'),keyval_from_name('KP_Enter')):
self.callback(widget)
def _getFilePaths(self, fileTypes, recursive=True):
import os
import re
from sys import argv
pt = re.compile(r'.*([%(0)s][^%(0)s]*)'%{'0':os.path.extsep})
path = [a for m,a in ((pt.match(os.path.basename(a)),a) for a in argv[1:]) if m and m.group(1) in fileTypes]
if not path:
path = '/home/pi/img/*.jpg'
if isinstance(path, str):
## Returns list containing paths of files in /path/ that are of a file type in /fileTypes/,
## if /recursive/ is False subdirectories are not checked.
paths = []
if recursive:
for root, folders, files in os.walk(path, followlinks=True):
for file in files:
for fileType in fileTypes:
if file.endswith(fileType):
paths.append(os.path.join(root, file))
else:
for item in os.listdir(path):
for fileType in fileTypes:
if item.endswith(fileType):
paths.append(os.path.join(root, item))
return paths
elif iterable(path):
return path
else:
return []
def _init_cb(self,trans):
from threading import Thread
if not iterable(trans):
trans = trans,
callbacks = []
for name,cb in trans:
t = Thread(target=cb, name='%sThread'%name)
t.daemon = True
t.start()
callbacks.append(cb.enqueue)
def wrap(msg):
for cb in callbacks:
if not cb(msg):
return False
return True
return wrap
def callback(self, widget):
from slideshow import SlideShow
from trans import Message,GpioTransceiver,JsonTransceiver
if not self.editable.get_text():
return False
img_cbs = self._init_cb([('ImgGpioCallback',GpioTransceiver(24)),('ImgJsonCallback',JsonTransceiver('img.json'))])
kp_cbs = self._init_cb([('KpGpioCallback',GpioTransceiver(26,bcd=False)),('KpJsonCallback',JsonTransceiver('kp.json'))])
def ordfnc(path):
from numpy.random import permutation
gray = path[0]
result = []
for p in permutation(path[1:]):
result.append(p)
result.append(gray)
return result
#.........这里部分代码省略.........
示例12: __init__
# 需要导入模块: from gtk import HBox [as 别名]
# 或者: from gtk.HBox import pack_start [as 别名]
def __init__(self,
trans, transid, plugin, gui_parent, change_register_function,
book, display_mode=TRANSACTION_ALL_EDIT_FIRST_TIME,
transaction_edit_finished_function=null_function):
self.trans = trans
self.transid = transid
self.plugin = plugin
self.gui_parent = gui_parent
self.change_register_function = change_register_function
self.book = book
self.display_mode = display_mode
self.transaction_edit_finished_function = (
null_function if display_mode not in HEADLESS_MODES
else transaction_edit_finished_function )
self.hide_parent = Window()
self.hide_parent.hide()
self.mainvbox = VBox()
self.hide_parent.add(self.mainvbox)
config = self.trans.get_configuration_and_provide_on_load_hook()
config_module_name = self.plugin.config_module_name
if not config_valid(config):
# even in the case of a broken config, we should still
# display all of the data we have available...
self.mainvbox.pack_start(Label("no configuration"))
elif not self.trans.can_safely_proceed_with_config_module(config):
# should display all data that's available instead of just
# this label
#
# and should give
# user an overide option where they either pick an old config
# for one time use or just blow out the memory of having used
# a different config...
#
# should also print the checksum itself so they know
# what they need...
#
# perhaps eventually we even put in place some archival support
# for saving old glade and config files and then code into the
# the transaction -- hey, code you need to be editable is
# over here..
#
# now hopefully there is no marking of this transaction dirty
# in this mode and the extra safegaurds we put into
# MultipageGladeTransaction don't get activated
self.mainvbox.pack_start(
Label("out of date configuration. data is read only here for "
"the safety of your old information, last adler "
"CRC was %s" % self.trans.config_crc_cache ))
else:
# if the safety cache was relied on before we need to tell the
# backend that the transaction is actually dirty,
# and now that we know that we have a workable config,
# there's a chance that we'll actually be able to avoid
# relying on the cache this time
if self.trans.get_safety_cache_was_used():
self.change_register_function()
self.page_label = Label("")
(x_align, y_align) = self.page_label.get_alignment()
self.page_label.set_alignment(0.0, y_align)
self.mainvbox.pack_start(self.page_label, expand=False)
# establish maincontainer, which is where the actual glade
# pages are put by attach_current_page
#
# The order of placement here is important, we place this
# after page_label has already been added to main
# and we also need to do this prior to attach_current_page
# being called, as it depends on self.maincontainer being
# there
#
# when we're in headless mode the maincontainer can just be
# the mainvbox itself
#
# but, outside headless mode we save screen real-estate and
# place a scrolled window (which becomes the maincontainer)
# inside the mainvbox and the glade by glade pages end up
# in there instead (again, in attach_current_page)
if display_mode in HEADLESS_MODES:
self.maincontainer = self.mainvbox
else:
self.maincontainer = Viewport()
sw = ScrolledWindow()
sw.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
sw.add( self.maincontainer)
self.mainvbox.pack_start(sw)
self.glade_pages = [
self.__setup_page(glade_file, top_glade_element)
for glade_file, top_glade_element in config.pages ]
self.glade_pages_by_ident_index = dict(
( (key, self.glade_pages[i])
for i, key in enumerate(config.pages)
) # end generator expression
) # end dict
self.__setup_auto_widgets()
#.........这里部分代码省略.........
示例13: Widget
# 需要导入模块: from gtk import HBox [as 别名]
# 或者: from gtk.HBox import pack_start [as 别名]
class Widget(SignalManager):
def __init__(self, manager, editor):
SignalManager.__init__(self)
self.__init_attributes(manager, editor)
self.__setup()
self.__emit()
self.__update_public_api()
self.connect(editor, "quit", self.__quit_cb)
editor.register_object(self)
self.__bar.hide()
def __init_attributes(self, manager, editor):
self.__manager = manager
self.__editor = editor
self.__label = self.__get_label()
self.__button = self.__get_button()
self.__bar = self.__get_bar()
from gtk import HBox, Image
self.__box = HBox(False, 5)
self.__image = Image()
self.__view = editor.textview
return
def __destroy(self):
self.disconnect()
self.__editor.unregister_object(self)
del self
return False
def __setup(self):
from gtk import TEXT_WINDOW_WIDGET
self.__view.add_child_in_window(self.__bar, TEXT_WINDOW_WIDGET, 0, -100)
self.__bar.add(self.__button)
self.__button.add(self.__box)
self.__box.pack_start(self.__image, False, False)
self.__box.pack_start(self.__label, False, False)
self.__bar.realize()
self.__bar.hide()
return False
def __emit(self):
self.__manager.emit("bar", self.__bar)
return False
def __update_public_api(self):
self.__editor.set_data("MessageBar", self.__manager)
self.__editor.set_data("StatusImage", self.__image)
self.__editor.set_data("StatusFeedback", self.__label)
return False
def __get_bar(self):
from gtk import EventBox
bar = EventBox()
# bar.props.visible_window = False
return bar
def __get_label(self):
from gtk import Label
label = Label()
label.set_property("single-line-mode", True)
label.set_property("use-markup", True)
return label
def __get_button(self):
from gtk import Button
button = Button()
button.set_property("focus-on-click", False)
button.set_property("can-default", False)
button.set_property("can-focus", False)
button.set_property("has-default", False)
button.set_property("is-focus", False)
button.set_property("receives-default", False)
button.set_property("receives-default", False)
return button
def __quit_cb(self, *args):
self.__destroy()
return False