def make_callsigns(self):
box = gtk.HBox(True, 2)
fixed = self.rthread.radio.get_features().has_implicit_calls
frame = gtk.Frame(_("Your callsign"))
self.editor_ucall = CallsignEditor(first_fixed=fixed)
self.editor_ucall.set_size_request(-1, 200)
self.editor_ucall.show()
frame.add(self.editor_ucall)
frame.show()
box.pack_start(frame, 1, 1, 0)
frame = gtk.Frame(_("Repeater callsign"))
self.editor_rcall = CallsignEditor(first_fixed=fixed)
self.editor_rcall.set_size_request(-1, 200)
self.editor_rcall.show()
frame.add(self.editor_rcall)
frame.show()
box.pack_start(frame, 1, 1, 0)
frame = gtk.Frame(_("My callsign"))
self.editor_mcall = CallsignEditor()
self.editor_mcall.set_size_request(-1, 200)
self.editor_mcall.show()
frame.add(self.editor_mcall)
frame.show()
box.pack_start(frame, 1, 1, 0)
box.show()
return box
python类Frame()的实例源码
def create_collector_bbox(self, collector):
frame = gtk.Frame(collector.name)
if collector.is_enabled():
layout = gtk.BUTTONBOX_SPREAD
spacing = 10
bbox = gtk.HButtonBox()
bbox.set_border_width(1)
bbox.set_layout(layout)
bbox.set_spacing(spacing)
frame.add(bbox)
startCollectorButton = gtk.Button('Start Collector')
startCollectorButton.connect("clicked", self.startIndividualCollector, collector)
startCollectorButton.set_sensitive(not isinstance(collector, engine.collector.ManualCollector))
bbox.add(startCollectorButton)
stopCollectorButton = gtk.Button('Stop Collector')
stopCollectorButton.connect("clicked", self.stopIndividualCollector, collector)
stopCollectorButton.set_sensitive(not isinstance(collector, engine.collector.ManualCollector))
bbox.add(stopCollectorButton)
parseButton = gtk.Button('Parse Data')
parseButton.connect("clicked", self.parser, collector)
bbox.add(parseButton)
else:
label = gtk.Label("Collector Disabled")
frame.add(label)
return frame
def create_config_vbox(self, inputs, types, constraints, trace_str):
vbox_main = gtk.VBox()
sensitivity_group = []
for (key, value), (_, value_type) in zip(inputs.items(), types.items()):
delimiter = self.current_plugin_config.TRACE_DELIMITER
if trace_str == "":
delimiter = ""
cur_trace_str = trace_str + delimiter + str(key)
if isinstance(value_type, dict):
frame = gtk.Frame(key.title() + ":")
sensitivity_group.append(frame)
vbox_main.pack_start(frame)
vbox_frame = self.create_config_vbox(inputs[key], value_type, constraints, cur_trace_str)
frame.add(vbox_frame)
else:
if cur_trace_str in constraints:
constraint = constraints[cur_trace_str]
item = self.value_type_create.get(value_type, self.create_error_hbox)(
key, inputs[key], cur_trace_str, sensitivity_group, constraint)
else:
item = self.value_type_create.get(value_type, self.create_error_hbox)(
key, inputs[key], cur_trace_str, sensitivity_group)
vbox_main.pack_start(item)
return vbox_main
def _setup(self):
self.thumbnail = gtk.Image()
self.label = gtk.Label(self.layer.name)
# creating the fix button, to anchor background frames.
self._fix_button = Utils.toggle_button_stock(gtk.STOCK_MEDIA_RECORD,20)
self._fix_button.set_tooltip_text("toggle fixed visibility.")
# update fixed variable
self.fixed = Utils.is_frame_fixed(self.layer)
#images
pin_img = gtk.Image()
pin_img.set_from_stock(gtk.STOCK_YES,20)
pin_img2 = gtk.Image()
pin_img2.set_from_stock(gtk.STOCK_MEDIA_RECORD,20)
self._fix_button_images = [pin_img,pin_img2]
## connect
self._fix_button.connect('clicked',self.on_toggle_fix)
if self.fixed:
self._fix_button.set_image(self._fix_button_images[0])
self._fix_button.set_active(True)
else :
self._fix_button.set_image(self._fix_button_images[1])
self._fix_button.set_active(False)
frame = gtk.Frame()
layout = gtk.VBox()
# add frame to this widget
self.add(frame)
# add layout manager to the frame
frame.add(layout)
layout.pack_start(self.label)
layout.pack_start(self._fix_button)
layout.pack_start(self.thumbnail)
self._get_thumb_image()
def on_add(self,widget,copy=False):
"""
Add new layer to the image and a new frame to the Timeline.
if copy is true them the current layer will be copy.
"""
# starting gimp undo group
self.image.undo_group_start()
name = "Frame " + str(len(self.frames))
# create the layer to add
l = None
if not copy:
l = gimp.Layer(self.image,name, self.image.width,self.image.height,RGBA_IMAGE,100,NORMAL_MODE)
else: # copy current layer to add
l = self.frames[self.active].layer.copy()
l.name = name
# adding layer
self.image.add_layer(l,self.active+1)
if self.new_layer_type == TRANSPARENT_FILL and not copy:
pdb.gimp_edit_clear(l)
self._scan_image_layers()
self.on_goto(None,NEXT,True)
if len(self.frames) == 1 :
self._toggle_enable_buttons(NO_FRAMES)
# ending gimp undo group
self.image.undo_group_end()
def make_select(self):
hbox = gtk.HBox(True, 2)
all = gtk.Button(_("All"))
all.connect("clicked", self.__select_all, True)
all.set_size_request(50, 25)
all.show()
hbox.pack_start(all, 0, 0, 0)
none = gtk.Button(_("None"))
none.connect("clicked", self.__select_all, False)
none.set_size_request(50, 25)
none.show()
hbox.pack_start(none, 0, 0, 0)
inv = gtk.Button(_("Inverse"))
inv.connect("clicked", self.__select_all, None)
inv.set_size_request(50, 25)
inv.show()
hbox.pack_start(inv, 0, 0, 0)
frame = gtk.Frame(_("Select"))
frame.show()
frame.add(hbox)
hbox.show()
return frame
def make_options(self):
hbox = gtk.HBox(True, 2)
confirm = gtk.CheckButton(_("Confirm overwrites"))
confirm.connect("toggled", __set_confirm)
confirm.show()
hbox.pack_start(confirm, 0, 0, 0)
frame = gtk.Frame(_("Options"))
frame.add(hbox)
frame.show()
hbox.show()
return frame
def make_radio_sel(self):
f = gtk.Frame("Radio")
hbox = gtk.HBox(False, 2)
hbox.set_border_width(2)
self.w_radio = make_choice(RADIOS, False, RADIOS[0])
self.w_radio.connect("changed", self.select_radio)
self.tips.set_tip(self.w_radio, "Select radio model")
self.w_radio.show()
hbox.pack_start(self.w_radio, 1, , )
l = gtk.Label(" on port ")
l.show()
hbox.pack_start(l, 0, , )
ports = platform.get_platform().list_serial_ports()
if len(ports) > 0:
default = ports[0]
else:
default = None
self.w_port = make_choice(ports, True, default)
self.w_port.connect("changed", self.select_radio)
self.tips.set_tip(self.w_port, "Select serial port")
self.w_port.show()
hbox.pack_start(self.w_port, 1, , )
f.add(hbox)
hbox.show()
f.show()
return f
def __init__(self, explorer, rootGroup, canvas):
"""Place a new Visage of an explorer in a canvas group.
I also need a 'canvas' reference is for certain coordinate
conversions, and pygnome doesn't give access to my GtkObject's
.canvas attribute. :(
"""
# Ugh. PyGtk/GtkObject/GnomeCanvas interfacing grits.
gnome.CanvasGroup.__init__(self,
_obj = rootGroup.add('group')._o)
self.propertyLabels = PairList()
reflect.accumulateClassList(self.__class__, 'propertyLabels',
self.propertyLabels)
self.groupLabels = PairList()
reflect.accumulateClassList(self.__class__, 'groupLabels',
self.groupLabels)
self.explorer = explorer
self.identifier = explorer.identifier
self.objectId = explorer.id
self.canvas = canvas
self.rootGroup = rootGroup
self.ebox = gtk.EventBox()
self.ebox.set_name("Visage")
self.frame = gtk.Frame(self.identifier)
self.container = gtk.VBox()
self.ebox.add(self.frame)
self.frame.add(self.container)
self.canvasWidget = self.add('widget', widget=self.ebox,
x=0, y=0, anchor=gtk.ANCHOR_NW,
size_pixels=0)
self.border = self.add('rect', x1=0, y1=0,
x2=1, y2=1,
fill_color=None,
outline_color=self.color['border'],
width_pixels=self.border_width)
self.subtable = {}
self._setup_table()
# TODO:
# Collapse me
# Movable/resizeable me
# Destroy me
# Set my detail level
self.frame.connect("size_allocate", self.signal_size_allocate,
None)
self.connect("destroy", self.signal_destroy, None)
self.connect("event", self.signal_event)
self.ebox.show_all()
# Our creator will call our fill_ methods when she has the goods.
def __init__(self, parent, plugins):
super(PluginConfigGUI, self).__init__()
self.main_gui = parent
#TODO: Add one for compression format
self.value_type_create = {
"text": self.create_text_hbox,
"number": self.create_number_hbox,
"checkbox": self.create_checkbox_hbox,
"radio": self.create_radio_hbox,
"option": self.create_option_hbox,
"options": self.create_options_hbox,
"time": self.create_time_hbox,
"netiface": self.create_netiface_hbox,
"netifaces": self.create_netifaces_hbox,
"filepath": self.create_filepath_hbox,
"path": self.create_path_hbox
}
self.set_title("Plugin Configurations")
self.set_modal(True)
self.set_transient_for(self.main_gui)
self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
#self.set_size_request(500, 700)
self.set_border_width(6)
self.set_resizable(False)
self.plugins = plugins
plugin_names = [plugin.name for plugin in self.plugins]
vbox_main = gtk.VBox()
hbox_plugins = gtk.HBox()
frame_plugin_confs = gtk.Frame("Plugin Configurations:")
self.vbox_plugin_main = None
label_plugins = gtk.Label("Plugin")
combobox_plugins = gtk.combo_box_new_text()
for label in plugin_names:
combobox_plugins.append_text(label)
combobox_plugins.set_active(0)
combobox_plugins.connect('changed', self.select_plugin, combobox_plugins, frame_plugin_confs)
button_close = gtk.Button("Close")
button_close.connect("clicked", self.close_plugin_config_dialog)
hbox_plugins.pack_start(label_plugins)
hbox_plugins.pack_start(combobox_plugins)
vbox_main.pack_start(hbox_plugins)
vbox_main.pack_start(frame_plugin_confs)
vbox_main.pack_start(button_close)
self.show_plugin_configs(combobox_plugins.get_active_text(), frame_plugin_confs)
self.add(vbox_main)
self.show_all()
def __init__(self, explorer, rootGroup, canvas):
"""Place a new Visage of an explorer in a canvas group.
I also need a 'canvas' reference is for certain coordinate
conversions, and pygnome doesn't give access to my GtkObject's
.canvas attribute. :(
"""
# Ugh. PyGtk/GtkObject/GnomeCanvas interfacing grits.
gnome.CanvasGroup.__init__(self,
_obj = rootGroup.add('group')._o)
self.propertyLabels = PairList()
reflect.accumulateClassList(self.__class__, 'propertyLabels',
self.propertyLabels)
self.groupLabels = PairList()
reflect.accumulateClassList(self.__class__, 'groupLabels',
self.groupLabels)
self.explorer = explorer
self.identifier = explorer.identifier
self.objectId = explorer.id
self.canvas = canvas
self.rootGroup = rootGroup
self.ebox = gtk.EventBox()
self.ebox.set_name("Visage")
self.frame = gtk.Frame(self.identifier)
self.container = gtk.VBox()
self.ebox.add(self.frame)
self.frame.add(self.container)
self.canvasWidget = self.add('widget', widget=self.ebox,
x=0, y=0, anchor=gtk.ANCHOR_NW,
size_pixels=0)
self.border = self.add('rect', x1=0, y1=0,
x2=1, y2=1,
fill_color=None,
outline_color=self.color['border'],
width_pixels=self.border_width)
self.subtable = {}
self._setup_table()
# TODO:
# Collapse me
# Movable/resizeable me
# Destroy me
# Set my detail level
self.frame.connect("size_allocate", self.signal_size_allocate,
None)
self.connect("destroy", self.signal_destroy, None)
self.connect("event", self.signal_event)
self.ebox.show_all()
# Our creator will call our fill_ methods when she has the goods.
def _create_legend(self):
icons = (
(gtk.STOCK_FILE, 'Class'),
(gtk.STOCK_EXECUTE, 'Method'),
(gtk.STOCK_SELECT_FONT, 'Field'),
(gtk.STOCK_DELETE, 'Declaration not found'),
(gtk.STOCK_INFO, 'Miscellaneous (info)'),
(u'?', 'Direct call – e.g. static, private, etc'),
(u'?', 'Virtual call (? + ?)'),
(u'?', 'Virtual call (indirect) which could be performed because '
'of polymorphism'),
(u'?', 'Virtual call (direct only) which does not actually '
'performed – e.g. interface method'),
(u'?', 'Super call (? + ?)'),
(u'?', 'Super call (indirect) because direct super does not '
'declare the method'),
(u'?', 'Super call (direct only) which does not actually '
'performed – e.g. not declared here'),
)
table = gtk.Table(7, 5)
table.set_border_width(8)
table.set_row_spacings(8)
table.set_col_spacings(8)
separator = gtk.VSeparator()
table.attach(separator, 2, 3, 0, 7, 0)
x, y = 0, 0
for icon, desc in icons:
if len(icon) == 1:
image = gtk.Label(icon)
else:
image = gtk.Image()
image.set_from_stock(icon, gtk.ICON_SIZE_MENU)
image.set_alignment(1, 0.5)
label = gtk.Label(desc)
label.set_alignment(0, 0.5)
table.attach(image, x + 0, x + 1, y, y + 1, gtk.FILL)
table.attach(label, x + 1, x + 2, y, y + 1, gtk.FILL)
y += 1
if y == 5 and x == 0:
x, y = 3, 0
frame = gtk.Frame('Legend')
frame.add(table)
return frame
def _info(type, value, tb):
"""display exception"""
#ungrab a potentially "grabbed" mouse pointer
gtk.gdk.pointer_ungrab()
#create dialog
dialog = gtk.MessageDialog(
parent = None,
flags = 0,
type = gtk.MESSAGE_WARNING,
buttons = gtk.BUTTONS_NONE,
message_format = _("<big><b>Error</b></big>"))
dialog.set_title(_("Bug Detected"))
dialog.vbox.get_children()[0].get_children()[1].get_children()[0].set_property("use-markup", True)
dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
#details
textview = gtk.TextView()
textview.show()
textview.set_editable(False)
textview.modify_font(pango.FontDescription("Monospace"))
sw = gtk.ScrolledWindow()
sw.show()
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
sw.add(textview)
frame = gtk.Frame()
frame.set_shadow_type(gtk.SHADOW_IN)
frame.add(sw)
frame.set_border_width(6)
dialog.vbox.add(frame)
textbuffer = textview.get_buffer()
trace = StringIO.StringIO()
traceback.print_exception(type, value, tb, None, trace)
textbuffer.set_text(trace.getvalue())
textview.set_size_request(gtk.gdk.screen_width()/2, gtk.gdk.screen_height()/3)
dialog.details = frame
dialog.set_position(gtk.WIN_POS_CENTER)
dialog.set_gravity(gtk.gdk.GRAVITY_CENTER)
dialog.details.show()
#display the dialog
resp = dialog.run()
if resp == gtk.RESPONSE_CLOSE:
pass
dialog.destroy()
sys.exit(1)
#sys.excepthook = _info
def _setup_widgets(self):
h_space = 4 # horizontal space
# create the frames to contein the diferent settings.
f_time = gtk.Frame(label="Time")
f_oskin = gtk.Frame(label="Onion Skin")
self.set_size_request(300,-1)
self.vbox.pack_start(f_time,True,True,h_space)
self.vbox.pack_start(f_oskin,True,True,h_space)
# create the time settings.
th = gtk.HBox()
fps,fps_spin = Utils.spin_button("Framerate",'int',self.last_config[FRAMERATE],1,100) #conf fps
th.pack_start(fps,True,True,h_space)
f_time.add(th)
# create onion skin settings
ov = gtk.VBox()
f_oskin.add(ov)
# fist line
oh1 = gtk.HBox()
depth,depth_spin = Utils.spin_button("Depth",'int',self.last_config[OSKIN_DEPTH],1,4,1) #conf depth
on_play = gtk.CheckButton("On Play")
on_play.set_active(self.last_config[OSKIN_ONPLAY])
oh1.pack_start(depth,True,True,h_space)
oh1.pack_start(on_play,True,True,h_space)
ov.pack_start(oh1)
# second line
oh2 = gtk.HBox()
forward = gtk.CheckButton("Forward")
forward.set_active(self.last_config[OSKIN_FORWARD])
backward = gtk.CheckButton("Backward")
backward.set_active(self.last_config[OSKIN_BACKWARD])
oh2.pack_start(forward,True,True,h_space)
oh2.pack_start(backward,True,True,h_space)
ov.pack_start(oh2)
# last line
# connect a callback to all
fps_spin.connect("value_changed",self.update_config,FRAMERATE)
depth_spin.connect("value_changed",self.update_config,OSKIN_DEPTH)
on_play.connect("toggled",self.update_config,OSKIN_ONPLAY)
forward.connect("toggled",self.update_config,OSKIN_FORWARD)
backward.connect("toggled",self.update_config,OSKIN_BACKWARD)
# show all
self.show_all()
def make_adjust(self):
hbox = gtk.HBox(True, 2)
incr = gtk.Button("+100")
incr.connect("clicked", self.__incrnew, 100)
incr.set_size_request(50, 25)
incr.show()
hbox.pack_start(incr, 0, 0, 0)
incr = gtk.Button("+10")
incr.connect("clicked", self.__incrnew, 10)
incr.set_size_request(50, 25)
incr.show()
hbox.pack_start(incr, 0, 0, 0)
incr = gtk.Button("+1")
incr.connect("clicked", self.__incrnew, 1)
incr.set_size_request(50, 25)
incr.show()
hbox.pack_start(incr, 0, 0, 0)
decr = gtk.Button("-1")
decr.connect("clicked", self.__incrnew, -1)
decr.set_size_request(50, 25)
decr.show()
hbox.pack_start(decr, 0, 0, 0)
decr = gtk.Button("-10")
decr.connect("clicked", self.__incrnew, -10)
decr.set_size_request(50, 25)
decr.show()
hbox.pack_start(decr, 0, 0, 0)
decr = gtk.Button("-100")
decr.connect("clicked", self.__incrnew, -100)
decr.set_size_request(50, 25)
decr.show()
hbox.pack_start(decr, 0, 0, 0)
auto = gtk.Button(_("Auto"))
auto.connect("clicked", self.__autonew)
auto.set_size_request(50, 25)
auto.show()
hbox.pack_start(auto, 0, 0, 0)
revr = gtk.Button(_("Reverse"))
revr.connect("clicked", self.__revrnew)
revr.set_size_request(50, 25)
revr.show()
hbox.pack_start(revr, 0, 0, 0)
frame = gtk.Frame(_("Adjust New Location"))
frame.show()
frame.add(hbox)
hbox.show()
return frame
def make_file_ctl(self):
self.w_fileframe = gtk.Frame("File")
vbox = gtk.VBox(False, 2)
vbox.set_border_width(2)
hbox = gtk.HBox(False, 2)
hbox.set_border_width(2)
l = gtk.Label("File")
l.show()
hbox.pack_start(l, 0, , )
self.w_filename = gtk.Entry()
self.w_filename.connect("changed", self.file_changed)
self.tips.set_tip(self.w_filename, "Path to CSV file")
self.w_filename.show()
hbox.pack_start(self.w_filename, 1, , )
bb = StdButton("Browse")
bb.connect("clicked", self.pick_file)
bb.show()
hbox.pack_start(bb, 0, , )
hbox.show()
vbox.pack_start(hbox, 0, , )
hbox = gtk.HBox(True, 2)
hbox.set_border_width(2)
def export_handler(x):
return self.fn_eport(self.w_filename.get_text())
self.w_export = StdButton("Export")
self.w_export.set_sensitive(False)
self.w_export.connect("clicked", export_handler)
self.tips.set_tip(self.w_export,
"Export radio memories to CSV file")
self.w_export.show()
hbox.pack_start(self.w_export, 0, , )
def import_handler(x):
return self.fn_iport(self.w_filename.get_text())
self.w_import = StdButton("Import")
self.w_import.set_sensitive(False)
self.w_import.connect("clicked", import_handler)
self.tips.set_tip(self.w_import,
"Import radio memories from CSV file")
self.w_import.show()
hbox.pack_start(self.w_import, 0, , )
hbox.show()
vbox.pack_start(hbox, 0, , )
vbox.show()
self.w_fileframe.add(vbox)
self.w_fileframe.show()
return self.w_fileframe