本文整理汇总了Python中gtk.glade方法的典型用法代码示例。如果您正苦于以下问题:Python gtk.glade方法的具体用法?Python gtk.glade怎么用?Python gtk.glade使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk
的用法示例。
在下文中一共展示了gtk.glade方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import glade [as 别名]
def __init__(self, o=None):
self.xml = x = gtk.glade.XML(sibpath(__file__, "inspectro.glade"))
self.tree_view = x.get_widget("treeview")
colnames = ["Name", "Value"]
for i in range(len(colnames)):
self.tree_view.append_column(
gtk.TreeViewColumn(
colnames[i], gtk.CellRendererText(), text=i))
d = {}
for m in reflect.prefixedMethods(self, "on_"):
d[m.im_func.__name__] = m
self.xml.signal_autoconnect(d)
if o is not None:
self.inspect(o)
self.ns = {'inspect': self.inspect}
iwidget = x.get_widget('input')
self.input = ConsoleInput(iwidget)
self.input.toplevel = self
iwidget.connect("key_press_event", self.input._on_key_press_event)
self.output = ConsoleOutput(x.get_widget('output'))
示例2: normalize_names
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import glade [as 别名]
def normalize_names(self):
"""
It is internally used to normalize the name of the widgets.
It means a widget named foo:vbox-dialog in glade
is refered self.vbox_dialog in the code.
It also sets a data "prefixes" with the list of
prefixes a widget has for each widget.
"""
for widget in self.get_widgets():
widget_name = gtk.Widget.get_name(widget)
prefixes_name_l = widget_name.split(":")
prefixes = prefixes_name_l[ : -1]
widget_api_name = prefixes_name_l[-1]
widget_api_name = "_".join( re.findall(tokenize.Name, widget_api_name) )
gtk.Widget.set_name(widget, widget_api_name)
if hasattr(self, widget_api_name):
raise AttributeError("instance %s already has an attribute %s" % (self,widget_api_name))
else:
setattr(self, widget_api_name, widget)
if prefixes:
gtk.Widget.set_data(widget, "prefixes", prefixes)
示例3: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import glade [as 别名]
def __init__(self, fname, layout):
self.glade = gtk.glade.XML(fname)
self.glade.signal_autoconnect(self)
self.getWidget(self.__class__.__name__).connect("delete_event", self.delete)
self.notebook_groups = {}
self.vwlayout = layout
示例4: textFromWidget
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import glade [as 别名]
def textFromWidget(self, wName):
wid = self.glade.get_widget(wName)
if not wid:
raise Exception("ERROR - Can't find widget %s" % wName)
return wid.get_text()
示例5: getWidget
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import glade [as 别名]
def getWidget(self, name):
return self.glade.get_widget(name)
示例6: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import glade [as 别名]
def __init__(self, glade, settings=None):
"""
Initial setup
:param glade: a gtk.glade object, see class doc_strings for info
:param settings: a dict of handler settings to pre-populate with
"""
self.glade = glade
self.initial_settings = settings
self.database_combo = self.glade.get_widget("database_combo")
self.rename_action_combo = self.glade.get_widget("rename_action_combo")
self.on_conflict_combo = self.glade.get_widget("on_conflict_combo")
self.episode_order_combo = self.glade.get_widget("episode_order_combo")
self.format_string_entry = self.glade.get_widget("format_string_entry")
self.query_entry = self.glade.get_widget("query_entry")
self.download_subs_checkbox = self.glade.get_widget("download_subs_checkbox")
self.subs_language_entry = self.glade.get_widget("subs_language_entry")
self.language_code_entry = self.glade.get_widget("language_code_entry")
self.encoding_entry = self.glade.get_widget("encoding_entry")
self.output_entry = self.glade.get_widget("output_entry")
self.populated = False
self.monitor_changes = True
self.glade.signal_autoconnect(
{'on_conflict_combo_changed': self.on_conflict_combo_changed}
)
client.filebottool.get_filebot_valid_values().addCallback(
self.init_combo_boxes)
示例7: collect_dialog_settings
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import glade [as 别名]
def collect_dialog_settings(self):
"""collects the settings on the widgets and serializes them into
a dict for sending to the server.
returns: a dictionary containing the user's setting values
"""
settings = {}
combos = {
"database": self.database_combo,
"rename_action": self.rename_action_combo,
"on_conflict": self.on_conflict_combo,
"episode_order": self.episode_order_combo
}
for setting in combos:
combo_model = combos[setting].get_model()
current_iter = combos[setting].get_active_iter()
if current_iter:
settings[setting] = combo_model[current_iter][0]
else:
settings[setting] = None
entries = {
"format_string": self.format_string_entry,
"encoding": self.encoding_entry,
"language_code": self.language_code_entry,
"subs_language": self.subs_language_entry,
"query_override": self.query_entry,
"output": self.output_entry
}
for setting in entries:
if not entries[setting]:
entries[setting] = ''
settings[setting] = entries[setting].get_text()
settings["show_advanced"] = self.glade.get_widget(
"advanced_options").get_visible()
settings["download_subs"] = self.download_subs_checkbox.get_active()
log.debug("Collected settings for server: {0}".format(settings))
return settings
示例8: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import glade [as 别名]
def __init__(self):
filename = 'dndtester.glade'
windowname = 'DNDTester'
self.wTree = gtk.glade.XML(filename, windowname)
self.log_buffer = gtk.TextBuffer()
self.setupWidgets()
示例9: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import glade [as 别名]
def __init__(self):
self.xml = gtk.glade.XML(util.sibpath(__file__,"gladereactor.glade"))
d = {}
for m in reflect.prefixedMethods(self, "on_"):
d[m.im_func.__name__] = m
self.xml.signal_autoconnect(d)
self.xml.get_widget('window1').connect('destroy',
lambda w: self.stop())
self.servers = self.xml.get_widget("servertree")
sel = self.servers.get_selection()
sel.set_mode(gtk.SELECTION_SINGLE)
sel.connect("changed",
self.servers_selection_changed)
## argh coredump: self.servers_selection_changed(sel)
self.xml.get_widget('suspend').set_sensitive(0)
self.xml.get_widget('disconnect').set_sensitive(0)
# setup model, connect it to my treeview
self.model = gtk.ListStore(str, object, gobject.TYPE_BOOLEAN,
gobject.TYPE_BOOLEAN)
self.servers.set_model(self.model)
self.servers.set_reorderable(1)
self.servers.set_headers_clickable(1)
# self.servers.set_headers_draggable(1)
# add a column
for col in [
gtk.TreeViewColumn('Server',
gtk.CellRendererText(),
text=0),
gtk.TreeViewColumn('Reading',
gtk.CellRendererToggle(),
active=2),
gtk.TreeViewColumn('Writing',
gtk.CellRendererToggle(),
active=3)]:
self.servers.append_column(col)
col.set_resizable(1)
sup.__init__(self)
示例10: bindtextdomain
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import glade [as 别名]
def bindtextdomain(app_name, locale_dir=None):
"""
Bind the domain represented by app_name to the locale directory locale_dir.
It has the effect of loading translations, enabling applications for different
languages.
app_name:
a domain to look for translations, tipically the name of an application.
locale_dir:
a directory with locales like locale_dir/lang_isocode/LC_MESSAGES/app_name.mo
If omitted or None, then the current binding for app_name is used.
"""
try:
import locale
import gettext
locale.setlocale(locale.LC_ALL, "")
gtk.glade.bindtextdomain(app_name, locale_dir)
gettext.install(app_name, locale_dir, unicode=1)
except (IOError,locale.Error), e:
#force english as default locale
try:
os.environ["LANGUAGE"] = "en_US.UTF-8"
locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
gtk.glade.bindtextdomain(app_name, locale_dir)
gettext.install(app_name, locale_dir, unicode=1)
return
except:
#english didnt work, just use spanish
try:
__builtins__.__dict__["_"] = lambda x : x
except:
__builtins__["_"] = lambda x : x
示例11: add_callbacks
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import glade [as 别名]
def add_callbacks(self, callbacks_proxy):
"""
It uses the methods of callbacks_proxy as callbacks.
The callbacks are specified by using:
Properties window -> Signals tab
in glade-2 (or any other gui designer like gazpacho).
Methods of classes inheriting from SimpleGladeApp are used as
callbacks automatically.
callbacks_proxy:
an instance with methods as code of callbacks.
It means it has methods like on_button1_clicked, on_entry1_activate, etc.
"""
self.glade.signal_autoconnect(callbacks_proxy)
示例12: add_prefix_actions
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import glade [as 别名]
def add_prefix_actions(self, prefix_actions_proxy):
"""
By using a gui designer (glade-2, gazpacho, etc)
widgets can have a prefix in theirs names
like foo:entry1 or foo:label3
It means entry1 and label3 has a prefix action named foo.
Then, prefix_actions_proxy must have a method named prefix_foo which
is called everytime a widget with prefix foo is found, using the found widget
as argument.
prefix_actions_proxy:
An instance with methods as prefix actions.
It means it has methods like prefix_foo, prefix_bar, etc.
"""
prefix_s = "prefix_"
prefix_pos = len(prefix_s)
is_method = lambda t : callable( t[1] )
is_prefix_action = lambda t : t[0].startswith(prefix_s)
drop_prefix = lambda (k,w): (k[prefix_pos:],w)
members_t = inspect.getmembers(prefix_actions_proxy)
methods_t = filter(is_method, members_t)
prefix_actions_t = filter(is_prefix_action, methods_t)
prefix_actions_d = dict( map(drop_prefix, prefix_actions_t) )
for widget in self.get_widgets():
prefixes = gtk.Widget.get_data(widget, "prefixes")
if prefixes:
for prefix in prefixes:
if prefix in prefix_actions_d:
prefix_action = prefix_actions_d[prefix]
prefix_action(widget)
示例13: install_custom_handler
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import glade [as 别名]
def install_custom_handler(self, custom_handler):
gtk.glade.set_custom_handler(custom_handler)
示例14: create_glade
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import glade [as 别名]
def create_glade(self, glade_path, root, domain):
return gtk.glade.XML(self.glade_path, root, domain)
示例15: get_widget
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import glade [as 别名]
def get_widget(self, widget_name):
return self.glade.get_widget(widget_name)