本文整理汇总了Python中higwidgets.higbuttons.HIGButton.connect方法的典型用法代码示例。如果您正苦于以下问题:Python HIGButton.connect方法的具体用法?Python HIGButton.connect怎么用?Python HIGButton.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类higwidgets.higbuttons.HIGButton
的用法示例。
在下文中一共展示了HIGButton.connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PathEntry
# 需要导入模块: from higwidgets.higbuttons import HIGButton [as 别名]
# 或者: from higwidgets.higbuttons.HIGButton import connect [as 别名]
class PathEntry(HIGHBox, object):
def __init__(self):
HIGHBox.__init__(self)
self.entry = gtk.Entry()
self.button = HIGButton(stock=gtk.STOCK_OPEN)
self.entry.set_width_chars(20)
self.button.connect("clicked", self.open_dialog)
self._pack_expand_fill(self.entry)
self._pack_noexpand_nofill(self.button)
def connect_entry_change(self, method):
self.entry.connect("focus-out-event", method)
def open_dialog(self, widget):
dialog = DirectoryChooserDialog(title=_("Choose the path to search in"))
dialog.run()
self.path = dialog.get_filename()
self.entry.grab_focus()
dialog.destroy()
def get_path(self):
return self.entry.get_text()
def set_path(self, path):
self.entry.set_text(path)
path = property(get_path, set_path)
示例2: create_widgets
# 需要导入模块: from higwidgets.higbuttons import HIGButton [as 别名]
# 或者: from higwidgets.higbuttons.HIGButton import connect [as 别名]
def create_widgets(self):
vboxmain = gtk.VBox()
sw = gtk.ScrolledWindow()
sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self.store = gtk.ListStore(str)
self.update_model()
self.treeView = gtk.TreeView(self.store)
#treeView.connect("row-activated", self.on_activated)
#treeView.set_rules_hint(True)
self.create_columns(self.treeView)
sw.add(self.treeView)
# buttons
vbox = HIGVBox()
btn = HIGButton(_("Edit..."), gtk.STOCK_EDIT)
vbox.pack_start(btn, False, False)
btn.connect("clicked", self._edit_template)
btn = HIGButton(_("Remove"), gtk.STOCK_REMOVE)
vbox.pack_start(btn, False, False)
btn.connect("clicked", self._remove_template)
hbox = HIGHBox()
hbox.pack_start(sw, True, True)
hbox.pack_start(vbox, False, False)
vboxmain.pack_start(hbox, True, True, 0)
self.add(vboxmain)
self.show_all()
示例3: OptionFile
# 需要导入模块: from higwidgets.higbuttons import HIGButton [as 别名]
# 或者: from higwidgets.higbuttons.HIGButton import connect [as 别名]
class OptionFile(HIGHBox, OptionWidget, object):
def __init__(self, param=""):
HIGHBox.__init__(self)
self.entry = OptionEntry()
self.button = HIGButton(stock=gtk.STOCK_OPEN)
self._pack_expand_fill(self.entry)
self._pack_noexpand_nofill(self.button)
self.entry.set_text(param)
self.button.connect('clicked', self.open_dialog_cb)
def open_dialog_cb(self, widget):
dialog = AllFilesFileChooserDialog(_("Choose file"))
if dialog.run() == gtk.RESPONSE_OK:
self.entry.set_text(dialog.get_filename())
dialog.destroy()
def get_filename(self):
return "\ ".join(self.entry.get_text().split(" "))
def set_filename(self, filename):
self.entry.set_text(" ".join(filename.split("\ ")))
filename = property(get_filename, set_filename)
示例4: About
# 需要导入模块: from higwidgets.higbuttons import HIGButton [as 别名]
# 或者: from higwidgets.higbuttons.HIGButton import connect [as 别名]
class About(HIGWindow):
def __init__(self):
HIGWindow.__init__(self)
self.lbl_program_version = gtk.Label(
("<span size='30000' weight='heavy'>UMIT %s</span>" % VERSION) +
("\n<span size='10000' weight='heavy'>Network Inventory ") +
_("Build") + (" %s</span>" % __version__))
self.lbl_program_description = gtk.Label(
_("UMIT Network Inventory and UMIT Scheduler are UMIT\n") +
_("extensions developed by") + (" %s\n" % __author__) +
_("and was sponsored by Google during the Summer of Code "
"2007.\nThanks Google!"))
self.logo_img = gtk.Image()
self.logo_img.set_from_file(logo)
self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE)
self.btn_close.connect('clicked', lambda x, y=None:self.destroy())
self.__set_props()
self.__do_layout()
def __set_props(self):
"""
Set widget properties.
"""
self.set_title(_("About UMIT Network Inventory"))
self.set_position(gtk.WIN_POS_CENTER)
self.lbl_program_version.set_use_markup(True)
self.lbl_program_description.set_justify(gtk.JUSTIFY_CENTER)
self.lbl_program_description.set_selectable(True)
self.lbl_program_version.set_selectable(True)
def __do_layout(self):
"""
Layout window widgets.
"""
main_vbox = HIGVBox()
btns_box = HIGHBox()
main_vbox.pack_start(self.logo_img)
main_vbox.pack_start(self.lbl_program_version)
main_vbox.pack_start(self.lbl_program_description)
btns_box.pack_end(self.btn_close)
main_vbox._pack_noexpand_nofill(btns_box)
self.btn_close.grab_focus()
self.add(main_vbox)
示例5: ScriptManagerProgressWindow
# 需要导入模块: from higwidgets.higbuttons import HIGButton [as 别名]
# 或者: from higwidgets.higbuttons.HIGButton import connect [as 别名]
class ScriptManagerProgressWindow(HIGWindow):
def __init__(self, parent):
HIGWindow.__init__(self)
self.set_title(_("Script Manager Progress"))
self.set_position(gtk.WIN_POS_CENTER)
self.set_size_request(300, 200)
self.vbox = HIGVBox()
self.label = gtk.Label()
self.vbox.pack_start(self.label)
self.progress_all = HIGLabeledProgressBar(_("Overall progress"))
self.vbox.pack_start(self.progress_all)
self.progress_current = HIGLabeledProgressBar(_("Current source"))
self.vbox.pack_start(self.progress_current)
self.btn_cancel = HIGButton(stock=gtk.STOCK_CANCEL)
self.btn_cancel.connect("clicked", self._cancel_cb)
self.vbox.pack_start(self.btn_cancel)
self.add(self.vbox)
self.show_all()
self.timeout_id = gobject.timeout_add(100, self.callback)
self.status = (None, None, None)
import thread
self.lock = thread.allocate_lock()
reload_thread(parent.base, self, self.lock)
#thread.start_new_thread(reload_thread, (parent.base, self, self.lock))
#self.thread = ScriptManagerReloadThread(parent.base)
#self.thread.start()
def _cancel_cb(self, widget):
if self.timeout_id:
gobject.source_remove(self.timeout_id)
self.lock.acquire()
self.destroy()
def callback(self):
src, all, current = self.status
print "cb:", self.status
if src:
self.label.set_text(src.path)
if all:
if all[0] == all[1]:
gobject.source_remove(self.timeout_id)
self.timeout_id = None
self.progress_all.progress_bar.set_fraction(float(all[0])/all[1])
self.progress_all.label.set_text("%d/%d" % all)
else:
self.progress_all.progress_bar.set_fraction(0)
self.progress_all.label.set_text("")
if current:
self.progress_current.progress_bar.set_fraction(float(current[0])/current[1])
self.progress_current.label.set_text("%d/%d" % current)
else:
self.progress_current.progress_bar.set_fraction(0)
self.progress_current.label.set_text("")
示例6: TimeBox
# 需要导入模块: from higwidgets.higbuttons import HIGButton [as 别名]
# 或者: from higwidgets.higbuttons.HIGButton import connect [as 别名]
class TimeBox(gtk.HBox):
"""
GUI Controls for handling Timeline date visualization.
"""
def __init__(self, connector, tlbase):
gtk.HBox.__init__(self)
self.connector = connector
self.tlbase = tlbase
self.connector.connect('date-changed', self._update_current_date)
# viewing by
cur_mode = view_mode_descr[self.tlbase.graph_mode]
self.dateselect_lbl = HIGEntryLabel(cur_mode)
values = self.tlbase.bounds_by_graphmode()
self.dateselect = gtk.SpinButton(gtk.Adjustment(value=values[2],
lower=values[0], upper=values[1], step_incr=1), 1)
self.dateselect_apply = HIGButton(stock=gtk.STOCK_APPLY)
self.dateselect_apply.connect("clicked", self._date_change)
self.__layout()
def _date_change(self, event):
"""
Sends new date.
"""
self.connector.emit('date-update', self.dateselect.get_value_as_int())
def _update_current_date(self, event):
"""
Update spinbutton and values based on new date.
"""
cur_mode = view_mode_descr[self.tlbase.graph_mode]
self.dateselect_lbl.set_label(cur_mode)
values = self.tlbase.bounds_by_graphmode()
self.dateselect.set_range(values[0], values[1])
self.dateselect.set_value(values[2])
def __layout(self):
"""
Layout widgets.
"""
self.pack_start(self.dateselect_lbl, False, False, 0)
self.pack_start(self.dateselect, False, False, 0)
self.pack_start(self.dateselect_apply, False, False, 0)
示例7: SearchWindow
# 需要导入模块: from higwidgets.higbuttons import HIGButton [as 别名]
# 或者: from higwidgets.higbuttons.HIGButton import connect [as 别名]
class SearchWindow(BaseSearchWindow, object):
def __init__(self, load_method, notebook):
BaseSearchWindow.__init__(self)
self.load_method = load_method
self.notebook = notebook
self._create_widgets()
self._pack_widgets()
self._connect_widgets()
def _create_widgets(self):
self.vbox = HIGVBox()
self.btn_box = gtk.HButtonBox()
self.btn_open = HIGButton(stock=gtk.STOCK_OPEN)
self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE)
self.search_gui = SearchGUI(self.notebook)
def _pack_widgets(self):
BaseSearchWindow._pack_widgets(self)
self.vbox.pack_start(self.search_gui)
self.vbox.pack_start(self.btn_box)
self.btn_box.set_layout(gtk.BUTTONBOX_END)
self.btn_box.set_spacing(6)
self.btn_box.pack_start(self.btn_close)
self.btn_box.pack_start(self.btn_open)
self.add(self.vbox)
def _connect_widgets(self):
# Double click on result, opens it
self.search_gui.result_view.connect("row-activated", self.open_selected)
self.btn_open.connect("clicked", self.open_selected)
self.btn_close.connect("clicked", self.close)
self.connect("delete-event", self.close)
def close(self, widget=None, event=None):
self.destroy()
def open_selected(self, widget=None, path=None,
view_column=None, extra=None):
# This avoids dialog to be closed for no results.
if len(self.results) <= 0:
dia = HIGAlertDialog(
parent=self,
message_format=_('No results'),
secondary_text=_('No such results to be opened.')
)
dia.run()
dia.destroy()
return
# Open selected results!
self.load_method(self.results)
# Close Search Window
self.close()
def get_results(self):
# Return list with parsed objects from result list store
return self.search_gui.selected_results
results = property(get_results)
示例8: SchedProfileEditor
# 需要导入模块: from higwidgets.higbuttons import HIGButton [as 别名]
# 或者: from higwidgets.higbuttons.HIGButton import connect [as 别名]
class SchedProfileEditor(HIGWindow):
"""
Scheduling Profiles Editor
"""
def __init__(self, daddy, profile=None):
HIGWindow.__init__(self)
self.daddy = daddy
self.wtitle = _("Scheduling Profiles Editor")
self.start_profile = profile
# header
self.title_markup = "<span size='16500' weight='heavy'>%s</span>"
self.ttitle = HIGEntryLabel("")
self.ttitle.set_line_wrap(False)
self.ttitle.set_markup(self.title_markup % self.wtitle)
self.umit_logo = gtk.Image()
self.umit_logo.set_from_file(logo)
# profiles name
self.schedp_name_lbl = HIGEntryLabel(_("Scheduling Profile"))
self.schedp_name = gtk.combo_box_entry_new_text()
self.schedp_name.connect("changed", self._check_profile)
# cron format
self.cron_frame = HIGFrame(_("Schedule"))
self.cron_minute_lbl = HIGEntryLabel(_("Minute"))
self.cron_minute = gtk.Entry()
self.cron_hour_lbl = HIGEntryLabel(_("Hour"))
self.cron_hour = gtk.Entry()
self.cron_day_lbl = HIGEntryLabel(_("Day of month"))
self.cron_day = gtk.Entry()
self.cron_month_lbl = HIGEntryLabel(_("Month"))
self.cron_month = gtk.Entry()
self.cron_weekday_lbl = HIGEntryLabel(_("Weekday"))
self.cron_weekday = gtk.Entry()
# bottom buttons
self.help = HIGButton(stock=gtk.STOCK_HELP)
self.help.connect("clicked", self._show_help)
self.apply = HIGButton(stock=gtk.STOCK_APPLY)
self.apply.connect("clicked", self._save_profile)
self.cancel = HIGButton(stock=gtk.STOCK_CANCEL)
self.cancel.connect("clicked", self._exit)
self.ok = HIGButton(stock=gtk.STOCK_OK)
self.ok.connect("clicked", self._save_profile_and_leave)
self.load_profiles()
self.__set_props()
self.__do_layout()
self.connect("destroy", self._exit)
def load_profiles(self):
"""
Load scheduling profiles.
"""
profiles = ConfigParser()
profiles.read(Path.sched_profiles)
self.sections = []
ind = 0
for indx, section in enumerate(profiles.sections()):
self.sections.append(section)
self.schedp_name.append_text(section)
if section == self.start_profile:
ind = indx
self.schedp_name.set_active(ind)
self._check_profile(None)
def _load_profile(self):
"""
Load current set schedule profile.
"""
profile = ConfigParser()
profile.read(Path.sched_profiles)
values = {
"minute": self.cron_minute.set_text,
"hour": self.cron_hour.set_text,
"day": self.cron_day.set_text,
"month": self.cron_month.set_text,
"weekday": self.cron_weekday.set_text,
}
for item in profile.items(self.schedp_name.get_active_text()):
values[item[0]](item[1])
def _check_profile(self, event):
"""
Check if current text in schedp_name combobox is a profile name.
"""
if self.schedp_name.get_active_text() in self.sections:
self._load_profile()
else:
self.cron_minute.set_text("")
self.cron_hour.set_text("")
self.cron_day.set_text("")
self.cron_month.set_text("")
self.cron_weekday.set_text("")
#.........这里部分代码省略.........
示例9: SchedSchemaEditor
# 需要导入模块: from higwidgets.higbuttons import HIGButton [as 别名]
# 或者: from higwidgets.higbuttons.HIGButton import connect [as 别名]
class SchedSchemaEditor(HIGWindow):
"""
Scheduler Schemas Editor
"""
def __init__(self, daddy=None):
HIGWindow.__init__(self)
self.daddy = daddy
self.wtitle = _("Scan Scheduler Editor")
# header
self.title_markup = "<span size='16500' weight='heavy'>%s</span>"
self.ttitle = HIGEntryLabel("")
self.ttitle.set_line_wrap(False)
self.ttitle.set_markup(self.title_markup % self.wtitle)
self.umit_logo = gtk.Image()
self.umit_logo.set_from_file(logo)
# schemas name
self.schema_name_lbl = HIGEntryLabel(_("Schema Name"))
self.schema_name = gtk.combo_box_entry_new_text()
self.schema_name.connect("changed", self._check_schema)
# target and scan profiles
# self.target_lbl = HIGEntryLabel(_("Target"))
# self.target = gtk.Entry()
self.scan_name_lbl = HIGEntryLabel(_("Scan Profile"))
self.scan_name = ProfileCombo()
self.scan_name.update()
self.scan_name.set_active(0)
self.scan_name.connect("changed", self._set_scan_command)
# scan command
self.scan_command_lbl = HIGEntryLabel(_("Command"))
self.scan_command = gtk.Entry()
# scheduling profile
self.sched_name_lbl = HIGEntryLabel(_("Scheduling Profile"))
self.sched_name = gtk.combo_box_new_text()
self.sched_name_edit = gtk.Button(stock=gtk.STOCK_EDIT)
blbl = self.sched_name_edit.get_children()[0].get_children()[0].get_children()[1]
blbl.set_text(_("Edit Profiles"))
self.sched_name_edit.connect("clicked", self._edit_schedprofiles)
# schema settings
self.schema_sett_frame = HIGFrame()
self.setting_saveto = gtk.CheckButton(_("Save outputs to"))
self.setting_saveto_entry = gtk.Entry()
self.setting_saveto_browse = gtk.Button(_("..."))
self.setting_saveto_browse.connect("clicked", self._select_saveto)
self.setting_mailto = gtk.CheckButton(_("Send output to email"))
self.setting_mailto_entry = gtk.Entry()
self.setting_smtp_lbl = HIGEntryLabel(_("SMTP Schema"))
self.setting_smtp = gtk.combo_box_new_text()
self.setting_addtoinv = gtk.CheckButton(_("Add to the Inventory"))
self.setting_enabled = gtk.CheckButton(_("Enabled"))
# bottom buttons
self.help = HIGButton(stock=gtk.STOCK_HELP)
self.help.connect("clicked", self._show_help)
self.apply = HIGButton(stock=gtk.STOCK_APPLY)
self.apply.connect("clicked", self._save_schema)
self.cancel = HIGButton(stock=gtk.STOCK_CANCEL)
self.cancel.connect("clicked", self._exit)
self.ok = HIGButton(stock=gtk.STOCK_OK)
self.ok.connect("clicked", self._save_schema_and_leave)
self.load_smtp_schemas()
self._set_scan_command(None)
self.profile_running = None # no SchedProfileEditor instance is running.
self._load_pscheds()
self.load_schemas()
self.__set_props()
self.__do_layout()
self.connect("destroy", self._exit)
def load_smtp_schemas(self):
"""
Load smtp profiles.
"""
schemas = ConfigParser()
schemas.read(Path.smtp_schemas)
self.smtp_sections = []
self.setting_smtp.get_model().clear()
for section in schemas.sections():
self.smtp_sections.append(section)
self.setting_smtp.append_text(section)
self.setting_smtp.set_active(0)
def load_schemas(self):
"""
Load schemas profiles.
"""
schemas = ConfigParser()
schemas.read(Path.sched_schemas)
self.sections = []
self.schema_name.get_model().clear()
for section in schemas.sections():
self.sections.append(section)
self.schema_name.append_text(section)
#.........这里部分代码省略.........
示例10: HighlightProperty
# 需要导入模块: from higwidgets.higbuttons import HIGButton [as 别名]
# 或者: from higwidgets.higbuttons.HIGButton import connect [as 别名]
class HighlightProperty(object):
def __init__(self, property_name, property):
self.__create_widgets()
self.property_name = property_name
self.property_label = property[0].capitalize()
self.example = property[1]
self.bold = property[2]
self.italic = property[3]
self.underline = property[4]
self.text_color = property[5]
self.highlight_color = property[6]
self.__connect_buttons()
def __create_widgets(self):
self.property_name_label = HIGEntryLabel("")
self.example_label = HIGEntryLabel("")
self.bold_tg_button = HIGToggleButton(" ", gtk.STOCK_BOLD)
self.italic_tg_button = HIGToggleButton(" ", gtk.STOCK_ITALIC)
self.underline_tg_button = HIGToggleButton(" ", gtk.STOCK_UNDERLINE)
self.text_color_button = HIGButton(_("Text"),
stock=gtk.STOCK_SELECT_COLOR)
self.highlight_color_button = HIGButton(_("Highlight"),
stock=gtk.STOCK_SELECT_COLOR)
def __connect_buttons(self):
self.bold_tg_button.connect("toggled", self.update_example)
self.italic_tg_button.connect("toggled", self.update_example)
self.underline_tg_button.connect("toggled", self.update_example)
self.text_color_button.connect("clicked",
self.text_color_dialog)
self.highlight_color_button.connect("clicked",
self.highlight_color_dialog)
####################################
# Text color dialog
def text_color_dialog(self, widget):
color_dialog = gtk.ColorSelectionDialog("%s %s" % (self.label,
_("text color")))
color_dialog.colorsel.set_current_color(self.text_color)
color_dialog.ok_button.connect("clicked",
self.text_color_dialog_ok,
color_dialog)
color_dialog.cancel_button.connect("clicked",
self.text_color_dialog_cancel,
color_dialog)
color_dialog.connect("delete-event",
self.text_color_dialog_close,
color_dialog)
color_dialog.run()
def text_color_dialog_ok(self, widget, color_dialog):
self.text_color = color_dialog.colorsel.get_current_color()
color_dialog.destroy()
self.update_example()
def text_color_dialog_cancel(self, widget, color_dialog):
color_dialog.destroy()
def text_color_dialog_close(self, widget, extra, color_dialog):
color_dialog.destroy()
#########################################
# Highlight color dialog
def highlight_color_dialog(self, widget):
color_dialog = gtk.ColorSelectionDialog("%s %s" % (self.property_name,
_("highlight color")))
color_dialog.colorsel.set_current_color(self.highlight_color)
color_dialog.ok_button.connect("clicked",
self.highlight_color_dialog_ok,
color_dialog)
color_dialog.cancel_button.connect("clicked",
self.highlight_color_dialog_cancel,
color_dialog)
color_dialog.connect("delete-event",
self.highlight_color_dialog_close,
color_dialog)
color_dialog.run()
def highlight_color_dialog_ok(self, widget, color_dialog):
self.highlight_color = color_dialog.colorsel.get_current_color()
color_dialog.destroy()
self.update_example()
def highlight_color_dialog_cancel(self, widget, color_dialog):
color_dialog.destroy()
def highlight_color_dialog_close(self, widget, extra, color_dialog):
color_dialog.destroy()
#.........这里部分代码省略.........
示例11: Proprieties
# 需要导入模块: from higwidgets.higbuttons import HIGButton [as 别名]
# 或者: from higwidgets.higbuttons.HIGButton import connect [as 别名]
class Proprieties(HIGScrolledWindow):
'''
This box should be configurable
if widget is of a type all configuration should be change to this type
#tricks: option_list have a icon to fill with options
and option_check have a list of options in combo to change
'''
def __init__(self):
HIGScrolledWindow.__init__(self)
self._boxeditable = None
vp = gtk.Viewport()
self._create_widgets()
vp.add(self._box)
vp.set_shadow_type(gtk.SHADOW_NONE)
self.add(vp)
self._profilecore = None
self._selected = None
def set_profilecore(self, profilecore):
self._profilecore = profilecore
def _create_widgets(self):
'''
Create the main entrys of the option
'''
self._box = HIGVBox()
self._table = HIGTable()
#Name
self._label_name = HIGEntryLabel(_('Name'))
self._entry_name = HIGTextEntry()
self._entry_name.connect('activate', self._update_label)
#Type
self._label_type = HIGEntryLabel(_('Type'))
self._combo_type = gtk.combo_box_new_text()
self._combo_type.append_text('')
self._combo_type.append_text('Option List')
self._combo_type.append_text('Option Check')
self._combo_type.set_active(0)
self._combo_type.connect('changed', self.change_combo)
self._label_opt = HIGEntryLabel(_('Option'))
self._entry_opt = HIGTextEntry()
self._entry_opt.set_sensitive(False)
#For option list open a dialog to add/remove options
self._button_list = HIGButton('Edit Option List')
img = gtk.Image()
img_dir = os.path.join(pixmaps_dir, 'uie', 'combo.png')
img.set_from_file(img_dir)
self._button_list.set_image(img)
self._button_list.connect('button-press-event', self._button_list_clicked)
self._table.attach(self._label_name, 0,1,0, 1)
self._table.attach(self._entry_name, 1,2,0,1)
self._table.attach(self._label_type, 0,1,1,2)
self._table.attach(self._combo_type, 1,2,1, 2)
self._table.attach(self._button_list, 0,2, 3,4)
self._table.attach(self._label_opt, 0,1, 4,5)
self._table.attach(self._entry_opt, 1,2,4,5)
self._box.pack_start(self._table, False, False)
def _button_list_clicked(self, widget, event):
section_name = self._boxeditable.get_name()
lm = ListManager(self._entry_name.get_text(),section_name,
self._profilecore, self._selected, _('List of items'))
def _update_label(self, widget):
#XXX Replace by Command
log.debug("Update Label")
selected = self._selected
cmd = CommandChangeLabel(selected, self._entry_name.get_text(),
self._profilecore,self._boxeditable, True)
command_manager.add_command(cmd)
def change_combo(self,combo):
model = combo.get_model()
index = combo.get_active()
if index:
if model[index][0]=='Option List':
log.debug('Show Button List ')
self._button_list.show()
else:
log.debug('Hide Button List ')
self._button_list.hide()
return
#.........这里部分代码省略.........
示例12: SMTPSetup
# 需要导入模块: from higwidgets.higbuttons import HIGButton [as 别名]
# 或者: from higwidgets.higbuttons.HIGButton import connect [as 别名]
class SMTPSetup(HIGWindow):
"""
SMTP editor.
"""
def __init__(self):
HIGWindow.__init__(self)
self.wtitle = _("SMTP Account Editor")
# header
self.title_markup = "<span size='16500' weight='heavy'>%s</span>"
self.ttitle = HIGEntryLabel("")
self.ttitle.set_line_wrap(False)
self.ttitle.set_markup(self.title_markup % self.wtitle)
self.umit_logo = gtk.Image()
self.umit_logo.set_from_file(logo)
# schemas name
self.schema_name_lbl = HIGEntryLabel(_("Schema name"))
self.schema_name = gtk.combo_box_entry_new_text()
self.schema_name.connect('changed', self._check_schema)
# smtp server
self.smtp_server_lbl = HIGEntryLabel(_("Server"))
self.smtp_server = gtk.Entry()
self.smtp_port_lbl = HIGEntryLabel(_("Port"))
self.smtp_port = gtk.Entry()
# sending mail..
self.smtp_mailfrom_lbl = HIGEntryLabel(_("Mail from"))
self.smtp_mailfrom = gtk.Entry()
# smtp auth
self.smtp_need_auth = gtk.CheckButton(_("Servers requires authentication"))
self.smtp_need_auth.connect('toggled', self._auth_need)
self.smtp_login_lbl = HIGEntryLabel(_("Username"))
self.smtp_login = gtk.Entry()
self.smtp_passwd_lbl = HIGEntryLabel(_("Password"))
self.smtp_passwd = gtk.Entry()
self.smtp_passwd.set_visibility(False)
self._auth_need(None)
# smtp encryption
self.smtp_encrypt_tls = gtk.CheckButton(_("Use TLS Encryption"))
"""
Missing: SSL encryption,
Other authentication methods.
"""
# bottom buttons
self.help = HIGButton(stock=gtk.STOCK_HELP)
self.help.connect('clicked', self._show_help)
self.apply = HIGButton(stock=gtk.STOCK_APPLY)
self.apply.connect('clicked', self._save_schema)
self.cancel = HIGButton(stock=gtk.STOCK_CANCEL)
self.cancel.connect('clicked', self._exit)
self.ok = HIGButton(stock=gtk.STOCK_OK)
self.ok.connect('clicked', self._save_schema_and_leave)
self.load_schemas()
self.__set_props()
self.__do_layout()
self.connect('destroy', self._exit)
def load_schemas(self):
"""
Load schemas profiles.
"""
schemas = ConfigParser()
schemas.read(Path.smtp_schemas)
self.sections = [ ]
self.schema_name.get_model().clear()
for section in schemas.sections():
self.sections.append(section)
self.schema_name.append_text(section)
self.schema_name.set_active(0)
self._check_schema(None)
def _load_schema(self):
"""
Load current set schedule schema.
"""
schema = ConfigParser()
schema.read(Path.smtp_schemas)
enable = {'tls':self.smtp_encrypt_tls.set_active,
'auth':self.smtp_need_auth.set_active}
values = {'user':self.smtp_login.set_text,
'pass':self.smtp_passwd.set_text,
'server':self.smtp_server.set_text,
'port':self.smtp_port.set_text,
'mailfrom':self.smtp_mailfrom.set_text}
for item in schema.items(self.schema_name.get_active_text()):
if item[0] in ('tls', 'auth'):
enable[item[0]](int(item[1]))
else:
#.........这里部分代码省略.........
示例13: About
# 需要导入模块: from higwidgets.higbuttons import HIGButton [as 别名]
# 或者: from higwidgets.higbuttons.HIGButton import connect [as 别名]
class About(HIGWindow):
def __init__(self):
""""""
HIGWindow.__init__(self)
self.set_title("About Open Monitor Desktop Agent")
self.set_position(gtk.WIN_POS_CENTER)
self.__create_widgets()
self.__packing()
self.__connect_widgets()
self.__set_img()
self.__set_text()
def __create_widgets(self):
""""""
self.vbox = HIGVBox()
self.vbox_content = HIGVBox()
self.img_logo = gtk.Image()
self.event_img_logo = gtk.EventBox()
self.vbox.set_border_width(5)
self.vbox.set_spacing(12)
self.img = 1
self.d = {}
for c in (65, 97):
for i in range(26):
self.d[chr(i+c)] = chr((i+13) % 26 + c)
self.lbl_program_version = gtk.Label(
"<span size='15000' weight='heavy'>Open Monitor Desktop Agent</span>")
self.lbl_program_description = gtk.Label("""\
ICM Internet Connectivity is a global monitor to
inspect the connectivity issues happened in the world.
Developer: Alan Wang<[email protected]>
Paul Pei<[email protected]>
Tianwei Liu<[email protected]>
It was sponsered by Google Summer of Code 2011-2012.
Thanks Google!""")
self.lbl_copyright=gtk.Label(
"<small>Copyright (C) 2012 Adriano Monteiro Marques</small>")
self.lbl_program_website = gtk.Label(
"<span underline='single' foreground='blue'>"
"http://www.umitproject.org</span>")
self.lbl_program_website2 = gtk.Label(
"<span underline='single' foreground='blue'>"
"http://www.openmonitor.org</span>")
self.bottom_btn_box = gtk.HButtonBox()
self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE)
self.btn_close.grab_focus()
def __packing(self):
""""""
self.vbox._pack_expand_fill(self.vbox_content)
self.vbox._pack_noexpand_nofill(self.bottom_btn_box)
self.bottom_btn_box.set_layout(gtk.BUTTONBOX_CENTER)
self.bottom_btn_box.set_spacing(8)
self.bottom_btn_box.pack_start(self.btn_close)
self.event_img_logo.add(self.img_logo)
self.vbox_content._pack_expand_fill(self.event_img_logo)
self.vbox_content._pack_expand_fill(self.lbl_program_version)
self.vbox_content._pack_expand_fill(self.lbl_program_description)
self.vbox_content._pack_expand_fill(self.lbl_copyright)
self.vbox_content._pack_expand_fill(self.lbl_program_website)
self.vbox_content._pack_expand_fill(self.lbl_program_website2)
self.add(self.vbox)
def __connect_widgets(self):
""""""
self.event_img_logo.connect('button-release-event', self.__set_size)
self.btn_close.connect('clicked', lambda x: self.destroy())
def __set_size(self, widget, extra = None):
""""""
if self.img >= 3:
import webbrowser
webbrowser.open("http://www.openmonitor.org")
#print "".join([self.d.get(c, c) for c in "vzcbeg cvpxyr,om2;sebz hzvg.pber.Cnguf\
#vzcbeg Cngu; rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bcs,'e'))"])
#exec "".join([self.d.get(c, c) for c in "vzcbeg cvpxyr,om2;sebz hzvg.pber.Cnguf\
#vzcbeg Cngu; rkrp cvpxyr.ybnq(om2.OM2Svyr(Cngu.hzvg_bcs,'e'))"])
else: self.img += 1
def __set_text(self):
""""""
self.lbl_program_version.set_use_markup(True)
self.lbl_copyright.set_use_markup(True)
self.lbl_program_website.set_use_markup(True)
self.lbl_program_website2.set_use_markup(True)
self.lbl_program_description.set_justify(gtk.JUSTIFY_CENTER)
#.........这里部分代码省略.........
示例14: PreferencesWindow
# 需要导入模块: from higwidgets.higbuttons import HIGButton [as 别名]
# 或者: from higwidgets.higbuttons.HIGButton import connect [as 别名]
class PreferencesWindow(HIGMainWindow):
def __init__(self):
HIGMainWindow.__init__(self)
self.set_title("Preferences")
self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
self.resize(950,500)
self.set_border_width(10)
self.__pixmap_d = Path.pixmaps_dir
self.__list = {
'General settings':'general.svg',
'Fonts':'fonts.svg',
'Expose/Interface':'expose.svg',
'Network':'network.svg'
}
self.__list_bw = {
'General settings':'general-bw.svg',
'Fonts':'fonts-bw.svg',
'Expose/Interface':'expose-bw.svg',
'Network':'network-bw.svg'
}
# FIXME
### Replace two list above
self.__dic_tabs = {
'Expose/Interface':['expose.svg','expose-bw.svg', ExposeGeneral],
#'Network':['network.svg', 'network-bw.svg', NetworkTab],
'.General settings':['general.svg','general-bw.svg',\
GeneralSettings],
'Interface Details':['fonts.svg','fonts-bw.svg', InterfaceDetails],
}
self.__create()
self.__pack()
self.__frame = None
#self.connect("destroy", lambda w: gtk.main_quit())
self.connect("delete_event", lambda w, e: self.close())
self._create_frame("General Settings", GeneralSettings)
# Add button Close and Help Button
self.__closeb = HIGButton(stock=gtk.STOCK_CANCEL)
self.__helpb = HIGButton(stock=gtk.STOCK_HELP)
self.__applyb = HIGButton(stock = gtk.STOCK_APPLY)
self.__okb = HIGButton(stock = gtk.STOCK_OK)
self.__buttons_box = HIGHBox()
self.__alignb_c = gtk.Alignment(0,0,0,0)
self.__alignb_h = gtk.Alignment(0,0,0,0)
self.__alignb_y = gtk.Alignment(0,0,0,0)
self.__alignb_k = gtk.Alignment(0,0,0,0)
self.__alignb_c.add(self.__closeb)
self.__alignb_h.add(self.__helpb)
self.__alignb_y.add(self.__applyb)
self.__alignb_k.add(self.__okb)
self.__alignb_y.set_padding(0,0, 1,1)
self.__alignb_c.set_padding(0,0, 1,1)
self.__alignb_h.set_padding(0,0, 1,1)
self.__alignb_k.set_padding(0,0, 1,1)
self.__buttons_box.pack_end(self.__alignb_k, False, False)
self.__buttons_box.pack_end(self.__alignb_y, False, False)
self.__buttons_box.pack_end(self.__alignb_c, False, False)
self.__buttons_box.pack_start(self.__alignb_h, False, False)
self.__box.pack_end(self.__buttons_box, False, True)
self.__closeb.connect("clicked", lambda e: self.close())
self.__applyb.connect("clicked", self.save_changes)
self.__okb.connect("clicked", self._save_close)
self.connect("key-press-event", self.cb_keypress)
self.show_all()
# Callbacks
def cb_keypress(self, widget, event):
'''
handle the "key-press-event" signal
'''
n = ord(event.string) if len(event.string) > 0 else ''
kv = event.keyval
print 'n: %s, keyval: %s' % (n, hex(kv))
def test1():
print "test"
string_dict = {
12 : test1 # ctrl-L
#.........这里部分代码省略.........
示例15: NmapOutputViewer
# 需要导入模块: from higwidgets.higbuttons import HIGButton [as 别名]
# 或者: from higwidgets.higbuttons.HIGButton import connect [as 别名]
#.........这里部分代码省略.........
for i in xrange(len(names)):
tag = gtk.TextTag(names[i])
for tup in zip(prop, values[i]):
tag.set_property(tup[0], tup[1])
tag_table.add(tag)
self.txg_font = gtk.TextTag()
self.txg_date = gtk.TextTag()
self.txg_font.set_property("family", "Monospace")
tag_table.add(self.txg_font)
tag_table.add(self.txg_date)
def __create_widgets (self):
# Creating widgets
self.scrolled = gtk.ScrolledWindow ()
self.text_view = gtk.TextView ()
self.btn_refresh = gtk.Button (stock=gtk.STOCK_REFRESH)
self.check_enable_color = gtk.CheckButton(\
_("Enable Nmap output highlight"))
self.btn_output_properties = HIGButton(stock=gtk.STOCK_PREFERENCES)
self.hbox_buttons = gtk.HBox (spacing=5)
def __set_scrolled_window(self):
# By default the vertical scroller remains at bottom
self._scroll_at_bottom = True
# Seting scrolled window
self.scrolled.set_border_width(5)
self.scrolled.add(self.text_view)
self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
vadjust = self.scrolled.get_vadjustment()
vadjust.connect('changed', self.__adjustment_update)
vadjust.connect('value-changed', self.__adjustment_at_bottom)
def __adjustment_at_bottom(self, adjustment):
vadjust_end = adjustment.upper - adjustment.page_size
self._scroll_at_bottom = adjustment.value == vadjust_end
def __adjustment_update(self, adjustment):
if self._scroll_at_bottom:
adjustment.set_value(adjustment.upper - adjustment.page_size)
def __set_text_view(self):
self.text_view.set_wrap_mode(gtk.WRAP_WORD)
self.text_view.set_editable(False)
def __set_buttons (self):
self.check_enable_color.set_active(self.nmap_highlight.enable)
# Connecting events
self.btn_refresh.connect('clicked',
self.refresh_output)
self.btn_output_properties.connect("clicked",
self.show_output_properties)
self.check_enable_color.connect("toggled",
self.enable_color_highlight)
# Setting hbox
self.hbox_buttons.set_border_width(5)
# Packing buttons
self.hbox_buttons.pack_start(self.check_enable_color)
self.hbox_buttons.pack_start(self.btn_output_properties)
self.hbox_buttons.pack_start(self.btn_refresh)